Hi All,
I'm working on an assignment to support an HID device as the XInput device in the game. I've hooked the XInput APIs and DirectInput APIs.
When I tested in the game GTA5, it crashes the game when calling the original callback function of the EnumObjects. Please take a look at the following log:
00000074 83.80397034 [4092] [4092 3296]UNICODE version interface
00000075 83.80400085 [4092] [4092 3296]CXGLDirectInput8W::CXGLDirectInput8W
00000076 83.80457306 [4092] [4092 3296]<<CXGLDInputImpl::DirectInput8Create - hr:0x0
00000077 83.80511475 [4092] [4092 3296]CXGLDirectInput8W::AddRef
00000078 83.80567932 [4092] [4092 3296]CXGLDirectInput8W::CreateDevice - guid:{6F1D2B61-D5A0-11CF-BFC7-444553540000}
00000079 83.80657959 [4092] [4092 3296]CXGLDirectInput8W::EnumDevices - devType:0x4, flags:0x1
00000080 83.82684326 [4092] [4092 3296]CXGLDirectInput8W::CreateDevice - guid:{FB219230-D9B8-11E6-8001-444553540000}
00000081 83.82961273 [4092] [4092 3296]CXGLDirectInput8W::CreateDevice - guid:{FF7B9D80-D9B8-11E6-8002-444553540000}
00000082 83.83124542 [4092] [4092 3296]CXGLDirectInput8W::CreateDevice - guid:{FFDAD480-D9B8-11E6-8003-444553540000}
00000083 83.83289337 [4092] [4092 3296]CXGLDirectInput8W::CreateDevice - guid:{00994280-D9B9-11E6-8004-444553540000}
00000084 83.83465576 [4092] [4092 3296]CXGLDirectInput8W::CreateDevice - guid:{C334046D-0000-0000-0000-504944564944}
00000085 83.83593750 [4092] [4092 3296]CXGLDirectInputDevice8W::CXGLDirectInputDevice8W - 0x0000000000000000
00000086 83.83647156 [4092] [4092 3296]CXGLDirectInputDevice8W::QueryInterface - guid:{54D41081-DC15-4833-A41B-748F73A38179}
00000087 83.83686066 [4092] [4092 3296]CXGLDirectInputDevice8W::AddRef - count:2
00000088 83.83724213 [4092] [4092 3296]CXGLDirectInputDevice8W::Release - count:1
00000089 83.83763885 [4092] [4092 3296]CXGLDirectInputDevice8W::GetDeviceInfo
00000090 83.83803558 [4092] [4092 3296]>>CXGLDirectInputDevice8W::EnumObjects - flags:0x0
00000091 85.62302399 [996] The process \??\C:\Windows\system32\WerFault.exe 3064 is created
00000092 85.62399292 [996] The process C:\Windows\system32\WerFault.exe 3064 164 232 starts
My code is as below:
HRESULT CXGLDirectInputDevice8W::EnumObjects(LPDIENUMDEVICEOBJECTSCALLBACKW callback, LPVOID ref, DWORD flags)
{
HRESULT hr = E_NOTIMPL;
XGLLog(L">>%s - flags:0x%x", __FUNCTIONW__, flags);
static DIDEVICEOBJECTINSTANCEW didoi[] =
{
{ sizeof(DIDEVICEOBJECTINSTANCEW), GUID_YAxis, 0x0, 0x102, 0x100, L"Y Axis", 0x0, 0x0, 0x1, 0x0, 0x1, 0x31, 0x0, 0x0, 0x0 }
};
if (callback != NULL)
{
switch (flags)
{
case DIDFT_ALL:
for (int nIndex = 0; nIndex < _countof(didoi); nIndex++)
{
(*callback)(&didoi[nIndex], ref);
}
break;
}
hr = DI_OK;
}
XGLLog(L"<<%s - hr:0x%x", __FUNCTIONW__, hr);
return hr;
}
Does any know why? How to fix it? I've attached the entire project for your reference.
XGLSim.zip 30.78KB
5 downloads
Thanks,
Marshall