From 24b379b27970105258d06d36aa74a2373793f2a1 Mon Sep 17 00:00:00 2001 From: bo3b Date: Fri, 4 Apr 2014 03:18:45 -0700 Subject: [PATCH] Add QueryInterface logging. For each call of QueryInterface, to get a better idea of which object is which. --- DirectX11/d3d11Wrapper.cpp | 5 +++++ DirectXGI/Direct3DXGIFunctions.h | 8 ++++++-- DirectXGI/d3dxgiWrapper.cpp | 14 +++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/DirectX11/d3d11Wrapper.cpp b/DirectX11/d3d11Wrapper.cpp index 469af5500..b1c056f07 100644 --- a/DirectX11/d3d11Wrapper.cpp +++ b/DirectX11/d3d11Wrapper.cpp @@ -2034,6 +2034,8 @@ static void RunFrameActions(D3D11Base::ID3D11Device *device) STDMETHODIMP D3D11Wrapper::IDirect3DUnknown::QueryInterface(THIS_ REFIID riid, void** ppvObj) { + if (LogFile) fprintf(LogFile, "D3D11Wrapper::IDirect3DUnknown::QueryInterface called at 'this': %s\n", typeid(this).name()); + IID m1 = { 0x017b2e72ul, 0xbcde, 0x9f15, { 0xa1, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f, 0x70, 0x01 } }; IID m2 = { 0x017b2e72ul, 0xbcde, 0x9f15, { 0xa1, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f, 0x70, 0x02 } }; IID m3 = { 0x017b2e72ul, 0xbcde, 0x9f15, { 0xa1, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f, 0x70, 0x03 } }; @@ -2121,6 +2123,9 @@ STDMETHODIMP D3D11Wrapper::IDirect3DUnknown::QueryInterface(THIS_ REFIID riid, v return E_OUTOFMEMORY; } */ + + if (LogFile) fprintf(LogFile, " calling m_pUnk->QueryInterface, m_pUnk: %s\n", typeid(m_pUnk).name()); + HRESULT hr = m_pUnk->QueryInterface(riid, ppvObj); if (hr == S_OK) { diff --git a/DirectXGI/Direct3DXGIFunctions.h b/DirectXGI/Direct3DXGIFunctions.h index f29949e50..d47612354 100644 --- a/DirectXGI/Direct3DXGIFunctions.h +++ b/DirectXGI/Direct3DXGIFunctions.h @@ -1185,7 +1185,9 @@ STDMETHODIMP D3D11Wrapper::IDXGISwapChain::Present(THIS_ const static IID marker = { 0x017b2e72ul, 0xbcde, 0x9f15, { 0xa1, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f, 0x70, 0x02 } }; IUnknown *deviceIU = (IUnknown *)m_WrappedDevice; int param = 0; - if (deviceIU->QueryInterface(marker, (void **) ¶m) == 0x13bc7e31) +// if (LogFile) fprintf(LogFile, "D3D11Wrapper::IDXGISwapChain::Present calling m_WrappedDevice->QueryInterface, m_WrappedDevice: %s\n", typeid(m_WrappedDevice).name()); + + if (deviceIU->QueryInterface(marker, (void **)¶m) == 0x13bc7e31) { //if (D3D11Wrapper::LogFile) fprintf(D3D11Wrapper::LogFile, " forward was successful.\n"); // @@ -1408,7 +1410,9 @@ STDMETHODIMP D3D11Wrapper::IDXGISwapChain1::Present1(THIS_ const static IID marker = { 0x017b2e72ul, 0xbcde, 0x9f15, { 0xa1, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f, 0x70, 0x02 } }; IUnknown *deviceIU = (IUnknown *)m_WrappedDevice; int param = 0; - if (deviceIU->QueryInterface(marker, (void **) ¶m) == 0x13bc7e31) +// if (LogFile) fprintf(LogFile, "D3D11Wrapper::IDXGISwapChain::Present1 calling m_WrappedDevice->QueryInterface, m_WrappedDevice: %s\n", typeid(m_WrappedDevice).name()); + + if (deviceIU->QueryInterface(marker, (void **)¶m) == 0x13bc7e31) { if (D3D11Wrapper::LogFile) fprintf(D3D11Wrapper::LogFile, " forward was successful.\n"); } diff --git a/DirectXGI/d3dxgiWrapper.cpp b/DirectXGI/d3dxgiWrapper.cpp index 25ed683c1..8139b3b6d 100644 --- a/DirectXGI/d3dxgiWrapper.cpp +++ b/DirectXGI/d3dxgiWrapper.cpp @@ -424,7 +424,9 @@ static void ReplaceInterface(void **ppvObj) STDMETHODIMP D3D11Wrapper::IDirect3DUnknown::QueryInterface(THIS_ REFIID riid, void** ppvObj) { - if (LogFile) fprintf(LogFile, "QueryInterface request for %08lx-%04hx-%04hx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx on %x\n", + if (LogFile) fprintf(LogFile, "D3D11Wrapper::IDirect3DUnknown::QueryInterface called at 'this': %s\n", typeid(this).name()); + + if (LogFile) fprintf(LogFile, "QueryInterface request for %08lx-%04hx-%04hx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx on %x\n", riid.Data1, riid.Data2, riid.Data3, riid.Data4[0], riid.Data4[1], riid.Data4[2], riid.Data4[3], riid.Data4[4], riid.Data4[5], riid.Data4[6], riid.Data4[7], this); bool unknown1 = riid.Data1 == 0x7abb6563 && riid.Data2 == 0x02bc && riid.Data3 == 0x47c4 && riid.Data4[0] == 0x8e && riid.Data4[1] == 0xf9 && riid.Data4[2] == 0xac && riid.Data4[3] == 0xc4 && riid.Data4[4] == 0x79 && @@ -437,6 +439,8 @@ STDMETHODIMP D3D11Wrapper::IDirect3DUnknown::QueryInterface(THIS_ REFIID riid, v return E_OUTOFMEMORY; } */ + if (LogFile) fprintf(LogFile, " calling m_pUnk->QueryInterface, m_pUnk: %s\n", typeid(m_pUnk).name()); + HRESULT hr = m_pUnk->QueryInterface(riid, ppvObj); if (LogFile) fprintf(LogFile, " result = %x, handle = %x\n", hr, *ppvObj); ReplaceInterface(ppvObj); @@ -459,7 +463,9 @@ static IUnknown *ReplaceDevice(IUnknown *wrapper) if (D3D11Wrapper::LogFile) fprintf(D3D11Wrapper::LogFile, " checking for device wrapper, handle = %x\n", wrapper); IID marker = { 0x017b2e72ul, 0xbcde, 0x9f15, { 0xa1, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f, 0x70, 0x01 } }; IUnknown *realDevice = wrapper; - if (wrapper->QueryInterface(marker, (void **) &realDevice) == 0x13bc7e31) + if (D3D11Wrapper::LogFile) fprintf(D3D11Wrapper::LogFile, " dxgi.ReplaceDevice calling wrapper->QueryInterface, wrapper: %s\n", typeid(wrapper).name()); + + if (wrapper->QueryInterface(marker, (void **)&realDevice) == 0x13bc7e31) { if (D3D11Wrapper::LogFile) fprintf(D3D11Wrapper::LogFile, " device found. replacing with original handle = %x\n", realDevice); @@ -482,7 +488,9 @@ static void SendScreenResolution(IUnknown *wrapper, int width, int height) info.width = width; info.height = height; SwapChainInfo *infoPtr = &info; - if (wrapper->QueryInterface(marker, (void **) &infoPtr) == 0x13bc7e31) + if (D3D11Wrapper::LogFile) fprintf(D3D11Wrapper::LogFile, " dxgi.SendScreenResolution calling wrapper->QueryInterface, wrapper: %s\n", typeid(wrapper).name()); + + if (wrapper->QueryInterface(marker, (void **)&infoPtr) == 0x13bc7e31) { if (D3D11Wrapper::LogFile) fprintf(D3D11Wrapper::LogFile, " notification successful.\n"); }