I've built an application that hooks into the Win32 TextOut function via APIHiJack. When applications are started, the DLL is injected as expected and my new TextOut function is called successfully.
Currently, there are two issues I'm struggling with regarding remove the hook and would like some guidance.
1) If some applications are closed, they do not send a FreeLibrary(?) call to the DLL to unhook and cleanup. Is this normal and if so, how is this usually dealt with?
2) More importantly, if my application crashes for any reason, the applications still have the hook and crash as expected as my new TextOut function no longer exists.
I have tried to enumerate all processes and find which ones contain the DLL (pretty much the reverse process of the hooking technique) but it never seems to find as many injection points as when hooking and therefore the hooked application(s) crash.
Many thanks in advance.