It looks to me like there might be a bug in the 35XX CE BSP's GPIO driver.
If you look at the gpio.h file in the common directory it clearly look like it was designed for both inprocess and cross process use.
The first call to GPIOOpen tests if it is an inprocess or out of process call (see GPIO.cpp). In process calls will use the returned function table for subsequent calls where as out of process call will use the DeviceIoControl call.
If you look at around 515 in gpio.h you will see DeviceIoControl return does not seem to handle the returned code correctly.
i.e.
// Get function pointers. If not possible (b/c of cross process calls), use IOCTLs instead
if (!DeviceIoControl(
hDevice, IOCTL_DDK_GET_DRIVER_IFC, (VOID*)&DEVICE_IFC_GPIO_GUID,
sizeof(DEVICE_IFC_GPIO_GUID), &pContext->ifc,
sizeof(DEVICE_IFC_GPIO), NULL, NULL))
{
// Need to use IOCTLs instead of direct function ptrs
pContext->ifc.context = 0;
DEBUGMSG(1, (L"GPIOOpen DeviceIoControl failed\r\n"));
CloseHandle(hDevice);
LocalFree(pContext);
pContext = NULL;
goto cleanUp;
}
// Save device handle
pContext->hDevice = hDevice;
cleanUp:
return pContext;
}
I think it should be something like:
// Get function pointers. If not possible (b/c of cross process calls), use IOCTLs instead
if
(!DeviceIoControl(
hDevice, IOCTL_DDK_GET_DRIVER_IFC, (VOID*)&DEVICE_IFC_GPIO_GUID,
sizeof
(DEVICE_IFC_GPIO_GUID), &pContext->ifc,
sizeof
(DEVICE_IFC_GPIO), NULL, NULL))
{
//// Need to use IOCTLs instead of direct function ptrs
//pContext->ifc.context = 0;
//DEBUGMSG(1, (L"GPIOOpen DeviceIoControl failed\r\n"));
//CloseHandle(hDevice);
//LocalFree(pContext);
//pContext = NULL;
//goto cleanUp;
if
(ERROR_ACCESS_DENIED == GetLastError())
{
// Need to use IOCTLs instead of direct function ptrs
pContext->ifc.context = 0; } else
{ DEBUGMSG(1, (L
"GPIOOpen DeviceIoControl failed\r\n"
));
CloseHandle(hDevice);
LocalFree(pContext);
pContext = NULL;
goto
cleanUp;
}
}
// Save device handle
pContext->hDevice = hDevice; cleanUp: return
pContext;
} Could someone please give me a second opinion? I have not fully verified but I think its better. DV