IRP_MJ_CREATE SE

Hello,

Thank you for the answer. :slight_smile: It was not a trick question - my problem is that I always do something in IRP_MJ_CREATE. I never made this function to … just successfuly return. I thought it might be some problem with the system if I do this. I am certanly not a DDK pro.

One more thing. Don’t I have to put this before your statements?

NTSTATUS status;
PIO_STACK_LOCATION irp;

irp = IoGetCurrentIrpStackLocation(Irp);

Thank you,
Andrei CIUBOTARU

Why would you have to? Nothing in his code uses the variables “status”
or “irp”.

IoGetCurrentIrpStackLocation just returns a pointer to the current irp
stack location - there’s no side effect that requires you to run it.

the IoStatus is a field in the IRP, not in the stack location.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
Ciubotaru Ovidiu Andrei
Sent: Thursday, February 10, 2005 10:47 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] IRP_MJ_CREATE SE

Hello,

Thank you for the answer. :slight_smile: It was not a trick question - my
problem is that I always do something in IRP_MJ_CREATE. I
never made this function to … just successfuly return. I
thought it might be some problem with the system if I do
this. I am certanly not a DDK pro.

One more thing. Don’t I have to put this before your statements?

NTSTATUS status;
PIO_STACK_LOCATION irp;

irp = IoGetCurrentIrpStackLocation(Irp);

Thank you,
Andrei CIUBOTARU


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@windows.microsoft.com To unsubscribe send a blank
email to xxxxx@lists.osr.com

Ciubotaru Ovidiu Andrei wrote:

Hello,

Thank you for the answer. :slight_smile: It was not a trick question - my problem is that I always do something in IRP_MJ_CREATE. I never made this function to … just successfuly return. I thought it might be some problem with the system if I do this. I am certanly not a DDK pro.

It won’t cause a problem with the system in and of itself. If your
driver doesn’t need to take any action on IRP_MJ_CREATE, the easiest
thing is not to supply a handler for it in DriverEntry. Leave
MajorFunction[IRP_MJ_CREATE] alone.

One more thing. Don’t I have to put this before your statements?

NTSTATUS status;
PIO_STACK_LOCATION irp;

irp = IoGetCurrentIrpStackLocation(Irp);

Not at all. The code I posted you will compile as-is. It never uses a
variable called “status”, so there is no point in creating one. The
IoStatus block is in the main part of the IRP, not in my stack
location. I never use my stack location, so why should I fetch a
pointer to it?

Further, you will surely bring onto your head the wrath of those driver
writers who follow you if you use a variable called “irp” to point to
something which is not an IRP. An IO_STACK_LOCATION is not an IRP. It
is PART of an IRP. Use a name like “ioStack” or “iosp” or even “pisl”,
but not “irp”.

if you don’t have a handler for IRP_MJ_CREATE then all create requests
will be failed by the default I/O manager handler. No one will be able
to open a handle to the device stack. I’m guessing that’s not what the
OP wanted.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Thursday, February 10, 2005 11:14 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] IRP_MJ_CREATE SE

Ciubotaru Ovidiu Andrei wrote:

>Hello,
>
>Thank you for the answer. :slight_smile: It was not a trick question -
my problem is that I always do something in IRP_MJ_CREATE. I
never made this function to … just successfuly return. I
thought it might be some problem with the system if I do
this. I am certanly not a DDK pro.
>
>

It won’t cause a problem with the system in and of itself.
If your driver doesn’t need to take any action on
IRP_MJ_CREATE, the easiest thing is not to supply a handler
for it in DriverEntry. Leave MajorFunction[IRP_MJ_CREATE] alone.

>One more thing. Don’t I have to put this before your statements?
>
>NTSTATUS status;
>PIO_STACK_LOCATION irp;
>
>irp = IoGetCurrentIrpStackLocation(Irp);
>
>

Not at all. The code I posted you will compile as-is. It
never uses a variable called “status”, so there is no point
in creating one. The IoStatus block is in the main part of
the IRP, not in my stack location. I never use my stack
location, so why should I fetch a pointer to it?

Further, you will surely bring onto your head the wrath of
those driver writers who follow you if you use a variable
called “irp” to point to something which is not an IRP. An
IO_STACK_LOCATION is not an IRP. It is PART of an IRP. Use
a name like “ioStack” or “iosp” or even “pisl”, but not “irp”.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com