Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Windows.h"
- #include <stdio.h>
- #include "tlhelp32.h"
- DWORD_PTR dwGetModuleBaseAddress(DWORD dwProcessIdentifier, TCHAR *szModuleName);
- DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offests[], DWORD BaseAddress);
- int main()
- {
- HWND hWindow = 0;
- while (hWindow == NULL)
- {
- hWindow = FindWindow(NULL, "TmForever");
- Sleep(1000);
- }
- DWORD dwProcessID = -1;
- GetWindowThreadProcessId(hWindow, &dwProcessID);
- if (dwProcessID == -1)
- printf("Error: ProcessID not found!");
- HANDLE hGameHandle = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, false, dwProcessID);
- if (!hGameHandle)
- printf("Error: GameHandle");
- printf("Loading hack....");
- DWORD baseAddress = dwGetModuleBaseAddress( dwProcessID,_T("TmForever.exe"));
- //dwGetModuleBaseAddress just returns 0000000 :(
- //baseAddress = {0x07E16430}; // i used this to test some functions. i used the base i got from cheatengine
- //but it didnt work with the pTemp in FindDmaAddy it was always 1
- DWORD staticOffset = { 0x976A7C }; //this is never used.. i dont know how to use this
- DWORD TmaniaOffset[] = { 0x188, 0x58, 0x328, 0xEE };
- DWORD AddressToWrite = FindDmaAddy(4, hGameHandle, TmaniaOffset, baseAddress );
- int coordinate;
- ReadProcessMemory(hGameHandle, (PBYTE*)(AddressToWrite), &coordinate, sizeof(int), NULL);
- coordinate = coordinate + 50;
- WriteProcessMemory(hGameHandle, (PBYTE*)(AddressToWrite), &coordinate, sizeof(coordinate), NULL);
- return 0;
- }
- DWORD_PTR dwGetModuleBaseAddress(DWORD dwProcessIdentifier, TCHAR *szModuleName)
- {
- DWORD_PTR dwModuleBaseAddress = 0;
- HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE , dwProcessIdentifier);
- if (hSnapshot != INVALID_HANDLE_VALUE)
- {
- MODULEENTRY32 ModuleEntry32;
- ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
- if (Module32First(hSnapshot, &ModuleEntry32))
- {
- do
- {
- //if (_tcscmp(ModuleEntry32.szModule, szModuleName) == 0)
- {
- dwModuleBaseAddress = (DWORD_PTR)ModuleEntry32.modBaseAddr;
- break;
- }
- }
- while (Module32Next(hSnapshot, &ModuleEntry32));
- }
- CloseHandle(hSnapshot);
- }
- return dwModuleBaseAddress;
- }
- DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offests[], DWORD BaseAddress)
- {
- DWORD pointer = BaseAddress;
- DWORD pTemp;
- DWORD pointerAddr;
- for(int i=0; i< PointerLevel; i++)
- {
- if(i == 0)
- {
- ReadProcessMemory(hProcHandle,(LPCVOID)pointer, &pTemp, sizeof(pTemp), NULL);
- }
- pointerAddr = pTemp + Offests[i];
- ReadProcessMemory(hProcHandle, (LPCVOID)pointerAddr, &pTemp, sizeof(pTemp), NULL);
- }
- return pointerAddr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement