@@ -59,32 +59,37 @@ bool ImGui::Init()
5959 // Get the DirectX9 Device.
6060 // Valve used DXVK for Vulkan, so the API it uses layers over DirectX's stuff so the device handle can be used for both cases.
6161
62- uintptr_t deviceAddressPtr = NULL ;
62+ IDirect3DDevice9** deviceHandlePtr ;
6363 if (Memory::GetModuleHandleByName (MODULE_SHADERAPIDX9))
64- deviceAddressPtr = Memory::Scan (MODULE_SHADERAPIDX9, " A1 ? ? ? ? 6A 00" , 1 );
64+ deviceHandlePtr = Memory::Scan<IDirect3DDevice9**> (MODULE_SHADERAPIDX9, " A1 ? ? ? ? 6A 00" , 1 );
6565 else
66- deviceAddressPtr = Memory::Scan (MODULE_APIVULKAN, " A1 ? ? ? ? 56 84 DB" , 1 );
66+ deviceHandlePtr = Memory::Scan<IDirect3DDevice9**> (MODULE_APIVULKAN, " A1 ? ? ? ? 56 84 DB" , 1 );
6767
68- if (!deviceAddressPtr )
68+ if (!deviceHandlePtr )
6969 {
7070 assert (0 && " Failed to get address pointer to the DirectX9 device!" );
7171 Log (WARNING, false , " Failed to get address pointer to the DirectX9 device!" );
7272 return false ;
7373 }
7474
7575 // Get the device itself from the pointer pointer of the device address.
76- ImGui::g_pDXDevice = Memory::Deref<IDirect3DDevice9*>(deviceAddressPtr) ;
77- if (!ImGui::g_pDXDevice )
76+ ImGui::dXDevice = *deviceHandlePtr ;
77+ if (!ImGui::dXDevice )
7878 {
7979 assert (0 && " Failed to get DirectX9 device!" );
8080 Log (WARNING, false , " Failed to get DirectX9 device!" );
8181 return false ;
8282 }
8383
84+ // Get the "Reset" class function
85+ ImGui::Reset = Memory::VMT<void *>(dXDevice, 16 );
86+ Log (INFO, false , " Reset %p" , Reset);
87+
8488 // Get the "Present" class function used for rendering to it can be hooked.
85- ImGui::Present = Memory::VMT<void *>(g_pDXDevice , 17 );
89+ ImGui::Present = Memory::VMT<void *>(dXDevice , 17 );
8690 Log (INFO, false , " Present %p" , Present);
8791
92+
8893 // TODO: Add ImGui initialization calls here.
8994
9095 return true ;
@@ -96,5 +101,6 @@ void ImGui::Shutdown()
96101}
97102
98103HWND GeneralGUI::hWnd = nullptr ;
99- IDirect3DDevice9* ImGui::g_pDXDevice = nullptr ;
104+ IDirect3DDevice9* ImGui::dXDevice = nullptr ;
105+ void * ImGui::Reset = nullptr ;
100106void * ImGui::Present = nullptr ;
0 commit comments