ntdll: Do not sort InMemoryOrderModuleList by memory address.

Signed-off-by: Michael Müller <michael@fds-team.de>
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Müller 2016-07-07 06:43:25 +02:00 committed by Alexandre Julliard
parent 422f0a87c4
commit 77be592845
1 changed files with 4 additions and 15 deletions

View File

@ -355,7 +355,6 @@ static WINE_MODREF *get_modref( HMODULE hmod )
mod = CONTAINING_RECORD(entry, LDR_MODULE, InMemoryOrderModuleList); mod = CONTAINING_RECORD(entry, LDR_MODULE, InMemoryOrderModuleList);
if (mod->BaseAddress == hmod) if (mod->BaseAddress == hmod)
return cached_modref = CONTAINING_RECORD(mod, WINE_MODREF, ldr); return cached_modref = CONTAINING_RECORD(mod, WINE_MODREF, ldr);
if (mod->BaseAddress > (void*)hmod) break;
} }
return NULL; return NULL;
} }
@ -932,7 +931,6 @@ static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename )
WINE_MODREF *wm; WINE_MODREF *wm;
const WCHAR *p; const WCHAR *p;
const IMAGE_NT_HEADERS *nt = RtlImageNtHeader(hModule); const IMAGE_NT_HEADERS *nt = RtlImageNtHeader(hModule);
PLIST_ENTRY entry, mark;
if (!(wm = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*wm) ))) return NULL; if (!(wm = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*wm) ))) return NULL;
@ -965,18 +963,8 @@ static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename )
InsertTailList(&NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList, InsertTailList(&NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList,
&wm->ldr.InLoadOrderModuleList); &wm->ldr.InLoadOrderModuleList);
InsertTailList(&NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList,
/* insert module in MemoryList, sorted in increasing base addresses */ &wm->ldr.InMemoryOrderModuleList);
mark = &NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList;
for (entry = mark->Flink; entry != mark; entry = entry->Flink)
{
if (CONTAINING_RECORD(entry, LDR_MODULE, InMemoryOrderModuleList)->BaseAddress > wm->ldr.BaseAddress)
break;
}
entry->Blink->Flink = &wm->ldr.InMemoryOrderModuleList;
wm->ldr.InMemoryOrderModuleList.Blink = entry->Blink;
wm->ldr.InMemoryOrderModuleList.Flink = entry;
entry->Blink = &wm->ldr.InMemoryOrderModuleList;
/* wait until init is called for inserting into this list */ /* wait until init is called for inserting into this list */
wm->ldr.InInitializationOrderModuleList.Flink = NULL; wm->ldr.InInitializationOrderModuleList.Flink = NULL;
@ -1386,7 +1374,6 @@ NTSTATUS WINAPI LdrFindEntryForAddress(const void* addr, PLDR_MODULE* pmod)
*pmod = mod; *pmod = mod;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
if (mod->BaseAddress > addr) break;
} }
return STATUS_NO_MORE_ENTRIES; return STATUS_NO_MORE_ENTRIES;
} }
@ -3088,6 +3075,8 @@ void WINAPI LdrInitializeThunk( void *kernel_start, ULONG_PTR unknown2,
/* the main exe needs to be the first in the load order list */ /* the main exe needs to be the first in the load order list */
RemoveEntryList( &wm->ldr.InLoadOrderModuleList ); RemoveEntryList( &wm->ldr.InLoadOrderModuleList );
InsertHeadList( &peb->LdrData->InLoadOrderModuleList, &wm->ldr.InLoadOrderModuleList ); InsertHeadList( &peb->LdrData->InLoadOrderModuleList, &wm->ldr.InLoadOrderModuleList );
RemoveEntryList( &wm->ldr.InMemoryOrderModuleList );
InsertHeadList( &peb->LdrData->InMemoryOrderModuleList, &wm->ldr.InMemoryOrderModuleList );
if ((status = virtual_alloc_thread_stack( NtCurrentTeb(), 0, 0 )) != STATUS_SUCCESS) goto error; if ((status = virtual_alloc_thread_stack( NtCurrentTeb(), 0, 0 )) != STATUS_SUCCESS) goto error;
if ((status = server_init_process_done()) != STATUS_SUCCESS) goto error; if ((status = server_init_process_done()) != STATUS_SUCCESS) goto error;