Hi all! I am a new guy for driver development. I had written a drive to implement a virtual disk through file. The DriverEntry routine is as below:
NTSTATUS DriverEntry(PDRIVER_OBJECT drvObject, PUNICODE_STRING usRegPath)
{
PKEY_VALUE_PARTIAL_INFORMATION startKeyValue;
ULONG version;
int i;
Dump("DriverEntry " DRIVER\_NAME " " DRIVER\_VERSION "\\n");
memset(&OsVersion, 0, sizeof(RTL\_OSVERSIONINFOW));
OsVersion.dwOSVersionInfoSize = sizeof(RTL\_OSVERSIONINFOW);
RtlGetVersion(&OsVersion);
//Dump("RtlGetVersion:%d,%d\\r\\n", OsVersion.dwMajorVersion, OsVersion.dwMinorVersion);
// Load dump filter if the main driver is already loaded
if (NT\_SUCCESS (FDDeviceIoControl (NT\_ROOT\_PREFIX, FD\_IOCTL\_GET\_DRIVER\_VERSION, NULL, 0, &version, sizeof (version))))
return DumpFilterEntry ((PFILTER\_EXTENSION) drvObject, (PFILTER\_INITIALIZATION\_DATA) usRegPath);
FDDriverObject = drvObject;
memset(VirtualVolumeDeviceObjects, 0, sizeof(VirtualVolumeDeviceObjects));
if(NT\_SUCCESS(FDReadRegistryKey(usRegPath, L"Start", &startKeyValue)))
{
if(startKeyValue->Type == REG\_DWORD && \*((uint32 \*)startKeyValue->Data) == SERVICE\_BOOT\_START)
{
LoadBootArguments();
}
FDfree(startKeyValue);
}
else
{
Dump("Read registry key value failure!\\n");
}
VolumeClassFilterRegistered = IsVolumeClassFilterRegistered();
ReportBOOL("VolumeClassFilterRegistered", VolumeClassFilterRegistered);
for (i = 0; i <= IRP\_MJ\_MAXIMUM\_FUNCTION; ++i)
{
FDDriverObject->MajorFunction\[i\] = FDDispatchQueueIRP;
}
FDDriverObject->DriverExtension->AddDevice = FileDiskAddDevice;
drvObject->DriverUnload = UnloadDriver;
return FDCreateRootDeviceObject(FDDriverObject);
}
In the code above, I had register a AddDevice routine named FileDiskAddDevice. Through the message output by DebugPrint, I look my driver can be loaded successfully by system. Next, I want to make IO manager call my AddDevice routine. But I don't know how to do it. My driver is just for a virtual device. No real device fits it. So I can't add device by unplug and plug again. I hope someone can be kind to tell me what I should do. Thank you! :) Be regards!
There is some white cloud floating on the blue sky. That's the landscape I like.