I have been trying to reverse a singleplayer x64 game to learn about reversing games. My problem is that I am trying to trace the arguments from a D3D11CreateDeviceAndSwapchain call and as far as I know the first 4 arguments should be stored in the registers rcx, rdx, r8 and r9 and the rest should be pushed to the stack ontop of the shadow area of the stack.

Looking at the assembly I am posting below from IDA, it only pushes something far beyond the shadow area and the data does not seem to have anything to do with the call at all. So im wondering if DirectX calls are different somehow? Or am I simply just looking in the wrong place?

.text:000000000143269B lea     rax, [rsp+218h+arg_0]
.text:00000000014326A3 lea     rbp, [rdi+0CA8h]
.text:00000000014326AA xor     r8d, r8d
.text:00000000014326AD mov     [rsp+218h+var_1C0], rax
.text:00000000014326B2 mov     [rsp+218h+var_1C8], rbp
.text:00000000014326B7 lea     rax, [rsp+218h+arg_10]
.text:00000000014326BF mov     [rsp+218h+var_1D0], rax
.text:00000000014326C4 lea     rax, [rsp+228h]
.text:00000000014326CC mov     [rsp+218h+var_1D8], rax
.text:00000000014326D1 mov     [rsp+218h+var_1E0], rsi
.text:00000000014326D6 mov     dword ptr [rsp+218h+var_1E8], 7
.text:00000000014326DE mov     dword ptr [rsp+218h+var_1F0], r15d
.text:00000000014326E3 mov     [rsp+218h+var_1F8], r15
.text:00000000014326E8 call    D3D11CreateDeviceAndSwapChain

1 Answer 1


The API D3D11CreateDeviceAndSwapChain function in question takes 12 arguments
From your disassembly find out what var_1c0 etc is defined as ( i would presume it is -0x1c0 )

so (218 + (-0x1c0 and so on it would be ) = 58 , 50 , 48 , 40 , 38, 30 ,28 ,20,r9,r8,rdx,rcx) etc etc

you can see pub const D3D11_SDK_VERSION: DWORD = 7 at 1e8 = (218-1e8)/8 = 30 which is the 7th argument according to the documentation

HRESULT D3D11CreateDeviceAndSwapChain(
  _In_opt_        IDXGIAdapter         *pAdapter,  ==== rcx
                  D3D_DRIVER_TYPE      DriverType,  ==== rdx
                  HMODULE              Software,    ==== r8
                  UINT                 Flags,       ==== r9 
  _In_opt_  const D3D_FEATURE_LEVEL    *pFeatureLevels, ==== 1f8 == 20
                  UINT                 FeatureLevels,   ===== 1f0 == 28
                  UINT                 SDKVersion, <<<<<< == 7 ===1e8 == 30
  _In_opt_  const DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
  _Out_opt_       IDXGISwapChain       **ppSwapChain,
  _Out_opt_       ID3D11Device         **ppDevice,
  _Out_opt_       D3D_FEATURE_LEVEL    *pFeatureLevel,
  _Out_opt_       ID3D11DeviceContext  **ppImmediateContext

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.