ntstatus to string

Is there a better way to map a kernel status value, from kernel or ndis, etc… to a string
than to roll out your own switch statement?

WPP: %!NTSTATUS!

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Friday, December 14, 2012 2:16 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] ntstatus to string

Is there a better way to map a kernel status value, from kernel or ndis, etc… to a string than to roll out your own switch statement?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

> Is there a better way to map a kernel status value, from kernel or ndis,

etc… to a string
than to roll out your own switch statement?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Under what conditions? User app or kernel space? For a user app, use
FormatMessage. Does the driver return custom error codes? What is the
planned use of this string?
joe

On 12/14/2012 5:15 PM, xxxxx@yahoo.com wrote:

Is there a better way to map a kernel status value, from kernel or ndis, etc… to a string
than to roll out your own switch statement?

It depends. If you are calling a win32 function such as DeviceIoControl
or ReadFile the win32 layer should map the NTSTATUS value to a win32
error code. You can then use FormatMessage to map the win32 error code
to a string. If you have some special requirements you can perform the
mapping your self either in kernel or user mode using
RtlNtStatusToDosError.
http://msdn.microsoft.com/en-us/library/windows/hardware/ff553127(v=vs.85).aspx.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms680600(v=vs.85).aspx.
Once you have a win32 error code you can let the OS map the error
value to a string using FormatMessage. Or you can define your own
proprietary error codes and provide the strings in a resource dll that
can be used with format message.