rundll32: Only call LoadLibrary16 on x86.

These are imported by ordinal, so on other architectures we end
up calling whatever ends up on that ordinal, which is currently
Beep on x86_64.

Signed-off-by: Esme Povirk <esme@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Esme Povirk 2021-07-06 16:31:47 -05:00 committed by Alexandre Julliard
parent adffa11609
commit 53ec99daeb

View file

@ -83,8 +83,6 @@ static void call_entry_point( void *func, HWND hwnd, HINSTANCE inst, void *cmdli
} }
#endif #endif
static HINSTANCE16 (WINAPI *pLoadLibrary16)(LPCSTR libname);
static FARPROC16 (WINAPI *pGetProcAddress16)(HMODULE16 hModule, LPCSTR name);
static void (WINAPI *pRunDLL_CallEntry16)( FARPROC proc, HWND hwnd, HINSTANCE inst, static void (WINAPI *pRunDLL_CallEntry16)( FARPROC proc, HWND hwnd, HINSTANCE inst,
LPCSTR cmdline, INT cmdshow ); LPCSTR cmdline, INT cmdshow );
@ -112,8 +110,11 @@ static ATOM register_class(void)
return RegisterClassExW(&wcex); return RegisterClassExW(&wcex);
} }
#ifdef __i386__
static HINSTANCE16 load_dll16( LPCWSTR dll ) static HINSTANCE16 load_dll16( LPCWSTR dll )
{ {
HINSTANCE16 (WINAPI *pLoadLibrary16)(LPCSTR libname);
HINSTANCE16 ret = 0; HINSTANCE16 ret = 0;
DWORD len = WideCharToMultiByte( CP_ACP, 0, dll, -1, NULL, 0, NULL, NULL ); DWORD len = WideCharToMultiByte( CP_ACP, 0, dll, -1, NULL, 0, NULL, NULL );
char *dllA = HeapAlloc( GetProcessHeap(), 0, len ); char *dllA = HeapAlloc( GetProcessHeap(), 0, len );
@ -130,6 +131,7 @@ static HINSTANCE16 load_dll16( LPCWSTR dll )
static FARPROC16 get_entry_point16( HINSTANCE16 inst, LPCWSTR entry ) static FARPROC16 get_entry_point16( HINSTANCE16 inst, LPCWSTR entry )
{ {
FARPROC16 (WINAPI *pGetProcAddress16)(HMODULE16 hModule, LPCSTR name);
FARPROC16 ret = 0; FARPROC16 ret = 0;
DWORD len = WideCharToMultiByte( CP_ACP, 0, entry, -1, NULL, 0, NULL, NULL ); DWORD len = WideCharToMultiByte( CP_ACP, 0, entry, -1, NULL, 0, NULL, NULL );
char *entryA = HeapAlloc( GetProcessHeap(), 0, len ); char *entryA = HeapAlloc( GetProcessHeap(), 0, len );
@ -143,6 +145,7 @@ static FARPROC16 get_entry_point16( HINSTANCE16 inst, LPCWSTR entry )
} }
return ret; return ret;
} }
#endif
static void *get_entry_point32( HMODULE module, LPCWSTR entry, BOOL *unicode ) static void *get_entry_point32( HMODULE module, LPCWSTR entry, BOOL *unicode )
{ {
@ -272,8 +275,8 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE hOldInstance, LPWSTR szCmdLine
{ {
HWND hWnd; HWND hWnd;
LPWSTR szDllName,szEntryPoint; LPWSTR szDllName,szEntryPoint;
void *entry_point; void *entry_point = NULL;
BOOL unicode = FALSE, win16; BOOL unicode = FALSE, win16 = FALSE;
STARTUPINFOW info; STARTUPINFOW info;
HMODULE hDll; HMODULE hDll;
@ -300,11 +303,8 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE hOldInstance, LPWSTR szCmdLine
/* Load the library */ /* Load the library */
hDll=LoadLibraryW(szDllName); hDll=LoadLibraryW(szDllName);
if (hDll) if (hDll) entry_point = get_entry_point32( hDll, szEntryPoint, &unicode );
{ #ifdef __i386__
win16 = FALSE;
entry_point = get_entry_point32( hDll, szEntryPoint, &unicode );
}
else else
{ {
HINSTANCE16 dll = load_dll16( szDllName ); HINSTANCE16 dll = load_dll16( szDllName );
@ -315,9 +315,9 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE hOldInstance, LPWSTR szCmdLine
goto CLEANUP; goto CLEANUP;
} }
win16 = TRUE; win16 = TRUE;
unicode = FALSE;
entry_point = get_entry_point16( dll, szEntryPoint ); entry_point = get_entry_point16( dll, szEntryPoint );
} }
#endif
if (!entry_point) if (!entry_point)
{ {