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 


How to unload injected dll?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
False Prophet
Expert Cheater
Reputation: -1

Joined: 28 May 2006
Posts: 121

PostPosted: Sun Dec 04, 2011 7:01 am    Post subject: How to unload injected dll? Reply with quote

I am injecting a dll into a process, but when I try to load it again it fails. I need to unload it but I have no idea how.
I am loading the DLL using createremotethread().

_________________
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Sun Dec 04, 2011 7:11 am    Post subject: Reply with quote

There are a few ways you can unload it:

1. Call an exported function in the DLL. This is the more proper way to allow the DLL to properly cleanup and exit gracefully. You can tell the DLL to unload by using FreeLibraryAndExitThread.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683153%28v=vs.85%29.aspx

2. Force the DLL to unload using FreeLibrary. You can call it the same way you are injecting with CreateRemoteThread.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683152%28v=vs.85%29.aspx

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
False Prophet
Expert Cheater
Reputation: -1

Joined: 28 May 2006
Posts: 121

PostPosted: Sun Dec 04, 2011 12:14 pm    Post subject: Reply with quote

Using FreeLibraryAndExitThread() method and still can't inject any dll afterwards.
_________________
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Sun Dec 04, 2011 1:55 pm    Post subject: Reply with quote

False Prophet wrote:
Using FreeLibraryAndExitThread() method and still can't inject any dll afterwards.


Make sure your DLL is fully cleaning up after itself or it may not unload. Check if its still in the process after you call FreeLibraryAndExitThread.

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

Joined: 09 Jan 2012
Posts: 3

PostPosted: Mon Jan 09, 2012 11:27 pm    Post subject: Reply with quote

Hi I've been developing an application which injects a dll via Win32 hook globally.
It had worked fine on Windows XP and its lower versions, but once I tested it in Vista the program just crashed.
To be detail, it wasn't the apllication but the process to which the dll had been injected which the crash occured with the following error info.
I've removed unnecessary information for your convenience.

Problem Event Name: BEX
Application Name: msgmsgr.exe
Fault Module Name: xxx.dll_unloaded. (xxx.dll is the dll I've made and injected)

So, why does this happen on Vista?
I've searched the web and all it says is to delete the dll file.
But this is not the solution for me, since I'm the one actually developing & deploying the file.
Does anyone have an idea which can help me out solve this problem?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Tue Jan 10, 2012 8:33 am    Post subject: Reply with quote

Without more information there isn't much we can do to help you.

What does your DLL do?
What does it hook?
Care to post the code so we can see if its a common mistake?

_________________
- 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 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