xref: /illumos-gate/usr/src/uts/common/fs/smbclnt/netsmb/smb_subrs.c (revision 598f4ceed9327d2d6c2325dd67cae3aa06f7fea6)
1 /*
2  * Copyright (c) 2000-2001 Boris Popov
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *    This product includes software developed by Boris Popov.
16  * 4. Neither the name of the author nor the names of any co-contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  *
32  * $Id: smb_subr.c,v 1.27.108.1 2005/06/02 00:55:39 lindak Exp $
33  */
34 
35 /*
36  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
37  */
38 
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/kmem.h>
42 #include <sys/proc.h>
43 #include <sys/lock.h>
44 #include <sys/socket.h>
45 #include <sys/isa_defs.h>
46 #include <sys/stream.h>
47 #include <sys/strsun.h>
48 #include <sys/sunddi.h>
49 #include <sys/cmn_err.h>
50 #include <sys/sdt.h>
51 #include <sys/priv.h>
52 #include <sys/u8_textprep.h>
53 
54 #include <netsmb/smb_osdep.h>
55 #include <netsmb/smb.h>
56 #include <netsmb/smb_conn.h>
57 #include <netsmb/smb_rq.h>
58 #include <netsmb/smb_subr.h>
59 
60 /*
61  * XXX:This conversion might not be fully MS-Compatible
62  * for calculating hashes. The output length may differ
63  * for some locales and needs to be handled from where
64  * the call is made.
65  */
66 int
67 smb_toupper(const char *inbuf, char *outbuf, size_t outlen)
68 {
69 	int err = 0;
70 	size_t inlen, inrem, outrem;
71 
72 	inrem = inlen = strlen(inbuf);
73 	outrem = outlen;
74 	(void) u8_textprep_str((char *)inbuf, &inrem, outbuf, &outrem,
75 	    U8_TEXTPREP_TOUPPER, U8_UNICODE_LATEST, &err);
76 	/* inrem, outrem are bytes unused, remaining */
77 	if (inrem) {
78 		SMBSDEBUG("input %d remains: %s\n", (int)inrem, inbuf);
79 		inlen -= inrem;
80 	}
81 	if (outrem) {
82 		outlen -= outrem;
83 		outbuf[outlen] = '\0';
84 	}
85 	if (outlen > inlen) {
86 		SMBSDEBUG("outlen > inlen! (%d > %d)\n",
87 		    (int)outlen, (int)inlen);
88 		/* Truncate to inlen here? */
89 	}
90 
91 	return (err);
92 }
93 
94 void
95 smb_credinit(struct smb_cred *scred, cred_t *cr)
96 {
97 	/* cr arg is optional */
98 	if (cr == NULL)
99 		cr = ddi_get_cred();
100 	if (is_system_labeled()) {
101 		cr = crdup(cr);
102 		(void) setpflags(NET_MAC_AWARE, 1, cr);
103 	} else {
104 		crhold(cr);
105 	}
106 	scred->scr_cred = cr;
107 }
108 
109 void
110 smb_credrele(struct smb_cred *scred)
111 {
112 	if (scred->scr_cred != NULL) {
113 		crfree(scred->scr_cred);
114 		scred->scr_cred = NULL;
115 	}
116 }
117 
118 /*
119  * Helper for the SMBERROR macro, etc.
120  * This is also a good place for a breakpoint
121  * or a dtrace probe, i.e. fbt:nsmb:smb_errmsg
122  */
123 void
124 smb_errmsg(int cel, const char *func_name, const char *fmt, ...)
125 {
126 	va_list adx;
127 	char buf[100];
128 
129 	va_start(adx, fmt);
130 	if (cel == CE_CONT) {
131 		/*
132 		 * This is one of our xxxDEBUG macros.
133 		 * Don't bother to log these, but just
134 		 * fire a dtrace probe with the message.
135 		 */
136 		(void) vsnprintf(buf, sizeof (buf), fmt, adx);
137 		DTRACE_PROBE2(debugmsg2,
138 		    (char *), func_name,
139 		    (char *), buf);
140 	} else {
141 		/*
142 		 * This is one of our xxxERROR macros.
143 		 * Add a prefix to the fmt string,
144 		 * then let vcmn_err do the args.
145 		 */
146 		(void) snprintf(buf, sizeof (buf), "?%s: %s", func_name, fmt);
147 		DTRACE_PROBE3(debugmsg3,
148 		    (char *), func_name,
149 		    (char *), buf,
150 		    va_list, adx);
151 		vcmn_err(cel, buf, adx);
152 	}
153 	va_end(adx);
154 }
155 
156 #if 1 /* def SMB_SOCKETDATA_DEBUG */
157 void
158 m_dumpm(mblk_t *m)
159 {
160 	int len, seg;
161 
162 	len = msgdsize(m);
163 	DTRACE_PROBE2(dsize, int, len, (mblk_t *), m);
164 
165 	for (seg = 0; m; seg++) {
166 		DTRACE_PROBE2(mblk, int, seg, (mblk_t *), m);
167 		m = m->b_cont;
168 	}
169 }
170 #endif
171 
172 #ifndef EPROTO
173 #define	EPROTO ECONNABORTED
174 #endif
175 #ifndef ELIBACC
176 #define	ELIBACC ENOENT
177 #endif
178 #ifndef ENODATA
179 #define	ENODATA EINVAL
180 #endif
181 #ifndef ENOTUNIQ
182 #define	ENOTUNIQ EADDRINUSE
183 #endif
184 #ifndef ECOMM
185 #define	ECOMM EIO
186 #endif
187 #ifndef ENOMEDIUM
188 #define	ENOMEDIUM ENXIO
189 #endif
190 #ifndef ETIME
191 #define	ETIME ETIMEDOUT
192 #endif
193 
194 /*
195  * Log any un-handled NT or DOS errors we encounter.
196  * Make these log NOTICE in a debug build to ensure
197  * they get noticed during tests.  In the field these
198  * are unimportant, so just fire a Dtrace probe.
199  */
200 static int unknown_err_logpri =
201 #ifdef	DEBUG
202 	CE_NOTE;
203 #else
204 	CE_CONT;
205 #endif
206 
207 typedef struct nt2errno {
208 	unsigned int nterr;
209 	int errno;
210 } nt2errno_t;
211 
212 static const nt2errno_t nt2errno[] = {
213 	/* Alphabetical order. */
214 	{NT_STATUS_ACCESS_DENIED,		EACCES},
215 	{NT_STATUS_ACCESS_VIOLATION,		EACCES},
216 	{NT_STATUS_ACCOUNT_DISABLED,		EACCES},
217 	{NT_STATUS_ACCOUNT_EXPIRED,		EACCES},
218 	{NT_STATUS_ACCOUNT_LOCKED_OUT,		EACCES},
219 	{NT_STATUS_ACCOUNT_RESTRICTION,		EACCES},
220 	{NT_STATUS_ADDRESS_ALREADY_EXISTS,	EADDRINUSE},
221 	{NT_STATUS_BAD_NETWORK_NAME,		ENOENT},
222 	{NT_STATUS_BUFFER_TOO_SMALL,		EMOREDATA},
223 	{NT_STATUS_CANNOT_DELETE,		EACCES},
224 	{NT_STATUS_CONFLICTING_ADDRESSES,	EADDRINUSE},
225 	{NT_STATUS_CONNECTION_ABORTED,		ECONNABORTED},
226 	{NT_STATUS_CONNECTION_DISCONNECTED,	ECONNABORTED},
227 	{NT_STATUS_CONNECTION_REFUSED,		ECONNREFUSED},
228 	{NT_STATUS_CONNECTION_RESET,		ENETRESET},
229 	{NT_STATUS_DELETE_PENDING,		EACCES},
230 	{NT_STATUS_DEVICE_DOES_NOT_EXIST,	ENODEV},
231 	{NT_STATUS_DEVICE_PROTOCOL_ERROR,	EPROTO},
232 	{NT_STATUS_DIRECTORY_NOT_EMPTY,		ENOTEMPTY},
233 	{NT_STATUS_DISK_FULL,			ENOSPC},
234 	{NT_STATUS_DLL_NOT_FOUND,		ELIBACC},
235 	{NT_STATUS_DUPLICATE_NAME,		EINVAL},
236 	{NT_STATUS_END_OF_FILE,			ENODATA},
237 	{NT_STATUS_FILE_IS_A_DIRECTORY,		EISDIR},
238 	{NT_STATUS_FILE_LOCK_CONFLICT,		EAGAIN},
239 	{NT_STATUS_FLOAT_INEXACT_RESULT,	ERANGE},
240 	{NT_STATUS_FLOAT_OVERFLOW,		ERANGE},
241 	{NT_STATUS_FLOAT_UNDERFLOW,		ERANGE},
242 	{NT_STATUS_HOST_UNREACHABLE,		EHOSTUNREACH},
243 	{NT_STATUS_ILL_FORMED_PASSWORD,		EACCES},
244 	{NT_STATUS_INTEGER_OVERFLOW,		ERANGE},
245 	{NT_STATUS_INVALID_ACCOUNT_NAME,	EACCES},
246 	{NT_STATUS_INVALID_HANDLE,		EBADF},
247 	{NT_STATUS_INVALID_LEVEL,		ENOTSUP},
248 	{NT_STATUS_INVALID_LOGON_HOURS,		EACCES},
249 	{NT_STATUS_INVALID_OWNER,		EINVAL},
250 	{NT_STATUS_INVALID_PARAMETER,		EINVAL},
251 	{NT_STATUS_INVALID_PIPE_STATE,		EPIPE},
252 	{NT_STATUS_INVALID_PRIMARY_GROUP,	EINVAL},
253 	{NT_STATUS_INVALID_WORKSTATION,		EACCES},
254 	{NT_STATUS_IN_PAGE_ERROR,		EFAULT},
255 	{NT_STATUS_IO_TIMEOUT,			ETIMEDOUT},
256 	{NT_STATUS_IP_ADDRESS_CONFLICT1,	ENOTUNIQ},
257 	{NT_STATUS_IP_ADDRESS_CONFLICT2,	ENOTUNIQ},
258 	{NT_STATUS_LICENSE_QUOTA_EXCEEDED,	EDQUOT},
259 	{NT_STATUS_LOCK_NOT_GRANTED,		EAGAIN},
260 	{NT_STATUS_LOGIN_TIME_RESTRICTION,	EACCES},
261 	{NT_STATUS_LOGON_FAILURE,		EACCES},
262 	{NT_STATUS_MEDIA_WRITE_PROTECTED,	EROFS},
263 	{NT_STATUS_MEMORY_NOT_ALLOCATED,	EFAULT},
264 	{NT_STATUS_NAME_TOO_LONG,		ENAMETOOLONG},
265 	{NT_STATUS_NETWORK_ACCESS_DENIED,	EACCES},
266 	{NT_STATUS_NETWORK_BUSY,		EBUSY},
267 	{NT_STATUS_NETWORK_UNREACHABLE,		ENETUNREACH},
268 	{NT_STATUS_NET_WRITE_FAULT,		ECOMM},
269 	{NT_STATUS_NONEXISTENT_SECTOR,		ESPIPE},
270 	{NT_STATUS_NONE_MAPPED,			EINVAL},
271 	{NT_STATUS_NOT_A_DIRECTORY,		ENOTDIR},
272 	{NT_STATUS_NOT_IMPLEMENTED,		ENOTSUP},
273 	{NT_STATUS_NOT_MAPPED_VIEW,		EINVAL},
274 	{NT_STATUS_NOT_SUPPORTED,		ENOTSUP},
275 	{NT_STATUS_NO_MEDIA,			ENOMEDIUM},
276 	{NT_STATUS_NO_MEDIA_IN_DEVICE,		ENOMEDIUM},
277 	{NT_STATUS_NO_MEMORY,			ENOMEM},
278 	{NT_STATUS_NO_SUCH_DEVICE,		ENODEV},
279 	{NT_STATUS_NO_SUCH_FILE,		ENOENT},
280 	{NT_STATUS_OBJECT_NAME_COLLISION,	EEXIST},
281 	{NT_STATUS_OBJECT_NAME_INVALID,		EINVAL},
282 	{NT_STATUS_OBJECT_NAME_NOT_FOUND,	ENOENT},
283 	{NT_STATUS_OBJECT_PATH_INVALID,		ENOTDIR},
284 	{NT_STATUS_OBJECT_PATH_NOT_FOUND,	ENOENT},
285 	{NT_STATUS_PAGEFILE_QUOTA,		EDQUOT},
286 	{NT_STATUS_PASSWORD_EXPIRED,		EACCES},
287 	{NT_STATUS_PASSWORD_MUST_CHANGE,	EACCES},
288 	{NT_STATUS_PASSWORD_RESTRICTION,	EACCES},
289 	{NT_STATUS_PATH_NOT_COVERED,		ENOENT},
290 	{NT_STATUS_PIPE_BROKEN,			EPIPE},
291 	{NT_STATUS_PIPE_BUSY,			EPIPE},
292 	{NT_STATUS_PIPE_CONNECTED,		EISCONN},
293 	{NT_STATUS_PIPE_DISCONNECTED,		EPIPE},
294 	{NT_STATUS_PIPE_NOT_AVAILABLE,		EBUSY},
295 	{NT_STATUS_PORT_CONNECTION_REFUSED,	ECONNREFUSED},
296 	{NT_STATUS_PORT_MESSAGE_TOO_LONG,	EMSGSIZE},
297 	{NT_STATUS_PORT_UNREACHABLE,		EHOSTUNREACH},
298 	{NT_STATUS_PROTOCOL_UNREACHABLE,	ENOPROTOOPT},
299 	{NT_STATUS_QUOTA_EXCEEDED,		EDQUOT},
300 	{NT_STATUS_RANGE_NOT_LOCKED,		EIO},
301 	{NT_STATUS_REGISTRY_QUOTA_LIMIT,	EDQUOT},
302 	{NT_STATUS_REMOTE_DISCONNECT,		ESHUTDOWN},
303 	{NT_STATUS_REMOTE_NOT_LISTENING,	ECONNREFUSED},
304 	{NT_STATUS_REQUEST_NOT_ACCEPTED,	EACCES},
305 	{NT_STATUS_RETRY,			EAGAIN},
306 	{NT_STATUS_SHARING_VIOLATION,		EBUSY},
307 	{NT_STATUS_TIMER_NOT_CANCELED,		ETIME},
308 	{NT_STATUS_TOO_MANY_LINKS,		EMLINK},
309 	{NT_STATUS_TOO_MANY_OPENED_FILES,	EMFILE},
310 	{NT_STATUS_UNABLE_TO_FREE_VM,		EADDRINUSE},
311 	{NT_STATUS_UNSUCCESSFUL,		EINVAL},
312 	{NT_STATUS_WRONG_PASSWORD,		EACCES},
313 	{0,	0}
314 };
315 
316 /*
317  * Table for converting NT STATUS values to DOS class/code.
318  * Rows ordered by integer value of last column (NT STATUS)
319  */
320 typedef struct nt2doserr {
321 	unsigned short dclass;
322 	unsigned short derr;
323 	unsigned int nterr;
324 } nt2doserr_t;
325 
326 static const nt2doserr_t nt2doserr[] = {
327 	{ERRDOS,	ERRgeneral,	NT_STATUS_UNSUCCESSFUL},
328 	{ERRDOS,	ERRbadfunc,	NT_STATUS_NOT_IMPLEMENTED},
329 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_INFO_CLASS},
330 	{ERRDOS, ERROR_BAD_LENGTH,	NT_STATUS_INFO_LENGTH_MISMATCH},
331 	{ERRHRD,	ERRgeneral,	NT_STATUS_ACCESS_VIOLATION},
332 	{ERRHRD,	ERRgeneral,	NT_STATUS_IN_PAGE_ERROR},
333 	{ERRHRD,	ERRgeneral,	NT_STATUS_PAGEFILE_QUOTA},
334 	{ERRDOS,	ERRbadfid,	NT_STATUS_INVALID_HANDLE},
335 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_INITIAL_STACK},
336 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_BAD_INITIAL_PC},
337 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_CID},
338 	{ERRHRD,	ERRgeneral,	NT_STATUS_TIMER_NOT_CANCELED},
339 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER},
340 	{ERRDOS,	ERRbadfile,	NT_STATUS_NO_SUCH_DEVICE},
341 	{ERRDOS,	ERRbadfile,	NT_STATUS_NO_SUCH_FILE},
342 	{ERRDOS,	ERRbadfunc,	NT_STATUS_INVALID_DEVICE_REQUEST},
343 	{ERRDOS, ERROR_HANDLE_EOF,	NT_STATUS_END_OF_FILE},
344 	{ERRDOS, ERROR_WRONG_DISK,	NT_STATUS_WRONG_VOLUME},
345 	{ERRDOS, ERROR_NOT_READY,	NT_STATUS_NO_MEDIA_IN_DEVICE},
346 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNRECOGNIZED_MEDIA},
347 	{ERRDOS, ERROR_SECTOR_NOT_FOUND,	NT_STATUS_NONEXISTENT_SECTOR},
348 	{ERRDOS,	ERRnomem,	NT_STATUS_NO_MEMORY},
349 	{ERRDOS, ERROR_INVALID_ADDRESS,	NT_STATUS_CONFLICTING_ADDRESSES},
350 	{ERRDOS, ERROR_INVALID_ADDRESS,	NT_STATUS_NOT_MAPPED_VIEW},
351 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_UNABLE_TO_FREE_VM},
352 	{ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_UNABLE_TO_DELETE_SECTION},
353 	{ERRDOS, NERR_InvalidAPI,	NT_STATUS_INVALID_SYSTEM_SERVICE},
354 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILLEGAL_INSTRUCTION},
355 	{ERRDOS,	ERRnoaccess,	NT_STATUS_INVALID_LOCK_SEQUENCE},
356 	{ERRDOS,	ERRnoaccess,	NT_STATUS_INVALID_VIEW_SIZE},
357 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_INVALID_FILE_FOR_SECTION},
358 	{ERRDOS,	ERRnoaccess,	NT_STATUS_ALREADY_COMMITTED},
359 	{ERRDOS,	ERRnoaccess,	NT_STATUS_ACCESS_DENIED},
360 	{ERRDOS, ERROR_BUFFER_OVERFLOW,	NT_STATUS_BUFFER_TOO_SMALL},
361 	{ERRDOS,	ERRbadfid,	NT_STATUS_OBJECT_TYPE_MISMATCH},
362 	{ERRHRD,	ERRgeneral,	NT_STATUS_NONCONTINUABLE_EXCEPTION},
363 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_DISPOSITION},
364 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNWIND},
365 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_STACK},
366 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_UNWIND_TARGET},
367 	{ERRDOS, ERROR_NOT_LOCKED,	NT_STATUS_NOT_LOCKED},
368 	{ERRHRD,	ERRgeneral,	NT_STATUS_PARITY_ERROR},
369 	{ERRDOS, ERROR_INVALID_ADDRESS,	NT_STATUS_UNABLE_TO_DECOMMIT_VM},
370 	{ERRDOS, ERROR_INVALID_ADDRESS,	NT_STATUS_NOT_COMMITTED},
371 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_PORT_ATTRIBUTES},
372 	{ERRHRD,	ERRgeneral,	NT_STATUS_PORT_MESSAGE_TOO_LONG},
373 	{ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_MIX},
374 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_QUOTA_LOWER},
375 	{ERRHRD,	ERRgeneral,	NT_STATUS_DISK_CORRUPT_ERROR},
376 	{ERRDOS, ERROR_INVALID_NAME,	NT_STATUS_OBJECT_NAME_INVALID},
377 	{ERRDOS,	ERRbadfile,	NT_STATUS_OBJECT_NAME_NOT_FOUND},
378 	{ERRDOS, ERROR_ALREADY_EXISTS,	NT_STATUS_OBJECT_NAME_COLLISION},
379 	{ERRDOS,	ERRbadfid,	NT_STATUS_PORT_DISCONNECTED},
380 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEVICE_ALREADY_ATTACHED},
381 	{ERRDOS, ERROR_BAD_PATHNAME,	NT_STATUS_OBJECT_PATH_INVALID},
382 	{ERRDOS,	ERRbadpath,	NT_STATUS_OBJECT_PATH_NOT_FOUND},
383 	{ERRDOS, ERROR_BAD_PATHNAME,	NT_STATUS_OBJECT_PATH_SYNTAX_BAD},
384 	{ERRHRD,	ERRgeneral,	NT_STATUS_DATA_OVERRUN},
385 	{ERRHRD,	ERRgeneral,	NT_STATUS_DATA_LATE_ERROR},
386 	{ERRDOS, ERROR_CRC,		NT_STATUS_DATA_ERROR},
387 	{ERRDOS, ERROR_CRC,		NT_STATUS_CRC_ERROR},
388 	{ERRDOS,	ERRnomem,	NT_STATUS_SECTION_TOO_BIG},
389 	{ERRDOS,	ERRnoaccess,	NT_STATUS_PORT_CONNECTION_REFUSED},
390 	{ERRDOS,	ERRbadfid,	NT_STATUS_INVALID_PORT_HANDLE},
391 	{ERRDOS, ERROR_SHARING_VIOLATION,	NT_STATUS_SHARING_VIOLATION},
392 	{ERRHRD,	ERRgeneral,	NT_STATUS_QUOTA_EXCEEDED},
393 	{ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PAGE_PROTECTION},
394 	{ERRDOS, ERROR_NOT_OWNER,	NT_STATUS_MUTANT_NOT_OWNED},
395 	{ERRDOS, ERROR_TOO_MANY_POSTS,	NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED},
396 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_PORT_ALREADY_SET},
397 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_SECTION_NOT_IMAGE},
398 	{ERRDOS, ERROR_SIGNAL_REFUSED,	NT_STATUS_SUSPEND_COUNT_EXCEEDED},
399 	{ERRDOS,	ERRnoaccess,	NT_STATUS_THREAD_IS_TERMINATING},
400 	{ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_BAD_WORKING_SET_LIMIT},
401 	{ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INCOMPATIBLE_FILE_MAP},
402 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_SECTION_PROTECTION},
403 	{ERRDOS, ERROR_EAS_NOT_SUPPORTED,	NT_STATUS_EAS_NOT_SUPPORTED},
404 	{ERRDOS, ERROR_EA_LIST_INCONSISTENT,	NT_STATUS_EA_TOO_LARGE},
405 	{ERRHRD,	ERRgeneral,	NT_STATUS_NONEXISTENT_EA_ENTRY},
406 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_EAS_ON_FILE},
407 	{ERRHRD,	ERRgeneral,	NT_STATUS_EA_CORRUPT_ERROR},
408 	{ERRDOS, ERROR_LOCK_VIOLATION,	NT_STATUS_FILE_LOCK_CONFLICT},
409 	{ERRDOS, ERROR_LOCK_VIOLATION,	NT_STATUS_LOCK_NOT_GRANTED},
410 	{ERRDOS,	ERRnoaccess,	NT_STATUS_DELETE_PENDING},
411 	{ERRDOS, ERROR_NOT_SUPPORTED,	NT_STATUS_CTL_FILE_NOT_SUPPORTED},
412 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNKNOWN_REVISION},
413 	{ERRHRD,	ERRgeneral,	NT_STATUS_REVISION_MISMATCH},
414 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_OWNER},
415 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_PRIMARY_GROUP},
416 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_IMPERSONATION_TOKEN},
417 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_DISABLE_MANDATORY},
418 	{ERRDOS, NERR_LogonServerNotFound,	NT_STATUS_NO_LOGON_SERVERS},
419 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_LOGON_SESSION},
420 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_PRIVILEGE},
421 	{ERRDOS,	ERRnoaccess,	NT_STATUS_PRIVILEGE_NOT_HELD},
422 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ACCOUNT_NAME},
423 	{ERRHRD,	ERRgeneral,	NT_STATUS_USER_EXISTS},
424 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_SUCH_USER},
425 	{ERRHRD,	ERRgeneral,	NT_STATUS_GROUP_EXISTS},
426 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_GROUP},
427 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBER_IN_GROUP},
428 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBER_NOT_IN_GROUP},
429 	{ERRHRD,	ERRgeneral,	NT_STATUS_LAST_ADMIN},
430 	{ERRSRV,	ERRbadpw,	NT_STATUS_WRONG_PASSWORD},
431 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILL_FORMED_PASSWORD},
432 	{ERRHRD,	ERRgeneral,	NT_STATUS_PASSWORD_RESTRICTION},
433 	{ERRDOS,	ERRnoaccess,	NT_STATUS_LOGON_FAILURE},
434 	{ERRHRD,	ERRgeneral,	NT_STATUS_ACCOUNT_RESTRICTION},
435 	{ERRSRV, NERR_InvalidLogonHours,	NT_STATUS_INVALID_LOGON_HOURS},
436 	{ERRSRV, NERR_InvalidWorkstation,	NT_STATUS_INVALID_WORKSTATION},
437 	{ERRSRV, NERR_PasswordExpired,	NT_STATUS_PASSWORD_EXPIRED},
438 	{ERRSRV, NERR_AccountExpired,	NT_STATUS_ACCOUNT_DISABLED},
439 	{ERRHRD,	ERRgeneral,	NT_STATUS_NONE_MAPPED},
440 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_LUIDS_REQUESTED},
441 	{ERRHRD,	ERRgeneral,	NT_STATUS_LUIDS_EXHAUSTED},
442 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_SUB_AUTHORITY},
443 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ACL},
444 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_SID},
445 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_SECURITY_DESCR},
446 	{ERRDOS, ERROR_PROC_NOT_FOUND,	NT_STATUS_PROCEDURE_NOT_FOUND},
447 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_INVALID_IMAGE_FORMAT},
448 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_TOKEN},
449 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_INHERITANCE_ACL},
450 	{ERRDOS, ERROR_NOT_LOCKED,	NT_STATUS_RANGE_NOT_LOCKED},
451 	{ERRDOS, ERROR_DISK_FULL,	NT_STATUS_DISK_FULL},
452 	{ERRHRD,	ERRgeneral,	NT_STATUS_SERVER_DISABLED},
453 	{ERRHRD,	ERRgeneral,	NT_STATUS_SERVER_NOT_DISABLED},
454 	{ERRDOS, ERROR_TOO_MANY_NAMES,	NT_STATUS_TOO_MANY_GUIDS_REQUESTED},
455 	{ERRDOS, ERROR_NO_MORE_ITEMS,	NT_STATUS_GUIDS_EXHAUSTED},
456 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ID_AUTHORITY},
457 	{ERRDOS, ERROR_NO_MORE_ITEMS,	NT_STATUS_AGENTS_EXHAUSTED},
458 	{ERRDOS, ERROR_LABEL_TOO_LONG,	NT_STATUS_INVALID_VOLUME_LABEL},
459 	{ERRDOS, ERROR_OUTOFMEMORY,	NT_STATUS_SECTION_NOT_EXTENDED},
460 	{ERRDOS, ERROR_INVALID_ADDRESS,	NT_STATUS_NOT_MAPPED_DATA},
461 	{ERRHRD,	ERRgeneral,	NT_STATUS_RESOURCE_DATA_NOT_FOUND},
462 	{ERRHRD,	ERRgeneral,	NT_STATUS_RESOURCE_TYPE_NOT_FOUND},
463 	{ERRHRD,	ERRgeneral,	NT_STATUS_RESOURCE_NAME_NOT_FOUND},
464 	{ERRHRD,	ERRgeneral,	NT_STATUS_ARRAY_BOUNDS_EXCEEDED},
465 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_DENORMAL_OPERAND},
466 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_DIVIDE_BY_ZERO},
467 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_INEXACT_RESULT},
468 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_INVALID_OPERATION},
469 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_OVERFLOW},
470 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_STACK_CHECK},
471 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_UNDERFLOW},
472 	{ERRHRD,	ERRgeneral,	NT_STATUS_INTEGER_DIVIDE_BY_ZERO},
473 	{ERRDOS, ERROR_ARITHMETIC_OVERFLOW,	NT_STATUS_INTEGER_OVERFLOW},
474 	{ERRHRD,	ERRgeneral,	NT_STATUS_PRIVILEGED_INSTRUCTION},
475 	{ERRDOS,	ERRnomem,	NT_STATUS_TOO_MANY_PAGING_FILES},
476 	{ERRHRD,	ERRgeneral,	NT_STATUS_FILE_INVALID},
477 	{ERRHRD,	ERRgeneral,	NT_STATUS_ALLOTTED_SPACE_EXCEEDED},
478 	{ERRDOS,	ERRnomem,	NT_STATUS_INSUFFICIENT_RESOURCES},
479 	{ERRDOS,	ERRbadpath,	NT_STATUS_DFS_EXIT_PATH_FOUND},
480 	{ERRDOS, ERROR_CRC,		NT_STATUS_DEVICE_DATA_ERROR},
481 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEVICE_NOT_CONNECTED},
482 	{ERRDOS, ERROR_NOT_READY,	NT_STATUS_DEVICE_POWER_FAILURE},
483 	{ERRDOS, ERROR_INVALID_ADDRESS,	NT_STATUS_FREE_VM_NOT_AT_BASE},
484 	{ERRDOS, ERROR_INVALID_ADDRESS,	NT_STATUS_MEMORY_NOT_ALLOCATED},
485 	{ERRHRD,	ERRgeneral,	NT_STATUS_WORKING_SET_QUOTA},
486 	{ERRDOS, ERROR_WRITE_PROTECT,	NT_STATUS_MEDIA_WRITE_PROTECTED},
487 	{ERRDOS, ERROR_NOT_READY,	NT_STATUS_DEVICE_NOT_READY},
488 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_GROUP_ATTRIBUTES},
489 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_IMPERSONATION_LEVEL},
490 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_OPEN_ANONYMOUS},
491 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_VALIDATION_CLASS},
492 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_TOKEN_TYPE},
493 	{ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_BAD_MASTER_BOOT_RECORD},
494 	{ERRHRD,	ERRgeneral,	NT_STATUS_INSTRUCTION_MISALIGNMENT},
495 	{ERRDOS, ERROR_PIPE_BUSY,	NT_STATUS_INSTANCE_NOT_AVAILABLE},
496 	{ERRDOS, ERROR_PIPE_BUSY,	NT_STATUS_PIPE_NOT_AVAILABLE},
497 	{ERRDOS, ERROR_BAD_PIPE,	NT_STATUS_INVALID_PIPE_STATE},
498 	{ERRDOS, ERROR_PIPE_BUSY,	NT_STATUS_PIPE_BUSY},
499 	{ERRDOS,	ERRbadfunc,	NT_STATUS_ILLEGAL_FUNCTION},
500 	{ERRDOS, ERROR_PIPE_NOT_CONNECTED,	NT_STATUS_PIPE_DISCONNECTED},
501 	{ERRDOS, ERROR_NO_DATA,	NT_STATUS_PIPE_CLOSING},
502 	{ERRHRD,	ERRgeneral,	NT_STATUS_PIPE_CONNECTED},
503 	{ERRHRD,	ERRgeneral,	NT_STATUS_PIPE_LISTENING},
504 	{ERRDOS, ERROR_BAD_PIPE,	NT_STATUS_INVALID_READ_MODE},
505 	{ERRDOS, ERROR_SEM_TIMEOUT,	NT_STATUS_IO_TIMEOUT},
506 	{ERRDOS, ERROR_HANDLE_EOF,	NT_STATUS_FILE_FORCED_CLOSED},
507 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROFILING_NOT_STARTED},
508 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROFILING_NOT_STOPPED},
509 	{ERRHRD,	ERRgeneral,	NT_STATUS_COULD_NOT_INTERPRET},
510 	{ERRDOS,	ERRnoaccess,	NT_STATUS_FILE_IS_A_DIRECTORY},
511 	{ERRDOS, ERROR_NOT_SUPPORTED,	NT_STATUS_NOT_SUPPORTED},
512 	{ERRDOS, ERROR_REM_NOT_LIST,	NT_STATUS_REMOTE_NOT_LISTENING},
513 	{ERRDOS, ERROR_DUP_NAME,	NT_STATUS_DUPLICATE_NAME},
514 	{ERRDOS, ERROR_BAD_NETPATH,	NT_STATUS_BAD_NETWORK_PATH},
515 	{ERRDOS, ERROR_NETWORK_BUSY,	NT_STATUS_NETWORK_BUSY},
516 	{ERRDOS, ERROR_DEV_NOT_EXIST,	NT_STATUS_DEVICE_DOES_NOT_EXIST},
517 	{ERRDOS, ERROR_TOO_MANY_CMDS,	NT_STATUS_TOO_MANY_COMMANDS},
518 	{ERRDOS, ERROR_ADAP_HDW_ERR,	NT_STATUS_ADAPTER_HARDWARE_ERROR},
519 	{ERRDOS, ERROR_BAD_NET_RESP,	NT_STATUS_INVALID_NETWORK_RESPONSE},
520 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_UNEXPECTED_NETWORK_ERROR},
521 	{ERRDOS, ERROR_BAD_REM_ADAP,	NT_STATUS_BAD_REMOTE_ADAPTER},
522 	{ERRDOS, ERROR_PRINTQ_FULL,	NT_STATUS_PRINT_QUEUE_FULL},
523 	{ERRDOS, ERROR_NO_SPOOL_SPACE,	NT_STATUS_NO_SPOOL_SPACE},
524 	{ERRDOS, ERROR_PRINT_CANCELLED,	NT_STATUS_PRINT_CANCELLED},
525 	{ERRDOS, ERROR_NETNAME_DELETED,	NT_STATUS_NETWORK_NAME_DELETED},
526 	{ERRDOS, ERROR_NETWORK_ACCESS_DENIED, NT_STATUS_NETWORK_ACCESS_DENIED},
527 	{ERRDOS, ERROR_BAD_DEV_TYPE,	NT_STATUS_BAD_DEVICE_TYPE},
528 	{ERRDOS, ERROR_BAD_NET_NAME,	NT_STATUS_BAD_NETWORK_NAME},
529 	{ERRDOS, ERROR_TOO_MANY_NAMES,	NT_STATUS_TOO_MANY_NAMES},
530 	{ERRDOS, ERROR_TOO_MANY_SESS,	NT_STATUS_TOO_MANY_SESSIONS},
531 	{ERRDOS, ERROR_SHARING_PAUSED,	NT_STATUS_SHARING_PAUSED},
532 	{ERRDOS, ERROR_REQ_NOT_ACCEP,	NT_STATUS_REQUEST_NOT_ACCEPTED},
533 	{ERRDOS, ERROR_REDIR_PAUSED,	NT_STATUS_REDIRECTOR_PAUSED},
534 	{ERRDOS, ERROR_NET_WRITE_FAULT,	NT_STATUS_NET_WRITE_FAULT},
535 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROFILING_AT_LIMIT},
536 	{ERRDOS, ERROR_NOT_SAME_DEVICE,	NT_STATUS_NOT_SAME_DEVICE},
537 	{ERRDOS,	ERRnoaccess,	NT_STATUS_FILE_RENAMED},
538 	{ERRDOS, ERROR_VC_DISCONNECTED,	NT_STATUS_VIRTUAL_CIRCUIT_CLOSED},
539 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SECURITY_ON_OBJECT},
540 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_WAIT},
541 	{ERRDOS, ERROR_NO_DATA,		NT_STATUS_PIPE_EMPTY},
542 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_ACCESS_DOMAIN_INFO},
543 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_TERMINATE_SELF},
544 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_SERVER_STATE},
545 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_DOMAIN_STATE},
546 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_DOMAIN_ROLE},
547 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_DOMAIN},
548 	{ERRHRD,	ERRgeneral,	NT_STATUS_DOMAIN_EXISTS},
549 	{ERRHRD,	ERRgeneral,	NT_STATUS_DOMAIN_LIMIT_EXCEEDED},
550 	{ERRDOS, ERROR_OPLOCK_NOT_GRANTED, NT_STATUS_OPLOCK_NOT_GRANTED},
551 	{ERRDOS, ERROR_INVALID_OPLOCK_PROTOCOL,
552 					NT_STATUS_INVALID_OPLOCK_PROTOCOL},
553 	{ERRHRD,	ERRgeneral,	NT_STATUS_INTERNAL_DB_CORRUPTION},
554 	{ERRHRD,	ERRgeneral,	NT_STATUS_INTERNAL_ERROR},
555 	{ERRHRD,	ERRgeneral,	NT_STATUS_GENERIC_NOT_MAPPED},
556 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_DESCRIPTOR_FORMAT},
557 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_USER_BUFFER},
558 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNEXPECTED_IO_ERROR},
559 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNEXPECTED_MM_CREATE_ERR},
560 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNEXPECTED_MM_MAP_ERROR},
561 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNEXPECTED_MM_EXTEND_ERR},
562 	{ERRHRD,	ERRgeneral,	NT_STATUS_NOT_LOGON_PROCESS},
563 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGON_SESSION_EXISTS},
564 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_1},
565 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_2},
566 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_3},
567 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_4},
568 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_5},
569 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_6},
570 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_7},
571 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_8},
572 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_9},
573 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_10},
574 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_11},
575 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_12},
576 	{ERRDOS,	ERRbadpath,	NT_STATUS_REDIRECTOR_NOT_STARTED},
577 	{ERRHRD,	ERRgeneral,	NT_STATUS_REDIRECTOR_STARTED},
578 	{ERRHRD,	ERRgeneral,	NT_STATUS_STACK_OVERFLOW},
579 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_PACKAGE},
580 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_FUNCTION_TABLE},
581 	{ERRDOS, ERROR_ENVVAR_NOT_FOUND,	NT_STATUS_VARIABLE_NOT_FOUND},
582 	{ERRDOS, ERROR_DIR_NOT_EMPTY,	NT_STATUS_DIRECTORY_NOT_EMPTY},
583 	{ERRHRD,	ERRgeneral,	NT_STATUS_FILE_CORRUPT_ERROR},
584 	{ERRDOS, ERROR_DIRECTORY,	NT_STATUS_NOT_A_DIRECTORY},
585 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_LOGON_SESSION_STATE},
586 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGON_SESSION_COLLISION},
587 	{ERRDOS, ERROR_FILENAME_EXCED_RANGE,	NT_STATUS_NAME_TOO_LONG},
588 	{ERRDOS, NERR_OpenFiles,	NT_STATUS_FILES_OPEN},
589 	{ERRDOS, NERR_DevInUse,		NT_STATUS_CONNECTION_IN_USE},
590 	{ERRHRD,	ERRgeneral,	NT_STATUS_MESSAGE_NOT_FOUND},
591 	{ERRDOS,	ERRnoaccess,	NT_STATUS_PROCESS_IS_TERMINATING},
592 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_LOGON_TYPE},
593 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_GUID_TRANSLATION},
594 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANNOT_IMPERSONATE},
595 	{ERRHRD,	ERRgeneral,	NT_STATUS_IMAGE_ALREADY_LOADED},
596 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_NOT_PRESENT},
597 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_LID_NOT_EXIST},
598 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_LID_ALREADY_OWNED},
599 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_NOT_LID_OWNER},
600 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_INVALID_COMMAND},
601 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_INVALID_LID},
602 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE},
603 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_INVALID_SELECTOR},
604 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_LDT},
605 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_LDT_SIZE},
606 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_LDT_OFFSET},
607 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_LDT_DESCRIPTOR},
608 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_INVALID_IMAGE_NE_FORMAT},
609 	{ERRHRD,	ERRgeneral,	NT_STATUS_RXACT_INVALID_STATE},
610 	{ERRHRD,	ERRgeneral,	NT_STATUS_RXACT_COMMIT_FAILURE},
611 	{ERRHRD,	ERRgeneral,	NT_STATUS_MAPPED_FILE_SIZE_ZERO},
612 	{ERRDOS,	ERRnofids,	NT_STATUS_TOO_MANY_OPENED_FILES},
613 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANCELLED},
614 	{ERRDOS,	ERRnoaccess,	NT_STATUS_CANNOT_DELETE},
615 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_COMPUTER_NAME},
616 	{ERRDOS,	ERRnoaccess,	NT_STATUS_FILE_DELETED},
617 	{ERRHRD,	ERRgeneral,	NT_STATUS_SPECIAL_ACCOUNT},
618 	{ERRHRD,	ERRgeneral,	NT_STATUS_SPECIAL_GROUP},
619 	{ERRHRD,	ERRgeneral,	NT_STATUS_SPECIAL_USER},
620 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBERS_PRIMARY_GROUP},
621 	{ERRDOS,	ERRbadfid,	NT_STATUS_FILE_CLOSED},
622 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_THREADS},
623 	{ERRHRD,	ERRgeneral,	NT_STATUS_THREAD_NOT_IN_PROCESS},
624 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOKEN_ALREADY_IN_USE},
625 	{ERRHRD,	ERRgeneral,	NT_STATUS_PAGEFILE_QUOTA_EXCEEDED},
626 	{ERRHRD,	ERRgeneral,	NT_STATUS_COMMITMENT_LIMIT},
627 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_INVALID_IMAGE_LE_FORMAT},
628 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_INVALID_IMAGE_NOT_MZ},
629 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_INVALID_IMAGE_PROTECT},
630 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_INVALID_IMAGE_WIN_16},
631 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGON_SERVER_CONFLICT},
632 	{ERRHRD,	ERRgeneral,	NT_STATUS_TIME_DIFFERENCE_AT_DC},
633 	{ERRHRD,	ERRgeneral,	NT_STATUS_SYNCHRONIZATION_REQUIRED},
634 	{ERRDOS, ERROR_MOD_NOT_FOUND,	NT_STATUS_DLL_NOT_FOUND},
635 	{ERRHRD,	ERRgeneral,	NT_STATUS_OPEN_FAILED},
636 	{ERRHRD,	ERRgeneral,	NT_STATUS_IO_PRIVILEGE_FAILED},
637 	{ERRDOS, ERROR_INVALID_ORDINAL,	NT_STATUS_ORDINAL_NOT_FOUND},
638 	{ERRDOS, ERROR_PROC_NOT_FOUND,	NT_STATUS_ENTRYPOINT_NOT_FOUND},
639 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONTROL_C_EXIT},
640 	{ERRDOS, ERROR_NETNAME_DELETED,	NT_STATUS_LOCAL_DISCONNECT},
641 	{ERRDOS, ERROR_NETNAME_DELETED,	NT_STATUS_REMOTE_DISCONNECT},
642 	{ERRDOS, ERROR_REM_NOT_LIST,	NT_STATUS_REMOTE_RESOURCES},
643 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_LINK_FAILED},
644 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_LINK_TIMEOUT},
645 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_INVALID_CONNECTION},
646 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_INVALID_ADDRESS},
647 	{ERRHRD,	ERRgeneral,	NT_STATUS_DLL_INIT_FAILED},
648 	{ERRHRD,	ERRgeneral,	NT_STATUS_MISSING_SYSTEMFILE},
649 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNHANDLED_EXCEPTION},
650 	{ERRHRD,	ERRgeneral,	NT_STATUS_APP_INIT_FAILURE},
651 	{ERRHRD,	ERRgeneral,	NT_STATUS_PAGEFILE_CREATE_FAILED},
652 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_PAGEFILE},
653 	{ERRDOS, ERROR_INVALID_LEVEL,	NT_STATUS_INVALID_LEVEL},
654 	{ERRDOS, ERROR_INVALID_PASSWORD,	NT_STATUS_WRONG_PASSWORD_CORE},
655 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILLEGAL_FLOAT_CONTEXT},
656 	{ERRDOS, ERROR_BROKEN_PIPE,	NT_STATUS_PIPE_BROKEN},
657 	{ERRHRD,	ERRgeneral,	NT_STATUS_REGISTRY_CORRUPT},
658 	{ERRHRD,	ERRgeneral,	NT_STATUS_REGISTRY_IO_FAILED},
659 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_EVENT_PAIR},
660 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNRECOGNIZED_VOLUME},
661 	{ERRHRD,	ERRgeneral,	NT_STATUS_SERIAL_NO_DEVICE_INITED},
662 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_ALIAS},
663 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBER_NOT_IN_ALIAS},
664 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBER_IN_ALIAS},
665 	{ERRHRD,	ERRgeneral,	NT_STATUS_ALIAS_EXISTS},
666 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGON_NOT_GRANTED},
667 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_SECRETS},
668 	{ERRHRD,	ERRgeneral,	NT_STATUS_SECRET_TOO_LONG},
669 	{ERRHRD,	ERRgeneral,	NT_STATUS_INTERNAL_DB_ERROR},
670 	{ERRHRD,	ERRgeneral,	NT_STATUS_FULLSCREEN_MODE},
671 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_CONTEXT_IDS},
672 	{ERRDOS,	ERRnoaccess,	NT_STATUS_LOGON_TYPE_NOT_GRANTED},
673 	{ERRHRD,	ERRgeneral,	NT_STATUS_NOT_REGISTRY_FILE},
674 	{ERRHRD,	ERRgeneral,	NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED},
675 	{ERRHRD,	ERRgeneral,	NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR},
676 	{ERRHRD,	ERRgeneral,	NT_STATUS_FT_MISSING_MEMBER},
677 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILL_FORMED_SERVICE_ENTRY},
678 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILLEGAL_CHARACTER},
679 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNMAPPABLE_CHARACTER},
680 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNDEFINED_CHARACTER},
681 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_VOLUME},
682 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND},
683 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_WRONG_CYLINDER},
684 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_UNKNOWN_ERROR},
685 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_BAD_REGISTERS},
686 	{ERRHRD,	ERRgeneral,	NT_STATUS_DISK_RECALIBRATE_FAILED},
687 	{ERRHRD,	ERRgeneral,	NT_STATUS_DISK_OPERATION_FAILED},
688 	{ERRHRD,	ERRgeneral,	NT_STATUS_DISK_RESET_FAILED},
689 	{ERRHRD,	ERRgeneral,	NT_STATUS_SHARED_IRQ_BUSY},
690 	{ERRHRD,	ERRgeneral,	NT_STATUS_FT_ORPHANING},
691 	{ERRHRD,	ERRgeneral,
692 		NT_STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT},
693 	{ERRHRD,	ERRgeneral,	NT_STATUS_PARTITION_FAILURE},
694 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_BLOCK_LENGTH},
695 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEVICE_NOT_PARTITIONED},
696 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNABLE_TO_LOCK_MEDIA},
697 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNABLE_TO_UNLOAD_MEDIA},
698 	{ERRHRD,	ERRgeneral,	NT_STATUS_EOM_OVERFLOW},
699 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_MEDIA},
700 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_MEMBER},
701 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_MEMBER},
702 	{ERRHRD,	ERRgeneral,	NT_STATUS_KEY_DELETED},
703 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_LOG_SPACE},
704 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_SIDS},
705 	{ERRHRD,	ERRgeneral,	NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED},
706 	{ERRHRD,	ERRgeneral,	NT_STATUS_KEY_HAS_CHILDREN},
707 	{ERRHRD,	ERRgeneral,	NT_STATUS_CHILD_MUST_BE_VOLATILE},
708 	{ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_DEVICE_CONFIGURATION_ERROR},
709 	{ERRHRD,	ERRgeneral,	NT_STATUS_DRIVER_INTERNAL_ERROR},
710 	{ERRDOS, ERROR_BAD_COMMAND,	NT_STATUS_INVALID_DEVICE_STATE},
711 	{ERRHRD,	ERRgeneral,	NT_STATUS_IO_DEVICE_ERROR},
712 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEVICE_PROTOCOL_ERROR},
713 	{ERRHRD,	ERRgeneral,	NT_STATUS_BACKUP_CONTROLLER},
714 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOG_FILE_FULL},
715 	{ERRDOS, ERROR_WRITE_PROTECT,	NT_STATUS_TOO_LATE},
716 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_TRUST_LSA_SECRET},
717 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_TRUST_SAM_ACCOUNT},
718 	{ERRDOS,	ERRnoaccess,	NT_STATUS_TRUSTED_DOMAIN_FAILURE},
719 	{ERRDOS,	ERRnoaccess,	NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE},
720 	{ERRHRD,	ERRgeneral,	NT_STATUS_EVENTLOG_FILE_CORRUPT},
721 	{ERRHRD,	ERRgeneral,	NT_STATUS_EVENTLOG_CANT_START},
722 	{ERRDOS,	ERRnoaccess,	NT_STATUS_TRUST_FAILURE},
723 	{ERRHRD,	ERRgeneral,	NT_STATUS_MUTANT_LIMIT_EXCEEDED},
724 	{ERRDOS, NERR_NetlogonNotStarted,	NT_STATUS_NETLOGON_NOT_STARTED},
725 	{ERRSRV, NERR_AccountExpired,	NT_STATUS_ACCOUNT_EXPIRED},
726 	{ERRHRD,	ERRgeneral,	NT_STATUS_POSSIBLE_DEADLOCK},
727 	{ERRHRD,	ERRgeneral,	NT_STATUS_NETWORK_CREDENTIAL_CONFLICT},
728 	{ERRHRD,	ERRgeneral,	NT_STATUS_REMOTE_SESSION_LIMIT},
729 	{ERRHRD,	ERRgeneral,	NT_STATUS_EVENTLOG_FILE_CHANGED},
730 	{ERRDOS,	ERRnoaccess,
731 		NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT},
732 	{ERRDOS,	ERRnoaccess,
733 		NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT},
734 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT},
735 	{ERRDOS,	ERRnoaccess,	NT_STATUS_DOMAIN_TRUST_INCONSISTENT},
736 	{ERRHRD,	ERRgeneral,	NT_STATUS_FS_DRIVER_REQUIRED},
737 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_USER_SESSION_KEY},
738 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_USER_SESSION_DELETED},
739 	{ERRHRD,	ERRgeneral,	NT_STATUS_RESOURCE_LANG_NOT_FOUND},
740 	{ERRDOS,	ERRnomem,	NT_STATUS_INSUFF_SERVER_RESOURCES},
741 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_BUFFER_SIZE},
742 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ADDRESS_COMPONENT},
743 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ADDRESS_WILDCARD},
744 	{ERRDOS, ERROR_TOO_MANY_NAMES,	NT_STATUS_TOO_MANY_ADDRESSES},
745 	{ERRDOS, ERROR_DUP_NAME,	NT_STATUS_ADDRESS_ALREADY_EXISTS},
746 	{ERRDOS, ERROR_NETNAME_DELETED,	NT_STATUS_ADDRESS_CLOSED},
747 	{ERRDOS, ERROR_NETNAME_DELETED,	NT_STATUS_CONNECTION_DISCONNECTED},
748 	{ERRDOS, ERROR_NETNAME_DELETED,	NT_STATUS_CONNECTION_RESET},
749 	{ERRDOS, ERROR_TOO_MANY_NAMES,	NT_STATUS_TOO_MANY_NODES},
750 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_TRANSACTION_ABORTED},
751 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_TRANSACTION_TIMED_OUT},
752 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_TRANSACTION_NO_RELEASE},
753 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_TRANSACTION_NO_MATCH},
754 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_TRANSACTION_RESPONDED},
755 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_TRANSACTION_INVALID_ID},
756 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_TRANSACTION_INVALID_TYPE},
757 	{ERRDOS, ERROR_NOT_SUPPORTED,	NT_STATUS_NOT_SERVER_SESSION},
758 	{ERRDOS, ERROR_NOT_SUPPORTED,	NT_STATUS_NOT_CLIENT_SESSION},
759 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANNOT_LOAD_REGISTRY_FILE},
760 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEBUG_ATTACH_FAILED},
761 	{ERRHRD,	ERRgeneral,	NT_STATUS_SYSTEM_PROCESS_TERMINATED},
762 	{ERRHRD,	ERRgeneral,	NT_STATUS_DATA_NOT_ACCEPTED},
763 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_BROWSER_SERVERS_FOUND},
764 	{ERRHRD,	ERRgeneral,	NT_STATUS_VDM_HARD_ERROR},
765 	{ERRHRD,	ERRgeneral,	NT_STATUS_DRIVER_CANCEL_TIMEOUT},
766 	{ERRHRD,	ERRgeneral,	NT_STATUS_REPLY_MESSAGE_MISMATCH},
767 	{ERRHRD,	ERRgeneral,	NT_STATUS_MAPPED_ALIGNMENT},
768 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_IMAGE_CHECKSUM_MISMATCH},
769 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOST_WRITEBEHIND_DATA},
770 	{ERRHRD,	ERRgeneral, NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID},
771 	{ERRSRV, NERR_PasswordExpired,	NT_STATUS_PASSWORD_MUST_CHANGE},
772 	{ERRHRD,	ERRgeneral,	NT_STATUS_NOT_FOUND},
773 	{ERRHRD,	ERRgeneral,	NT_STATUS_NOT_TINY_STREAM},
774 	{ERRHRD,	ERRgeneral,	NT_STATUS_RECOVERY_FAILURE},
775 	{ERRHRD,	ERRgeneral,	NT_STATUS_STACK_OVERFLOW_READ},
776 	{ERRHRD,	ERRgeneral,	NT_STATUS_FAIL_CHECK},
777 	{ERRHRD,	ERRgeneral,	NT_STATUS_DUPLICATE_OBJECTID},
778 	{ERRHRD,	ERRgeneral,	NT_STATUS_OBJECTID_EXISTS},
779 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONVERT_TO_LARGE},
780 	{ERRHRD,	ERRgeneral,	NT_STATUS_RETRY},
781 	{ERRHRD,	ERRgeneral,	NT_STATUS_FOUND_OUT_OF_SCOPE},
782 	{ERRHRD,	ERRgeneral,	NT_STATUS_ALLOCATE_BUCKET},
783 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROPSET_NOT_FOUND},
784 	{ERRHRD,	ERRgeneral,	NT_STATUS_MARSHALL_OVERFLOW},
785 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_VARIANT},
786 	{ERRHRD,	ERRgeneral,	NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND},
787 	{ERRDOS,	ERRnoaccess,	NT_STATUS_ACCOUNT_LOCKED_OUT},
788 	{ERRDOS,	ERRbadfid,	NT_STATUS_HANDLE_NOT_CLOSABLE},
789 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_REFUSED},
790 	{ERRHRD,	ERRgeneral,	NT_STATUS_GRACEFUL_DISCONNECT},
791 	{ERRHRD,	ERRgeneral,	NT_STATUS_ADDRESS_ALREADY_ASSOCIATED},
792 	{ERRHRD,	ERRgeneral,	NT_STATUS_ADDRESS_NOT_ASSOCIATED},
793 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_INVALID},
794 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_ACTIVE},
795 	{ERRHRD,	ERRgeneral,	NT_STATUS_NETWORK_UNREACHABLE},
796 	{ERRHRD,	ERRgeneral,	NT_STATUS_HOST_UNREACHABLE},
797 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROTOCOL_UNREACHABLE},
798 	{ERRHRD,	ERRgeneral,	NT_STATUS_PORT_UNREACHABLE},
799 	{ERRHRD,	ERRgeneral,	NT_STATUS_REQUEST_ABORTED},
800 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_ABORTED},
801 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_COMPRESSION_BUFFER},
802 	{ERRHRD,	ERRgeneral,	NT_STATUS_USER_MAPPED_FILE},
803 	{ERRHRD,	ERRgeneral,	NT_STATUS_AUDIT_FAILED},
804 	{ERRHRD,	ERRgeneral,	NT_STATUS_TIMER_RESOLUTION_NOT_SET},
805 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_COUNT_LIMIT},
806 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGIN_TIME_RESTRICTION},
807 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGIN_WKSTA_RESTRICTION},
808 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_IMAGE_MP_UP_MISMATCH},
809 	{ERRHRD,	ERRgeneral,	NT_STATUS_INSUFFICIENT_LOGON_INFO},
810 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_DLL_ENTRYPOINT},
811 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_SERVICE_ENTRYPOINT},
812 	{ERRHRD,	ERRgeneral,	NT_STATUS_LPC_REPLY_LOST},
813 	{ERRHRD,	ERRgeneral,	NT_STATUS_IP_ADDRESS_CONFLICT1},
814 	{ERRHRD,	ERRgeneral,	NT_STATUS_IP_ADDRESS_CONFLICT2},
815 	{ERRHRD,	ERRgeneral,	NT_STATUS_REGISTRY_QUOTA_LIMIT},
816 	{ERRSRV,	ERRbadtype,	NT_STATUS_PATH_NOT_COVERED},
817 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_CALLBACK_ACTIVE},
818 	{ERRHRD,	ERRgeneral,	NT_STATUS_LICENSE_QUOTA_EXCEEDED},
819 	{ERRHRD,	ERRgeneral,	NT_STATUS_PWD_TOO_SHORT},
820 	{ERRHRD,	ERRgeneral,	NT_STATUS_PWD_TOO_RECENT},
821 	{ERRHRD,	ERRgeneral,	NT_STATUS_PWD_HISTORY_CONFLICT},
822 	{ERRHRD,	ERRgeneral,	NT_STATUS_PLUGPLAY_NO_DEVICE},
823 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNSUPPORTED_COMPRESSION},
824 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_HW_PROFILE},
825 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH},
826 	{ERRDOS, ERROR_INVALID_ORDINAL,	NT_STATUS_DRIVER_ORDINAL_NOT_FOUND},
827 	{ERRDOS, ERROR_PROC_NOT_FOUND,	NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND},
828 	{ERRDOS, ERROR_NOT_OWNER,	NT_STATUS_RESOURCE_NOT_OWNED},
829 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_LINKS},
830 	{ERRHRD,	ERRgeneral,	NT_STATUS_QUOTA_LIST_INCONSISTENT},
831 	{ERRHRD,	ERRgeneral,	NT_STATUS_FILE_IS_OFFLINE},
832 	{ERRDOS, ERROR_NOT_READY,	NT_STATUS_VOLUME_DISMOUNTED},
833 	{ERRDOS, ERROR_BAD_PATHNAME,	NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT},
834 	{ERRDOS,	ERRnoaccess,	NT_STATUS_ENCRYPTION_FAILED},
835 	{ERRDOS,	ERRnoaccess,	NT_STATUS_DECRYPTION_FAILED},
836 	{ERRHRD,	ERRgeneral,	NT_STATUS_RANGE_NOT_FOUND},
837 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_RECOVERY_POLICY},
838 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_EFS},
839 	{ERRDOS,	ERRnoaccess,	NT_STATUS_WRONG_EFS},
840 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_USER_KEYS},
841 	{ERRDOS,	ERRbadfunc,	NT_STATUS_VOLUME_NOT_UPGRADED},
842 	{0, 0, 0}
843 };
844 
845 int
846 smb_maperr32(uint32_t nterr)
847 {
848 	const nt2errno_t *nt2e;
849 	const nt2doserr_t *nt2d;
850 
851 	switch (NT_SC_SEVERITY(nterr)) {
852 	case NT_STATUS_SEVERITY_SUCCESS:
853 	case NT_STATUS_SEVERITY_INFORMATIONAL:
854 		return (0);
855 	}
856 
857 	/* first try direct map to unix */
858 	for (nt2e = nt2errno; nt2e->errno; nt2e++)
859 		if (nt2e->nterr == nterr)
860 			return (nt2e->errno);
861 	smb_errmsg(unknown_err_logpri, "smb_maperr32",
862 	    "No direct map for 32 bit server error (0x%x)\n", nterr);
863 
864 	/* ok, then try mapping to dos to unix */
865 	for (nt2d = nt2doserr; nt2d->nterr; nt2d++)
866 		if (nt2d->nterr == nterr)
867 			return (smb_maperror(nt2d->dclass, nt2d->derr));
868 	return (EIO);
869 }
870 
871 
872 int
873 smb_maperror(int eclass, int eno)
874 {
875 	if (eclass == 0 && eno == 0)
876 		return (0);
877 	switch (eclass) {
878 	case ERRDOS:
879 		switch (eno) {
880 		case ERROR_INVALID_LEVEL:
881 			return (ENOTSUP);
882 		case ERRbadfunc:
883 		case ERRbadenv:
884 		case ERRbadformat:
885 		case ERRremcd:
886 		case ERRrmuns:
887 			return (EINVAL);
888 		case ERRbadfile:
889 		case ERRbadpath:
890 		case ERROR_BAD_DEV_TYPE:
891 		case ERROR_BAD_NET_NAME:
892 			return (ENOENT);
893 		case ERRnofids:
894 			return (EMFILE);
895 		case ERRnoaccess:
896 			/*
897 			 * XXX CSM Reported on samba-technical 12/7/2002
898 			 *
899 			 * There is a case for which server(s) return
900 			 * ERRnoaccess but should return ERRdiskfull: When
901 			 * the offset for a write is exactly the server
902 			 * file size limit then Samba (at least) thinks
903 			 * the reason for zero bytes having been written
904 			 * must have been "access denied" from the local
905 			 * filesystem.  This cannot be easily worked
906 			 * around since the server behaviour is
907 			 * indistinguishable from actual access denied.
908 			 * An incomplete workaround: attempt a 2 byte write
909 			 * from "offset-1".  (That may require reading at
910 			 * offset-1 first.)  The flaw is that reading or
911 			 * writing at offset-1 could cause an
912 			 * unrelated error (due to a byte range lock
913 			 * for instance) and we can't presume the
914 			 * order servers check errors in.
915 			 */
916 		case ERRbadaccess:
917 			return (EACCES);
918 		case ERRbadshare:
919 			return (EBUSY);
920 		case ERRbadfid:
921 			return (EBADF);
922 		case ERRbadmcb:
923 			return (EIO);
924 		case ERRnomem:
925 			return (ENOMEM);	/* actually remote no mem... */
926 		case ERRbadmem:
927 			return (EFAULT);
928 		case ERRbaddata:
929 			return (E2BIG);
930 		case ERRbaddrive:
931 		case ERRnotready:	/* nt */
932 			return (ENXIO);
933 		case ERRdiffdevice:
934 			return (EXDEV);
935 		case ERRnofiles:
936 			return (0);	/* eeof ? */
937 		case ERRlock:
938 			return (EAGAIN);
939 		case ERRfilexists:
940 			return (EEXIST);
941 		case ERROR_INVALID_NAME:
942 			return (ENOENT);
943 		case ERROR_DIR_NOT_EMPTY:
944 			return (ENOTEMPTY);
945 		case ERROR_NOT_LOCKED:
946 			return (0); /* we unlock on any close */
947 		case ERROR_ALREADY_EXISTS:
948 			return (EEXIST);
949 		case ERRmoredata:
950 			return (EMOREDATA);
951 		}
952 		break;
953 	case ERRSRV:
954 		switch (eno) {
955 		case ERRerror:
956 			return (EINVAL);
957 		case ERRbadpw:
958 			return (EAUTH);
959 		case ERRaccess:
960 		case ERRbaduid:
961 			return (EACCES);
962 		case ERRinvnid:
963 			return (ENETRESET);
964 		case ERRinvnetname:
965 			return (ENXIO);
966 		case ERRbadtype:		/* reserved and returned */
967 			return (EIO);
968 		case NERR_AccountExpired: /* account exists but disabled */
969 			return (EPERM);
970 		}
971 		break;
972 	case ERRHRD:
973 		switch (eno) {
974 		case ERRnowrite:
975 			return (EROFS);
976 		case ERRbadunit:
977 			return (ENODEV);
978 		case ERRbadreq:
979 			return (EBADRPC);
980 		case ERRbadshare:
981 			return (ETXTBSY);
982 		case ERRlock:
983 			return (EAGAIN);
984 		case ERRdiskfull:
985 			return (EFBIG);
986 		case ERRnotready:
987 		case ERRbadcmd:
988 		case ERRdata:
989 		case ERRgeneral:
990 			return (EIO);
991 		}
992 	}
993 
994 	smb_errmsg(unknown_err_logpri, "smb_maperror",
995 	    "Unknown DOS error %d/%d\n", eclass, eno);
996 	return (EIO);
997 }
998 
999 #if defined(NOICONVSUPPORT) || defined(lint)
1000 extern int iconv_conv(void *handle, const char **inbuf,
1001     size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
1002 #endif
1003 
1004 #define	SMALL_CONV 256
1005 
1006 /*ARGSUSED*/
1007 int
1008 smb_put_dmem(struct mbchain *mbp, struct smb_vc *vcp, const char *src,
1009 	int size, int caseopt, int *lenp)
1010 {
1011 	uint16_t convbuf[SMALL_CONV];
1012 	uint16_t *cbuf;
1013 	size_t cbufalloc, inlen, outlen;
1014 	int error;
1015 
1016 	if (size <= 0)
1017 		return (0);
1018 
1019 	/*
1020 	 * Handle the easy case (non-unicode).
1021 	 * XXX: Technically, we should convert
1022 	 * the string to OEM codeset first...
1023 	 * Modern servers all use Unicode, so
1024 	 * this is good enough.
1025 	 */
1026 	if (SMB_UNICODE_STRINGS(vcp) == 0) {
1027 		error = mb_put_mem(mbp, src, size, MB_MSYSTEM);
1028 		if (!error && lenp)
1029 			*lenp += size;
1030 		return (error);
1031 	}
1032 
1033 	/*
1034 	 * Convert to UCS-2 (really UTF-16).
1035 	 * Use stack buffer if the string is
1036 	 * small enough, else allocate.
1037 	 */
1038 	if (size <= SMALL_CONV) {
1039 		cbufalloc = 0;
1040 		outlen = SMALL_CONV;
1041 		cbuf = convbuf;
1042 	} else {
1043 		outlen = size; /* in utf-16 characters */
1044 		cbufalloc = outlen * 2;
1045 		cbuf = kmem_alloc(cbufalloc, KM_SLEEP);
1046 	}
1047 
1048 	inlen = size;
1049 	error = uconv_u8tou16((uchar_t *)src, &inlen, cbuf, &outlen,
1050 	    UCONV_OUT_LITTLE_ENDIAN | UCONV_IGNORE_NULL);
1051 	outlen *= 2;  /* convert to bytes */
1052 
1053 	if (!error) {
1054 		(void) mb_put_padbyte(mbp); /* align */
1055 		error = mb_put_mem(mbp, (char *)cbuf, outlen, MB_MSYSTEM);
1056 	}
1057 	if (!error && lenp)
1058 		*lenp += outlen;
1059 
1060 	if (cbufalloc)
1061 		kmem_free(cbuf, cbufalloc);
1062 
1063 	return (error);
1064 }
1065 
1066 int
1067 smb_put_dstring(struct mbchain *mbp, struct smb_vc *vcp, const char *src,
1068 	int caseopt)
1069 {
1070 	int error, len;
1071 
1072 	/*
1073 	 * Let smb_put_dmem put both the string
1074 	 * and the terminating null.
1075 	 */
1076 	len = strlen(src) + 1;
1077 	error = smb_put_dmem(mbp, vcp, src, len, caseopt, NULL);
1078 	if (error)
1079 		return (error);
1080 
1081 	return (error);
1082 }
1083