ich habe momentan ein problem.
Die Programmbase von SpiderSolitär ändert sich nach jedem neustart des Programms.
Das bedeutet für mich, dass ich diese herausfinden muss.
Nun hab ich hier einen Code, der jedoch einfach nicht funktionieren will.
Hier mal der Code:
Code:
#include <windows.h>
#include <tlhelp32.h>
#include <iostream>
using namespace std;
// Forward declarations:
BOOL ListProcessModules( DWORD dwPID );
int main(void)
{
//Process ID herausfinden
HWND window = FindWindow(0, ("Spider Solitär"));
if(window == 0)
{
cerr << "Window not found!" << endl;
system ("Pause");
return 0;
}
DWORD dwPID = 0;
GetWindowThreadProcessId(window, &dwPID);
cout << "Window found. PID: " << dwPID << endl;
ListProcessModules(dwPID);
system ("Pause");
return 0;
}
BOOL ListProcessModules(DWORD dwPID)
{
HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
MODULEENTRY32 me32;
hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwPID);
if(hModuleSnap == INVALID_HANDLE_VALUE)
{
cout << "INVALID_HANDLE_VALUE --- CreateToolhelp32Snapshot" << endl;
return( FALSE );
}
// Set the size of the structure before using it.
me32.dwSize = sizeof( MODULEENTRY32 );
// Retrieve information about the first module,
// and exit if unsuccessful
if( !Module32First( hModuleSnap, &me32 ) )
{
CloseHandle( hModuleSnap );
return( FALSE );
}
// Now walk the module list of the process,
// and display information about each module
do
{
printf( TEXT("\n base address = 0x%08X"), (DWORD) me32.modBaseAddr );
}
while( Module32Next( hModuleSnap, &me32 ) );
printf( TEXT("\n"));
CloseHandle( hModuleSnap );
return( TRUE );
}
Code:
hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwPID);
Jedoch weiß ich nicht, was genau da falsch ist.
Kennt sich jemand damit aus und könnte mal gucken, wo der fehler liegt?
Mit freundlichem Gruß
xX.Slayer.Xx







