[PATCH v2 0/2] MR5009: ntoskrnl.exe: Support ImagePaths just starting with System32.
https://bugs.winehq.org/show_bug.cgi?id=51998 The first patch should make no functional change, just move the block out to a helper function. I assume changing to L"" literals is expected? The second patch handles ImagePaths starting with `System32` similar like it is already done for `\\SystemRoot\\` and adds the windows directory in front of it. -- v2: ntoskrnl.exe: Support ImagePaths just starting with System32. ntoskrnl.exe: Add helper to create absolute ImagePath. https://gitlab.winehq.org/wine/wine/-/merge_requests/5009
From: Bernhard Übelacker <bernhardu(a)mailbox.org> --- dlls/ntoskrnl.exe/ntoskrnl.c | 38 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index ec67781d9d1..a47bba8df13 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -3915,14 +3915,29 @@ static void WINAPI ldr_notify_callback(ULONG reason, LDR_DLL_NOTIFICATION_DATA * } } +static WCHAR* get_absolute_imagepath( WCHAR *path, DWORD size, DWORD offset ) +{ + WCHAR buffer[MAX_PATH]; + LPWSTR str; + + GetWindowsDirectoryW(buffer, MAX_PATH); + + str = HeapAlloc(GetProcessHeap(), 0, + (size - offset + lstrlenW(buffer)) * sizeof(WCHAR)); + lstrcpyW(str, buffer); + lstrcatW(str, path + offset); + HeapFree( GetProcessHeap(), 0, path ); + return str; +} + /* load the .sys module for a device driver */ static HMODULE load_driver( const WCHAR *driver_name, const UNICODE_STRING *keyname ) { - static const WCHAR driversW[] = {'\\','d','r','i','v','e','r','s','\\',0}; - static const WCHAR systemrootW[] = {'\\','S','y','s','t','e','m','R','o','o','t','\\',0}; - static const WCHAR postfixW[] = {'.','s','y','s',0}; - static const WCHAR ntprefixW[] = {'\\','?','?','\\',0}; - static const WCHAR ImagePathW[] = {'I','m','a','g','e','P','a','t','h',0}; + static const WCHAR driversW[] = L"\\drivers\\"; + static const WCHAR systemrootW[] = L"\\SystemRoot\\"; + static const WCHAR postfixW[] = L".sys"; + static const WCHAR ntprefixW[] = L"\\??\\"; + static const WCHAR ImagePathW[] = L"ImagePath"; HKEY driver_hkey; HMODULE module; LPWSTR path = NULL, str; @@ -3953,18 +3968,7 @@ static HMODULE load_driver( const WCHAR *driver_name, const UNICODE_STRING *keyn } if (!wcsnicmp( path, systemrootW, 12 )) - { - WCHAR buffer[MAX_PATH]; - - GetWindowsDirectoryW(buffer, MAX_PATH); - - str = HeapAlloc(GetProcessHeap(), 0, (size -11 + lstrlenW(buffer)) - * sizeof(WCHAR)); - lstrcpyW(str, buffer); - lstrcatW(str, path + 11); - HeapFree( GetProcessHeap(), 0, path ); - path = str; - } + str = path = get_absolute_imagepath( path, size, 11 ); else if (!wcsncmp( path, ntprefixW, 4 )) str = path + 4; else -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5009
From: Bernhard Übelacker <bernhardu(a)mailbox.org> https://bugs.winehq.org/show_bug.cgi?id=51998 --- dlls/ntoskrnl.exe/ntoskrnl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index a47bba8df13..2b94e4ed807 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -3917,14 +3917,16 @@ static void WINAPI ldr_notify_callback(ULONG reason, LDR_DLL_NOTIFICATION_DATA * static WCHAR* get_absolute_imagepath( WCHAR *path, DWORD size, DWORD offset ) { + static const WCHAR separator[] = L"\\"; WCHAR buffer[MAX_PATH]; LPWSTR str; GetWindowsDirectoryW(buffer, MAX_PATH); str = HeapAlloc(GetProcessHeap(), 0, - (size - offset + lstrlenW(buffer)) * sizeof(WCHAR)); + (size - offset + lstrlenW(buffer) + lstrlenW(separator)) * sizeof(WCHAR)); lstrcpyW(str, buffer); + lstrcatW(str, separator); lstrcatW(str, path + offset); HeapFree( GetProcessHeap(), 0, path ); return str; @@ -3935,6 +3937,7 @@ static HMODULE load_driver( const WCHAR *driver_name, const UNICODE_STRING *keyn { static const WCHAR driversW[] = L"\\drivers\\"; static const WCHAR systemrootW[] = L"\\SystemRoot\\"; + static const WCHAR system32W[] = L"System32"; static const WCHAR postfixW[] = L".sys"; static const WCHAR ntprefixW[] = L"\\??\\"; static const WCHAR ImagePathW[] = L"ImagePath"; @@ -3968,7 +3971,9 @@ static HMODULE load_driver( const WCHAR *driver_name, const UNICODE_STRING *keyn } if (!wcsnicmp( path, systemrootW, 12 )) - str = path = get_absolute_imagepath( path, size, 11 ); + str = path = get_absolute_imagepath( path, size, 12 ); + else if (!wcsnicmp( path, system32W, 8 )) + str = path = get_absolute_imagepath( path, size, 0 ); else if (!wcsncmp( path, ntprefixW, 4 )) str = path + 4; else -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5009
Hello, rebased the patches to wine-9.16. Are there changes needed to get this accepted? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5009#note_79941
This merge request was closed by Alexandre Julliard. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5009
Superseded by a581f11e3e536fbef1865f701c0db2444673d096. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5009#note_90422
participants (2)
-
Alexandre Julliard (@julliard) -
Bernhard Übelacker