Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

Monthly Seminars at OSR Headquarters

East Coast USA
Windows Internals and SW Drivers, Dulles (Sterling) VA, 13 November 2017

Kernel Debugging & Crash Analysis for Windows, Nashua (Amherst) NH, 4 December 2017

Writing WDF Drivers I: Core Concepts, Nashua (Amherst) NH, 8 January 2018

WDF Drivers II: Advanced Implementation Techniques, Nashua (Amherst) NH, 15 January 2018


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 9  
09 Aug 17 17:00
Doron Holan
xxxxxx@microsoft.com
Join Date: 08 Sep 2005
Posts To This List: 10090
[OSR-DETECTED-SPAM] Re: SetupDiGetDeviceInterfaceDetail Function & DevicePath

Does intel have sample applications that work? All signs point to the driver refusing the file create though. Have you set a bp on the driver's MJ_CREATE handler to see if it is invoked and what it is returning? Bent from my phone ________________________________ From: xxxxx@lists.osr.com <xxxxx@lists.osr.com> on behalf of xxxxx@winsystems.com xxxxx@lists.osr.com <xxxxx@winsystems.com xxxxx@lists.osr.com> Sent: Wednesday, August 9, 2017 8:37:36 AM To: Windows System Software Devs Interest List Subject: RE:[ntdev] SetupDiGetDeviceInterfaceDetail Function & DevicePath I am running the application in an administrator console window. --- NTDEV is sponsored by OSR Visit the list online at: <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osronline.co m%2Fshowlists.cfm%3Flist%3Dntdev&data=02%7C01%7CDoron.Holan%40microsoft.com%7C534 eca4ddc8f486a70f008d4df3cbc21%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636378 899328192144&sdata=oC7bfp7bJl0uBSvJo7%2FAWGqSG%2BavdOlgCDBebdVAULU%3D&reserved=0> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers! Details at <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osr.com%2Fse minars&data=02%7C01%7CDoron.Holan%40microsoft.com%7C534eca4ddc8f486a70f008d4df3cb c21%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636378899328192144&sdata=QFxAeSQ m0QGBp%2BK6rXb9m1a%2BEJs3kgECzCBI6qHhqHg%3D&reserved=0> To unsubscribe, visit the List Server section of OSR Online at <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osronline.co m%2Fpage.cfm%3Fname%3DListServer&data=02%7C01%7CDoron.Holan%40microsoft.com%7C534 eca4ddc8f486a70f008d4df3cbc21%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636378 899328192144&sdata=ZUFwoef7Z1uRDsRhtQka2eQ4sKOef9LFMp2gW3dsAJk%3D&reserved=0> --
  Message 2 of 9  
09 Aug 17 17:23
PBD
xxxxxx@winsystems.com
Join Date: 03 May 2010
Posts To This List: 71
[OSR-DETECTED-SPAM] Re: SetupDiGetDeviceInterfaceDetail Function & DevicePath

