From: bluestar on
I used sample code:KMDF-usbsamp to modify my driver.
I use the below Interface GUID to search my device, but failed in XP
I felt confused for 2 things, hope give me some help.

1. INF file has ClassGUID and I register Interface GUID in callback
function:EvtDeviceAdd
in my driver. What's different between both?
//-----INF File-------//
[Version]
Class=USB
ClassGUID={36FC9E60-C465-11CF-8056-444553540000}
//-----INF File-------//
//-------Driver------//
DEFINE_GUID(GUID_DEVINTERFACE_MyUSB,
0x873fdf, 0x61a8, 0x11d1, 0xaa, 0x5e, 0x0, 0xc0, 0x4f, 0xb1,
0x72,
0x8b);
status = WdfDeviceCreateDeviceInterface(device,
(LPGUID) &GUID_DEVINTERFACE_MyUSB,
NULL);// Reference String
//-------Driver------//


2. Following above setting, I use the interface GUID that registered
by me to enumdevice, but fail to get SP_INTERFACE_DEVICE_DETAIL_DATA.
What's wrong with my code or something?

//--------AP--------//
OpenUsbDevice((LPGUID)&GUID_DEVINTERFACE_MyUSB);


BOOL OpenUsbDevice(LPGUID pGuid)
{
...code omitted...
hardwareDeviceInfo = SetupDiGetClassDevs ( pGuid,
NULL, // Define no enumerator (global)
NULL, // Define no
(DIGCF_PRESENT | // Only Devices
present
DIGCF_DEVICEINTERFACE)); // Function class
devices.
if (hardwareDeviceInfo == INVALID_HANDLE_VALUE) {
return FALSE ;
}

bLoop = TRUE;
nIndex = iCtrlNum = 0;
for(;bLoop;)
{
deviceInterfaceData.cbSize = sizeof (SP_DEVICE_INTERFACE_DATA);
bStatus = SetupDiEnumDeviceInterfaces (hardwareDeviceInfo,
0, // No care about specific PDOs
pGuid,
nIndex, //
&deviceInterfaceData);
if(bStatus == FALSE)
{
SetupDiDestroyDeviceInfoList (hardwareDeviceInfo);
bLoop = FALSE;
continue;
}
nIndex++;
requiredLength = 0;
bStatus = SetupDiGetInterfaceDeviceDetail (
hardwareDeviceInfo,
&deviceInterfaceData,
NULL, // probing so no output buffer yet
0, // probing so output buffer length of zero
&requiredLength,
NULL); // not interested in the specific dev-
node
if(bStatus == FALSE)
{
dwError = GetLastError();
if( dwError != ERROR_INSUFFICIENT_BUFFER )
continue;
}
deviceInterfaceDetailSize = requiredLength;
deviceInterfaceDetailData = (PSP_INTERFACE_DEVICE_DETAIL_DATA)
new BYTE[deviceInterfaceDetailSize];
if( deviceInterfaceDetailData == NULL )
continue;
ZeroMemory(deviceInterfaceDetailData, deviceInterfaceDetailSize);
deviceInterfaceDetailData->cbSize =
sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
bStatus = SetupDiGetInterfaceDeviceDetail (
hardwareDeviceInfo,
&deviceInterfaceData,
deviceInterfaceDetailData,
deviceInterfaceDetailSize,
&requiredLength,
NULL);
=============================> Can't find
deviceInterfaceDetailData
if( bStatus == FALSE)
{
delete[] deviceInterfaceDetailData;
continue;
}
str = deviceInterfaceDetailData->DevicePath;
hOut = NULL;
hOut = CreateFile ( deviceInterfaceDetailData->DevicePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, // no
SECURITY_ATTRIBUTES structure
OPEN_EXISTING, // No special
create flags
0, // No
special attributes
NULL); // No template
file
if (INVALID_HANDLE_VALUE != hOut) {
pCtrlDrvInfo.hPLDevice[iCtrlNum] = hOut;
memcpy(&pCtrlDrvInfo[iCtrlNum].szDevicePath,
&deviceInterfaceDetailData->DevicePath,
strlen(deviceInterfaceDetailData->DevicePath));
iCtrlNum++;
}
delete[] deviceInterfaceDetailData;

}


SetupDiDestroyDeviceInfoList (hardwareDeviceInfo);
//--------AP--------//

From: dsrking2006 on
(1) ClassGUID in inf indicates the class id of your driver (eg.
HID,USB,SYSTEM,etc.,) which is given by microsoft (by default).

(2) DEFINE_GUID is for your application interface. By using this GUID,
you can link both driver & application.

Both are different.

To find your driver, give proper ClassGUID.

======
Dsrking.
From: bluestar on
Thanks for your kindly explanation.
I got more.

On 9$B7n(B10$BF|(B, $B2<8a(B3$B;~(B29$BJ,(B, dsrking2...(a)gmail.com wrote:
> (1) ClassGUID in inf indicates the class id of your driver (eg.
> HID,USB,SYSTEM,etc.,) which is given by microsoft (by default).
>
> (2) DEFINE_GUID is for your application interface. By using this GUID,
> you can link both driver & application.
>
> Both are different.
>
> To find your driver, give proper ClassGUID.
>
> ======
> Dsrking.

 | 
Pages: 1
Prev: BSOD with DC2
Next: Canon MultiPass MCP600F