Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to unload a user DLL from a process created by the DetourCreateProcessWithDllEx function? #317

Open
XiaopengZHOU opened this issue Jul 12, 2024 · 1 comment
Labels

Comments

@XiaopengZHOU
Copy link

Hello everybody,

I want to unload the DLL (inserted with DetourCreateProcessWithDllEx) after use. But the FreeLibrary (or FreeLibraryAndExitThread) function does not work for this case. Is there a solution ?

Thank you so much!

@sylveon
Copy link
Contributor

sylveon commented Jul 13, 2024

When using this method, the DLL is injected by starting the process suspended (before the system can resolve any DLL), adding your DLL to the import table of the process, then resuming the process. So, it's considered a hard dependency of the process by the system.

If you want the DLL to be unloadable, you have to use other techniques to inject at runtime instead of at startup like CreateRemoteThread with LoadLibrary, or SetWindowsHookEx. Alternatively, you could do something like making the DLL uninstall all its hooks, making it do effectively nothing in the process anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants