Prev: Is it a Bug for DTM in USB Digital TV Tuner Card Testing
Next: Spooler Notification, Vista x64 and splwow64
From: alexander.sandler on 14 Mar 2007 18:44 I am trying to get list of hard disks in my computer with IoGetDeviceInterface(). Here is the code: DbgPrint( "About to list hard disk devices\n" ); nResult = IoGetDeviceInterfaces( (LPGUID)&GUID_DEVCLASS_DISKDRIVE, NULL, 0, &pDeviceList ); if (nResult != STATUS_SUCCESS) { DbgPrint( "IoGetDeviceInterfaces() failed with error %d\n", nResult ); } else { pTemp = pDeviceList; DbgPrint( "Printing device list (%d)\n", 0xffff & *pTemp ); while (*pTemp != UNICODE_NULL) { RtlInitUnicodeString( &sTemp, pTemp ); nResult = IoGetDeviceObjectPointer ( &sTemp, FILE_ALL_ACCESS, NULL, &pDO ); if (nResult != STATUS_SUCCESS) { DbgPrint( "IoGetDeviceObjectPointer() returned %x\n", nResult ); } else { // TODO: ObDeferenceObject( pDO ) } pTemp += (sTemp.Length + sizeof( UNICODE_NULL )) / sizeof( WCHAR ); } // TODO: ExFreePool( pDeviceList ); } I used code in src\Swtuner\BDAtuner\gentuner\Filter.cpp as an example. It's quite strange, but I am getting empty list. Here are the debug printouts: About to list hard disk devices Printing device list (0) This is despite I do have a hard disk in my machine. Also, devcon shows it clearly. Any ideas what's the problem and how to get this thing working? Thanks!
From: Doron Holan [MS] on 15 Mar 2007 00:31 you are using the wront GUID. GUID_DEVCLASS_DISKDRIVE is the device class guid (e.g. the one you find at the top of the INF), not the device interface GUID. The DEVCLASS part of the name is a clear indication of this. GUID_DEVINTERFACE_DISK in winioctl.h is probably what you want d -- Please do not send e-mail directly to this alias. this alias is for newsgroup purposes only. This posting is provided "AS IS" with no warranties, and confers no rights. <alexander.sandler(a)gmail.com> wrote in message news:1173912263.506306.312900(a)y80g2000hsf.googlegroups.com... >I am trying to get list of hard disks in my computer with > IoGetDeviceInterface(). Here is the code: > > DbgPrint( "About to list hard disk devices\n" ); > > nResult = IoGetDeviceInterfaces( (LPGUID)&GUID_DEVCLASS_DISKDRIVE, > NULL, 0, &pDeviceList ); > if (nResult != STATUS_SUCCESS) > { > DbgPrint( "IoGetDeviceInterfaces() failed with error %d\n", > nResult ); > } > else > { > pTemp = pDeviceList; > > DbgPrint( "Printing device list (%d)\n", 0xffff & *pTemp ); > > while (*pTemp != UNICODE_NULL) > { > RtlInitUnicodeString( &sTemp, pTemp ); > nResult = IoGetDeviceObjectPointer ( &sTemp, FILE_ALL_ACCESS, NULL, > &pDO ); > if (nResult != STATUS_SUCCESS) > { > DbgPrint( "IoGetDeviceObjectPointer() returned %x\n", nResult ); > } > else > { > // TODO: ObDeferenceObject( pDO ) > } > > pTemp += (sTemp.Length + sizeof( UNICODE_NULL )) / sizeof( WCHAR ); > } > > // TODO: ExFreePool( pDeviceList ); > } > > I used code in src\Swtuner\BDAtuner\gentuner\Filter.cpp as an example. > It's quite strange, but I am getting empty list. Here are the debug > printouts: > > About to list hard disk devices > Printing device list (0) > > This is despite I do have a hard disk in my machine. Also, devcon > shows it clearly. > Any ideas what's the problem and how to get this thing working? > > Thanks! >
From: alexander.sandler on 15 Mar 2007 03:30
Oh my bad. Thanks a lot Doron. Using right GUID definitely helps :-) Alexander. On Mar 15, 6:31 am, "Doron Holan [MS]" <dor...(a)nospam.microsoft.com> wrote: > you are using the wront GUID. GUID_DEVCLASS_DISKDRIVE is the device class > guid (e.g. the one you find at the top of the INF), not the device interface > GUID. The DEVCLASS part of the name is a clear indication of this. > > GUID_DEVINTERFACE_DISK in winioctl.h is probably what you want > > d > -- > Please do not send e-mail directly to this alias. this alias is for > newsgroup purposes only. > This posting is provided "AS IS" with no warranties, and confers no rights. > > <alexander.sand...(a)gmail.com> wrote in message > > news:1173912263.506306.312900(a)y80g2000hsf.googlegroups.com... > > >I am trying to get list of hard disks in my computer with > > IoGetDeviceInterface(). Here is the code: > > > DbgPrint( "About to list hard disk devices\n" ); > > > nResult = IoGetDeviceInterfaces( (LPGUID)&GUID_DEVCLASS_DISKDRIVE, > > NULL, 0, &pDeviceList ); > > if (nResult != STATUS_SUCCESS) > > { > > DbgPrint( "IoGetDeviceInterfaces() failed with error %d\n", > > nResult ); > > } > > else > > { > > pTemp = pDeviceList; > > > DbgPrint( "Printing device list (%d)\n", 0xffff & *pTemp ); > > > while (*pTemp != UNICODE_NULL) > > { > > RtlInitUnicodeString( &sTemp, pTemp ); > > nResult = IoGetDeviceObjectPointer ( &sTemp, FILE_ALL_ACCESS, NULL, > > &pDO ); > > if (nResult != STATUS_SUCCESS) > > { > > DbgPrint( "IoGetDeviceObjectPointer() returned %x\n", nResult ); > > } > > else > > { > > // TODO: ObDeferenceObject( pDO ) > > } > > > pTemp += (sTemp.Length + sizeof( UNICODE_NULL )) / sizeof( WCHAR ); > > } > > > // TODO: ExFreePool( pDeviceList ); > > } > > > I used code in src\Swtuner\BDAtuner\gentuner\Filter.cpp as an example. > > It's quite strange, but I am getting empty list. Here are the debug > > printouts: > > > About to list hard disk devices > > Printing device list (0) > > > This is despite I do have a hard disk in my machine. Also, devcon > > shows it clearly. > > Any ideas what's the problem and how to get this thing working? > > > Thanks! |