diff options
Diffstat (limited to 'Source.cpp')
-rw-r--r-- | Source.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -24,6 +24,8 @@ ID3D11DeviceContext* pContext = nullptr; DWORD_PTR* pSwapChainVtable = nullptr; +Core* core = nullptr; + #include "main.h" //helper funcs @@ -183,7 +185,10 @@ HRESULT __stdcall hookD3D11Present(IDXGISwapChain* pSwapChain, UINT SyncInterval ImGui_ImplDX11_NewFrame(); ImGui::NewFrame(); - static Core* core = new Core(); + if (!core) + { + core = new Core(); + } core->OnPresent(); ImGui::EndFrame(); @@ -209,6 +214,7 @@ DWORD __stdcall InitHooks(LPVOID hModule) IDXGISwapChain* pSwapChain; + WNDCLASSEXA wc = { sizeof(WNDCLASSEX), CS_CLASSDC, DXGIMsgProc, 0L, 0L, GetModuleHandleA(NULL), NULL, NULL, NULL, NULL, "DX", NULL }; RegisterClassExA(&wc); HWND hWnd = CreateWindowA("DX", NULL, WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, NULL, NULL, wc.hInstance, NULL); @@ -262,12 +268,16 @@ DWORD __stdcall InitHooks(LPVOID hModule) return NULL; } + pSwapChainVtable = (DWORD_PTR*)pSwapChain; pSwapChainVtable = (DWORD_PTR*)pSwapChainVtable[0]; + + phookD3D11Present = (D3D11PresentHook)(DWORD_PTR*)pSwapChainVtable[8]; VmtHook presentHook = VmtHook((void**)pSwapChainVtable); + presentHook.Hook(8, hookD3D11Present); pDevice->Release(); @@ -279,16 +289,15 @@ DWORD __stdcall InitHooks(LPVOID hModule) } FeatureManager::Get()->OnShutdown(); - + Sleep(200); + core->OnShutdown(); + Sleep(200); presentHook.Unhook(); - Sleep(1000); - (WNDPROC)SetWindowLongPtr(window, GWLP_WNDPROC, (LONG_PTR)OriginalWndProcHandler); - Sleep(1000); - FreeLibraryAndExitThread((HMODULE)hModule, 0); + Sleep(100); } BOOL __stdcall DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) |