Commit 19c48204 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Allow the module file name to not be null-terminated.

parent fd799297
...@@ -1174,6 +1174,7 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path ) ...@@ -1174,6 +1174,7 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
*/ */
static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name, BOOL builtin ) static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name, BOOL builtin )
{ {
WCHAR *buffer;
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);
...@@ -1186,9 +1187,16 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name ...@@ -1186,9 +1187,16 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name
wm->ldr.TlsIndex = -1; wm->ldr.TlsIndex = -1;
wm->ldr.LoadCount = 1; wm->ldr.LoadCount = 1;
RtlCreateUnicodeString( &wm->ldr.FullDllName, nt_name->Buffer + 4 /* \??\ prefix */ ); if (!(buffer = RtlAllocateHeap( GetProcessHeap(), 0, nt_name->Length - 3 * sizeof(WCHAR) )))
if ((p = wcsrchr( wm->ldr.FullDllName.Buffer, '\\' ))) p++; {
else p = wm->ldr.FullDllName.Buffer; RtlFreeHeap( GetProcessHeap(), 0, wm );
return NULL;
}
memcpy( buffer, nt_name->Buffer + 4 /* \??\ prefix */, nt_name->Length - 4 * sizeof(WCHAR) );
buffer[nt_name->Length/sizeof(WCHAR) - 4] = 0;
if ((p = wcsrchr( buffer, '\\' ))) p++;
else p = buffer;
RtlInitUnicodeString( &wm->ldr.FullDllName, buffer );
RtlInitUnicodeString( &wm->ldr.BaseDllName, p ); RtlInitUnicodeString( &wm->ldr.BaseDllName, p );
if (!is_dll_native_subsystem( &wm->ldr, nt, p )) if (!is_dll_native_subsystem( &wm->ldr, nt, p ))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment