Hi,
I am trying to attach a file system driver to the existing
partitions in Windows 2000. To attach to a partition I am looking for
FtDisk driver. If FtDisk driver is started then I attach to the
partition and creates symbolic links.
My code fails if DiskPerf monitor is enabled using Diskperf -YV command.
DiskPerf monitor loads above FTDisk driver, so whenever I query for FT
driver my call fails.
Is there any way to enumerate the underlying drivers?
My code looks like this:
// Prepare device names
//
WCHAR wszRepDeviceName[256], wszDiskDevicePath[256],
wszRepDevicePath[256];
swprintf(wszRepDeviceName, L"Upanshu\Harddisk%d\Partition%d",
RDRC_SSD_DEVICE_NAME_BASE, ulDiskNum, ulPartNum);
swprintf(wszDiskDevicePath, L"\Device\Harddisk%d\Partition%d",
ulDiskNum, ulPartNum);
swprintf(wszRepDevicePath, L"Singhal%d\Partition%d",
RDRC_SSD_DISK_DEVICE_BASE, ulDiskNum, ulPartNum);
//
// Check for device existence
//
PDEVICE_OBJECT pTargetDevice, pNextDevice;
PFILE_OBJECT pFileObject;
PDRIVER_OBJECT pNextDriverObject = NULL;
if( !NT_SUCCESS(IoGetDeviceObjectPointer(KUstring(wszDiskDevicePath),
FILE_READ_ATTRIBUTES, &pFileObject, &pTargetDevice)) )
{
t << “Device '” << wszRepDeviceName << “' doesn’t exist\n”;
return STATUS_NO_SUCH_DEVICE;
}
ObDereferenceObject(pFileObject);
//
// Determine the type of the underlying driver
//
if( !g_pLowDriver && pTargetDevice && ulPartNum )
{
g_pLowDriver = pTargetDevice -> DriverObject;
POBJECT_NAME_INFORMATION pDriverName =
(POBJECT_NAME_INFORMATION)new(NonPagedPool) BYTE[512];
ULONG ulRet = 0;
if( NT_SUCCESS(ObQueryNameString(g_pLowDriver, pDriverName, 512,
&ulRet)) )
{
WCHAR wszDriverName[256];
memset(wszDriverName, 0, sizeof(WCHAR)*256);
wcsncpy(wszDriverName, pDriverName->Name.Buffer,
pDriverName->Name.Length / sizeof(WCHAR));
t << “Detected underlying driver name: " << wszDriverName <<
“\n”;
if( !wcscmp(wszDriverName, L”\Driver\Ftdisk")) {
g_bFTDriverActive = TRUE;
}
}
delete pDriverName;
}
//
// Call special function for device attachment in Win2000.
// NB! We need to do it only when running on Windows 2000 and FT driver
is started.
// Also we must skip Partition0, because FT driver doesn’t attach to
that device.
//
if( g_bIsWin2000 && g_bFTDriverActive && ulPartNum )
return ConnectToPartition(pTargetDevice, ppFilterDevice);
Thanks,
-Upanshu