I cannot do a printf since I am in a DLL, but I used the MessageBoxW to confirm that the \\?\ is indeed present. The CreateFile returns a -1 and the GetLastError returns a 2. I have hard coded these strings and tied to open the device with no luck. I see the I2C devices in Device Manager with a loaded driver (iaioi2c.sys). The I2Cpublic.h include file from Intel has this: DEFINE_GUID(I2C_LPSS_INTERFACE_GUID, 0x4fd00181, 0xf807, 0x41aa, 0x8d, 0x33, 0xf2, 0x2c, 0x5d, 0x7c, 0xae, 0xbd); I am including the entire function here so all is visible. Thanks for the help Tim. DECLDIR int InitializeSession() { HDEVINFO DeviceInfoSet; SP_DEVINFO_DATA DeviceInfoData; SP_DEVICE_INTERFACE_DATA DeviceInterfaceData; PSP_DEVICE_INTERFACE_DETAIL_DATA DeviceInterfaceDetailData = NULL; ULONG requiredSize = 0, Length; DWORD Index = 0; HANDLE tempHandle; WCHAR *i2cDevice = I2C_CONTROLLER_NUM; // L"0f41" DWORD LastError; DWORD status = SUCCESS; DeviceInfoSet = SetupDiGetClassDevs((GUID*)&I2C_LPSS_INTERFACE_GUID, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); if (DeviceInfoSet == INVALID_HANDLE_VALUE) return status = INVALID_HANDLE; SetupDiEnumDeviceInfo(DeviceInfoSet, Index, &DeviceInfoData); DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); while (SetupDiEnumDeviceInfo(DeviceInfoSet, Index, &DeviceInfoData)) { DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); SetupDiCreateDeviceInterface(DeviceInfoSet, &DeviceInfoData, &DeviceInfoData.ClassGuid, NULL, 0, &DeviceInterfaceData); // call the first time to get required buffer size status = SetupDiGetDeviceInterfaceDetail(DeviceInfoSet, &DeviceInterfaceData, NULL, 0, &requiredSize, NULL); LastError = GetLastError(); if (status == FALSE && LastError != ERROR_INSUFFICIENT_BUFFER) { SetupDiDestroyDeviceInfoList(DeviceInfoSet); return LastError; } // allocate required buffer if (requiredSize) DeviceInterfaceDetailData = (PSP_INTERFACE_DEVICE_DETAIL_DATA)LocalAlloc(LMEM_FIXED, requiredSize); if (DeviceInterfaceDetailData == NULL) { SetupDiDestroyDeviceInfoList(DeviceInfoSet); return status = INSUFFICIENT_MEMORY; } // call the second time to get detailed info DeviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); Length = requiredSize; status = SetupDiGetDeviceInterfaceDetail(DeviceInfoSet, &DeviceInterfaceData, DeviceInterfaceDetailData, Length, &requiredSize, NULL); if (status == FALSE) { SetupDiDestroyDeviceInfoList(DeviceInfoSet); LocalFree(DeviceInterfaceDetailData); return GetLastError(); } // check for i2c controller #1 and break if (wcsstr(DeviceInterfaceDetailData->DevicePath, i2cDevice) != NULL) break; Index++; } if (DeviceInterfaceDetailData) { tempHandle = CreateFileW(DeviceInterfaceDetailData->DevicePath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); LastError = GetLastError(); if (tempHandle == INVALID_HANDLE_VALUE) status = INVALID_HANDLE; else lvdsControllerHandle = tempHandle; } LocalFree(DeviceInterfaceDetailData); SetupDiDestroyDeviceInfoList(DeviceInfoSet); return status; }
  Message 3 of 9  
09 Aug 17 17:34
PBD
xxxxxx@winsystems.com
Join Date: 03 May 2010
Posts To This List: 71
[OSR-DETECTED-SPAM] Re: SetupDiGetDeviceInterfaceDetail Function & DevicePath

Intel does not provide any code samples but they would be very helpful. I am in contact with them also but they aren't much help. Agreed that the driver does not like what I am trying. Don't believe I have visibility to set bp's in the driver.
  Message 4 of 9  
09 Aug 17 17:52
Doron Holan
xxxxxx@microsoft.com
Join Date: 08 Sep 2005
Posts To This List: 10090
[OSR-DETECTED-SPAM] Re: SetupDiGetDeviceInterfaceDetail Function & DevicePath

As a side note, you are leaking DeviceInterfaceDetailData when if you go th= rough the loop more than once d -----Original Message----- From: xxxxx@lists.osr.com [mailto:bounce-636002-26293@lists.o= sr.com] On Behalf Of xxxxx@winsystems.com xxxxx@lists.osr.com Sent: Wednesday, August 9, 2017 2:22 PM To: Windows System Software Devs Interest List <xxxxx@lists.osr.com> Subject: RE:[ntdev] SetupDiGetDeviceInterfaceDetail Function & DevicePath I cannot do a printf since I am in a DLL, but I used the MessageBoxW to con= firm that the \\?\ is indeed present. The CreateFile returns a -1 and the GetLastError returns a 2. I have hard coded these strings and tied to open the device with no luck. I see the I2C devices in Device Manager with a loaded driver (iaioi2c.sys).= The I2Cpublic.h include file from Intel has this: DEFINE_GUID(I2C_LPSS_INTERFACE_GUID,=20 0x4fd00181, 0xf807, 0x41aa, 0x8d, 0x33, 0xf2, 0x2c, 0x5d, 0x7c, 0xae, 0= xbd); I am including the entire function here so all is visible. Thanks for the h= elp Tim. DECLDIR int InitializeSession() { HDEVINFO DeviceInfoSet; SP_DEVINFO_DATA DeviceInfoData; SP_DEVICE_INTERFACE_DATA DeviceInterfaceData; PSP_DEVICE_INTERFACE_DETAIL_DATA DeviceInterfaceDetailData =3D NULL= ; ULONG requiredSize =3D 0, Length; DWORD Index =3D 0; HANDLE tempHandle; WCHAR *i2cDevice =3D I2C_CONTROLLER_NUM; // L"0f41" DWORD LastError; DWORD status =3D SUCCESS; DeviceInfoSet =3D SetupDiGetClassDevs((GUID*)&I2C_LPSS_INTERFACE_GU= ID, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); if (DeviceInfoSet =3D=3D INVALID_HANDLE_VALUE) return status =3D INVALID_HANDLE; SetupDiEnumDeviceInfo(DeviceInfoSet, Index, &DeviceInfoData); DeviceInfoData.cbSize =3D sizeof(SP_DEVINFO_DATA); while (SetupDiEnumDeviceInfo(DeviceInfoSet, Index, &DeviceInfoData)= ) { DeviceInterfaceData.cbSize =3D sizeof(SP_DEVICE_INTERFACE_DATA)= ; SetupDiCreateDeviceInterface(DeviceInfoSet, &DeviceInfoData, &D= eviceInfoData.ClassGuid, NULL, 0, &DeviceInterfaceData); // call the first time to get required buffer size status =3D SetupDiGetDeviceInterfaceDetail(DeviceInfoSet, &Devi= ceInterfaceData, NULL, 0, &requiredSize, NULL); LastError =3D GetLastError(); if (status =3D=3D FALSE && LastError !=3D ERROR_INSUFFICIENT_BU= FFER) { SetupDiDestroyDeviceInfoList(DeviceInfoSet); return LastError; } // allocate required buffer if (requiredSize) DeviceInterfaceDetailData =3D (PSP_INTERFACE_DEVICE_DETAIL_= DATA)LocalAlloc(LMEM_FIXED, requiredSize); if (DeviceInterfaceDetailData =3D=3D NULL) { SetupDiDestroyDeviceInfoList(DeviceInfoSet); return status =3D INSUFFICIENT_MEMORY; } // call the second time to get detailed info DeviceInterfaceDetailData->cbSize =3D sizeof(SP_DEVICE_INTERFAC= E_DETAIL_DATA); Length =3D requiredSize; status =3D SetupDiGetDeviceInterfaceDetail(DeviceInfoSet, &Devi= ceInterfaceData, DeviceInterfaceDetailData, Length, &requiredSize, NULL); if (status =3D=3D FALSE) { SetupDiDestroyDeviceInfoList(DeviceInfoSet); LocalFree(DeviceInterfaceDetailData); return GetLastError(); } // check for i2c controller #1 and break if (wcsstr(DeviceInterfaceDetailData->DevicePath, i2cDevice) != =3D NULL) break; Index++; } if (DeviceInterfaceDetailData) { tempHandle =3D CreateFileW(DeviceInterfaceDetailData->DevicePat= h, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); LastError =3D GetLastError(); =20 if (tempHandle =3D=3D INVALID_HANDLE_VALUE) status =3D INVALID_HANDLE; else lvdsControllerHandle =3D tempHandle; } LocalFree(DeviceInterfaceDetailData); SetupDiDestroyDeviceInfoList(DeviceInfoSet); return status; } --- NTDEV is sponsored by OSR Visit the list online at: <https://na01.safelinks.protection.outlook.com/?u= rl=3Dhttp%3A%2F%2Fwww.osronline.com%2Fshowlists.cfm%3Flist%3Dntdev&data=3D0= 2%7C01%7CDoron.Holan%40microsoft.com%7C71e5cf79a12244d157b108d4df6cc507%7C7= 2f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636379105638066297&sdata=3DzlZ1ix= daEk2HuUw%2BrqmhL4Hwl67XHWFrlDxGRCPRQTU%3D&reserved=3D0> MONTHLY seminars on crash dump analysis, WDF, Windows internals and softwar= e drivers! Details at <https://na01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F= %2Fwww.osr.com%2Fseminars&data=3D02%7C01%7CDoron.Holan%40microsoft.com%7C71= e5cf79a12244d157b108d4df6cc507%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7= C636379105638066297&sdata=3DByugIsaoTrggRuQx%2Fv4dAUPJv9uBzNKkTySKjJUzRoU%3= D&reserved=3D0> To unsubscribe, visit the List Server section of OSR Online at <https://na0= 1.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fwww.osronline.com%2F= page.cfm%3Fname%3DListServer&data=3D02%7C01%7CDoron.Holan%40microsoft.com%7= C71e5cf79a12244d157b108d4df6cc507%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C= 0%7C636379105638066297&sdata=3DRjdsDPFPV4VDEv%2BaFpGB7ZRoSFxvDGsmjb2%2FA6mq= vpo%3D&reserved=3D0>
  Message 5 of 9  
09 Aug 17 17:55
Doron Holan
xxxxxx@microsoft.com
Join Date: 08 Sep 2005
Posts To This List: 10090
[OSR-DETECTED-SPAM] Re: SetupDiGetDeviceInterfaceDetail Function & DevicePath

For the breakpoint, sure you do and you don't need symbols. !drvobj <driver= object> 2 will show you the entry points, including the one for IRP_MJ_CRE= ATE. You can get the driver object from the device object or !object \Drive= r d -----Original Message----- From: xxxxx@lists.osr.com [mailto:bounce-636003-26293@lists.o= sr.com] On Behalf Of xxxxx@winsystems.com xxxxx@lists.osr.com Sent: Wednesday, August 9, 2017 2:33 PM To: Windows System Software Devs Interest List <xxxxx@lists.osr.com> Subject: RE:[ntdev] [OSR-DETECTED-SPAM] Re: SetupDiGetDeviceInterfaceDetail= Function & DevicePath Intel does not provide any code samples but they would be very helpful. I a= m in contact with them also but they aren't much help. Agreed that the driv= er does not like what I am trying. Don't believe I have visibility to set b= p's in the driver.=20 --- NTDEV is sponsored by OSR Visit the list online at: <https://na01.safelinks.protection.outlook.com/?u= rl=3Dhttp%3A%2F%2Fwww.osronline.com%2Fshowlists.cfm%3Flist%3Dntdev&data=3D0= 2%7C01%7CDoron.Holan%40microsoft.com%7C1a0d4b69b2ea4588801c08d4df6e5e4a%7C7= 2f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636379112588684000&sdata=3D64aO%2= B4WE8hZ9FI4%2BheoEDUGZyx53swO6XW6ajlap7xw%3D&reserved=3D0> MONTHLY seminars on crash dump analysis, WDF, Windows internals and softwar= e drivers! Details at <https://na01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F= %2Fwww.osr.com%2Fseminars&data=3D02%7C01%7CDoron.Holan%40microsoft.com%7C1a= 0d4b69b2ea4588801c08d4df6e5e4a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7= C636379112588684000&sdata=3DXDsvy6B19MQzkQUHKk6xw5w54DRSe%2B%2FYdvVXxeqfMT8= %3D&reserved=3D0> To unsubscribe, visit the List Server section of OSR Online at <https://na0= 1.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fwww.osronline.com%2F= page.cfm%3Fname%3DListServer&data=3D02%7C01%7CDoron.Holan%40microsoft.com%7= C1a0d4b69b2ea4588801c08d4df6e5e4a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C= 0%7C636379112588684000&sdata=3DaOsh5V2ct%2F9dkRCrkK6dcMl4%2Fs%2BeAA2TMBWYua= kbqZk%3D&reserved=3D0>
  Message 6 of 9  
10 Aug 17 13:08
PBD
xxxxxx@winsystems.com
Join Date: 03 May 2010
Posts To This List: 71
[OSR-DETECTED-SPAM] Re: SetupDiGetDeviceInterfaceDetail Function & DevicePath

These look like windbg commands. I am launching the application remotely from Visual Studio 2013. I tried to step into CreateFile but am obviously missing the necessary data. This is something I have never done before. Sorry for my ignorance.
  Message 7 of 9  
10 Aug 17 19:15
W. D.
xxxxxx@gmail.com
Join Date: 12 Oct 2017
Posts To This List: 40
[OSR-DETECTED-SPAM] Re: SetupDiGetDeviceInterfaceDetail Function & DevicePath

Sorry about my last post. I looked back at the headers and the strings used are TCHAR strings. I wonder if SetupDiCreateDeviceInterface is the right choice. The doc states that the interface created by the app must be enabled by the driver. Typically, to open a device handle with a device interface, you do the following: 1) Open the device info list with SetupDiGetClassDevs like you did. 2) Loop through the list of device interfaces with SetupDiEnumDeviceInterfaces. 3) For each device interface, get the detailed data (device path) with SetupDiGetDeviceInterfaceDetail. You should give it a try.
  Message 8 of 9  
