text: #pragma once
  
  #include "IDirect3DVolume9Hook.h"
  
  /*** IUnknown methods ***/
  COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE IDirect3DVolume9Hook::QueryInterface(THIS_ REFIID riid, void** ppvObj)
  {
  	HRESULT ret = realObject->QueryInterface(riid, ppvObj);
  	if (ret == NOERROR)
  	{
  		*ppvObj = this;
  		AddRef();
  	}
  	return ret;
  }
  
  COM_DECLSPEC_NOTHROW ULONG STDMETHODCALLTYPE IDirect3DVolume9Hook::AddRef(THIS)
  {
  	ULONG ret = realObject->AddRef();
  	++refCount;
  	return ret;
  }
  
  COM_DECLSPEC_NOTHROW ULONG STDMETHODCALLTYPE IDirect3DVolume9Hook::Release(THIS)
  {
  	ULONG ret = realObject->Release();
  	if (--refCount == 0)
  	{
  #ifdef DEBUGPRINT_D3DHOOKOBJECT_FULLRELEASES
  		char printBuffer[128] = {0};
  #pragma warning(push)
  #pragma warning(disable:4996)
  		sprintf(printBuffer, "Fully releasing hooked Volume Surface %p\n", this);
  #pragma warning(pop)
  		OutputDebugStringA(printBuffer);
  #endif
  		delete this;
  	}
  	return ret;
  }
  
  /*** IDirect3DVolume9 methods ***/
  COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE IDirect3DVolume9Hook::GetDevice(THIS_ IDirect3DDevice9** ppDevice)
  {
  	LPDIRECT3DDEVICE9 realD3D9dev = NULL;
  	HRESULT ret = realObject->GetDevice(&realD3D9dev);
  	if (FAILED(ret) )
  	{
  		*ppDevice = NULL;
  		return ret;
  	}
  
  	// Check that the parentHook's underlying IDirect3DDevice9* matches the realD3D9dev pointer
  	if (parentDevice->GetUnderlyingDevice() != realD3D9dev)
  	{
  		DbgBreakPrint("Error: Unknown d3d9 device hook detected!");
  	}
  	parentDevice->AddRef(); // Super important to increment the ref-count here, otherwise our parent object will get destroyed when Release() is called on it!
  
  	*ppDevice = parentDevice;
  	return ret;
  }
  
  COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE IDirect3DVolume9Hook::SetPrivateData(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags)
  {
  	HRESULT ret = realObject->SetPrivateData(refguid, pData, SizeOfData, Flags);
  	return ret;
  }
  
  COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE IDirect3DVolume9Hook::GetPrivateData(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData)
  {
  	HRESULT ret = realObject->GetPrivateData(refguid, pData, pSizeOfData);
  	return ret;
  }
  
  COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE IDirect3DVolume9Hook::FreePrivateData(THIS_ REFGUID refguid)
  {
  	HRESULT ret = realObject->FreePrivateData(refguid);
  	return ret;
  }
  
  COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE IDirect3DVolume9Hook::GetContainer(THIS_ REFIID riid,void** ppContainer)
  {
  	HRESULT ret = realObject->GetContainer(riid, ppContainer);
  	return ret;
  }
  
  COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE IDirect3DVolume9Hook::GetDesc(THIS_ D3DVOLUME_DESC *pDesc)
  {
  	HRESULT ret = realObject->GetDesc(pDesc);
  	return ret;
  }
  
  COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE IDirect3DVolume9Hook::LockBox(THIS_ D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX* pBox,DWORD Flags)
  {
  	HRESULT ret = realObject->LockBox(pLockedVolume, pBox, Flags);
  	return ret;
  }
  
  COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE IDirect3DVolume9Hook::UnlockBox(THIS)
  {
  	HRESULT ret = realObject->UnlockBox();
  	return ret;
  }
  