Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #undef UNICODE
- #define PSAPI_VERSION 1
- #include<iostream>
- #include<Windows.h>
- #include<TlHelp32.h>
- #include <stdio.h>
- #include <tchar.h>
- #include <psapi.h>
- DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offsets[], DWORD BaseAddress);
- using namespace std;
- DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offsets[], DWORD BaseAddress)
- {
- //DECLARE BASE ADDRESS
- DWORD pointer = BaseAddress; // Declare a pointer of DWORD
- //USED TO output the contents in the pointer
- DWORD pTemp;
- DWORD pointerAddr;
- for (int i = 0; i < PointerLevel; i++)
- {
- if (i == 0)
- {
- ReadProcessMemory(hProcHandle, (LPCVOID)pointer, &pTemp, 4, NULL);
- }
- //add first offset to that address
- pointerAddr = pTemp + Offsets[i]; // Set p1 to content of p + offset
- //Read memory one more time and exit the loop
- ReadProcessMemory(hProcHandle, (LPCVOID)pointerAddr, &pTemp, 4, NULL);
- }
- return pointerAddr;
- }
- DWORD dwGetModuleBaseAddress(DWORD dwProcessIdentifier, CHAR *lpszModuleName)
- {
- HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessIdentifier);
- DWORD dwModuleBaseAddress = 0;
- if (hSnapshot != INVALID_HANDLE_VALUE)
- {
- MODULEENTRY32 ModuleEntry32 = { 0 };
- ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
- if (Module32First(hSnapshot, &ModuleEntry32))
- {
- do
- {
- if (_tcscmp(ModuleEntry32.szModule, lpszModuleName) == 0)
- {
- dwModuleBaseAddress = (DWORD)ModuleEntry32.modBaseAddr;
- break;
- }
- } while (Module32Next(hSnapshot, &ModuleEntry32));
- }
- CloseHandle(hSnapshot);
- }
- return dwModuleBaseAddress;
- }
- DWORD hackBaseAddress = {0x006A1E98};
- DWORD woodOffsets[] = {0x30, 0x3D0, 0x480 };
- int main()
- {
- HWND hwnd = FindWindowA(NULL, "Harvest Seasons");
- if (hwnd == NULL)
- {
- cout << "Cannot find window" << endl;
- Sleep(3000);
- exit(-1);
- }
- else
- {
- DWORD procID;
- GetWindowThreadProcessId(hwnd, &procID);
- HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID);
- DWORD baseAddr = dwGetModuleBaseAddress(procID, (char*)TEXT("Harvest Seasons.exe"));
- if (hProc == NULL)
- {
- std::cout << "Cannot open process...";
- Sleep(3000);
- exit(-1);
- }
- else
- {
- DWORD WoodValue = 1000;
- DWORD WoodAddressToWrite = FindDmaAddy(3, hProc, woodOffsets, baseAddr);
- printf("%x", WoodAddressToWrite);
- Sleep(10000);
- WriteProcessMemory(hProc, (BYTE*)WoodAddressToWrite, &WoodValue, sizeof(WoodValue), NULL);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement