From Newsgroup: comp.os.ms-windows.misc
I'm using PSAPI.DLL functions like EnumProcesses(). It works
fine as long as I use the import library. But when I use dynamic
binding via GetProcAddress() it crashes in trying to call my
func-pointer. I'm using gcc + MingW. A small snippet:
static BOOL (WINAPI *_EnumProcesses) (ULONG*, ULONG, ULONG*);
ULONG processIds [256], numProcesses;
if (!(*_EnumProcesses) (processIds, sizeof(processIds), &numProcesses))
return (0);
/* Crashes above */
Results of LoadLibrary/GetProcAddress seems fine to me:
LoadExtendedFuncs(): ntdll.dll, RtlInitUnicodeString -> 77F941F8 LoadExtendedFuncs(): ntdll.dll, RtlNtStatusToDosError -> 77F939A6 LoadExtendedFuncs(): psapi.dll, EnumProcesses -> 76BE2FCE
LoadExtendedFuncs(): psapi.dll, EnumProcessModules -> 76BE1913 LoadExtendedFuncs(): psapi.dll, GetModuleFileNameExA -> 76BE1A45
My other func-pointer seems okay. Here's the register dump from DrMingW:
sof.exe caused an Access Violation at location 76be2fce Reading from location 76be2fce.
Registers:
eax=76be2fce ebx=003d3cb8 ecx=00000000 edx=00000000 esi=00000020 edi=0022fee8 eip=76be2fce esp=0022f4fc ebp=0022fe58 iopl=0 nv up ei pl nz ac po nc cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000216
if (!(*_EnumProcesses) (processIds, sizeof(processIds), &numProcesses))
return (0);
Any ideas?
-- gv
--- Synchronet 3.18b-Win32 NewsLink 1.113