Page 1 of 1

Why does this not work and make an error?

Posted: Mon Sep 12, 2005 5:21 pm
by mikecaliber
ws_psapi_lib = 1
ws_psapi_h.l = OpenLibrary(ws_psapi_lib,"PSAPI.DLL")
*ws_EnumProcessModules = IsFunction(ws_psapi_h,"EnumProcessModules")
CloseLibrary(ws_psapi_lib)



Enter that code into your pb and run it.... I get a Windows runtime error. I am trying to use that .dll call (EnumProcessModules) as it is not one of the "built-in" calls in PB. I don't think that the PSAPI library is supported natively by PB yet, right?

best,
cal

Posted: Mon Sep 12, 2005 6:19 pm
by Pupil
Are you sure that the dll is opened properly (you don't check this in the code you posted here)?

Posted: Mon Sep 12, 2005 6:31 pm
by freak
You must pass the 'ws_psapi_lib' value to IsFunction, not the other one.

Posted: Mon Sep 12, 2005 7:24 pm
by mikecaliber
thanks freak!

i am an idiot for missing that-

in the following code,

DWORD FindModule (HANDLE hProcess, const char* sModule)
{
HMODULE hMod[1024];
DWORD cbNeeded;

If( EnumProcessModules( hProcess, hMod, SizeOf(hMod), &cbNeeded) )
{
For ( unsigned int i=0 ; i < (cbNeeded / sizeof(HMODULE)) ; i++ )
{
char sModName[MAX_PATH];

GetModuleBaseNameA( hProcess, hMod, sModName, SizeOf(sModName) );

If ( !stricmp(sModName, sModule) )
{
Return (DWORD)hMod;
}
}
}

Return 0;
}

which is c++, what would I do to make the conversion to PB. for instance-

the HANDLE type, what do i use there? the HMODULE type? what to use there? swap DWORD with .l?

also, what would be a good way to convert the line:

HMODULE hMod[1024];

into pb? what does this do and what would be the code that would represent this in pb?




best,
mike

Posted: Mon Sep 12, 2005 7:33 pm
by mikecaliber
bump for more views

Posted: Mon Sep 12, 2005 7:39 pm
by traumatic