ntdll: Use the standard code path to load ntdll.dll.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
20e0fd6e99
commit
7cec3dc284
|
@ -1438,24 +1438,12 @@ found:
|
||||||
static void load_ntdll(void)
|
static void load_ntdll(void)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
SECTION_IMAGE_INFORMATION info;
|
||||||
void *module;
|
void *module;
|
||||||
int fd;
|
char *name = build_path( dll_dir, "ntdll.dll.so" );
|
||||||
char *name = build_path( dll_dir, "ntdll.dll" );
|
|
||||||
|
|
||||||
if ((fd = open( name, O_RDONLY )) != -1)
|
name[strlen(name) - 3] = 0; /* remove .so */
|
||||||
{
|
status = open_builtin_file( name, &module, &info );
|
||||||
struct stat st;
|
|
||||||
fstat( fd, &st );
|
|
||||||
if (!(status = virtual_map_ntdll( fd, &module )))
|
|
||||||
add_builtin_module( module, NULL, &st );
|
|
||||||
close( fd );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
free( name );
|
|
||||||
name = build_path( dll_dir, "ntdll.dll.so" );
|
|
||||||
status = dlopen_dll( name, &module );
|
|
||||||
}
|
|
||||||
if (status) fatal_error( "failed to load %s error %x\n", name, status );
|
if (status) fatal_error( "failed to load %s error %x\n", name, status );
|
||||||
free( name );
|
free( name );
|
||||||
load_ntdll_functions( module );
|
load_ntdll_functions( module );
|
||||||
|
|
|
@ -177,7 +177,6 @@ extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct o
|
||||||
extern void *anon_mmap_fixed( void *start, size_t size, int prot, int flags ) DECLSPEC_HIDDEN;
|
extern void *anon_mmap_fixed( void *start, size_t size, int prot, int flags ) DECLSPEC_HIDDEN;
|
||||||
extern void *anon_mmap_alloc( size_t size, int prot ) DECLSPEC_HIDDEN;
|
extern void *anon_mmap_alloc( size_t size, int prot ) DECLSPEC_HIDDEN;
|
||||||
extern void virtual_init(void) DECLSPEC_HIDDEN;
|
extern void virtual_init(void) DECLSPEC_HIDDEN;
|
||||||
extern NTSTATUS virtual_map_ntdll( int fd, void **module ) DECLSPEC_HIDDEN;
|
|
||||||
extern ULONG_PTR get_system_affinity_mask(void) DECLSPEC_HIDDEN;
|
extern ULONG_PTR get_system_affinity_mask(void) DECLSPEC_HIDDEN;
|
||||||
extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECLSPEC_HIDDEN;
|
extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECLSPEC_HIDDEN;
|
||||||
extern NTSTATUS virtual_create_builtin_view( void *module ) DECLSPEC_HIDDEN;
|
extern NTSTATUS virtual_create_builtin_view( void *module ) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -2436,56 +2436,6 @@ void virtual_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* virtual_map_ntdll
|
|
||||||
*
|
|
||||||
* Map ntdll, used instead of virtual_map_section() because some things are not initialized yet.
|
|
||||||
*/
|
|
||||||
NTSTATUS virtual_map_ntdll( int fd, void **module )
|
|
||||||
{
|
|
||||||
IMAGE_DOS_HEADER dos;
|
|
||||||
IMAGE_NT_HEADERS nt;
|
|
||||||
NTSTATUS status;
|
|
||||||
SIZE_T size;
|
|
||||||
void *base;
|
|
||||||
unsigned int vprot;
|
|
||||||
struct file_view *view;
|
|
||||||
|
|
||||||
/* load the headers */
|
|
||||||
|
|
||||||
size = pread( fd, &dos, sizeof(dos), 0 );
|
|
||||||
if (size < sizeof(dos)) return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
if (dos.e_magic != IMAGE_DOS_SIGNATURE) return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
|
|
||||||
size = pread( fd, &nt, sizeof(nt), dos.e_lfanew );
|
|
||||||
if (size < sizeof(nt)) return STATUS_INVALID_IMAGE_PROTECT;
|
|
||||||
if (nt.Signature != IMAGE_NT_SIGNATURE) return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
if (nt.OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC) return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
#ifdef __i386__
|
|
||||||
if (nt.FileHeader.Machine != IMAGE_FILE_MACHINE_I386) return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
#elif defined(__x86_64__)
|
|
||||||
if (nt.FileHeader.Machine != IMAGE_FILE_MACHINE_AMD64) return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
#elif defined(__arm__)
|
|
||||||
if (nt.FileHeader.Machine != IMAGE_FILE_MACHINE_ARM &&
|
|
||||||
nt.FileHeader.Machine != IMAGE_FILE_MACHINE_THUMB &&
|
|
||||||
nt.FileHeader.Machine != IMAGE_FILE_MACHINE_ARMNT) return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
#elif defined(__aarch64__)
|
|
||||||
if (nt.FileHeader.Machine != IMAGE_FILE_MACHINE_ARM64) return STATUS_INVALID_IMAGE_FORMAT;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
base = (void *)nt.OptionalHeader.ImageBase;
|
|
||||||
size = ROUND_SIZE( 0, nt.OptionalHeader.SizeOfImage );
|
|
||||||
vprot = SEC_IMAGE | SEC_FILE | VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY;
|
|
||||||
|
|
||||||
status = map_view( &view, base, size, FALSE, vprot, 0 );
|
|
||||||
if (status == STATUS_CONFLICTING_ADDRESSES)
|
|
||||||
ERR( "couldn't load ntdll at preferred address %p\n", base );
|
|
||||||
if (status) return status;
|
|
||||||
*module = view->base;
|
|
||||||
return map_image_into_view( view, fd, base, nt.OptionalHeader.SizeOfHeaders, 0, -1, FALSE );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* get_system_affinity_mask
|
* get_system_affinity_mask
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue