how to find a loaded driver's DriverObject?

Hello,
I want to provide some pnp features in my driver for NT4. One is to
dynamically load the driver and call AddDevice later when device is
physically online. The problem is ZwLoadDriver returns nothing after
successfully loading the driver, and the way is broken to acquiring the
pointer to the driver object for that driver. Any ideas? I found
“ObOpenObjectByName” in the export table? anyone know something about it?
zhiwood

On Mon, 15 Mar 2004 15:44:39 +0800, zhiming wrote:

I believe the API you’re looking for is ObReferenceObjectByName()…

NTSTATUS
ObReferenceObjectByName(
IN PUNICODE_STRING ObjectName,
IN ULONG Attributes,
IN PACCESS_STATE PassedAccessState OPTIONAL,
IN ACCESS_MASK DesiredAccess OPTIONAL,
IN POBJECT_TYPE ObjectType,
IN KPROCESSOR_MODE AccessMode,
IN OUT PVOID ParseContext OPTIONAL,
OUT PVOID *Object
);

‘ObjectName’ is in the form “\Driver\<driver_name>” (ex.
‘\Driver\Disk’)

> Hello,
> I want to provide some pnp features in my driver for NT4. One is to
> dynamically load the driver and call AddDevice later when device is
> physically online. The problem is ZwLoadDriver returns nothing after
> successfully loading the driver, and the way is broken to acquiring the
> pointer to the driver object for that driver. Any ideas? I found
> “ObOpenObjectByName” in the export table? anyone know something about it?
> zhiwood</driver_name>

zhiming wrote:

physically online. The problem is ZwLoadDriver returns nothing after
successfully loading the driver, and the way is broken to acquiring the
pointer to the driver object for that driver. Any ideas? I found
“ObOpenObjectByName” in the export table? anyone know something about it?

First of all, stay away from functions that you merely “find in the
export table.”

If this is the NTV4 world you’re almost certainly creating a device
object in your DriverEntry function, right? If that device object is
named, then the invoking driver needs just call
IoGetDeviceObjectPointer. If you really want a pointer to the driver
object, use DeviceObject->DriverObject.

Peter
OSR

> I want to provide some pnp features in my driver for NT4.
You can’t provide PNP features in NT4. NT4 doesnt support that.

dynamically load the driver and call AddDevice later
Your statement is a bit confusing… There is no ‘AddDevice’ routine for a
NT4 device
driver. Are you writing a WDM driver and expect it to work on NT4!? It won’t
work.

Hope this helps!

-Vijay
----- Original Message -----
From: “zhiming”
To: “Windows System Software Devs Interest List”
Sent: Monday, March 15, 2004 1:14 PM
Subject: [ntdev] how to find a loaded driver’s DriverObject?

> Hello,
> I want to provide some pnp features in my driver for NT4. One is to
> dynamically load the driver and call AddDevice later when device is
> physically online. The problem is ZwLoadDriver returns nothing after
> successfully loading the driver, and the way is broken to acquiring the
> pointer to the driver object for that driver. Any ideas? I found
> “ObOpenObjectByName” in the export table? anyone know something about it?
> zhiwood
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@hotmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>