Rebase against 3fc1180623b9a0c9fc9e16abf358b179f2eff49b

This commit is contained in:
Alistair Leslie-Hughes
2019-02-15 11:18:02 +11:00
parent 27ff0169ed
commit 7cbbfd0a9e
11 changed files with 131 additions and 389 deletions

View File

@@ -1,16 +1,16 @@
From 33e1022c63ace91f96c3e1376412bcb17a3a4289 Mon Sep 17 00:00:00 2001
From 0c8487ff0c2b10bae391672c5876bfcc5987f7de 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 | 76 ++++++++++++++++++++++++++++++++++++
dlls/ntdll/loader.c | 65 ++++++++++++++++++++++++++++++
include/winternl.h | 6 ++-
dlls/kernel32/tests/loader.c | 76 ++++++++++++++++++++++++++++++++++++++++++++
dlls/ntdll/loader.c | 65 +++++++++++++++++++++++++++++++++++++
include/winternl.h | 6 ++--
3 files changed, 145 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 165c05ea..d26b7879 100644
index b497ce3..c54eade 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -30,6 +30,7 @@
@@ -21,7 +21,7 @@ index 165c05ea..d26b7879 100644
#include "wine/test.h"
#include "delayloadhandler.h"
@@ -3806,6 +3807,79 @@ static void test_InMemoryOrderModuleList(void)
@@ -3842,6 +3843,79 @@ static void test_InMemoryOrderModuleList(void)
ok(entry2 == mark2, "expected entry2 == mark2, got %p and %p\n", entry2, mark2);
}
@@ -101,7 +101,7 @@ index 165c05ea..d26b7879 100644
START_TEST(loader)
{
int argc;
@@ -3872,6 +3946,8 @@ START_TEST(loader)
@@ -3908,6 +3982,8 @@ START_TEST(loader)
test_import_resolution();
test_ExitProcess();
test_InMemoryOrderModuleList();
@@ -111,10 +111,10 @@ index 165c05ea..d26b7879 100644
test_Loader();
}
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index e7a9c2ca..83b95fa9 100644
index 0546478..381c13a 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -93,6 +93,9 @@ static const char * const reason_names[] =
@@ -96,6 +96,9 @@ static const char * const reason_names[] =
static const WCHAR dllW[] = {'.','d','l','l',0};
@@ -124,11 +124,10 @@ index e7a9c2ca..83b95fa9 100644
/* internal representation of 32bit modules. per process. */
typedef struct _wine_modref
{
@@ -375,6 +378,52 @@ static void call_ldr_notifications( ULONG reason, LDR_MODULE *module )
}
@@ -379,6 +382,52 @@ static void call_ldr_notifications( ULONG reason, LDR_MODULE *module )
}
+/*************************************************************************
/*************************************************************************
+ * hash_basename
+ *
+ * Calculates the bucket index of a dll using the basename.
@@ -174,10 +173,11 @@ index e7a9c2ca..83b95fa9 100644
+ }
+}
+
/*************************************************************************
+/*************************************************************************
* get_modref
*
@@ -1099,7 +1148,12 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name
* Looks for the referenced HMODULE in the current process
@@ -1102,7 +1151,12 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name
&wm->ldr.InLoadOrderModuleList);
InsertTailList(&NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList,
&wm->ldr.InMemoryOrderModuleList);
@@ -190,7 +190,7 @@ index e7a9c2ca..83b95fa9 100644
if (!(nt->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NX_COMPAT))
{
@@ -1776,6 +1830,7 @@ static void load_builtin_callback( void *module, const char *filename )
@@ -1846,6 +1900,7 @@ static void load_builtin_callback( void *module, const char *filename )
/* the module has only be inserted in the load & memory order lists */
RemoveEntryList(&wm->ldr.InLoadOrderModuleList);
RemoveEntryList(&wm->ldr.InMemoryOrderModuleList);
@@ -198,7 +198,7 @@ index e7a9c2ca..83b95fa9 100644
/* FIXME: free the modref */
builtin_load_info->status = STATUS_DLL_NOT_FOUND;
return;
@@ -2089,6 +2144,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, const UNICODE_STRING *nt_nam
@@ -2130,6 +2185,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, const UNICODE_STRING *nt_nam
/* the module has only be inserted in the load & memory order lists */
RemoveEntryList(&wm->ldr.InLoadOrderModuleList);
RemoveEntryList(&wm->ldr.InMemoryOrderModuleList);
@@ -206,7 +206,7 @@ index e7a9c2ca..83b95fa9 100644
/* FIXME: there are several more dangling references
* left. Including dlls loaded by this dll before the
@@ -3089,6 +3145,7 @@ static void free_modref( WINE_MODREF *wm )
@@ -3180,6 +3236,7 @@ static void free_modref( WINE_MODREF *wm )
{
RemoveEntryList(&wm->ldr.InLoadOrderModuleList);
RemoveEntryList(&wm->ldr.InMemoryOrderModuleList);
@@ -214,25 +214,15 @@ index e7a9c2ca..83b95fa9 100644
if (wm->ldr.InInitializationOrderModuleList.Flink)
RemoveEntryList(&wm->ldr.InInitializationOrderModuleList);
@@ -3416,6 +3473,9 @@ void WINAPI LdrInitializeThunk( void *kernel_start, ULONG_PTR unknown2,
RemoveEntryList( &wm->ldr.InMemoryOrderModuleList );
InsertHeadList( &peb->LdrData->InMemoryOrderModuleList, &wm->ldr.InMemoryOrderModuleList );
+ /* the windows version was not set yet when ntdll and kernel32 were loaded */
+ recompute_hash_map();
+
if ((status = virtual_alloc_thread_stack( NtCurrentTeb(), 0, 0, NULL )) != STATUS_SUCCESS)
{
ERR( "Main exe initialization for %s failed, status %x\n",
@@ -3563,6 +3623,7 @@ void __wine_process_init(void)
@@ -3660,6 +3717,7 @@ void __wine_process_init(void)
ANSI_STRING func_name;
UNICODE_STRING nt_name;
void (* DECLSPEC_NORETURN CDECL init_func)(void);
void * (CDECL *init_func)(void);
+ DWORD i;
thread_init();
@@ -3572,6 +3633,10 @@ void __wine_process_init(void)
@@ -3669,6 +3727,10 @@ void __wine_process_init(void)
load_global_options();
@@ -243,11 +233,21 @@ index e7a9c2ca..83b95fa9 100644
/* setup the load callback and create ntdll modref */
wine_dll_set_callback( load_builtin_callback );
@@ -3723,6 +3785,9 @@ void __wine_process_init(void)
RemoveEntryList( &wm->ldr.InMemoryOrderModuleList );
InsertHeadList( &NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList, &wm->ldr.InMemoryOrderModuleList );
+ /* the windows version was not set yet when ntdll and kernel32 were loaded */
+ recompute_hash_map();
+
if ((status = virtual_alloc_thread_stack( NtCurrentTeb(), 0, 0, NULL )) != STATUS_SUCCESS)
{
ERR( "Main exe initialization for %s failed, status %x\n",
diff --git a/include/winternl.h b/include/winternl.h
index 9dfc4407..ee89bc31 100644
index 6e75b0b..7ee4b25 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -2198,8 +2198,7 @@ typedef struct _LDR_MODULE
@@ -2199,8 +2199,7 @@ typedef struct _LDR_MODULE
ULONG Flags;
SHORT LoadCount;
SHORT TlsIndex;
@@ -257,7 +257,7 @@ index 9dfc4407..ee89bc31 100644
ULONG TimeDateStamp;
HANDLE ActivationContext;
PVOID PatchInformation;
@@ -2209,6 +2208,9 @@ typedef struct _LDR_MODULE
@@ -2210,6 +2209,9 @@ typedef struct _LDR_MODULE
PVOID ContextInformation;
ULONG_PTR OriginalBase;
LARGE_INTEGER LoadTime;
@@ -268,5 +268,5 @@ index 9dfc4407..ee89bc31 100644
typedef struct _LDR_DLL_LOADED_NOTIFICATION_DATA
--
2.20.1
1.9.1