Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Hardware & Devices
  4. How to make IO Manager call my AddDevice routine in my driver?

How to make IO Manager call my AddDevice routine in my driver?

Scheduled Pinned Locked Moved Hardware & Devices
windows-adminhostingcloudtutorialquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    whiteclouds
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups