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