ntdll: Use nameless unions/structs for loader data.
This commit is contained in:
parent
7f088b0b13
commit
65edf1925f
6 changed files with 26 additions and 36 deletions
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#define NONAMELESSUNION
|
||||
#include "winternl.h"
|
||||
#include "ddk/wdm.h"
|
||||
#include "ntdll_misc.h"
|
||||
|
@ -2942,7 +2941,7 @@ static NTSTATUS find_first_manifest_resource_in_module( HANDLE hModule, const WC
|
|||
if (!resdir->NumberOfIdEntries) return STATUS_RESOURCE_NAME_NOT_FOUND;
|
||||
entry_base = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(resdir + 1);
|
||||
entry = entry_base + resdir->NumberOfNamedEntries;
|
||||
*resname = (const WCHAR *)(ULONG_PTR)entry->u.Id;
|
||||
*resname = (const WCHAR *)(ULONG_PTR)entry->Id;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -3285,14 +3284,14 @@ static NTSTATUS lookup_winsxs(struct actctx_loader* acl, struct assembly_identit
|
|||
|
||||
if (!open_nt_file( &handle, &path_us ))
|
||||
{
|
||||
io.u.Status = get_manifest_in_manifest_file(acl, &sxs_ai, path_us.Buffer, file, TRUE, handle);
|
||||
io.Status = get_manifest_in_manifest_file(acl, &sxs_ai, path_us.Buffer, file, TRUE, handle);
|
||||
NtClose( handle );
|
||||
}
|
||||
else io.u.Status = STATUS_NO_SUCH_FILE;
|
||||
else io.Status = STATUS_NO_SUCH_FILE;
|
||||
|
||||
RtlFreeHeap( GetProcessHeap(), 0, file );
|
||||
RtlFreeUnicodeString( &path_us );
|
||||
return io.u.Status;
|
||||
return io.Status;
|
||||
}
|
||||
|
||||
static NTSTATUS lookup_assembly(struct actctx_loader* acl,
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#define NONAMELESSUNION
|
||||
#define NONAMELESSSTRUCT
|
||||
#include "windef.h"
|
||||
#include "winnt.h"
|
||||
#include "winioctl.h"
|
||||
|
@ -1057,8 +1055,8 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
|
|||
DWORD protect_old;
|
||||
|
||||
thunk_list = get_rva( module, (DWORD)descr->FirstThunk );
|
||||
if (descr->u.OriginalFirstThunk)
|
||||
import_list = get_rva( module, (DWORD)descr->u.OriginalFirstThunk );
|
||||
if (descr->OriginalFirstThunk)
|
||||
import_list = get_rva( module, (DWORD)descr->OriginalFirstThunk );
|
||||
else
|
||||
import_list = thunk_list;
|
||||
|
||||
|
@ -2134,7 +2132,7 @@ static NTSTATUS build_module( LPCWSTR load_path, const UNICODE_STRING *nt_name,
|
|||
|
||||
if (id) wm->id = *id;
|
||||
if (image_info->LoaderFlags) wm->ldr.Flags |= LDR_COR_IMAGE;
|
||||
if (image_info->u.s.ComPlusILOnly) wm->ldr.Flags |= LDR_COR_ILONLY;
|
||||
if (image_info->ComPlusILOnly) wm->ldr.Flags |= LDR_COR_ILONLY;
|
||||
wm->system = system;
|
||||
|
||||
set_security_cookie( *module, map_size );
|
||||
|
@ -2352,7 +2350,7 @@ static BOOL is_valid_binary( HANDLE file, const SECTION_IMAGE_INFORMATION *info
|
|||
if (current_machine == IMAGE_FILE_MACHINE_AMD64 && has_chpe_metadata( file, info )) return TRUE;
|
||||
/* support 32-bit IL-only images on 64-bit */
|
||||
if (!info->ImageContainsCode) return TRUE;
|
||||
if (info->u.s.ComPlusNativeReady) return TRUE;
|
||||
if (info->ComPlusNativeReady) return TRUE;
|
||||
return is_com_ilonly( file, info );
|
||||
}
|
||||
|
||||
|
@ -4188,7 +4186,7 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
|
|||
#elif defined(__arm__)
|
||||
entry = (void **)&context->R0;
|
||||
#elif defined(__aarch64__)
|
||||
entry = (void **)&context->u.s.X0;
|
||||
entry = (void **)&context->X0;
|
||||
#endif
|
||||
|
||||
if (process_detaching) NtTerminateThread( GetCurrentThread(), 0 );
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#define NONAMELESSUNION
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define NONAMELESSUNION
|
||||
#define NONAMELESSSTRUCT
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#include "windef.h"
|
||||
|
@ -84,8 +82,8 @@ static const IMAGE_RESOURCE_DIRECTORY *find_first_entry( const IMAGE_RESOURCE_DI
|
|||
|
||||
for (pos = 0; pos < dir->NumberOfNamedEntries + dir->NumberOfIdEntries; pos++)
|
||||
{
|
||||
if (!entry[pos].u2.s2.DataIsDirectory == !want_dir)
|
||||
return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s2.OffsetToDirectory);
|
||||
if (!entry[pos].DataIsDirectory == !want_dir)
|
||||
return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].OffsetToDirectory);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -108,17 +106,17 @@ static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_id( const IMAGE_RESOURCE_DI
|
|||
while (min <= max)
|
||||
{
|
||||
pos = (min + max) / 2;
|
||||
if (entry[pos].u.Id == id)
|
||||
if (entry[pos].Id == id)
|
||||
{
|
||||
if (!entry[pos].u2.s2.DataIsDirectory == !want_dir)
|
||||
if (!entry[pos].DataIsDirectory == !want_dir)
|
||||
{
|
||||
TRACE("root %p dir %p id %04x ret %p\n",
|
||||
root, dir, id, (const char*)root + entry[pos].u2.s2.OffsetToDirectory);
|
||||
return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s2.OffsetToDirectory);
|
||||
root, dir, id, (const char*)root + entry[pos].OffsetToDirectory);
|
||||
return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].OffsetToDirectory);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (entry[pos].u.Id > id) max = pos - 1;
|
||||
if (entry[pos].Id > id) max = pos - 1;
|
||||
else min = pos + 1;
|
||||
}
|
||||
TRACE("root %p dir %p id %04x not found\n", root, dir, id );
|
||||
|
@ -147,15 +145,15 @@ static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_name( const IMAGE_RESOURCE_
|
|||
while (min <= max)
|
||||
{
|
||||
pos = (min + max) / 2;
|
||||
str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const char *)root + entry[pos].u.s.NameOffset);
|
||||
str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const char *)root + entry[pos].NameOffset);
|
||||
res = wcsncmp( name, str->NameString, str->Length );
|
||||
if (!res && namelen == str->Length)
|
||||
{
|
||||
if (!entry[pos].u2.s2.DataIsDirectory == !want_dir)
|
||||
if (!entry[pos].DataIsDirectory == !want_dir)
|
||||
{
|
||||
TRACE("root %p dir %p name %s ret %p\n",
|
||||
root, dir, debugstr_w(name), (const char*)root + entry[pos].u2.s2.OffsetToDirectory);
|
||||
return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s2.OffsetToDirectory);
|
||||
root, dir, debugstr_w(name), (const char*)root + entry[pos].OffsetToDirectory);
|
||||
return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].OffsetToDirectory);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define NONAMELESSUNION
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#include "winternl.h"
|
||||
|
|
|
@ -80,8 +80,6 @@
|
|||
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#define NONAMELESSUNION
|
||||
#define NONAMELESSSTRUCT
|
||||
#include "windef.h"
|
||||
#include "winnt.h"
|
||||
#include "winbase.h"
|
||||
|
@ -423,8 +421,8 @@ static void fixup_so_resources( IMAGE_RESOURCE_DIRECTORY *dir, BYTE *root, int d
|
|||
|
||||
for (i = 0; i < dir->NumberOfNamedEntries + dir->NumberOfIdEntries; i++, entry++)
|
||||
{
|
||||
void *ptr = root + entry->u2.s2.OffsetToDirectory;
|
||||
if (entry->u2.s2.DataIsDirectory) fixup_so_resources( ptr, root, delta );
|
||||
void *ptr = root + entry->OffsetToDirectory;
|
||||
if (entry->DataIsDirectory) fixup_so_resources( ptr, root, delta );
|
||||
else fixup_rva_dwords( &((IMAGE_RESOURCE_DATA_ENTRY *)ptr)->OffsetToData, delta, 1 );
|
||||
}
|
||||
}
|
||||
|
@ -931,11 +929,11 @@ static NTSTATUS map_so_dll( const IMAGE_NT_HEADERS *nt_descr, HMODULE module )
|
|||
|
||||
while (imports->Name)
|
||||
{
|
||||
fixup_rva_dwords( &imports->u.OriginalFirstThunk, delta, 1 );
|
||||
fixup_rva_dwords( &imports->OriginalFirstThunk, delta, 1 );
|
||||
fixup_rva_dwords( &imports->Name, delta, 1 );
|
||||
fixup_rva_dwords( &imports->FirstThunk, delta, 1 );
|
||||
if (imports->u.OriginalFirstThunk)
|
||||
fixup_rva_names( (UINT_PTR *)(addr + imports->u.OriginalFirstThunk), delta );
|
||||
if (imports->OriginalFirstThunk)
|
||||
fixup_rva_names( (UINT_PTR *)(addr + imports->OriginalFirstThunk), delta );
|
||||
if (imports->FirstThunk)
|
||||
fixup_rva_names( (UINT_PTR *)(addr + imports->FirstThunk), delta );
|
||||
imports++;
|
||||
|
@ -1694,7 +1692,7 @@ static NTSTATUS open_main_image( WCHAR *image, void **module, SECTION_IMAGE_INFO
|
|||
if (!status)
|
||||
{
|
||||
status = virtual_map_module( mapping, module, &size, info, 0, machine );
|
||||
if (status == STATUS_IMAGE_MACHINE_TYPE_MISMATCH && info->u.s.ComPlusNativeReady)
|
||||
if (status == STATUS_IMAGE_MACHINE_TYPE_MISMATCH && info->ComPlusNativeReady)
|
||||
{
|
||||
info->Machine = native_machine;
|
||||
status = STATUS_SUCCESS;
|
||||
|
|
Loading…
Add table
Reference in a new issue