Alexandre Julliard : regsvr32: Don't use GetBinaryType() on DLL files.
Alexandre Julliard
julliard at winehq.org
Tue Apr 6 15:50:12 CDT 2021
Module: wine
Branch: master
Commit: 44f0a67ba5ab782c7722a682e721ab8f7371dca2
URL: https://source.winehq.org/git/wine.git/?a=commit;h=44f0a67ba5ab782c7722a682e721ab8f7371dca2
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Apr 6 12:01:15 2021 +0200
regsvr32: Don't use GetBinaryType() on DLL files.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
programs/regsvr32/regsvr32.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/programs/regsvr32/regsvr32.c b/programs/regsvr32/regsvr32.c
index ecfd95234dd..ee915ed3e21 100644
--- a/programs/regsvr32/regsvr32.c
+++ b/programs/regsvr32/regsvr32.c
@@ -23,6 +23,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
+#include <winternl.h>
#include <ole2.h>
#include "regsvr32.h"
#include "wine/debug.h"
@@ -166,9 +167,9 @@ static void reexec_self(void)
}
#ifdef _WIN64
-# define ALT_BINARY_TYPE SCS_32BIT_BINARY
+# define ALT_MACHINE IMAGE_FILE_MACHINE_I386
#else
-# define ALT_BINARY_TYPE SCS_64BIT_BINARY
+# define ALT_MACHINE IMAGE_FILE_MACHINE_AMD64
#endif
/**
@@ -187,12 +188,12 @@ static VOID *LoadProc(const WCHAR* strDll, const char* procName, HMODULE* DllHan
*DllHandle = LoadLibraryExW(strDll, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
if(!*DllHandle)
{
- DWORD binary_type;
+ HMODULE module;
if (firstDll && GetLastError() == ERROR_BAD_EXE_FORMAT &&
- GetBinaryTypeW(strDll, &binary_type) &&
- binary_type == ALT_BINARY_TYPE)
+ (module = LoadLibraryExW(strDll, 0, LOAD_LIBRARY_AS_IMAGE_RESOURCE)))
{
- reexec_self();
+ IMAGE_NT_HEADERS *nt = RtlImageNtHeader( (HMODULE)((ULONG_PTR)module & ~3) );
+ if (nt->FileHeader.Machine == ALT_MACHINE) reexec_self();
}
output_write(STRING_DLL_LOAD_FAILED, strDll);
ExitProcess(LOADLIBRARY_FAILED);
More information about the wine-cvs
mailing list