converting from NTSTATUS code to Win32 error codes

Hi all

In my device driver I try to complete an IRP with a certain error code to
show the application what the problem is (i.e. STATUS_INVALID_HANDLE or
STATUS_ILLEGAL_INSTRUCTION). According to the appendix A from Peter
G.Viscarolas Driver book I should get the corresponding win32 error code,
if I call straight after the DeviceIoControl() function the GetLastError()
function. But it’s not like that, no matter which STATUS_… code I
choose, I always get the error code 2 (ERROR_FILE_NOT_FOUND) after calling
the GetLastError(), I checked the return code from the DeviceIoControl()
and it is really 0 (for error).

Does somebody has a clue what the problem could be?
Thanks for taking time
Daniel

You could save your driver’s error within the driver and instead of calling
GetLastError call the driver again to request it’s last error.
Else

“Daniel Luethi”

> cc:
Sent by: Subject: [ntdev] converting from NTSTATUS code to Win32 error codes
xxxxx@lis
ts.osr.com

16.10.2002 14:40
Please respond to “NT
Developers Interest
List”

Hi all

In my device driver I try to complete an IRP with a certain error code to
show the application what the problem is (i.e. STATUS_INVALID_HANDLE or
STATUS_ILLEGAL_INSTRUCTION). According to the appendix A from Peter
G.Viscarolas Driver book I should get the corresponding win32 error code,
if I call straight after the DeviceIoControl() function the GetLastError()
function. But it’s not like that, no matter which STATUS_… code I
choose, I always get the error code 2 (ERROR_FILE_NOT_FOUND) after calling
the GetLastError(), I checked the return code from the DeviceIoControl()
and it is really 0 (for error).

Does somebody has a clue what the problem could be?
Thanks for taking time
Daniel


You are currently subscribed to ntdev as: xxxxx@utimaco.de
To unsubscribe send a blank email to %%email.unsub%%

Well that is not such a good idea. Consider that this doubles the number
of transactions required. Consider also that you now have to correlate
the error condition with the original request.

The mapping between NT and win32 error codes is defined in KB article
Q113996.

In addition you can get extended status information, including the
original NT status code, from the operation, if you open the file for
asynchronous operations and use the overlapped structure.

However, the mapping from NT status to win32 works fine as far as I
know, so if the IO operation is returning ERROR_FILE_NOT_FOUND then the
NT status that you are setting in BOTH THE IRP AND AS THE RETURN VALUE
FROM YOUR DISPATCH ROUTINE maps to ERROR_FILE_NOT_FOUND.

===========================
Mark Roddy
Consultant, Microsoft DDK MVP
Hollis Technology Solutions
xxxxx@hollistech.com
www.hollistech.com
603-321-1032

-----Original Message-----
From: “Else Kluger”
To: “NT Developers Interest List”
Date: Wed, 16 Oct 2002 16:35:25 +0200
Subject: [ntdev] Re: converting from NTSTATUS code to Win32 error codes

>
> You could save your driver’s error within the driver and instead of
> calling
> GetLastError call the driver again to request it’s last error.
> Else
>
>
>
>
> Hi all
>
> In my device driver I try to complete an IRP with a certain error code
> to
> show the application what the problem is (i.e. STATUS_INVALID_HANDLE or
> STATUS_ILLEGAL_INSTRUCTION). According to the appendix A from Peter
> G.Viscarolas Driver book I should get the corresponding win32 error
> code,
> if I call straight after the DeviceIoControl() function the
> GetLastError()
> function. But it’s not like that, no matter which STATUS_… code I
> choose, I always get the error code 2 (ERROR_FILE_NOT_FOUND) after
> calling
> the GetLastError(), I checked the return code from the
> DeviceIoControl()
> and it is really 0 (for error).
>
> Does somebody has a clue what the problem could be?
> Thanks for taking time
> Daniel
>

I use the following routine: RtlNtStatusToDosError

Regards,
Max

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark Roddy
Sent: 16 ??? 2002 ?. 19:05
To: NT Developers Interest List
Subject: [ntdev] Re: converting from NTSTATUS code to Win32 error codes

Well that is not such a good idea. Consider that this doubles the number

