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 


[C++]Writing OpCode to Memory

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Blackvz
Newbie cheater
Reputation: 0

Joined: 08 Jul 2012
Posts: 19

PostPosted: Sun Jun 23, 2013 10:13 am    Post subject: [C++]Writing OpCode to Memory Reply with quote

So all I want to know is how I can write opcode to a specific memory address.
So I have a adress ... e.g. : 0x323F with the instruction : jmp 0555938

and my Aim is to NOP it with C++.
Before that i already connected to the Process of the game.

Hope someone can help Smile
Back to top
View user's profile Send private message
Innovation
Grandmaster Cheater
Reputation: 12

Joined: 14 Aug 2008
Posts: 617

PostPosted: Sun Jun 23, 2013 10:37 am    Post subject: Reply with quote

In an injected DLL, you need only dereference the address after making sure the memory is writable.

In a separate process, you can use OpenProcess and WriteProcessMemory (again, after making sure the memory is writable).


Last edited by Innovation on Sun Jun 23, 2013 10:55 am; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25823
Location: The netherlands

PostPosted: Sun Jun 23, 2013 10:48 am    Post subject: Reply with quote

don't forget VirtualQuery(Ex) in both cases
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Blackvz
Newbie cheater
Reputation: 0

Joined: 08 Jul 2012
Posts: 19

PostPosted: Sun Jun 23, 2013 1:52 pm    Post subject: Reply with quote

Sorry guys , I need a little more help because its just new to me :/
Sorry sorry :s

I know how to write a Value to memory...
It's like that one :

int newammo = 999;

WriteProcessMemory(hproc,(LPVOID)erg3,&newammo,
sizeof(newammo),0);

but how should i write asm to it ?

Maybe __asm {} ? But which type is it etc...Please give me a short example :S
Back to top
View user's profile Send private message
berkay2578
How do I cheat?
Reputation: 0

Joined: 24 Dec 2012
Posts: 3
Location: Turkey

PostPosted: Tue Jun 25, 2013 2:00 am    Post subject: Reply with quote

BYTE NOPBytes[5] = "\x90\x90\x90\x90\x90";
DWORD NOPAddr = 0x00001234;

WriteProcessMemory( hProcessHandle, (LPVOID)NOPAddr, &NOPBytes, 5, NULL );

//Just use bytes instead of asm
Back to top
View user's profile Send private message
Blackvz
Newbie cheater
Reputation: 0

Joined: 08 Jul 2012
Posts: 19

PostPosted: Tue Jun 25, 2013 3:06 pm    Post subject: Reply with quote

Thanks Bro !

Works perfectly !! Thankssss

but how it works e.g. with JMP 05523389
Is there any way to convert it ?
Back to top
View user's profile Send private message
logical_operator
How do I cheat?
Reputation: 1

Joined: 17 Jun 2013
Posts: 5

PostPosted: Wed Jun 26, 2013 4:16 am    Post subject: Reply with quote

Code:
#define CALC_REL32(from, to) (reinterpret_cast<DWORD>(to) - reinterpret_cast<DWORD>(from) - 5)

...

   const LPVOID    dest = reinterpret_cast<LPVOID>(0x00400100);
   BYTE          hook_jmp[] = [ 0xE9, 0x00, 0x00, 0x00, 0x00 ]; // 0xE9 = far jump opcode, rel32 follows

   *reinterpret_cast<DWORD*>(hook_jmp + 1) = CALC_REL32(dest, hook);

   if (!WriteProcessMemory(hProcess, dest, reinterpret_cast<LPCVOID>(hook_jmp), sizeof(hook_jmp), NULL))
   {
      // print error
   }
Back to top
View user's profile Send private message
Blackvz
Newbie cheater
Reputation: 0

Joined: 08 Jul 2012
Posts: 19

PostPosted: Wed Jun 26, 2013 12:46 pm    Post subject: Reply with quote

Everythink works , I found out with a simple try!
Thanks to all , who helped.
Not the first time , really good support here Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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