SpecterNGU How do I cheat?
Reputation: 0
Joined: 03 Apr 2016 Posts: 1
|
Posted: Sun Apr 03, 2016 11:23 am Post subject: Cheats won't work via code but will work via CE? [C++] |
|
|
I'm attempting to make a little trainer for a game, and I do have a basic understanding of memory and the assembly used. There's a specific instruction that I need to NOP out (with an instruction length of 2 bytes), so I attempted writing the byte array of {0x90, 0x90} to the address, however it doesn't seem to change anything in the game, where if the same thing is done via cheat engine and setting it to active, it works fine.
Is there something I'm forgetting to do? I don't believe I have to freeze the value as I tried and that didn't work either. When I viewed the section in memory of the address I want to modify in cheat engine, it did in-fact change, so I'm confused as to how my code wont cheat the game but adding the address and setting the value in cheat engine will. I've attached my code below;
| Code: | int main()
{
HWND hWindow;
hWindow = FindWindow(0, _T("Tom Clancy's The Division"));
if(!hWindow)
{
printf("[ERROR] Window could not be loaded\n");
return 1;
}
else
{
printf("[SUCCESS] Window loaded successfully...\n");
}
DWORD pid;
GetWindowThreadProcessId(hWindow,&pid);
if(pid == -1)
{
printf("[ERROR] Failed to get process ID.");
return 1;
}
else
{
printf("[SUCCESS] Found PID of game process to be [%lu]\n", pid);
}
BYTE newNop[] = {0x90, 0x90};
QWORD baseAddress = dwGetModuleBaseAddress(pid, _T("TheDivision.exe"));
QWORD recoilAddress = 0x360E5EC;
HANDLE phandle = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, false, pid);
// DEBUG ONLY
std::cout << "Calculated base address to be " << std::hex << std::uppercase << baseAddress << std::endl;
// END OF DEBUG
if(WriteProcessMemory(phandle,(void*)(baseAddress + recoilAddress),newNop,sizeof(newNop),NULL))
{
printf("Success!");
}
while(1)
{
Sleep(1);
WriteProcessMemory(phandle,(void*)(baseAddress + recoilAddress),newNop,sizeof(newNop),NULL);
}
CloseHandle(phandle);
} |
However, this works:
imgur: fNJiK31
[Put into a URL as I don't have those perms]
I'm sure it might just be something minor but I've been looking over it for a while and hopefully someone here knows something I don't.
|
|