Use LoadLibrary instead of LoadModule

LoadLibrary increase the reference count to the library. So we make sure this library is still loaded when we shut down the hook.
This commit is contained in:
Nemirtingas 2019-08-18 16:19:28 +02:00
parent fdeb5912d3
commit f096a2d8a2
7 changed files with 27 additions and 24 deletions

View file

@ -166,7 +166,7 @@ DX10_Hook::DX10_Hook():
pDevice(nullptr),
mainRenderTargetView(nullptr)
{
_dll = GetModuleHandle(DLL_NAME);
_library = LoadLibrary(DLL_NAME);
// Hook to D3D10CreateDevice and D3D10CreateDeviceAndSwapChain so we know when it gets called.
// If its called, then DX10 will be used to render the overlay.
@ -185,8 +185,9 @@ DX10_Hook::~DX10_Hook()
{
PRINT_DEBUG("DX10 Hook removed\n");
if (_hooked)
resetRenderState();
resetRenderState();
FreeLibrary(reinterpret_cast<HMODULE>(_library));
_inst = nullptr;
}