PFD has hardcoded knowledge about the function named DriverEntry and the
rules that go along with it. I fwd’ed the issue to the owner of PFD,
but in the meantime, what happens if you rename the class function
DriverEntry to something else ?
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Udo Eberhardt
Sent: Sunday, December 10, 2006 6:17 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Strange Prefast warning about DriverObject
Hmm, you are correct. There was a mistake in communication between a
colleague and me. The “offending” piece of code was from a different
driver. Sorry for this inaccuracy.
Actually the driver is written in C++ and prefast complains about the
following construct:
extern “C”
NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
// gKnDriverObject is an instance of class KnDriverObject
NTSTATUS st =
gKnDriverObject->DriverEntry(DriverObject,RegistryPath);
…
}
NTSTATUS
KnDriverObject::DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
// mDriverObject is a member variable of type DRIVER_OBJECT*
mDriverObject = DriverObject; //on this line prefast reports warning
28131
…
}
prefast reports:
warning 28131: The DriverEntry routine should save a copy of the
argument DriverObject, not the pointer, since the I/O Manager frees the
buffer after DriverEntry returns.
It seems that prefast confuses KnDriverObject::DriverEntry and
DriverEntry, and in addition confuses DriverObject and RegistryPath
arguments.
Udo
Scott Noone wrote:
Weird, I don’t get that warning when prefasting this
-scott
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer