@@ -72,14 +72,17 @@ static LONG WINAPI NewSetWindowLong(_In_ HWND hWnd, _In_ int nIndex, _In_ LONG d
7272 // If we haven't yet set the RemixWndProc, as is evident by g_gameWndProc being invalid, then just
7373 // call OrigSetWindowLong as usual
7474 if (isSet ()) {
75+ // We only handle cases wherein the window's handle matches the window's handle
76+ // used in D3DDEVICE_CREATION_PARAMETERS or D3DPRESENT_PARAMETERS
7577 if (hWnd != g_hwnd) {
7678 Logger::debug (format_string (kStr_newSetWindowLong_settingHwnd , hWnd, g_hwnd));
77- g_hwnd = hWnd;
7879 }
79- auto oldGameWndProc = asLong (g_gameWndProc);
80- g_gameWndProc = asWndProcP (dwNewLong);
81- Logger::debug (format_string (kStr_newSetWindowLong_settingWndProc , g_gameWndProc, oldGameWndProc));
82- return oldGameWndProc;
80+ else {
81+ auto oldGameWndProc = asLong (g_gameWndProc);
82+ g_gameWndProc = asWndProcP (dwNewLong);
83+ Logger::debug (format_string (kStr_newSetWindowLong_settingWndProc , g_gameWndProc, oldGameWndProc));
84+ return oldGameWndProc;
85+ }
8386 }
8487 }
8588 if constexpr (bUnicode) {
@@ -97,7 +100,10 @@ static LONG WINAPI NewGetWindowLong(_In_ HWND hWnd, _In_ int nIndex) {
97100 // call OrigGetWindowLong as usual
98101 if (isSet ()) {
99102 Logger::debug (format_string (kStr_newGetWindowLong_gettingWndProc , g_gameWndProc));
100- return asLong (g_gameWndProc);
103+ // We only handle cases wherein the window's handle matches the window's handle
104+ // used in D3DDEVICE_CREATION_PARAMETERS or D3DPRESENT_PARAMETERS
105+ if (hWnd == g_hwnd)
106+ return asLong (g_gameWndProc);
101107 }
102108 }
103109 if constexpr (bUnicode) {
@@ -355,6 +361,7 @@ bool set(HWND hwnd) {
355361 DInputSetDefaultWindow (hwnd);
356362
357363 Logger::debug (format_string (kStr_set_settingWndProc , RemixWndProc, g_gameWndProc));
364+
358365 return true ;
359366}
360367
@@ -375,6 +382,7 @@ bool unset() {
375382 g_gameWndProc = nullptr ;
376383
377384 Logger::debug (format_string (kStr_unset_unsettingWndProc , prevWndProc, g_gameWndProc));
385+
378386 return true ;
379387}
380388
0 commit comments