I have copied for a test a c++ code (Mw3 code) but there is an error...
Code:
// Mw3Hack.cpp : definisce il punto di ingresso dell'applicazione console.
//
#include "stdafx.h"
#include <Windows.h>
#include <tlhelp32.h>
#include <process.h>
DWORD MW3_PID;
HWND MW3_HWND;
HANDLE MW3_HANDLE;
BYTE* GetEntryPoint(DWORD MW3_PID);
void Do_stuff(void*);
int main()
{
LPCWSTR process = L"iw5mp";
while (!(MW3_HWND = FindWindow(NULL, process)))
Sleep(10);
while (!(GetWindowThreadProcessId(MW3_HWND, &MW3_PID)))
Sleep(10);
while (!(MW3_HANDLE = OpenProcess(PROCESS_ALL_ACCESS, false, MW3_PID)))
Sleep(10);
_beginthread(Do_stuff, 0, 0);
while (MW3_HWND = FindWindow(NULL, process))
{
Sleep(200);
}
return 0;
}
BYTE* GetEntryPoint(DWORD MW3_PID)
{
MODULEENTRY32 iw5mp;
BYTE* ModuleBase = 0; //Byte isn't = NULL
HANDLE hSnapShot = NULL;
if (MW3_PID == 0) return 0;
iw5mp.dwSize = sizeof(iw5mp);
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, MW3_PID);
ModuleBase = iw5mp.modBaseAddr;
CloseHandle(hSnapShot);
return ModuleBase;
}
void Do_stuff(void*)
{
// Let's use DWORDs for the sake of clarity..
DWORD Base = (DWORD)GetEntryPoint(MW3_PID);
DWORD Address = Base + 0x22311; // iw5mp.exe + 0x22311
BYTE temp = 0;
while (1)
{
// Wait for input..
// Then do whatever you want to the address..
WriteProcessMemory(MW3_HANDLE, (PVOID)Address, &temp, 1, NULL);
SetForegroundWindow(MW3_HWND);
}
}
In: BYTE* GetEntryPointThere is a problem with ModuleBase It says: used local variable 'iw5mp' uninitialized