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