Skip to content

Commit

Permalink
Add QueryInterface logging.
Browse files Browse the repository at this point in the history
For each call of QueryInterface, to get a better idea of which object is which.
  • Loading branch information
bo3b committed Apr 4, 2014
1 parent be02411 commit 24b379b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
5 changes: 5 additions & 0 deletions DirectX11/d3d11Wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 } };
Expand Down Expand Up @@ -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)
{
Expand Down
8 changes: 6 additions & 2 deletions DirectXGI/Direct3DXGIFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 **) &param) == 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 **)&param) == 0x13bc7e31)
{
//if (D3D11Wrapper::LogFile) fprintf(D3D11Wrapper::LogFile, " forward was successful.\n");
//
Expand Down Expand Up @@ -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 **) &param) == 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 **)&param) == 0x13bc7e31)
{
if (D3D11Wrapper::LogFile) fprintf(D3D11Wrapper::LogFile, " forward was successful.\n");
}
Expand Down
14 changes: 11 additions & 3 deletions DirectXGI/d3dxgiWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -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);
Expand All @@ -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);

Expand All @@ -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");
}
Expand Down

0 comments on commit 24b379b

Please sign in to comment.