Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Cheats won't work via code but will work via CE? [C++]

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
SpecterNGU
How do I cheat?
Reputation: 0

Joined: 03 Apr 2016
Posts: 1

PostPosted: Sun Apr 03, 2016 11:23 am    Post subject: Cheats won't work via code but will work via CE? [C++] Reply with quote

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.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun Apr 03, 2016 12:18 pm    Post subject: Reply with quote

We do not support online / multiplayer hacking on this site.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites