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#] Inject Opcode into game

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
onlyu1106
How do I cheat?
Reputation: 0

Joined: 25 Nov 2015
Posts: 8

PostPosted: Wed Dec 23, 2015 4:27 am    Post subject: [C#] Inject Opcode into game Reply with quote

I'm using C# to inject my ASM code into game to make the bot
My problem here is how to inject by C#?
I researched and my result are:
VirtualAlloc / VirtualAllocEX (I should use VirtualAlloc or VirtualAllocEX?
WriteProcessMemory
CreateRemoteTheard
WaitForSingleObject / WaitForMultipleObjects ( I should use WaitForSingleObject or WaitForMultipleObjects ?)
VirtualFree/ VirtualFreeEX
CloseHandle(Thread)
Is it right? Please help me, sorry if my english is not good Sad
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: Wed Dec 23, 2015 12:21 pm    Post subject: Reply with quote

If you are looking to do memory edits to a remote process in C# you can use the Process class to obtain the process and its handle:
https://msdn.microsoft.com/en-us/library/system.diagnostics.process(v=vs.110).aspx

Afterward you may need the following API imports:
- VirtualAllocEx
- VirtualFreeEx
- VirtualProtectEx
- CreateRemoteThread
- WaitForSingleObject
- GetExitCodeThread
- WriteProcessMemory

In C# you don't need to use CloseHandle since the process namespace will handle that for you if you use the handle from that. You also don't need things like VirtualAlloc / VirtualFree since those are meant for the current process and not remote processes. (The Ex versions are meant for remote processes.)

If you are just looking to write things like nops or other simple patches you wont need CreateRemoteThread either.

As for WaitForSingleObject or WaitForMultipleObjects, you only need WaitForSingleObject since you are only creating a single handle (the thread if needed) and are waiting for that alone.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
onlyu1106
How do I cheat?
Reputation: 0

Joined: 25 Nov 2015
Posts: 8

PostPosted: Sat Dec 26, 2015 6:05 am    Post subject: Reply with quote

serialize is:
VirtualAllocEx
VirtualProtectEx
WriteProcessMemory
CreateRemoteThread
WaitForSingleObject
GetExitCodeThread
Isnt it???
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: Sat Dec 26, 2015 9:45 pm    Post subject: Reply with quote

What do you mean by serialize? Since the API you listed is the common API for DLL injection, but nothing to do with any type of serialization.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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