I'm trying to get the base address of a process using a method from a previous question. However when I try to compile it gives me this error in CodeBlocks C:CodeBlocks Projects...main.cpp|38|error: invalid conversion from 'BYTE* {aka unsigned char*}' to 'DWORD {aka long unsigned int}' [-fpermissive]|
. I have tried looking up solutions but different types of casting suggested by others failed. Any help would be much appreciated. And here is my code just in case it's needed.
#include <windows.h>
#include <tlhelp32.h>
#include <iostream>
#define UNINITIALIZED 0xFFFFFFFF
using namespace std;
int main()
{
DWORD processID = NULL;
DWORD base_addr = UNINITIALIZED;
HANDLE procH = INVALID_HANDLE_VALUE;
MODULEENTRY32 mod_entry;
CHAR proc_name[40];
ZeroMemory(&proc_name, sizeof(proc_name));
system("tasklist");
cout << "Please enter the PID: " << flush;
cin >> processID;
cout << "Please enter the name: " << flush;
cin >> proc_name;
system("CLS");
procH = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, processID);
if(procH == INVALID_HANDLE_VALUE)
{
cout << "Process handle could not be retrieved" << endl;
return 1;
}
while(base_addr == UNINITIALIZED)
{
do
{
if(!strcmp(mod_entry.szModule, proc_name))
{
base_addr = mod_entry.modBaseAddr;
system("CLS");
cout << "Base address found: " << hex << base_addr << endl;
system("pause");
break;
}
cout << mod_entry.szModule << endl;
} while(Module32First(procH, &mod_entry));
if(base_addr == UNINITIALIZED)
{
system("CLS");
cout << "Failed to find module " << proc_name << endl;
Sleep(200);
}
}
return 0;
}
The error occurs on the line with this: base_addr = mod_entry.modBaseAddr;
.
Aucun commentaire:
Enregistrer un commentaire