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.
|
||||
*/
|
||||
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;
|
||||
NTSTATUS status;
|
||||
|
@ -1281,7 +1281,7 @@ static NTSTATUS open_dll_file( const char *name, OBJECT_ATTRIBUTES *attr, void *
|
|||
NtClose( mapping );
|
||||
return STATUS_IMAGE_ALREADY_LOADED;
|
||||
}
|
||||
status = virtual_map_builtin_module( mapping, module );
|
||||
status = virtual_map_builtin_module( mapping, module, size_ptr );
|
||||
NtClose( mapping );
|
||||
return status;
|
||||
}
|
||||
|
@ -1290,14 +1290,14 @@ static NTSTATUS open_dll_file( const char *name, OBJECT_ATTRIBUTES *attr, void *
|
|||
/***********************************************************************
|
||||
* 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 )
|
||||
{
|
||||
NTSTATUS status;
|
||||
int fd;
|
||||
|
||||
*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;
|
||||
|
||||
/* try .so file */
|
||||
|
@ -1325,10 +1325,10 @@ 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,
|
||||
SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native )
|
||||
static NTSTATUS find_builtin_dll( UNICODE_STRING *nt_name, void **module, SIZE_T *size_ptr,
|
||||
SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native )
|
||||
{
|
||||
unsigned int i, pos, namepos, namelen, maxlen = 0;
|
||||
unsigned int len = nt_name->Length / sizeof(WCHAR);
|
||||
|
@ -1369,7 +1369,7 @@ static NTSTATUS CDECL load_builtin_dll( UNICODE_STRING *nt_name, void **module,
|
|||
ptr = prepend( ptr, ptr, namelen );
|
||||
ptr = prepend( ptr, "/dlls", sizeof("/dlls") - 1 );
|
||||
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;
|
||||
|
||||
/* 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, "/programs", sizeof("/programs") - 1 );
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1388,17 +1388,15 @@ static NTSTATUS CDECL load_builtin_dll( UNICODE_STRING *nt_name, void **module,
|
|||
{
|
||||
file[pos + len + 1] = 0;
|
||||
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;
|
||||
else if (status != STATUS_DLL_NOT_FOUND) goto done;
|
||||
}
|
||||
|
||||
if (found_image) status = STATUS_IMAGE_MACHINE_TYPE_MISMATCH;
|
||||
WARN( "cannot find builtin library for %s\n", debugstr_us(nt_name) );
|
||||
|
||||
done:
|
||||
if (status == STATUS_IMAGE_NOT_AT_BASE) status = STATUS_SUCCESS;
|
||||
if (!status && ext)
|
||||
if (status >= 0 && ext)
|
||||
{
|
||||
strcpy( ext, ".so" );
|
||||
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__
|
||||
/* 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
|
||||
|
@ -1500,12 +1513,13 @@ static void load_ntdll(void)
|
|||
OBJECT_ATTRIBUTES attr;
|
||||
UNICODE_STRING str;
|
||||
void *module;
|
||||
SIZE_T size = 0;
|
||||
char *name = build_path( dll_dir, "ntdll.dll.so" );
|
||||
|
||||
init_unicode_string( &str, path );
|
||||
InitializeObjectAttributes( &attr, &str, 0, 0, NULL );
|
||||
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 );
|
||||
else if (status) fatal_error( "failed to load %s error %x\n", name, status );
|
||||
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 ULONG_PTR get_system_affinity_mask(void) 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,
|
||||
pe_image_info_t *info, void *so_handle ) 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
|
||||
*/
|
||||
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;
|
||||
unsigned int sec_flags;
|
||||
HANDLE shared_file;
|
||||
pe_image_info_t *image_info = NULL;
|
||||
ACCESS_MASK access = SECTION_MAP_READ | SECTION_MAP_EXECUTE;
|
||||
SIZE_T size = 0;
|
||||
NTSTATUS status;
|
||||
WCHAR *filename;
|
||||
|
||||
|
@ -2749,9 +2748,10 @@ NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module )
|
|||
if (!image_info) return STATUS_INVALID_PARAMETER;
|
||||
|
||||
*module = NULL;
|
||||
*size = 0;
|
||||
filename = (WCHAR *)(image_info + 1);
|
||||
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 );
|
||||
free( image_info );
|
||||
return status;
|
||||
|
|
Loading…
Reference in New Issue