99 *****************************************************************************/
1010
1111#include " StdInc.h"
12+ #define FUNC_rwDeviceSystemRequest 0x7F2AB0
13+ #define FUNC_DialogFunc 0x745E50
14+ #define FUNC_RwEngineGetSubSystemInfo 0x7F2C30
15+ #define CLASS_RwGlobals 0xC97B24
16+ #define CLASS_IDirect3D9 0xC97C20
17+ #define NUM_DialogFuncStackPushAddress 0x746239
1218
1319// This is copied from SilentPatch:
1420// https://github.com/CookiePLMonster/SilentPatch/blob/dev/SilentPatch/FriendlyMonitorNames.cpp
@@ -88,16 +94,15 @@ struct RwSubSystemInfo
8894 char name[80 ];
8995};
9096
91- #define FUNC_rwDeviceSystemRequest 0x7F2AB0
9297using rwDeviceSystemRequest = RwSubSystemInfo*(__cdecl*)(RwDevice* device, std::int32_t requestId, RwSubSystemInfo* pOut, void * pInOut, std::int32_t numIn);
9398static RwSubSystemInfo* RwEngineGetSubSystemInfo_Hooked (RwSubSystemInfo* subSystemInfo, std::int32_t subSystemIndex)
9499{
95- auto * rwGlobals = *(RwGlobals**)( 0xC97B24 ) ;
100+ auto * rwGlobals = *(RwGlobals**)CLASS_RwGlobals ;
96101 auto * rwDeviceSystemRequestFunc = (rwDeviceSystemRequest)(FUNC_rwDeviceSystemRequest);
97102 if (!rwDeviceSystemRequestFunc (&rwGlobals->dOpenDevice , 14 , subSystemInfo, nullptr , subSystemIndex))
98103 return nullptr ;
99104
100- auto * pDxDevice = *(IDirect3D9**)0xC97C20 ;
105+ auto * pDxDevice = *(IDirect3D9**)CLASS_IDirect3D9 ;
101106 if (!pDxDevice)
102107 return subSystemInfo;
103108
@@ -121,7 +126,6 @@ static RwSubSystemInfo* RwEngineGetSubSystemInfo_Hooked(RwSubSystemInfo* subSyst
121126 return subSystemInfo;
122127}
123128
124- #define FUNC_DialogFunc 0x745E50
125129INT_PTR CALLBACK CustomDlgProc (HWND window, UINT msg, WPARAM wParam, LPARAM lParam)
126130{
127131 auto * orgDialogFunc = (DLGPROC)FUNC_DialogFunc;
@@ -142,11 +146,10 @@ INT_PTR CALLBACK CustomDlgProc(HWND window, UINT msg, WPARAM wParam, LPARAM lPar
142146 return FALSE ;
143147}
144148
145- #define FUNC_RwEngineGetSubSystemInfo 0x7F2C30
146149void CMultiplayerSA::InitHooks_DeviceSelection ()
147150{
148151 // 0x746239 -> Exact address where the original DialogFunc address is being pushed as an argument to DialogBoxParamA(),
149152 // we're replacing it with out own proxy function
150- MemPut<DLGPROC>(0x746239 , (DLGPROC)&CustomDlgProc);
153+ MemPut<DLGPROC>(NUM_DialogFuncStackPushAddress , (DLGPROC)&CustomDlgProc);
151154 HookInstall (FUNC_RwEngineGetSubSystemInfo, (DWORD)RwEngineGetSubSystemInfo_Hooked, 6 );
152155}
0 commit comments