of transactions required. Consider also that you now have to correlate
the error condition with the original request.

The mapping between NT and win32 error codes is defined in KB article
Q113996.

In addition you can get extended status information, including the
original NT status code, from the operation, if you open the file for
asynchronous operations and use the overlapped structure.

However, the mapping from NT status to win32 works fine as far as I
know, so if the IO operation is returning ERROR_FILE_NOT_FOUND then the
NT status that you are setting in BOTH THE IRP AND AS THE RETURN VALUE
FROM YOUR DISPATCH ROUTINE maps to ERROR_FILE_NOT_FOUND.

===========================
Mark Roddy
Consultant, Microsoft DDK MVP
Hollis Technology Solutions
xxxxx@hollistech.com
www.hollistech.com
603-321-1032

-----Original Message-----
From: “Else Kluger”
To: “NT Developers Interest List”
Date: Wed, 16 Oct 2002 16:35:25 +0200
Subject: [ntdev] Re: converting from NTSTATUS code to Win32 error codes

>
> You could save your driver’s error within the driver and instead of
> calling
> GetLastError call the driver again to request it’s last error.
> Else
>
>
>
>
> Hi all
>
> In my device driver I try to complete an IRP with a certain error code
> to
> show the application what the problem is (i.e. STATUS_INVALID_HANDLE
or
> STATUS_ILLEGAL_INSTRUCTION). According to the appendix A from Peter
> G.Viscarolas Driver book I should get the corresponding win32 error
> code,
> if I call straight after the DeviceIoControl() function the
> GetLastError()
> function. But it’s not like that, no matter which STATUS_… code I
> choose, I always get the error code 2 (ERROR_FILE_NOT_FOUND) after
> calling
> the GetLastError(), I checked the return code from the
> DeviceIoControl()
> and it is really 0 (for error).
>
> Does somebody has a clue what the problem could be?
> Thanks for taking time
> Daniel
>


You are currently subscribed to ntdev as: xxxxx@acronis.com
To unsubscribe send a blank email to %%email.unsub%%

It is now documented by MS due to some legal issues.

The even documented RtlUnwind - the engine which calls your __except()
handlers - which is surely funny, no sane developer will ever call
this function instead of RaiseException, thus no need (except the
attorney’s claims) for this internal routine to be documented.

Max

----- Original Message -----
From: “Max Lyadvinsky”
To: “NT Developers Interest List”
Sent: Wednesday, October 16, 2002 10:48 PM
Subject: [ntdev] Re: converting from NTSTATUS code to Win32 error
codes

I use the following routine: RtlNtStatusToDosError

Regards,
Max

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark Roddy
Sent: 16 ÏËÔÑÂÒÑ 2002 Ç. 19:05
To: NT Developers Interest List
Subject: [ntdev] Re: converting from NTSTATUS code to Win32 error
codes

Well that is not such a good idea. Consider that this doubles the
number

of transactions required. Consider also that you now have to correlate
the error condition with the original request.

The mapping between NT and win32 error codes is defined in KB article
Q113996.

In addition you can get extended status information, including the
original NT status code, from the operation, if you open the file for
asynchronous operations and use the overlapped structure.

However, the mapping from NT status to win32 works fine as far as I
know, so if the IO operation is returning ERROR_FILE_NOT_FOUND then
the
NT status that you are setting in BOTH THE IRP AND AS THE RETURN VALUE
FROM YOUR DISPATCH ROUTINE maps to ERROR_FILE_NOT_FOUND.

===========================
Mark Roddy
Consultant, Microsoft DDK MVP
Hollis Technology Solutions
xxxxx@hollistech.com
www.hollistech.com
603-321-1032

-----Original Message-----
From: “Else Kluger”
To: “NT Developers Interest List”
Date: Wed, 16 Oct 2002 16:35:25 +0200
Subject: [ntdev] Re: converting from NTSTATUS code to Win32 error
codes