10 Aug 17 19:33
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 11622
[OSR-DETECTED-SPAM] Re: SetupDiGetDeviceInterfaceDetail Function & DevicePath

windev234 wrote: > I wonder if SetupDiCreateDeviceInterface is the right choice. The doc states that the interface created by the app must be enabled by the driver. Typically, to open a device handle with a device interface, you do the following: Hmmm -- I never even noticed that. xxxxx@winsystems.com xxxxx@lists.osr.com wrote: > while (SetupDiEnumDeviceInfo(DeviceInfoSet, Index, &DeviceInfoData)) > { > DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); > SetupDiCreateDeviceInterface(DeviceInfoSet, &DeviceInfoData, &DeviceInfoData.ClassGuid, NULL, 0, &DeviceInterfaceData); Yes, this is totally wrong. You want to enumerate the interfaces that have already been exposed by existing drivers. You cannot add additional interfaces to existing drivers, because you don't know what interfaces they support. Plus, you are adding the ClassGuid, which is the Device Manager install class, not a device interface. You need to rip this line right out. -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 9 of 9  
11 Aug 17 10:04
PBD
xxxxxx@winsystems.com
Join Date: 03 May 2010
Posts To This List: 71
[OSR-DETECTED-SPAM] Re: SetupDiGetDeviceInterfaceDetail Function & DevicePath

I actually discovered last night that the GUID of the Device Class was being appended to the path instead of the GUID of the device itself. In the registry, it showed the proper name in the SymbolicLink property. After I hard coded the device name with the right GUID, I was able to open the device. I was going to research how to fix the code this morning but the answer was waiting for me here. I added your code fixes and it works! Thanks to all who helped. This is a great resource!
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 07:13.


Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license