Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 50590f1

Browse files
committed
Use GetModuleHandleW to avoid *A functions where possible.
1 parent d61fdc1 commit 50590f1

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

Modules/posixmodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ check_GetFinalPathNameByHandle()
11551155
/* only recheck */
11561156
if (!has_GetFinalPathNameByHandle)
11571157
{
1158-
hKernel32 = GetModuleHandle("KERNEL32");
1158+
hKernel32 = GetModuleHandleW(L"KERNEL32");
11591159
*(FARPROC*)&Py_GetFinalPathNameByHandleA = GetProcAddress(hKernel32,
11601160
"GetFinalPathNameByHandleA");
11611161
*(FARPROC*)&Py_GetFinalPathNameByHandleW = GetProcAddress(hKernel32,
@@ -6526,7 +6526,7 @@ check_CreateSymbolicLinkW()
65266526
/* only recheck */
65276527
if (has_CreateSymbolicLinkW)
65286528
return has_CreateSymbolicLinkW;
6529-
hKernel32 = GetModuleHandle("KERNEL32");
6529+
hKernel32 = GetModuleHandleW(L"KERNEL32");
65306530
*(FARPROC*)&Py_CreateSymbolicLinkW = GetProcAddress(hKernel32,
65316531
"CreateSymbolicLinkW");
65326532
if (Py_CreateSymbolicLinkW)
@@ -9365,7 +9365,7 @@ win32_urandom(PyObject *self, PyObject *args)
93659365

93669366
/* Obtain handle to the DLL containing CryptoAPI
93679367
This should not fail */
9368-
hAdvAPI32 = GetModuleHandle("advapi32.dll");
9368+
hAdvAPI32 = GetModuleHandleW(L"advapi32.dll");
93699369
if(hAdvAPI32 == NULL)
93709370
return win32_error("GetModuleHandle", NULL);
93719371

PC/frozen_dllmain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ BOOL CallModuleDllMain(char *modName, DWORD dwReason)
118118
BOOL (WINAPI * pfndllmain)(HINSTANCE, DWORD, LPVOID);
119119

120120
char funcName[255];
121-
HMODULE hmod = GetModuleHandle(NULL);
121+
HMODULE hmod = GetModuleHandleW(NULL);
122122
strcpy(funcName, "_DllMain");
123123
strcat(funcName, modName);
124124
strcat(funcName, "@12"); // stdcall convention.

PC/winreg.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ PyDeleteKeyEx(PyObject *self, PyObject *args, PyObject *kwargs)
10661066

10671067
/* Only available on 64bit platforms, so we must load it
10681068
dynamically. */
1069-
hMod = GetModuleHandle("advapi32.dll");
1069+
hMod = GetModuleHandleW(L"advapi32.dll");
10701070
if (hMod)
10711071
pfn = (RDKEFunc)GetProcAddress(hMod,
10721072
"RegDeleteKeyExW");
@@ -1590,7 +1590,7 @@ PyDisableReflectionKey(PyObject *self, PyObject *args)
15901590

15911591
/* Only available on 64bit platforms, so we must load it
15921592
dynamically.*/
1593-
hMod = GetModuleHandle("advapi32.dll");
1593+
hMod = GetModuleHandleW(L"advapi32.dll");
15941594
if (hMod)
15951595
pfn = (RDRKFunc)GetProcAddress(hMod,
15961596
"RegDisableReflectionKey");
@@ -1626,7 +1626,7 @@ PyEnableReflectionKey(PyObject *self, PyObject *args)
16261626

16271627
/* Only available on 64bit platforms, so we must load it
16281628
dynamically.*/
1629-
hMod = GetModuleHandle("advapi32.dll");
1629+
hMod = GetModuleHandleW(L"advapi32.dll");
16301630
if (hMod)
16311631
pfn = (RERKFunc)GetProcAddress(hMod,
16321632
"RegEnableReflectionKey");
@@ -1663,7 +1663,7 @@ PyQueryReflectionKey(PyObject *self, PyObject *args)
16631663

16641664
/* Only available on 64bit platforms, so we must load it
16651665
dynamically.*/
1666-
hMod = GetModuleHandle("advapi32.dll");
1666+
hMod = GetModuleHandleW(L"advapi32.dll");
16671667
if (hMod)
16681668
pfn = (RQRKFunc)GetProcAddress(hMod,
16691669
"RegQueryReflectionKey");

0 commit comments

Comments
 (0)