ntdll: Return the mapping size in virtual_map_builtin_module().
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0ea5772113
commit
5dcd3c1dd9
|
@ -1234,7 +1234,7 @@ static inline char *prepend( char *buffer, const char *str, size_t len )
|
||||||
* Open a file for a new dll. Helper for open_builtin_file.
|
* Open a file for a new dll. Helper for open_builtin_file.
|
||||||
*/
|
*/
|
||||||
static NTSTATUS open_dll_file( const char *name, OBJECT_ATTRIBUTES *attr, void **module,
|
static NTSTATUS open_dll_file( const char *name, OBJECT_ATTRIBUTES *attr, void **module,
|
||||||
SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native )
|
SIZE_T *size_ptr, SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native )
|
||||||
{
|
{
|
||||||
LARGE_INTEGER size;
|
LARGE_INTEGER size;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
@ -1281,7 +1281,7 @@ static NTSTATUS open_dll_file( const char *name, OBJECT_ATTRIBUTES *attr, void *
|
||||||
NtClose( mapping );
|
NtClose( mapping );
|
||||||
return STATUS_IMAGE_ALREADY_LOADED;
|
return STATUS_IMAGE_ALREADY_LOADED;
|
||||||
}
|
}
|
||||||
status = virtual_map_builtin_module( mapping, module );
|
status = virtual_map_builtin_module( mapping, module, size_ptr );
|
||||||
NtClose( mapping );
|
NtClose( mapping );
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1290,14 +1290,14 @@ static NTSTATUS open_dll_file( const char *name, OBJECT_ATTRIBUTES *attr, void *
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* open_builtin_file
|
* open_builtin_file
|
||||||
*/
|
*/
|
||||||
static NTSTATUS open_builtin_file( char *name, OBJECT_ATTRIBUTES *attr, void **module,
|
static NTSTATUS open_builtin_file( char *name, OBJECT_ATTRIBUTES *attr, void **module, SIZE_T *size,
|
||||||
SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native )
|
SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native )
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
*module = NULL;
|
*module = NULL;
|
||||||
status = open_dll_file( name, attr, module, image_info, prefer_native );
|
status = open_dll_file( name, attr, module, size, image_info, prefer_native );
|
||||||
if (status != STATUS_DLL_NOT_FOUND) return status;
|
if (status != STATUS_DLL_NOT_FOUND) return status;
|
||||||
|
|
||||||
/* try .so file */
|
/* try .so file */
|
||||||
|
@ -1325,9 +1325,9 @@ static NTSTATUS open_builtin_file( char *name, OBJECT_ATTRIBUTES *attr, void **m
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* load_builtin_dll
|
* find_builtin_dll
|
||||||
*/
|
*/
|
||||||
static NTSTATUS CDECL load_builtin_dll( UNICODE_STRING *nt_name, void **module,
|
static NTSTATUS find_builtin_dll( UNICODE_STRING *nt_name, void **module, SIZE_T *size_ptr,
|
||||||
SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native )
|
SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native )
|
||||||
{
|
{
|
||||||
unsigned int i, pos, namepos, namelen, maxlen = 0;
|
unsigned int i, pos, namepos, namelen, maxlen = 0;
|
||||||
|
@ -1369,7 +1369,7 @@ static NTSTATUS CDECL load_builtin_dll( UNICODE_STRING *nt_name, void **module,
|
||||||
ptr = prepend( ptr, ptr, namelen );
|
ptr = prepend( ptr, ptr, namelen );
|
||||||
ptr = prepend( ptr, "/dlls", sizeof("/dlls") - 1 );
|
ptr = prepend( ptr, "/dlls", sizeof("/dlls") - 1 );
|
||||||
ptr = prepend( ptr, build_dir, strlen(build_dir) );
|
ptr = prepend( ptr, build_dir, strlen(build_dir) );
|
||||||
status = open_builtin_file( ptr, &attr, module, image_info, prefer_native );
|
status = open_builtin_file( ptr, &attr, module, size_ptr, image_info, prefer_native );
|
||||||
if (status != STATUS_DLL_NOT_FOUND) goto done;
|
if (status != STATUS_DLL_NOT_FOUND) goto done;
|
||||||
|
|
||||||
/* now as a program */
|
/* now as a program */
|
||||||
|
@ -1380,7 +1380,7 @@ static NTSTATUS CDECL load_builtin_dll( UNICODE_STRING *nt_name, void **module,
|
||||||
ptr = prepend( ptr, ptr, namelen );
|
ptr = prepend( ptr, ptr, namelen );
|
||||||
ptr = prepend( ptr, "/programs", sizeof("/programs") - 1 );
|
ptr = prepend( ptr, "/programs", sizeof("/programs") - 1 );
|
||||||
ptr = prepend( ptr, build_dir, strlen(build_dir) );
|
ptr = prepend( ptr, build_dir, strlen(build_dir) );
|
||||||
status = open_builtin_file( ptr, &attr, module, image_info, prefer_native );
|
status = open_builtin_file( ptr, &attr, module, size_ptr, image_info, prefer_native );
|
||||||
if (status != STATUS_DLL_NOT_FOUND) goto done;
|
if (status != STATUS_DLL_NOT_FOUND) goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1388,17 +1388,15 @@ static NTSTATUS CDECL load_builtin_dll( UNICODE_STRING *nt_name, void **module,
|
||||||
{
|
{
|
||||||
file[pos + len + 1] = 0;
|
file[pos + len + 1] = 0;
|
||||||
ptr = prepend( file + pos, dll_paths[i], strlen(dll_paths[i]) );
|
ptr = prepend( file + pos, dll_paths[i], strlen(dll_paths[i]) );
|
||||||
status = open_builtin_file( ptr, &attr, module, image_info, prefer_native );
|
status = open_builtin_file( ptr, &attr, module, size_ptr, image_info, prefer_native );
|
||||||
if (status == STATUS_IMAGE_MACHINE_TYPE_MISMATCH) found_image = TRUE;
|
if (status == STATUS_IMAGE_MACHINE_TYPE_MISMATCH) found_image = TRUE;
|
||||||
else if (status != STATUS_DLL_NOT_FOUND) goto done;
|
else if (status != STATUS_DLL_NOT_FOUND) goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found_image) status = STATUS_IMAGE_MACHINE_TYPE_MISMATCH;
|
if (found_image) status = STATUS_IMAGE_MACHINE_TYPE_MISMATCH;
|
||||||
WARN( "cannot find builtin library for %s\n", debugstr_us(nt_name) );
|
WARN( "cannot find builtin library for %s\n", debugstr_us(nt_name) );
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (status == STATUS_IMAGE_NOT_AT_BASE) status = STATUS_SUCCESS;
|
if (status >= 0 && ext)
|
||||||
if (!status && ext)
|
|
||||||
{
|
{
|
||||||
strcpy( ext, ".so" );
|
strcpy( ext, ".so" );
|
||||||
set_builtin_unix_info( *module, ptr, NULL, NULL );
|
set_builtin_unix_info( *module, ptr, NULL, NULL );
|
||||||
|
@ -1408,6 +1406,21 @@ done:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* load_builtin_dll
|
||||||
|
*/
|
||||||
|
static NTSTATUS CDECL load_builtin_dll( UNICODE_STRING *nt_name, void **module,
|
||||||
|
SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native )
|
||||||
|
{
|
||||||
|
SIZE_T size;
|
||||||
|
NTSTATUS status;
|
||||||
|
|
||||||
|
status = find_builtin_dll( nt_name, module, &size, image_info, prefer_native );
|
||||||
|
if (status == STATUS_IMAGE_NOT_AT_BASE) status = STATUS_SUCCESS;
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
/* The PT_LOAD segments are sorted in increasing order, and the first
|
/* The PT_LOAD segments are sorted in increasing order, and the first
|
||||||
* starts at the beginning of the ELF file. By parsing the file, we can
|
* starts at the beginning of the ELF file. By parsing the file, we can
|
||||||
|
@ -1500,12 +1513,13 @@ static void load_ntdll(void)
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
UNICODE_STRING str;
|
UNICODE_STRING str;
|
||||||
void *module;
|
void *module;
|
||||||
|
SIZE_T size = 0;
|
||||||
char *name = build_path( dll_dir, "ntdll.dll.so" );
|
char *name = build_path( dll_dir, "ntdll.dll.so" );
|
||||||
|
|
||||||
init_unicode_string( &str, path );
|
init_unicode_string( &str, path );
|
||||||
InitializeObjectAttributes( &attr, &str, 0, 0, NULL );
|
InitializeObjectAttributes( &attr, &str, 0, 0, NULL );
|
||||||
name[strlen(name) - 3] = 0; /* remove .so */
|
name[strlen(name) - 3] = 0; /* remove .so */
|
||||||
status = open_builtin_file( name, &attr, &module, &info, FALSE );
|
status = open_builtin_file( name, &attr, &module, &size, &info, FALSE );
|
||||||
if (status == STATUS_IMAGE_NOT_AT_BASE) relocate_ntdll( module );
|
if (status == STATUS_IMAGE_NOT_AT_BASE) relocate_ntdll( module );
|
||||||
else if (status) fatal_error( "failed to load %s error %x\n", name, status );
|
else if (status) fatal_error( "failed to load %s error %x\n", name, status );
|
||||||
free( name );
|
free( name );
|
||||||
|
|
|
@ -178,7 +178,7 @@ 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 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_map_builtin_module( HANDLE mapping, void **module ) DECLSPEC_HIDDEN;
|
extern NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module, SIZE_T *size ) DECLSPEC_HIDDEN;
|
||||||
extern NTSTATUS virtual_create_builtin_view( void *module, const UNICODE_STRING *nt_name,
|
extern NTSTATUS virtual_create_builtin_view( void *module, const UNICODE_STRING *nt_name,
|
||||||
pe_image_info_t *info, void *so_handle ) DECLSPEC_HIDDEN;
|
pe_image_info_t *info, void *so_handle ) DECLSPEC_HIDDEN;
|
||||||
extern TEB *virtual_alloc_first_teb(void) DECLSPEC_HIDDEN;
|
extern TEB *virtual_alloc_first_teb(void) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -2732,14 +2732,13 @@ void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info )
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* virtual_map_builtin_module
|
* virtual_map_builtin_module
|
||||||
*/
|
*/
|
||||||
NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module )
|
NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module, SIZE_T *size )
|
||||||
{
|
{
|
||||||
mem_size_t full_size;
|
mem_size_t full_size;
|
||||||
unsigned int sec_flags;
|
unsigned int sec_flags;
|
||||||
HANDLE shared_file;
|
HANDLE shared_file;
|
||||||
pe_image_info_t *image_info = NULL;
|
pe_image_info_t *image_info = NULL;
|
||||||
ACCESS_MASK access = SECTION_MAP_READ | SECTION_MAP_EXECUTE;
|
ACCESS_MASK access = SECTION_MAP_READ | SECTION_MAP_EXECUTE;
|
||||||
SIZE_T size = 0;
|
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
WCHAR *filename;
|
WCHAR *filename;
|
||||||
|
|
||||||
|
@ -2749,9 +2748,10 @@ NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module )
|
||||||
if (!image_info) return STATUS_INVALID_PARAMETER;
|
if (!image_info) return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
*module = NULL;
|
*module = NULL;
|
||||||
|
*size = 0;
|
||||||
filename = (WCHAR *)(image_info + 1);
|
filename = (WCHAR *)(image_info + 1);
|
||||||
status = virtual_map_image( mapping, SECTION_MAP_READ | SECTION_MAP_EXECUTE,
|
status = virtual_map_image( mapping, SECTION_MAP_READ | SECTION_MAP_EXECUTE,
|
||||||
module, &size, 0, shared_file, 0, image_info, filename, TRUE );
|
module, size, 0, shared_file, 0, image_info, filename, TRUE );
|
||||||
if (shared_file) NtClose( shared_file );
|
if (shared_file) NtClose( shared_file );
|
||||||
free( image_info );
|
free( image_info );
|
||||||
return status;
|
return status;
|
||||||
|
|
Loading…
Reference in New Issue