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 


ASM (editing EXE)

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

Joined: 08 Mar 2008
Posts: 37

PostPosted: Fri Apr 16, 2010 3:13 pm    Post subject: ASM (editing EXE) Reply with quote

Editing a game EXE in Ollydbg.

So far I have edited everything and it all works however I need to do something else for what I want to do to work.

The game loads a DLL which needs to be loaded however once it has been loaded you can remove it (I have removed it manually by closing its threads to the DLL)

However I want to make it so the EXE closes the threads after the DLL has been fully loaded.

I got the space to do it and I know where to call the code to do it.

The problem is the ASM To do it, the game loads up Kernel32.dll so I got access to the FreeLibrary, close thread etc however I do not know which one I need, what I need to pass to it etc.

Any help on it will be appreciated.


Example, Calls to Kernel32.

Close (Terminate) Thread - CALL DWORD PTR DS:[76B280]

Close Handle - CALL DWORD PTR DS:[76B27C]

Free Library - CALL DWORD PTR DS:[76B0C4]
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sat Apr 17, 2010 5:26 am    Post subject: Reply with quote

so you want to kill threads belonging to that dll ? how are you currently doing that ? then what ? free the library ?
Back to top
View user's profile Send private message
Uli
Cheater
Reputation: 0

Joined: 08 Mar 2008
Posts: 37

PostPosted: Sat Apr 17, 2010 6:17 am    Post subject: Reply with quote

Slugsnack wrote:
so you want to kill threads belonging to that dll ? how are you currently doing that ? then what ? free the library ?


I'm unsure what the hHandle will need to be and that.
Yeah I want to kill the Threads in the EXE which are linked to the DLL.

If freelibrary is enough then I need just to know what hHandle needs to be (Full directory path or just whatever.dll)
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sat Apr 17, 2010 6:22 am    Post subject: Reply with quote

i'm not sure why you want the dll to be loaded up then freed straight afterwards. i mean if that is really the case then you could just write some code in the dllmain that creates a new thread, passing the hinstance which calls freelibraryandexitthread

how are you currently doing this ?

if you freelibrary and there is a thread executing inside that dll at the time, on the next fetch-execute cycle, it would crash with an memory violation
Back to top
View user's profile Send private message
Uli
Cheater
Reputation: 0

Joined: 08 Mar 2008
Posts: 37

PostPosted: Sat Apr 17, 2010 6:36 am    Post subject: Reply with quote

Slugsnack wrote:
i'm not sure why you want the dll to be loaded up then freed straight afterwards. i mean if that is really the case then you could just write some code in the dllmain that creates a new thread, passing the hinstance which calls freelibraryandexitthread

how are you currently doing this ?

if you freelibrary and there is a thread executing inside that dll at the time, on the next fetch-execute cycle, it would crash with an memory violation


okay will try the try that.

The DLL will only get executed if 3 threads respond to it, i removed those 3 threads already however the DLL detects these threads are missing and it close it however if I close the X amount of dll threads in the EXE then it will not close.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sat Apr 17, 2010 6:49 am    Post subject: Reply with quote

what do you mean by X amount of dll threads ? what do you mean by 'the dll will only get executed if 3 threads respond to it' ?

if the dll is able to detect that certain threads are not running then it implies it is in some way synchronizing with those threads. if your solution is to free that dll, then that thread that we assume is executing this synchronization code within the dll must be terminated. is that what you want to do ?

it is odd, though, that a dll would be loaded up for the sole purpose of thread synchronization. mostly, a thread would be created in a function in the calling module for something like that
Back to top
View user's profile Send private message
Uli
Cheater
Reputation: 0

Joined: 08 Mar 2008
Posts: 37

PostPosted: Sat Apr 17, 2010 7:11 am    Post subject: Reply with quote

Slugsnack wrote:
what do you mean by X amount of dll threads ? what do you mean by 'the dll will only get executed if 3 threads respond to it' ?

if the dll is able to detect that certain threads are not running then it implies it is in some way synchronizing with those threads. if your solution is to free that dll, then that thread that we assume is executing this synchronization code within the dll must be terminated. is that what you want to do ?

it is odd, though, that a dll would be loaded up for the sole purpose of thread synchronization. mostly, a thread would be created in a function in the calling module for something like that


Cheat protection, its making sure thats its running otherwise it terminates it.

Free lib and terminate threads is definitely the way I need to handle this, going to try some stuff now hopefully it should work.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sat Apr 17, 2010 7:30 am    Post subject: Reply with quote

it's not a simple matter enumerating threads ( easy part ) and finding which modules they belong to ( at least not in inline asm ). if you're gonna do that, might as well code your own module in asm or something and inject it.

can't you just block the loadlibrary call in the first place ?
Back to top
View user's profile Send private message
Uli
Cheater
Reputation: 0

Joined: 08 Mar 2008
Posts: 37

PostPosted: Sat Apr 17, 2010 7:57 am    Post subject: Reply with quote

Slugsnack wrote:
it's not a simple matter enumerating threads ( easy part ) and finding which modules they belong to ( at least not in inline asm ). if you're gonna do that, might as well code your own module in asm or something and inject it.

can't you just block the loadlibrary call in the first place ?


Things which are needed to run the game are also contained in the library so the library needs to be loaded in order for the game to boot properly. I could add in a loadlibrary for a dll I make which removes the threads required after the game fully boots.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sat Apr 17, 2010 8:20 am    Post subject: Reply with quote

you could always find where this 'check thread' is being launched and disable that call. from what it sounds like, this may well be dllmain. it's unlikely another module would load the library then create the corresponding thread to run inside the new module.
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