Code
Long setSunMoney ()
{
DWORD pId;
HWND myWnd, gameWnd;
GameWnd = FindWindow (NULL, _ T ("Chinese version of Plants vs. Zombies "));
MyWnd = FindWindow (NULL, _ T ("Plants vs. botnets "));
DWORD sun, money;
Sun = (DWORD) GetDlgItemInt (myWnd, IDC_EDIT_SUN, NULL, FALSE );
Money = (DWORD) GetDlgItemInt (myWnd, IDC_EDIT_MONEY, NULL, FALSE );
If (gameWnd = NULL)
{
// MessageBox (myWnd, _ T ("no game found! "), _ T (" Game "), MB_ OK );
Return FALSE;
}
GetWindowThreadProcessId (gameWnd, & pId );
HANDLE hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pId );
LPVOID lpOneBaseAddress = (LPVOID) 0x006a9ec0;
DWORD dwOne;
ReadProcessMemory (
Hprocess,
Lponebaseaddress,
(Lpvoid) & dwone,
Sizeof (DWORD ),
0
);
LPVOID lpTwoBaseAddress = (LPVOID) (dwOne + 0x768 );
DWORD dwTwo;
ReadProcessMemory (
HProcess,
LpTwoBaseAddress,
(LPVOID) & dwTwo,
Sizeof (DWORD ),
0
);
LPVOID lpTrueHPAddress = (LPVOID) (dwTwo + 0x5560 );
/* DWORD dwHP;
ReadProcessMemory (
HProcess,
LpTrueHPAddress,
(LPVOID) & dwHP,
Sizeof (DWORD ),
0
);*/
WriteProcessMemory (
HProcess,
LpTrueHPAddress,
(LPVOID) & sun,
Sizeof (DWORD ),
0
);
Lpvoid lponemoney = (lpvoid) 0x006a9ec0;
DWORD lponeinfo;
Readprocessmemory (hprocess, lponemoney, (lpvoid) & lponeinfo, sizeof (DWORD), 0 );
Lpvoid lptwomoney = (lpvoid) (lponeinfo + 0x82c );
DWORD lptwoinfo;
ReadProcessMemory (hProcess, lpTwoMoney, (LPVOID) & lpTwoInfo, sizeof (DWORD), 0 );
LPVOID lpThreeMoney = (LPVOID) (lpTwoInfo + 0x28 );
/* DWORD lpThreeInfo;
ReadProcessMemory (hProcess, lpThreeMoney, (LPVOID) & lpThreeInfo, sizeof (DWORD), 0 );*/
// DWORD money = 0xea60;
WriteProcessMemory (
HProcess, // HANDLE hProcess,
(LPVOID) lpThreeMoney, // LPVOID lpBaseAddress,
(LPVOID) & money, // LPVOID lpBuffer,
Sizeof (DWORD), // DWORD nSize,
0 // LPDWORD lpNumberOfBytesWritten
);
Return TRUE;
}
Code
DWORD GetWindowThreadProcessId (
HWND hWnd, // handle to window
LPDWORD lpdwProcessId // process identifier
);
BOOL ReadProcessMemory (
HANDLE hProcess, // handle to the process
LPCVOID lpBaseAddress, // base of memory area
LPVOID lpBuffer, // data buffer
Size_t nsize, // number of bytes to read
Size_t * lpnumberofbytesread // number of bytes read
);
Bool writeprocessmemory (
Handle hprocess, // handle to process
Lpvoid lpbaseaddress, // base of memory area
Lpvoid lpbuffer, // data buffer
Size_t nsize, // count of bytes to write
Size_t * lpnumberofbyteswritten // count of bytes written
);