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!