Osiris: [Help] FreeLibrary after restoring hooks

Created on 3 Oct 2019  路  5Comments  路  Source: danielkrupinski/Osiris

I'm a beginner so sorry if I'm doing something stupid or don't understand something.

The dll is still loaded after restoring the hooks, would be nice to be able to unhook and free library so you can reinject without restarting the game.

As far as I understand the dll is not creating a new thread so FreeLibrary (and not FreeLibraryAndExitThread) should be enough.
I tried adding the following in the end of the restore function of the Hooks class:

Sleep(100); // Just to ensure I'm not inside a hooked function when library is freed.
FreeLibrary(GetModuleHandleA("Osiris.dll"));

The game crashes with a memory access violation when I press Unhook, but I don't know enough to proceed any further.

PS:
I'm trying to inject a debug build btw, does anyone else have any problems with this?

Most helpful comment

@mathiasxx94 Global objects are created by C-RunTime library in compiler-generated dllmain_crt_dispatch function.

All 5 comments

If you inject a debug build, it will inject and the GUI will open, however when loading a map in game, you will end up crashing.

If you're trying to unhook and inject again use mmap injection.

Thanks works great.

BTW. Do you know how the injected code starts running? There's no DllMain so I can't understand why the functions are hooked.

If you're trying to unhook and inject again use mmap injection.

Thanks works great.

BTW. Do you know how the injected code starts running? There's no DllMain so I can't understand why the functions are hooked.

Osiris.cpp is DllMain.cpp

If you're trying to unhook and inject again use mmap injection.

Thanks works great.
BTW. Do you know how the injected code starts running? There's no DllMain so I can't understand why the functions are hooked.

Osiris.cpp is DllMain.cpp

I'm probably stupid, but why is that? There's only creation of class objects in Osiris.cpp isn't it?

@mathiasxx94 Global objects are created by C-RunTime library in compiler-generated dllmain_crt_dispatch function.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NameNotTakenYAY picture NameNotTakenYAY  路  3Comments

LuizDanG picture LuizDanG  路  3Comments

DivyanshuYT picture DivyanshuYT  路  3Comments

noteffex picture noteffex  路  4Comments

kschou95 picture kschou95  路  3Comments