>
> You could save your driver’s error within the driver and instead of
> calling
> GetLastError call the driver again to request it’s last error.
> Else
>
>
>
>
> Hi all
>
> In my device driver I try to complete an IRP with a certain error
code
> to
> show the application what the problem is (i.e. STATUS_INVALID_HANDLE
or
> STATUS_ILLEGAL_INSTRUCTION). According to the appendix A from Peter
> G.Viscarolas Driver book I should get the corresponding win32 error
> code,
> if I call straight after the DeviceIoControl() function the
> GetLastError()
> function. But it’s not like that, no matter which STATUS_… code I
> choose, I always get the error code 2 (ERROR_FILE_NOT_FOUND) after
> calling
> the GetLastError(), I checked the return code from the
> DeviceIoControl()
> and it is really 0 (for error).
>
> Does somebody has a clue what the problem could be?
> Thanks for taking time
> Daniel
>


You are currently subscribed to ntdev as: xxxxx@acronis.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to %%email.unsub%%

RtlUnwind is documented for compiler writers and most of them, to my best
knowledge, are sane.
Also Numega DriverWorks uses RtlUnwind (and even RtlUnwind2 on IA64) to
implement C++ exception handling in kernel mode.

It is now documented by MS due to some legal issues.

The even documented RtlUnwind - the engine which calls your __except()
handlers - which is surely funny, no sane developer will ever call
this function instead of RaiseException, thus no need (except the
attorney’s claims) for this internal routine to be documented.

Max

----- Original Message -----
From: “Max Lyadvinsky”
> To: “NT Developers Interest List”
> Sent: Wednesday, October 16, 2002 10:48 PM
> Subject: [ntdev] Re: converting from NTSTATUS code to Win32 error
> codes
>
>
> I use the following routine: RtlNtStatusToDosError
>
> Regards,
> Max
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Mark Roddy
> Sent: 16 ÏËÔÑÂÒÑ 2002 Ç. 19:05
> To: NT Developers Interest List
> Subject: [ntdev] Re: converting from NTSTATUS code to Win32 error
> codes
>
>
> Well that is not such a good idea. Consider that this doubles the
> number
>
> of transactions required. Consider also that you now have to correlate
> the error condition with the original request.
>
> The mapping between NT and win32 error codes is defined in KB article
> Q113996.
>
> In addition you can get extended status information, including the
> original NT status code, from the operation, if you open the file for
> asynchronous operations and use the overlapped structure.
>
> However, the mapping from NT status to win32 works fine as far as I
> know, so if the IO operation is returning ERROR_FILE_NOT_FOUND then
> the
> NT status that you are setting in BOTH THE IRP AND AS THE RETURN VALUE
> FROM YOUR DISPATCH ROUTINE maps to ERROR_FILE_NOT_FOUND.
>
> ===========================
> Mark Roddy
> Consultant, Microsoft DDK MVP
> Hollis Technology Solutions
> xxxxx@hollistech.com
> www.hollistech.com
> 603-321-1032
>
>
> -----Original Message-----
> From: “Else Kluger”
> To: “NT Developers Interest List”
> Date: Wed, 16 Oct 2002 16:35:25 +0200
> Subject: [ntdev] Re: converting from NTSTATUS code to Win32 error
> codes
>
> >
> > You could save your driver’s error within the driver and instead of
> > calling
> > GetLastError call the driver again to request it’s last error.
> > Else
> >
> >
> >
> >
> > Hi all
> >
> > In my device driver I try to complete an IRP with a certain error
> code
> > to
> > show the application what the problem is (i.e. STATUS_INVALID_HANDLE
> or
> > STATUS_ILLEGAL_INSTRUCTION). According to the appendix A from Peter
> > G.Viscarolas Driver book I should get the corresponding win32 error
> > code,
> > if I call straight after the DeviceIoControl() function the
> > GetLastError()
> > function. But it’s not like that, no matter which STATUS_… code I
> > choose, I always get the error code 2 (ERROR_FILE_NOT_FOUND) after
> > calling
> > the GetLastError(), I checked the return code from the
> > DeviceIoControl()
> > and it is really 0 (for error).
> >
> > Does somebody has a clue what the problem could be?
> > Thanks for taking time
> > Daniel
> >
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@acronis.com
> To unsubscribe send a blank email to %%email.unsub%%
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to %%email.unsub%%