Skip to content

Commit 6bdf2cb

Browse files
committed
Hook WndProc before calling CreateDevice()
1 parent 7f5a927 commit 6bdf2cb

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

Resources/BuildNo.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define BUILD_NUMBER 2222
1+
#define BUILD_NUMBER 2223

Wrappers/d3d8/IDirect3D8.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,15 @@ HRESULT m_IDirect3D8::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFo
249249
// Update presentation parameters
250250
UpdatePresentParameter(pPresentationParameters, hFocusWindow);
251251

252-
// Set Silent Hill 2 window to forground
253-
SetForegroundWindow(DeviceWindow);
252+
// Get WndProc
253+
if (HookWndProc && DeviceWindow && !OriginalWndProc)
254+
{
255+
OriginalWndProc = (WNDPROC)GetWindowLongA(DeviceWindow, GWL_WNDPROC);
256+
if (OriginalWndProc)
257+
{
258+
SetWindowLongA(DeviceWindow, GWL_WNDPROC, (LONG)WndProc);
259+
}
260+
}
254261

255262
HRESULT hr = D3DERR_INVALIDCALL;
256263

@@ -319,16 +326,6 @@ HRESULT m_IDirect3D8::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFo
319326
RUNCODEONCE(CreateThread(nullptr, 0, SaveScreenshotFile, nullptr, 0, nullptr));
320327
}
321328

322-
// Get WndProc
323-
if (HookWndProc && DeviceWindow && !OriginalWndProc)
324-
{
325-
OriginalWndProc = (WNDPROC)GetWindowLongA(DeviceWindow, GWL_WNDPROC);
326-
if (OriginalWndProc)
327-
{
328-
SetWindowLongA(DeviceWindow, GWL_WNDPROC, (LONG)WndProc);
329-
}
330-
}
331-
332329
GameWindowHandle = DeviceWindow;
333330

334331
return hr;

0 commit comments

Comments
 (0)