Return errorcode to Windows

When I want to create a handle using createfile! A handle is created when
all is successfull.
When my IRP is not succesfull and I return for example
STATUS_INSUFFICIENT_RESOURCES windows
does not see this and does not creat a error.

Which parameter must be set? A incorrect return (!STATUS_SUCCESS) is not
enough!!!

Rob Schalken

>

Which parameter must be set? A incorrect return (!STATUS_SUCCESS) is not
enough!!!

Did you set Irp->IoStatus.Status?

vlad-ntdev

yes.

Irp->IoStatus.Status = Function

Status = Irp->IoStatus.Status;

if (Status == STATUS_SUCCESS)
{
This is working fine!!
}

return Status;

So I have to set another flag???

-----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%%

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%%

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%%

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%%

I’m sorry, but NT_SUCCESS works, has worked, will work correctly. The value
returned from your function DriverOpen would appear to be the problem.
Perhaps you could print its actual hex value?

-----Original Message-----
From: Schalken, Rob [mailto:xxxxx@emdes.nl]
Sent: Thursday, May 30, 2002 9: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@stratus.com
To unsubscribe send a blank email to %%email.unsub%%

> I noticed that the NT_SUCCESS macro does not work correctly!!!

So that’s why I use if (Status == STATUS_SUCCESS).

What do you mean saying that the NT_SUCCESS macro doesn’t work? If you
look at the definition, you will see that it simply returns TRUE for a
set of values of Status that the system doesn’t consider as errors…

case IRP_MJ_CREATE:
Irp->IoStatus.Status = DriverOpen( DeviceObject, Irp );

What do you do inside the function DriverOpen() ? Do you pass the Irp
down or do you handle it completely inside the function?

For which values of Status (!= STATUS_SUCCESS) does Windows still give
you a handle after IRP_MJ_CREATE ?

Carlo

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%%

> I noticed that the NT_SUCCESS macro does not work correctly!!!

In what respect?
It always worked correctly.

Max

First, how are you defining “Function” in the statement Irp->IoStatus.Status
= Function? That status field should ONLY contain a valid status code, and
if it does not then do not expect to see any kind of meaningful status
reported from your driver. Look at NTSTATUS.H to get an idea of what a
status code should look like. Note that, ANY status code you define must
have the Customer bit set, or it will be ignored if the status you pass is
not defined in the system status/error messages.

Using “Function” suggests that you are trying to return the address of a
failing function in the device driver to the user mode application. This is
HIGHLY unlikely to work since the you cannot guarantee that this faux status
will appear as kosher when the IRP is completed.

Simply stated …
Error and status codes must be VALID error and status codes.
Valid error and status codes are generated by the message compiler, with
the -c switch to set the Customer bit.
The driver binary must then be compiled using the header and resource files
produced by MC, and linked with the BIN produced by MC.

Now if you don’t understand any of the above, more than likely you have no
idea what an error/status code is and need to do some further investigation.
If you do understand this, then look at the your driver in the EventLog key
of the registry and be sure that you have indicated a path to your driver.


Gary G. Little
xxxxx@broadstor.com
xxxxx@inland.net

“Schalken, Rob” wrote in message news:xxxxx@ntdev…
>
> When I want to create a handle using createfile! A handle is created when
> all is successfull.
> When my IRP is not succesfull and I return for example
> STATUS_INSUFFICIENT_RESOURCES windows
> does not see this and does not creat a error.
>
> Which parameter must be set? A incorrect return (!STATUS_SUCCESS) is not
> enough!!!
>
> Rob Schalken
>
>
>

A perfect example of an answer that has nothing in common with a question…

-----Original Message-----
From: Gary G. Little [mailto:xxxxx@broadstor.com]
Sent: Monday, June 03, 2002 1:23 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Return errorcode to Windows

First, how are you defining “Function” in the statement
Irp->IoStatus.Status = Function? That status field should
ONLY contain a valid status code, and if it does not then do
not expect to see any kind of meaningful status reported from
your driver. Look at NTSTATUS.H to get an idea of what a
status code should look like. Note that, ANY status code you
define must have the Customer bit set, or it will be ignored
if the status you pass is not defined in the system
status/error messages.

Using “Function” suggests that you are trying to return the
address of a failing function in the device driver to the
user mode application. This is HIGHLY unlikely to work since
the you cannot guarantee that this faux status will appear as
kosher when the IRP is completed.

Simply stated …
Error and status codes must be VALID error and status codes.
Valid error and status codes are generated by the message
compiler, with the -c switch to set the Customer bit. The
driver binary must then be compiled using the header and
resource files produced by MC, and linked with the BIN produced by MC.

Now if you don’t understand any of the above, more than
likely you have no idea what an error/status code is and need
to do some further investigation. If you do understand this,
then look at the your driver in the EventLog key of the
registry and be sure that you have indicated a path to your driver.


Gary G. Little
xxxxx@broadstor.com
xxxxx@inland.net

“Schalken, Rob” wrote in message
> news:xxxxx@ntdev…
> >
> > When I want to create a handle using
> createfile! A handle is created
> > when all is successfull. When my IRP is not succesfull and I return
> > for example STATUS_INSUFFICIENT_RESOURCES windows
> > does not see this and does not creat a error.
> >
> > Which parameter must be set? A incorrect return
> (!STATUS_SUCCESS) is
> > not enough!!!
> >
> > Rob Schalken
> >
> >
> >
>
>
>
> —
> You are currently subscribed to ntdev as:
> xxxxx@setengineering.com To unsubscribe send a blank
> email to %%email.unsub%%
>

Hi

I need to add a menu item in File Menu of Word, powerpoint and
excel applications programmatically and call a dll function or
running an EXE on selecting the menu item.

Is there anyone know how to do this.

Thanks,
Sridhar


Get your own “800” number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag

You might try going to http://support.microsoft.com and doing a “all words”
search for “add menu item” for Office 2000.

“Sridhar Krishnan” wrote in message
news:xxxxx@ntdev…
>
> Hi
>
> I need to add a menu item in File Menu of Word, powerpoint and
> excel applications programmatically and call a dll function or
> running an EXE on selecting the menu item.
>
> Is there anyone know how to do this.
>
> Thanks,
> Sridhar
>
> ________________________________________________
> Get your own “800” number
> Voicemail, fax, email, and a lot more
> http://www.ureach.com/reg/tag
>
>

Common USER32 functions can help you. Install a hook on WM_COMMAND and
add the menu item by InsertMenu or such.

Max

----- Original Message -----
From: “Sridhar Krishnan”
To: “NT Developers Interest List”
Sent: Tuesday, July 02, 2002 8:55 PM
Subject: [ntdev] Windows

> Hi
>
> I need to add a menu item in File Menu of Word, powerpoint and
> excel applications programmatically and call a dll function or
> running an EXE on selecting the menu item.
>
> Is there anyone know how to do this.
>
> Thanks,
> Sridhar
>
> ________________________________________________
> Get your own “800” number
> Voicemail, fax, email, and a lot more
> http://www.ureach.com/reg/tag
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to %%email.unsub%%
>