I tried to hook the d3d9:createdevice API and create a NvIFR object in it. But in the NvIFRlib.create(), the API NvIFR_CreateEx_fn() always return -17. But -17 is not defined in NVIFRRESULT. What does it mean? Any ideas? Thanks a lot.
DllExport HRESULT __stdcall
hook_D3D9CreateDevice(
IDirect3DDevice9 * This,
UINT Adapter,
D3DDEVTYPE DeviceType,
HWND hFocusWindow,
DWORD BehaviorFlags,
D3DPRESENT_PARAMETERS *pPresentationParameters,
LPDIRECT3DDEVICE9 *ppReturnedDeviceInterface
)
{
static int createdevice_hooked = 0;
HRESULT hr = pD3D9CreateDevice(This, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
if(createdevice_hooked > 0)
return hr;
if(FAILED(hr))
return hr;
//! Turn off culling
(*ppReturnedDeviceInterface)->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
//! Turn off D3D lighting
(*ppReturnedDeviceInterface)->SetRenderState( D3DRS_LIGHTING, FALSE );
//! Turn on the zbuffer
(*ppReturnedDeviceInterface)->SetRenderState( D3DRS_ZENABLE, TRUE );
HINSTANCE g_hNvIFRDll=NULL;
NvIFRLibrary NvIFRlib;
//! Load the NvIFR.dll library
if(NULL == (g_hNvIFRDll = NvIFRlib.load()))
{
ga_error("Unable to load the NvIFR library\r\n");
}
g_pIFRtest = (NvIFRToSys *)NvIFRlib.create(*ppReturnedDeviceInterface, NVIFR_TOSYS);
if (!g_pIFRtest)
{
ga_error( "Failed to create the NvIFRToSys Interface\r\n");
}
.....
}