what error code are you returning?
-----Original Message-----
From: Schalken, Rob [mailto:xxxxx@emdes.nl]
Sent: Thursday, May 30, 2002 6:56 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Return errorcode to Windows
I noticed that the NT_SUCCESS macro does not work correctly!!! So that’s
why I use if (Status == STATUS_SUCCESS).
I use the IoCompleteRequest: IoCompleteRequest( Irp, IO_NO_INCREMENT );
So I think these suggestions are nog correct for met!
Here a part of my dispatch function:
NTSTATUS DriverDispatch( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) {
NTSTATUS Status;
PIO_STACK_LOCATION IrpStack;
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
IrpStack = IoGetCurrentIrpStackLocation( Irp );
switch( IrpStack->MajorFunction )
{
case IRP_MJ_CREATE:
Irp->IoStatus.Status = DriverOpen( DeviceObject, Irp );
Status = Irp->IoStatus.Status;
if (Status != STATUS_SUCCESS)
{
DbgPrint(“Error”);
}
break;
default:
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
Status = Irp->IoStatus.Status;
break;
}
IoCompleteRequest( Irp, IO_NO_INCREMENT );
return Status;
}
When I place a DbgPrint before the return value then this will show a
correct value, but windows still returns a handle!!!
-----Original Message-----
From: Roddy, Mark [mailto:xxxxx@stratus.com]
Sent: Thursday, May 30, 2002 3:16 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Return errorcode to Windows
I have no idea what the value of Function might be, but the test:
if (Status == STATUS_SUCCESS)
is wrong. The correct test is:
if (NT_SUCCESS(Status))
if the value of function is, for example, STATUS_PENDING, your code is
just broken.
Also, I do not see a call to IoCompleteRequest in your pseudo code. If
this call precedes your example, then any attempt to access the IRP
afterwards is incorrect. If you are missing this call entirely, your
code is simply broken.
Your earlier posting indicated that you thought !STATUS_SUCCESS might be
a valid way of expressing a failure code. It isn’t. Please see the
definition of NT error codes in the ddk include files.
-----Original Message-----
From: Schalken, Rob [mailto:xxxxx@emdes.nl]
Sent: Thursday, May 30, 2002 8:46 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Return errorcode to Windows
This is my example the funtion returns a (NTSTATUS) value:
Irp->IoStatus.Status = Function
Status = Irp->IoStatus.Status;
if (Status == STATUS_SUCCESS)
{
if status is incorrect a event is written to
the event log, this is working fine!!
}
return Status;
So here the value of Irp->IoStatus.Status is returnend.
This is my general structure, when I call createfile a HANDLE
is still created even when I return something else then
STATUS_SUCCESS!!!
Pleas can you help me because everything will crash if this
will not work!!!
-----Original Message-----
From: vlad-ntdev [mailto:xxxxx@unshadow.net]
Sent: Thursday, May 30, 2002 2:13 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Return errorcode to Windows
>
> Which parameter must be set? A incorrect return
(!STATUS_SUCCESS) is
> not enough!!!
>
Did you set Irp->IoStatus.Status?
vlad-ntdev
You are currently subscribed to ntdev as:
xxxxx@emdes.nl To unsubscribe send a blank email to
%%email.unsub%%
You are currently subscribed to ntdev as:
xxxxx@emdes.nl To unsubscribe send a blank email to
%%email.unsub%%
You are currently subscribed to ntdev as:
xxxxx@stratus.com To unsubscribe send a blank email to
%%email.unsub%%
You are currently subscribed to ntdev as: xxxxx@emdes.nl
To unsubscribe send a blank email to %%email.unsub%%
You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to %%email.unsub%%