WDM Driver Loading Mode understanding

Source: Internet
Author: User

When the PC learns that a new device is plugged in, the bus driver creates the corresponding physical drive PDO and then prompts for a new device insertion, which calls the AddDevice method of the corresponding driver to create a function-driven FDO

The following is a typical AddDevice method

#pragmaPagedcodeNTSTATUS Hellowdmadddevice (in Pdriver_object driverobject, in Pdevice_object Physicaldeviceo    bject) {Paged_code (); Kdprint (("Enter hellowdmadddevice\n"));    NTSTATUS status;    Pdevice_object Fdo;    Unicode_string Devname; Rtlinitunicodestring (&devname,l"\\Device\\MyWDMDevice"); Status=IoCreateDevice (DriverObject,sizeof(device_extension),&(unicode_string) devname, File_device_unknown,0, FALSE,&FDO); if( !nt_success (status))returnstatus; Pdevice_extension PDX= (pdevice_extension) fdo->deviceextension; PDX->fdo =Fdo; PDX->nextstackdevice =IoAttachDeviceToDeviceStack (FDO, physicaldeviceobject);    Unicode_string Symlinkname; Rtlinitunicodestring (&symlinkname,l"\\DosDevices\\HelloWDM"); PDX->ustrdevicename =Devname; PDX->ustrsymlinkname =Symlinkname; Status= Iocreatesymboliclink (& (unicode_string) symlinkname,&(unicode_string) devname); if( !nt_success (status)) {Iodeletesymboliclink (&pdx->ustrsymlinkname); Status= Iocreatesymboliclink (&symLinkName,&devname); if( !nt_success (status)) {            returnstatus; }} FDO->flags |= Do_buffered_io |do_power_pagable; FDO->flags &= ~do_device_initializing; Kdprint (("Leave hellowdmadddevice\n")); returnstatus_success;}

The careful person may feel that this method's second parameter physicaldeviceobject, namely PDO, comes somewhat inexplicably, does not have the explanation type and so on

This object can specify its type in the INF, such as

Servicetype=1

WDM Driver Loading Mode understanding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.