Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


sending IRP_MJ_PNP to \device\harddisk0\partition0 with minor function IRP_MN_QUERY_DEVICE_RELATIONS

Liam__hkLiam__hk Member Posts: 1
edited November 2 in NTDEV

I was reading about file system stack and found a source code and i am trying to understand what it is actually doing

it is finding the device object of \device\harddisk0\partition0 and then it sends a IRP_MJ_PNP request to it and builds the IRP using IoBuildSynchronousFsdRequest, sets the minorfunc to IRP_MN_QUERY_DEVICE_RELATIONS and QueryDeviceRelations.Type to TargetDeviceRelation

now can someone explain what does this actually do? whats the purpose of IRP_MN_QUERY_DEVICE_RELATIONS regarding the partition0 device object and whats the deal with this TargetDeviceRelation? where can i read more about this?

    KeInitializeEvent( &event, NotificationEvent, FALSE );

    irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP,
                                        DeviceObject,
                                        NULL,
                                        0,
                                        NULL,
                                        &event,
                                        &ioStatusBlock );

    if (irp == NULL) {
        status = STATUS_INSUFFICIENT_RESOURCES;
        goto End;
    }

    irpStack = IoGetNextIrpStackLocation( irp );
    irpStack->MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS;
    irpStack->Parameters.QueryDeviceRelations.Type = TargetDeviceRelation;

    irp->IoStatus.Status = STATUS_NOT_SUPPORTED ;


    status = IoCallDriver( DeviceObject, irp );

    if (status == STATUS_PENDING) {

        KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL );
        status = ioStatusBlock.Status;}


Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,695
    edited November 2

    where can i read more about this?

    How can you ask that question with a straight face? I Googled for IRP_MN_QUERY_DEVICE_RELATIONS, and the top hit was the MSDN page that describes these option. TargetDeviceRelations returns the device object associated with a particular file object.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Internals & Software Drivers 25 Jan 2021 LIVE ONLINE
Developing Minifilters 8 March 2021 LIVE ONLINE