How to find the IDirect3DDevice9 parameter of CreateDevice already defined

Ask gaming related questions (AHK v1.1 and older)
whynotregister
Posts: 147
Joined: 05 Nov 2016, 22:42

How to find the IDirect3DDevice9 parameter of CreateDevice already defined

Post by whynotregister » 25 Oct 2021, 04:49

Code: Select all

Direct3DCreate9(SDKVersion)
{
   if !DllCall("GetModuleHandle","str",(a_windir)"\SysWOW64\d3d9", "PTR")
   {
      MsgBox Error Direct3DCreate9
      Return
   }
   return DllCall((a_windir)"\SysWOW64\d3d9\Direct3DCreate9", "uint", SDKVersion)
}

IDirect3D9_CreateDevice(this,Adapter,DeviceType,hFocusWindow,BehaviorFlags,pPresentationParameters,ByRef ppReturnedDeviceInterface)
{
   hr := DllCall(NumGet(NumGet(this+0)+64),"uint",this,"uint",Adapter,"uint",DeviceType,"uint",hFocusWindow,"uint",BehaviorFlags,"uint",pPresentationParameters,"uint*",ppReturnedDeviceInterface)
   if hr
      MsgBox Error IDirect3D9_CreateDevice
}

d3d := Direct3DCreate9("32")
VarSetCapacity(D3DPRESENT_PARAMETERS, 48+2*A_PtrSize, 0)
NumPut(1, D3DPRESENT_PARAMETERS, 0)
NumPut(1, D3DPRESENT_PARAMETERS, 4)
NumPut(1, D3DPRESENT_PARAMETERS, 24)
NumPut(1, D3DPRESENT_PARAMETERS, 24+2*A_PtrSize)
IDirect3D9_CreateDevice(d3d, 0, 1, 0, 0x00000040, &D3DP
so.. can use the code above to get the EndScene address in window mode. However this is problematic because CreateDevice can't be used in fullscreen.
As a workaround, I found that this is possible by getting the IDirect3DDevice9 parameter value of the already defined CreateDevice and replacing it.
If anyone knows how to implement this, please reply.

Return to “Gaming Help (v1)”