aboutsummaryrefslogtreecommitdiff
path: root/Source.cpp
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2020-10-30 12:26:48 +0100
committerToni Uhlig <matzeton@googlemail.com>2020-10-30 12:26:48 +0100
commit51787d2240b8836b31e38e0590090bbb9041d8c2 (patch)
tree9d18db6661cc208a1ae4dba8097437a6a09ab39c /Source.cpp
parentf873d61f36a46c42cc444dcb596f0d354ae3d202 (diff)
parent822b531a4f9b8120f1126fbaec085b8b6fab4c57 (diff)
Merge branch 'master' of https://github.com/simonsan/Age_of_Empires_II_Definitive-Edition-SDKHEADmaster
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'Source.cpp')
-rw-r--r--Source.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/Source.cpp b/Source.cpp
index e4459e4..ff17667 100644
--- a/Source.cpp
+++ b/Source.cpp
@@ -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)