Use GetModuleHandleW ()

Also fix an unwanted ref-count increment on a module HANDLE
This commit is contained in:
Luca Bacci 2022-12-30 16:42:02 +01:00 committed by Jehan
parent f7be0cf68e
commit ed1e4236ba
6 changed files with 15 additions and 14 deletions

View file

@ -221,7 +221,7 @@ gui_unique_win32_init (Gimp *gimp)
/* register window class for proxy window */ /* register window class for proxy window */
memset (&wc, 0, sizeof (wc)); memset (&wc, 0, sizeof (wc));
wc.hInstance = GetModuleHandle (NULL); wc.hInstance = GetModuleHandleW (NULL);
wc.lpfnWndProc = gui_unique_win32_message_handler; wc.lpfnWndProc = gui_unique_win32_message_handler;
wc.lpszClassName = GIMP_UNIQUE_WIN32_WINDOW_CLASS; wc.lpszClassName = GIMP_UNIQUE_WIN32_WINDOW_CLASS;

View file

@ -613,7 +613,7 @@ main (int argc,
t_SetDllDirectoryA p_SetDllDirectoryA; t_SetDllDirectoryA p_SetDllDirectoryA;
p_SetDllDirectoryA = p_SetDllDirectoryA =
(t_SetDllDirectoryA) GetProcAddress (GetModuleHandle ("kernel32.dll"), (t_SetDllDirectoryA) GetProcAddress (GetModuleHandleW (L"kernel32.dll"),
"SetDllDirectoryA"); "SetDllDirectoryA");
if (p_SetDllDirectoryA) if (p_SetDllDirectoryA)
(*p_SetDllDirectoryA) (""); (*p_SetDllDirectoryA) ("");
@ -647,7 +647,7 @@ main (int argc,
t_SetProcessDEPPolicy p_SetProcessDEPPolicy; t_SetProcessDEPPolicy p_SetProcessDEPPolicy;
p_SetProcessDEPPolicy = p_SetProcessDEPPolicy =
(t_SetProcessDEPPolicy) GetProcAddress (GetModuleHandle ("kernel32.dll"), (t_SetProcessDEPPolicy) GetProcAddress (GetModuleHandleW (L"kernel32.dll"),
"SetProcessDEPPolicy"); "SetProcessDEPPolicy");
if (p_SetProcessDEPPolicy) if (p_SetProcessDEPPolicy)
(*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE|PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION); (*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE|PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);
@ -660,7 +660,7 @@ main (int argc,
t_SetCurrentProcessExplicitAppUserModelID p_SetCurrentProcessExplicitAppUserModelID; t_SetCurrentProcessExplicitAppUserModelID p_SetCurrentProcessExplicitAppUserModelID;
p_SetCurrentProcessExplicitAppUserModelID = p_SetCurrentProcessExplicitAppUserModelID =
(t_SetCurrentProcessExplicitAppUserModelID) GetProcAddress (GetModuleHandle ("shell32.dll"), (t_SetCurrentProcessExplicitAppUserModelID) GetProcAddress (GetModuleHandleW (L"shell32.dll"),
"SetCurrentProcessExplicitAppUserModelID"); "SetCurrentProcessExplicitAppUserModelID");
if (p_SetCurrentProcessExplicitAppUserModelID) if (p_SetCurrentProcessExplicitAppUserModelID)
(*p_SetCurrentProcessExplicitAppUserModelID) (L"gimp.GimpApplication"); (*p_SetCurrentProcessExplicitAppUserModelID) (L"gimp.GimpApplication");

View file

@ -200,7 +200,7 @@ gimp_main (GType plug_in_type,
typedef BOOL (WINAPI *t_SetDllDirectoryA) (LPCSTR lpPathName); typedef BOOL (WINAPI *t_SetDllDirectoryA) (LPCSTR lpPathName);
t_SetDllDirectoryA p_SetDllDirectoryA; t_SetDllDirectoryA p_SetDllDirectoryA;
p_SetDllDirectoryA = (t_SetDllDirectoryA) GetProcAddress (GetModuleHandle ("kernel32.dll"), p_SetDllDirectoryA = (t_SetDllDirectoryA) GetProcAddress (GetModuleHandleW (L"kernel32.dll"),
"SetDllDirectoryA"); "SetDllDirectoryA");
if (p_SetDllDirectoryA) if (p_SetDllDirectoryA)
(*p_SetDllDirectoryA) (""); (*p_SetDllDirectoryA) ("");
@ -269,7 +269,7 @@ gimp_main (GType plug_in_type,
typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags); typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
t_SetProcessDEPPolicy p_SetProcessDEPPolicy; t_SetProcessDEPPolicy p_SetProcessDEPPolicy;
p_SetProcessDEPPolicy = GetProcAddress (GetModuleHandle ("kernel32.dll"), p_SetProcessDEPPolicy = GetProcAddress (GetModuleHandleW (L"kernel32.dll"),
"SetProcessDEPPolicy"); "SetProcessDEPPolicy");
if (p_SetProcessDEPPolicy) if (p_SetProcessDEPPolicy)
(*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE|PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION); (*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE|PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);
@ -281,7 +281,7 @@ gimp_main (GType plug_in_type,
typedef HRESULT (WINAPI *t_SetCurrentProcessExplicitAppUserModelID) (PCWSTR lpPathName); typedef HRESULT (WINAPI *t_SetCurrentProcessExplicitAppUserModelID) (PCWSTR lpPathName);
t_SetCurrentProcessExplicitAppUserModelID p_SetCurrentProcessExplicitAppUserModelID; t_SetCurrentProcessExplicitAppUserModelID p_SetCurrentProcessExplicitAppUserModelID;
p_SetCurrentProcessExplicitAppUserModelID = (t_SetCurrentProcessExplicitAppUserModelID) GetProcAddress (GetModuleHandle ("shell32.dll"), p_SetCurrentProcessExplicitAppUserModelID = (t_SetCurrentProcessExplicitAppUserModelID) GetProcAddress (GetModuleHandleW (L"shell32.dll"),
"SetCurrentProcessExplicitAppUserModelID"); "SetCurrentProcessExplicitAppUserModelID");
if (p_SetCurrentProcessExplicitAppUserModelID) if (p_SetCurrentProcessExplicitAppUserModelID)
(*p_SetCurrentProcessExplicitAppUserModelID) (L"gimp.GimpApplication"); (*p_SetCurrentProcessExplicitAppUserModelID) (L"gimp.GimpApplication");

View file

@ -204,7 +204,8 @@ gimp_input_device_store_init (GimpInputDeviceStore *store)
gtk_list_store_set_column_types (GTK_LIST_STORE (store), gtk_list_store_set_column_types (GTK_LIST_STORE (store),
G_N_ELEMENTS (types), types); G_N_ELEMENTS (types), types);
if (!GetModuleHandleEx (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, if (!GetModuleHandleExW (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPCTSTR) &gimp_input_device_store_init, (LPCTSTR) &gimp_input_device_store_init,
&thismodule)) &thismodule))
return; return;

View file

@ -790,7 +790,7 @@ doCaptureMagnificationAPI (HWND selectedHwnd,
/* Create the host window that will store the mag child window */ /* Create the host window that will store the mag child window */
hwndHost = CreateWindowEx (0x08000000 | 0x080000 | 0x80 | 0x20, APP_NAME, NULL, 0x80000000, hwndHost = CreateWindowEx (0x08000000 | 0x080000 | 0x80 | 0x20, APP_NAME, NULL, 0x80000000,
0, 0, 0, 0, NULL, NULL, GetModuleHandle (NULL), NULL); 0, 0, 0, 0, NULL, NULL, GetModuleHandleW (NULL), NULL);
if (!hwndHost) if (!hwndHost)
{ {
@ -808,7 +808,7 @@ doCaptureMagnificationAPI (HWND selectedHwnd,
hwndMag = CreateWindow (WC_MAGNIFIER, TEXT ("MagnifierWindow"), hwndMag = CreateWindow (WC_MAGNIFIER, TEXT ("MagnifierWindow"),
magStyles, magStyles,
0, 0, round4Rect.right - round4Rect.left, round4Rect.bottom - round4Rect.top, 0, 0, round4Rect.right - round4Rect.left, round4Rect.bottom - round4Rect.top,
hwndHost, NULL, GetModuleHandle (NULL), NULL); hwndHost, NULL, GetModuleHandleW (NULL), NULL);
/* Set the callback function that will be called by the api to get the pixels */ /* Set the callback function that will be called by the api to get the pixels */
if (!MagSetImageScalingCallback (hwndMag, (MagImageScalingCallback)doCaptureMagnificationAPI_callback)) if (!MagSetImageScalingCallback (hwndMag, (MagImageScalingCallback)doCaptureMagnificationAPI_callback))

View file

@ -346,9 +346,9 @@ twainMain (void)
pTW_SESSION twSession = initializeTwain(); pTW_SESSION twSession = initializeTwain();
/* Since we are not using our own WinMain anymore where we /* Since we are not using our own WinMain anymore where we
could get hInst we get it here using GetModuleHandle. */ could get hInst we get it here using GetModuleHandleW. */
if (!hInst) if (!hInst)
hInst = GetModuleHandle(NULL); hInst = GetModuleHandleW(NULL);
/* Perform instance initialization */ /* Perform instance initialization */
if (!InitApplication(hInst)) if (!InitApplication(hInst))