Refactor dx device creation

Find the game's window instead of using the foreground window.
This commit is contained in:
Nemirtingas 2019-08-20 23:27:17 +02:00
parent dc7480c633
commit 5a0653d080
7 changed files with 71 additions and 12 deletions

View file

@ -7,6 +7,26 @@ extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam
#include "../dll/dll.h"
HWND GetGameWindow()
{
HWND hWnd = FindWindow(NULL, NULL);
while (hWnd)
{
if (!GetParent(hWnd))
{
#if defined(_WIN64)
if (GetModuleHandle(NULL) == (HINSTANCE)GetWindowLong(hWnd, GWLP_HINSTANCE))
break;
#elif defined(_WIN32)
if (GetModuleHandle(NULL) == (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE))
break;
#endif
}
hWnd = GetWindow(hWnd, GW_HWNDNEXT);
}
return hWnd;
}
bool Windows_Hook::start_hook()
{
if (!_hooked)