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/


How to get the driver name from PDRIVER_OBJECT

Andrey_KhramovAndrey_Khramov Member Posts: 4

Hello,

I've run the code analysis on the usbip-win project.
I get the following warning:

driver\stub\stub_dev.c(130): warning C28175: The 'DriverName' member of _DRIVER_OBJECT should not be accessed by a driver:  Access to this member may be permitted for certain classes of drivers. See the documentation for this warning for more information.

The source code follows as below:

static BOOLEAN
is_usbip_stub_attached(PDEVICE_OBJECT pdo)
{
    DEVICE_OBJECT   *attached;

    attached = pdo->AttachedDevice;
    while (attached) {
        PDRIVER_OBJECT  drvobj = attached->DriverObject;

        if (drvobj != NULL) {
            UNICODE_STRING  name_uni;
            RtlInitUnicodeString(&name_uni, L"\\driver\\usbip_stub");
            if (RtlEqualUnicodeString(&drvobj->DriverName, &name_uni, TRUE))
                return TRUE;
        }
        attached = attached->AttachedDevice;
    }
    return FALSE;
}

I've found that I can get the 'DriverName' member of _DRIVER_OBJECT using ObQueryNameString() API via the following discussion:
Getting driver name from PDRIVER_OBJECT
I have checked the usage of the ObQueryNameString() API, but I couldn't find the relevant example code.

I hope someone to let me know how to get the driver name of PDRIVER_OBJECT using ObQueryNameString() API.
If there is another method to get the driver name, please let me know.

Thanks,
Andrey

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

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!
Kernel Debugging 30 January 2023 Live, Online
Developing Minifilters 20 March 2023 Live, Online
Writing WDF Drivers TBD 2023 Live, Online
Internals & Software Drivers 17 April 2023 Live, Online