in conjuction with my other thread (thread116-1064158)
i have a follow up question regarding void pointers
when working with LPVOID how can i increment the value (see latest attempt in bold, which causes an exception error on about the 3rd loop)
this is visual basic version of the code which works
im trying to now write a vis C++ version but i keep getting errors due to void pointers.
visual C++ code so far
am i on the correct line of attack, or is there another way to work with SYSTEM_INFO void pointers?
any input greatly appreciated
If somethings hard to do, its not worth doing - Homer Simpson
i have a follow up question regarding void pointers
when working with LPVOID how can i increment the value (see latest attempt in bold, which causes an exception error on about the 3rd loop)
this is visual basic version of the code which works
Code:
Dim hProcess As Long
Dim lpMem As Long, ret As Long, lLenMBI As Long
Dim si As SYSTEM_INFO
Dim mbi As MEMORY_BASIC_INFORMATION
hProcess = OpenProcess(PROCESS_READ_WRITE_QUERY, False, myPID)
lLenMBI = Len(mbi)
Call GetSystemInfo(si)
lpMem = si.lpMinimumApplicationAddress
Do While lpMem < si.lpMaximumApplicationAddress
mbi.RegionSize = 0
ret = VirtualQueryEx(hProcess, ByVal lpMem, mbi, lLenMBI)
If ret = lLenMBI Then
If ((mbi.lType = MEM_PRIVATE) And (mbi.State = MEM_COMMIT)) Then
' this block is In use by this process
'do some stuff here
End If
lpMem = mbi.BaseAddress + mbi.RegionSize
Else
MsgBox "debug:failed"
End If
Loop
CloseHandle hProcess
im trying to now write a vis C++ version but i keep getting errors due to void pointers.
visual C++ code so far
Code:
{
HMODULE hModule[50];
char ModuleName[50];
unsigned char i=0;
SYSTEM_INFO si;
MEMORY_BASIC_INFORMATION mbi;
LPVOID lpMem=0;
LONG ret=0;
LONG lLenMBI=0;
LPVOID lowerGameAdd=0;
LPVOID upperGameAdd=0;
while(i<dwCbNeeded/sizeof(DWORD))
{
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ|PROCESS_TERMINATE,0,ProcessIDList[i++]);
if(hProcess)
{
cbRet=0;
if(lpfEnumProcessModules(hProcess,hModule,50,&cbRet))
if(lpfGetModuleBaseName(hProcess,hModule[0],ModuleName,50))
if(!stricmp(ModuleName,"lithtech.exe"))
{
lLenMBI = sizeof(mbi);
GetSystemInfo(&si);
lpMem = si.lpMinimumApplicationAddress;
while(lpMem < si.lpMaximumApplicationAddress)
{
mbi.RegionSize = 0;
ret = VirtualQueryEx(hProcess, lpMem, &mbi, lLenMBI);
if(ret == lLenMBI)
if((mbi.Type == MEM_PRIVATE) && (mbi.State == MEM_COMMIT))
{
//do stuff here
}
//[b]this line is causing me the biggest headache[/b]
lpMem = (void *)((*((unsigned long*)mbi.BaseAddress)) + mbi.RegionSize);
}
cbRet=GetLastError();
CloseHandle(hProcess);
}
}
}
FreeLibrary(hiPSAPI);
}
am i on the correct line of attack, or is there another way to work with SYSTEM_INFO void pointers?
any input greatly appreciated
If somethings hard to do, its not worth doing - Homer Simpson