Page 1 of 1

(4.40b2 x86) GetProcAddress_() returns wrong value

Posted: Tue Sep 15, 2009 7:00 am
by breeze4me

Code: Select all

hMod = GetModuleHandle_("Kernel32.dll")
Debug hMod

*p = GetProcAddress_(hMod, "GetCurrentProcessId")
Debug *p  ;<---------- 0

If OpenLibrary(0, "Kernel32.dll")
  Debug GetFunction(0, "GetCurrentProcessId")
EndIf
unicode mode.
;2088763392
;0
;2088802592
ascii mode.
;2088763392
;2088802592
;2088802592

Re: (4.40b2 x86) GetProcAddress_() returns wrong value

Posted: Tue Sep 15, 2009 8:48 am
by Thorium
Confirmed for x86 and x64

Maybe it's because GetProcAddress allways wants a ASCII String.

Re: (4.40b2 x86) GetProcAddress_() returns wrong value

Posted: Tue Sep 15, 2009 11:13 am
by Fred
Yes, it is. You will have to handle this yourself, as PB string are UTF-16 in Unicode mode (best is to use an import with p-ascii like below):

Code: Select all

Import "Kernel32.lib"
  GetProcAddressAscii_(Module, FunctionName.p-ascii) As "_GetProcAddress@8" ; Should be "GetProcAddress" for x64
EndImport

hMod = GetModuleHandle_("Kernel32.dll")
Debug hMod

*p = GetProcAddressAscii_(hMod, "GetCurrentProcessId")
Debug *p

Re: (4.40b2 x86) GetProcAddress_() returns wrong value

Posted: Sat May 05, 2018 2:05 am
by Poplar
hMod = GetModuleHandle_("Kernel32.dll")
Debug hMod

*p = GetProcAddress_(hMod, UTF8("GetCurrentProcessId"))
Debug *p ;<---------- Not null

Re: (4.40b2 x86) GetProcAddress_() returns wrong value

Posted: Sat May 05, 2018 6:03 pm
by Fred
You need to free the UTF8() result somewhere