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 


Hooking in C# / .net framework application

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

Joined: 11 Dec 2016
Posts: 2

PostPosted: Sun Dec 11, 2016 2:18 pm    Post subject: Hooking in C# / .net framework application Reply with quote

Hey guys!
I've been looking for a solution for this problem for a while now: I'm writing a hack via dll injection for a program, and I would really like to hook a specific function. Now, if that function was simply part of the windows api or any dll with exported symbols, I'd have no problem at all. Hooking that seems rather straightforwad, and there are hundreds of libraries available that allow you to do that without even knowing what you're doing.
Unfortunately, the function I want to hook is part of the .net framework. From what I've read, you have to mess around with JIT-compilation and also apply the hook at the exact, right time of it if you want every call, including the very first one, to be redirected. At least the function is static, so, unless the .net framework behaves different from what I'd expect, which I could totally imagine as a C++ developer, I wouldn't need an instance pointer or anything like that.
So, what I wanted to ask, is there any guide out there explaining how to hook managed code, maybe even a library that already allows it? It would be cool if it was for C++, though I'd be happy with a solution for C# as well. I'm not picky here, I just want this working.
Just editing the executable is not an option since it checks its own hash. That would probably be bypassable as well, but I'd rather not mess with that right now. The hooking approach would probably come in handy at other times later on as well.
So yeah, if anyone could help me out here, I'd be really grateful!
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 62

Joined: 01 Oct 2008
Posts: 960

PostPosted: Sun Dec 11, 2016 4:31 pm    Post subject: Reply with quote

May be a hint?
http://forum.cheatengine.org/viewtopic.php?p=5509265&sid=8e6d4a8a9be5b2731052e47d5860108c
A Terraria mod.

_________________
- Retarded.
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 Dec 11, 2016 8:26 pm    Post subject: Reply with quote

As panraven pointed to a project of mine, use reflection and library rewriting tools such as Mono.Cecil or dnlib to edit the function as needed. It is extremely easy to hook C# applications using these tools.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Canty
How do I cheat?
Reputation: 0

Joined: 11 Dec 2016
Posts: 2

PostPosted: Mon Dec 12, 2016 1:03 pm    Post subject: Reply with quote

Thanks guys, I'll look into that mod and those libraries. You've been a great help!
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 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