Little program to report how NT stati are converted into a Win32 error code by NTDLL...
[reactos.git] / reactos / apps / utils / nts2w32err / nts2w32err.c
1 /* $Id: nts2w32err.c,v 1.1 2004/01/11 17:06:21 ea Exp $
2 *
3 * Convert NTSTATUS codes to Win32 error codes: run it
4 * on a NT box AND on a ROS box, then diff the results.
5 *
6 * This utility should help keeping correct how Ros
7 * translates executive's errors codes into Win32 error
8 * codes.
9 *
10 * Usage: nts2w32err [MaxStatusCode] > log.txt
11 *
12 * 2004-01-10 Emanuele Aliberti
13 *
14 */
15 #include <ddk/ntddk.h>
16 #include <windows.h>
17 #include <stdio.h>
18
19 int main (int argc, char * argv [])
20 {
21 NTSTATUS Severity = 0;
22 NTSTATUS StatusCode = STATUS_SUCCESS;
23 NTSTATUS Status = STATUS_SUCCESS;
24 DWORD LastError = ERROR_SUCCESS;
25 DWORD Maximum = 0x40000;
26
27 if (2 == argc)
28 {
29 sscanf (argv[1], "%lx", & Maximum);
30 }
31
32 printf ("NT error codes 0x0-0x%lx that get translated *not* to ERROR_MR_MID_NOT_FOUND (317)\n\n", Maximum);
33
34 for ( Severity = 0;
35 Severity < 4;
36 Severity ++)
37 {
38 printf ("--- Severity %ld ---\n", Severity);
39
40 for ( StatusCode = STATUS_SUCCESS;
41 StatusCode <= Maximum ;
42 StatusCode ++)
43 {
44 Status = ((Severity << 30) | StatusCode);
45 LastError = RtlNtStatusToDosError (Status);
46 if (ERROR_MR_MID_NOT_FOUND != LastError)
47 {
48 printf ("0x%08lx => %ldL\n", Status, LastError);
49 }
50 }
51 }
52 return EXIT_SUCCESS;
53 }
54 /* EOF */