IoAllocateDriverObjectExtension (fwd)

Hi all,
what this function means, when:

NTSTATUS
IoAllocateDriverObjectExtension(
IN PDRIVER_OBJECT DriverObject,
IN PVOID ClientIdentificationAddress,
IN ULONG DriverObjectExtensionSize,
OUT PVOID *DriverObjectExtension
);

DriverObjectExtension
Points to, on completion, the allocated context area.

But the code (implementation is: )
PUNICODE_STRING regPath;

status = IoAllocateDriverObjectExtension(DriverObject,
(PVOID) 1,
sizeof(UNICODE_STRING),
(PVOID *) &regPath);
How can I understand this?
I can create DriverExtension and save pointer to registry path?
This code is from MS DDK sermdep.c (serial mouse port driver)

Ozon

******************************************
* David Mensik
* student of Palacky University
*
* e-mail: xxxxx@seznam.cz
* www: http://www.inf.upol.cz/~mensikd
* icq: 19658607
******************************************

Hi,
it simply allocates space for a UNICODE_STRING structure.
At return, the regPath variable is initialized as a pointer to this
structure.
Then, it fills UNICODE_STRING fields.

This is done in sermdep.c as follows:

(Note that Buffer space is allocated int third line)

if (regPath) {
regPath->MaximumLength = RegistryPath->Length +
sizeof(UNICODE_NULL);
regPath->Length = RegistryPath->Length;
regPath->Buffer = ExAllocatePool(NonPagedPool,
regPath->MaximumLength);

if (regPath->Buffer) {
RtlZeroMemory(regPath->Buffer,
regPath->MaximumLength);

RtlMoveMemory(regPath->Buffer,
RegistryPath->Buffer,
RegistryPath->Length);

etc.

-----Original Message-----
From: David Mensik
Sent: lunes 12 de junio de 2000 20:59
To: File Systems Developers
Subject: [ntfsd] IoAllocateDriverObjectExtension (fwd)

Hi all,
what this function means, when:

NTSTATUS
IoAllocateDriverObjectExtension(
IN PDRIVER_OBJECT DriverObject,
IN PVOID ClientIdentificationAddress,
IN ULONG DriverObjectExtensionSize,
OUT PVOID *DriverObjectExtension
);

DriverObjectExtension
Points to, on completion, the allocated context area.

But the code (implementation is: )
PUNICODE_STRING regPath;

status = IoAllocateDriverObjectExtension(DriverObject,
(PVOID) 1,
sizeof(UNICODE_STRING),
(PVOID *) &regPath);
How can I understand this?
I can create DriverExtension and save pointer to registry path?
This code is from MS DDK sermdep.c (serial mouse port driver)

Ozon

******************************************
* David Mensik
* student of Palacky University
*
* e-mail: xxxxx@seznam.cz
* www: http://www.inf.upol.cz/~mensikd
* icq: 19658607
******************************************


You are currently subscribed to ntfsd as: xxxxx@pandasoftware.es
To unsubscribe send a blank email to $subst(‘Email.Unsub’)

> Hi all,

what this function means, when:

NTSTATUS
IoAllocateDriverObjectExtension(
IN PDRIVER_OBJECT DriverObject,
IN PVOID ClientIdentificationAddress,
IN ULONG DriverObjectExtensionSize,
OUT PVOID *DriverObjectExtension
);

AFAIK this is primarily intended for class drivers which have miniports
plugged into them (CLASS2.SYS, for instance).

Let’s see:

  • in a class/miniport model, the driver object belongs to the miniport.
    (class can even have no driver object at all like NT4’s SCSIPORT).
  • miniport’s DriverEntrty just treats its parameters as 2 opaque PVOIDs,
    fills
    a registration record including the callback functions and calls something
    like
    xxxClassRegisterMiniport.
  • xxxClassRegisterMiniport in the class driver fills the miniport’s driver
    object
    with the class’s dispatch functions (usually internal) - miniports usually
    do not
    know on IRPs at all and has no dispatch functions.
  • when the IO manager calls this class’s dispatch function, it must call
    some
    callbacks in the appropriate miniport. The callback pointers are in the
    registration record for the miniport.
  • so, the class must maintain the DriverObject -> RegistrationRecord
    relationship. This is necessary for class’s dispatch functions. Registration
    record and callback functions cannot be stored to the driver object - no
    fields
    in it.
  • IoAllocateDriverObjectExtension is intended for the class driver to
    maintain
    this relationship. The driver object extension is exactly the place for a
    class to
    store the miniport’s registration record.

Surely, IoAllocateDriverObjectExtension can be used for other things too.

Max