Alexandre Julliard : ntdll:
Check for existing modref for the main exe before creating it
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Feb 8 09:12:44 CST 2006
Module: wine
Branch: refs/heads/master
Commit: 1d23e7fee2534c725c2f178963085918c74bde5b
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=1d23e7fee2534c725c2f178963085918c74bde5b
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Feb 8 15:10:56 2006 +0100
ntdll: Check for existing modref for the main exe before creating it
in LdrInitializeThunk.
---
dlls/ntdll/loader.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index c72646a..72022ba 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -2023,18 +2023,20 @@ void WINAPI LdrInitializeThunk( HANDLE m
WINE_MODREF *wm;
LPCWSTR load_path;
PEB *peb = NtCurrentTeb()->Peb;
- UNICODE_STRING *main_exe_name = &peb->ProcessParameters->ImagePathName;
IMAGE_NT_HEADERS *nt = RtlImageNtHeader( peb->ImageBaseAddress );
- version_init( main_exe_name->Buffer );
-
- /* allocate the modref for the main exe */
- if (!(wm = alloc_module( peb->ImageBaseAddress, main_exe_name->Buffer )))
+ /* allocate the modref for the main exe (if not already done) */
+ if (!(wm = get_modref( peb->ImageBaseAddress )) &&
+ !(wm = alloc_module( peb->ImageBaseAddress, peb->ProcessParameters->ImagePathName.Buffer )))
{
status = STATUS_NO_MEMORY;
goto error;
}
wm->ldr.LoadCount = -1; /* can't unload main exe */
+ wm->ldr.Flags &= ~LDR_DONT_RESOLVE_REFS;
+
+ peb->ProcessParameters->ImagePathName = wm->ldr.FullDllName;
+ version_init( wm->ldr.FullDllName.Buffer );
/* the main exe needs to be the first in the load order list */
RemoveEntryList( &wm->ldr.InLoadOrderModuleList );
@@ -2055,10 +2057,10 @@ void WINAPI LdrInitializeThunk( HANDLE m
req->module_size = wm->ldr.SizeOfImage;
req->entry = (char *)peb->ImageBaseAddress + nt->OptionalHeader.AddressOfEntryPoint;
/* API requires a double indirection */
- req->name = &main_exe_name->Buffer;
+ req->name = &wm->ldr.FullDllName.Buffer;
req->exe_file = main_file;
req->gui = (nt->OptionalHeader.Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CUI);
- wine_server_add_data( req, main_exe_name->Buffer, main_exe_name->Length );
+ wine_server_add_data( req, wm->ldr.FullDllName.Buffer, wm->ldr.FullDllName.Length );
wine_server_call( req );
}
SERVER_END_REQ;
@@ -2085,7 +2087,8 @@ void WINAPI LdrInitializeThunk( HANDLE m
return;
error:
- ERR( "Main exe initialization for %s failed, status %lx\n", debugstr_w(main_exe_name->Buffer), status );
+ ERR( "Main exe initialization for %s failed, status %lx\n",
+ debugstr_w(peb->ProcessParameters->ImagePathName.Buffer), status );
exit(1);
}
More information about the wine-cvs
mailing list