Rebase against 8d076bc5e46cc11ec94db631e7c608f62d75cee2.

This commit is contained in:
Zebediah Figura
2021-04-06 17:41:23 -05:00
parent 733a420dd7
commit 0c295023f1
9 changed files with 85 additions and 104 deletions

View File

@@ -1,13 +1,13 @@
From 7357cb7a11d785aca554e255bc5c672c279d948f Mon Sep 17 00:00:00 2001
From 78e8d51910a41db9a31ec350228989a0c65cf899 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Mon, 3 Apr 2017 05:30:27 +0200
Subject: [PATCH] ntdll: Implement HashLinks field in LDR module data.
---
dlls/kernel32/tests/loader.c | 75 ++++++++++++++++++++++++++++++++++++
dlls/ntdll/loader.c | 65 +++++++++++++++++++++++++++++++
dlls/ntdll/loader.c | 60 +++++++++++++++++++++++++++++
include/winternl.h | 2 +-
3 files changed, 141 insertions(+), 1 deletion(-)
3 files changed, 136 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 1db68a191a3..bec46088518 100644
@@ -110,7 +110,7 @@ index 1db68a191a3..bec46088518 100644
test_dll_file( "kernel32.dll" );
test_dll_file( "advapi32.dll" );
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index daee7675196..659cba51768 100644
index 7a714a5aa6d..996a749ebaa 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -113,6 +113,9 @@ struct file_id
@@ -123,7 +123,7 @@ index daee7675196..659cba51768 100644
/* internal representation of loaded modules */
typedef struct _wine_modref
{
@@ -451,6 +454,52 @@ static void call_ldr_notifications( ULONG reason, LDR_DATA_TABLE_ENTRY *module )
@@ -458,6 +461,52 @@ static void call_ldr_notifications( ULONG reason, LDR_DATA_TABLE_ENTRY *module )
}
}
@@ -176,7 +176,7 @@ index daee7675196..659cba51768 100644
/*************************************************************************
* get_modref
*
@@ -1197,7 +1246,12 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name
@@ -1204,7 +1253,12 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name
&wm->ldr.InLoadOrderLinks);
InsertTailList(&NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList,
&wm->ldr.InMemoryOrderLinks);
@@ -189,7 +189,7 @@ index daee7675196..659cba51768 100644
if (!(nt->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NX_COMPAT))
{
@@ -1877,6 +1931,7 @@ static NTSTATUS build_module( LPCWSTR load_path, const UNICODE_STRING *nt_name,
@@ -1884,6 +1938,7 @@ static NTSTATUS build_module( LPCWSTR load_path, const UNICODE_STRING *nt_name,
/* the module has only be inserted in the load & memory order lists */
RemoveEntryList(&wm->ldr.InLoadOrderLinks);
RemoveEntryList(&wm->ldr.InMemoryOrderLinks);
@@ -197,7 +197,7 @@ index daee7675196..659cba51768 100644
/* FIXME: there are several more dangling references
* left. Including dlls loaded by this dll before the
@@ -3307,6 +3362,7 @@ static void free_modref( WINE_MODREF *wm )
@@ -3314,6 +3369,7 @@ static void free_modref( WINE_MODREF *wm )
{
RemoveEntryList(&wm->ldr.InLoadOrderLinks);
RemoveEntryList(&wm->ldr.InMemoryOrderLinks);
@@ -205,41 +205,22 @@ index daee7675196..659cba51768 100644
if (wm->ldr.InInitializationOrderLinks.Flink)
RemoveEntryList(&wm->ldr.InInitializationOrderLinks);
@@ -4024,6 +4080,7 @@ static NTSTATUS process_init(void)
{
TEB *teb = NtCurrentTeb();
PEB *peb = teb->Peb;
+ DWORD i;
@@ -3641,6 +3697,10 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
sizeof(peb->TlsExpansionBitmapBits) * 8 );
RtlSetBits( peb->TlsBitmap, 0, 1 ); /* TLS index 0 is reserved and should be initialized to NULL. */
peb->LdrData = &ldr;
peb->FastPebLock = &peb_lock;
@@ -4047,6 +4104,10 @@ static NTSTATUS process_init(void)
InitializeListHead( &ldr.InMemoryOrderModuleList );
InitializeListHead( &ldr.InInitializationOrderModuleList );
+ /* initialize hash table */
+ for (i = 0; i < HASH_MAP_SIZE; i++)
+ InitializeListHead(&hash_table[i]);
+ /* initialize hash table */
+ for (i = 0; i < HASH_MAP_SIZE; i++)
+ InitializeListHead( &hash_table[i] );
+
init_user_process_params();
load_global_options();
version_init();
@@ -4064,6 +4125,10 @@ static NTSTATUS process_init(void)
map_wow64cpu();
}
#endif
+
+ /* the windows version was not set yet when ntdll and kernel32 were loaded */
+ recompute_hash_map();
+
return STATUS_SUCCESS;
}
init_user_process_params();
load_global_options();
version_init();
diff --git a/include/winternl.h b/include/winternl.h
index 9e6bde25569..0fa75e676fe 100644
index 298ebbc2d36..64aac3f955d 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -3181,8 +3181,8 @@ typedef struct _LDR_DATA_TABLE_ENTRY
@@ -3183,8 +3183,8 @@ typedef struct _LDR_DATA_TABLE_ENTRY
ULONG Flags;
SHORT LoadCount;
SHORT TlsIndex;