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

@ -137,7 +137,7 @@ DX12_Hook::DX12_Hook():
pCmdList(nullptr),
pDescriptorHeap(nullptr)
{
_dll = GetModuleHandle(DLL_NAME);
_library = GetModuleHandle(DLL_NAME);
PRINT_DEBUG("Trying to hook DX12 but DX12_Hook is not implemented yet, please report to DEV with the game name.");
@ -156,8 +156,9 @@ DX12_Hook::~DX12_Hook()
{
PRINT_DEBUG("DX12 Hook removed\n");
if (_hooked)
resetRenderState();
resetRenderState();
FreeLibrary(reinterpret_cast<HMODULE>(_library));
_inst = nullptr;
}