ntdll: Compare builtins by their device and inode number directly.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-07-29 11:41:04 -05:00 committed by Alexandre Julliard
parent d9c085f182
commit 3f8d60e2ac

View file

@ -129,7 +129,8 @@ static HMODULE ntdll_module;
struct file_id
{
BYTE ObjectId[16];
dev_t dev;
ino_t ino;
};
struct builtin_module
@ -142,13 +143,17 @@ struct builtin_module
static struct list builtin_modules = LIST_INIT( builtin_modules );
static NTSTATUS add_builtin_module( void *module, void *handle, const FILE_OBJECTID_BUFFER *id )
static NTSTATUS add_builtin_module( void *module, void *handle, const struct stat *st )
{
struct builtin_module *builtin;
if (!(builtin = malloc( sizeof(*builtin) ))) return STATUS_NO_MEMORY;
builtin->handle = handle;
builtin->module = module;
if (id) memcpy( &builtin->id, id->ObjectId, sizeof(builtin->id) );
if (st)
{
builtin->id.dev = st->st_dev;
builtin->id.ino = st->st_ino;
}
else memset( &builtin->id, 0, sizeof(builtin->id) );
list_add_tail( &builtin_modules, &builtin->entry );
return STATUS_SUCCESS;
@ -996,9 +1001,7 @@ static NTSTATUS open_dll_file( const char *name, void **module, pe_image_info_t
{
struct builtin_module *builtin;
OBJECT_ATTRIBUTES attr = { sizeof(attr) };
IO_STATUS_BLOCK io;
LARGE_INTEGER size;
FILE_OBJECTID_BUFFER id;
struct stat st;
SIZE_T len = 0;
NTSTATUS status;
@ -1017,11 +1020,11 @@ static NTSTATUS open_dll_file( const char *name, void **module, pe_image_info_t
return STATUS_DLL_NOT_FOUND;
}
if (!NtFsControlFile( handle, 0, NULL, NULL, &io, FSCTL_GET_OBJECT_ID, NULL, 0, &id, sizeof(id) ))
if (!stat( name, &st ))
{
LIST_FOR_EACH_ENTRY( builtin, &builtin_modules, struct builtin_module, entry )
{
if (!memcmp( &builtin->id, id.ObjectId, sizeof(builtin->id) ))
if (builtin->id.dev == st.st_dev && builtin->id.ino == st.st_ino)
{
TRACE( "%s is the same file as existing module %p\n", debugstr_a(name),
builtin->module );
@ -1032,7 +1035,7 @@ static NTSTATUS open_dll_file( const char *name, void **module, pe_image_info_t
}
}
}
else memset( id.ObjectId, 0, sizeof(id.ObjectId) );
else memset( &st, 0, sizeof(st) );
size.QuadPart = 0;
status = NtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_QUERY |
@ -1063,7 +1066,7 @@ static NTSTATUS open_dll_file( const char *name, void **module, pe_image_info_t
status = STATUS_IMAGE_MACHINE_TYPE_MISMATCH;
}
if (!status) status = add_builtin_module( *module, NULL, &id );
if (!status) status = add_builtin_module( *module, NULL, &st );
if (status)
{