xref: /illumos-gate/usr/src/uts/common/fs/smbclnt/netsmb/smb_subrs.c (revision b1d7ec75953cd517f5b7c3d9cb427ff8ec5d7d07)
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 typedef struct nt2errno {
195 	unsigned int nterr;
196 	int errno;
197 } nt2errno_t;
198 
199 static const nt2errno_t nt2errno[] = {
200 	/* Alphabetical order. */
201 	{NT_STATUS_ACCESS_DENIED,		EACCES},
202 	{NT_STATUS_ACCESS_VIOLATION,		EACCES},
203 	{NT_STATUS_ACCOUNT_DISABLED,		EACCES},
204 	{NT_STATUS_ACCOUNT_EXPIRED,		EACCES},
205 	{NT_STATUS_ACCOUNT_LOCKED_OUT,		EACCES},
206 	{NT_STATUS_ACCOUNT_RESTRICTION,		EACCES},
207 	{NT_STATUS_ADDRESS_ALREADY_EXISTS,	EADDRINUSE},
208 	{NT_STATUS_BAD_NETWORK_NAME,		ENOENT},
209 	{NT_STATUS_BUFFER_TOO_SMALL,		EMOREDATA},
210 	{NT_STATUS_CANNOT_DELETE,		EACCES},
211 	{NT_STATUS_CONFLICTING_ADDRESSES,	EADDRINUSE},
212 	{NT_STATUS_CONNECTION_ABORTED,		ECONNABORTED},
213 	{NT_STATUS_CONNECTION_DISCONNECTED,	ECONNABORTED},
214 	{NT_STATUS_CONNECTION_REFUSED,		ECONNREFUSED},
215 	{NT_STATUS_CONNECTION_RESET,		ENETRESET},
216 	{NT_STATUS_DELETE_PENDING,		EACCES},
217 	{NT_STATUS_DEVICE_DOES_NOT_EXIST,	ENODEV},
218 	{NT_STATUS_DEVICE_PROTOCOL_ERROR,	EPROTO},
219 	{NT_STATUS_DIRECTORY_NOT_EMPTY,		ENOTEMPTY},
220 	{NT_STATUS_DISK_FULL,			ENOSPC},
221 	{NT_STATUS_DLL_NOT_FOUND,		ELIBACC},
222 	{NT_STATUS_END_OF_FILE,			ENODATA},
223 	{NT_STATUS_FILE_IS_A_DIRECTORY,		EISDIR},
224 	{NT_STATUS_FILE_LOCK_CONFLICT,		EAGAIN},
225 	{NT_STATUS_FLOAT_INEXACT_RESULT,	ERANGE},
226 	{NT_STATUS_FLOAT_OVERFLOW,		ERANGE},
227 	{NT_STATUS_FLOAT_UNDERFLOW,		ERANGE},
228 	{NT_STATUS_HOST_UNREACHABLE,		EHOSTUNREACH},
229 	{NT_STATUS_ILL_FORMED_PASSWORD,		EACCES},
230 	{NT_STATUS_INTEGER_OVERFLOW,		ERANGE},
231 	{NT_STATUS_INVALID_ACCOUNT_NAME,	EACCES},
232 	{NT_STATUS_INVALID_HANDLE,		EBADF},
233 	{NT_STATUS_INVALID_LEVEL,		ENOTSUP},
234 	{NT_STATUS_INVALID_LOGON_HOURS,		EACCES},
235 	{NT_STATUS_INVALID_OWNER,		EINVAL},
236 	{NT_STATUS_INVALID_PARAMETER,		EINVAL},
237 	{NT_STATUS_INVALID_PIPE_STATE,		EPIPE},
238 	{NT_STATUS_INVALID_PRIMARY_GROUP,	EINVAL},
239 	{NT_STATUS_INVALID_WORKSTATION,		EACCES},
240 	{NT_STATUS_IN_PAGE_ERROR,		EFAULT},
241 	{NT_STATUS_IO_TIMEOUT,			ETIMEDOUT},
242 	{NT_STATUS_IP_ADDRESS_CONFLICT1,	ENOTUNIQ},
243 	{NT_STATUS_IP_ADDRESS_CONFLICT2,	ENOTUNIQ},
244 	{NT_STATUS_LICENSE_QUOTA_EXCEEDED,	EDQUOT},
245 	{NT_STATUS_LOCK_NOT_GRANTED,		EAGAIN},
246 	{NT_STATUS_LOGIN_TIME_RESTRICTION,	EACCES},
247 	{NT_STATUS_LOGON_FAILURE,		EACCES},
248 	{NT_STATUS_MEDIA_WRITE_PROTECTED,	EROFS},
249 	{NT_STATUS_MEMORY_NOT_ALLOCATED,	EFAULT},
250 	{NT_STATUS_NAME_TOO_LONG,		ENAMETOOLONG},
251 	{NT_STATUS_NETWORK_ACCESS_DENIED,	EACCES},
252 	{NT_STATUS_NETWORK_BUSY,		EBUSY},
253 	{NT_STATUS_NETWORK_UNREACHABLE,		ENETUNREACH},
254 	{NT_STATUS_NET_WRITE_FAULT,		ECOMM},
255 	{NT_STATUS_NONEXISTENT_SECTOR,		ESPIPE},
256 	{NT_STATUS_NONE_MAPPED,			EINVAL},
257 	{NT_STATUS_NOT_A_DIRECTORY,		ENOTDIR},
258 	{NT_STATUS_NOT_IMPLEMENTED,		ENOSYS},
259 	{NT_STATUS_NOT_MAPPED_VIEW,		EINVAL},
260 	{NT_STATUS_NOT_SUPPORTED,		ENOSYS},
261 	{NT_STATUS_NO_MEDIA,			ENOMEDIUM},
262 	{NT_STATUS_NO_MEDIA_IN_DEVICE,		ENOMEDIUM},
263 	{NT_STATUS_NO_MEMORY,			ENOMEM},
264 	{NT_STATUS_NO_SUCH_DEVICE,		ENODEV},
265 	{NT_STATUS_NO_SUCH_FILE,		ENOENT},
266 	{NT_STATUS_OBJECT_NAME_COLLISION,	EEXIST},
267 	{NT_STATUS_OBJECT_NAME_INVALID,		EINVAL},
268 	{NT_STATUS_OBJECT_NAME_NOT_FOUND,	ENOENT},
269 	{NT_STATUS_OBJECT_PATH_INVALID,		ENOTDIR},
270 	{NT_STATUS_OBJECT_PATH_NOT_FOUND,	ENOENT},
271 	{NT_STATUS_PAGEFILE_QUOTA,		EDQUOT},
272 	{NT_STATUS_PASSWORD_EXPIRED,		EACCES},
273 	{NT_STATUS_PASSWORD_MUST_CHANGE,	EACCES},
274 	{NT_STATUS_PASSWORD_RESTRICTION,	EACCES},
275 	{NT_STATUS_PATH_NOT_COVERED,		ENOENT},
276 	{NT_STATUS_PIPE_BROKEN,			EPIPE},
277 	{NT_STATUS_PIPE_BUSY,			EPIPE},
278 	{NT_STATUS_PIPE_CONNECTED,		EISCONN},
279 	{NT_STATUS_PIPE_DISCONNECTED,		EPIPE},
280 	{NT_STATUS_PIPE_NOT_AVAILABLE,		ENOSYS},
281 	{NT_STATUS_PORT_CONNECTION_REFUSED,	ECONNREFUSED},
282 	{NT_STATUS_PORT_MESSAGE_TOO_LONG,	EMSGSIZE},
283 	{NT_STATUS_PORT_UNREACHABLE,		EHOSTUNREACH},
284 	{NT_STATUS_PROTOCOL_UNREACHABLE,	ENOPROTOOPT},
285 	{NT_STATUS_QUOTA_EXCEEDED,		EDQUOT},
286 	{NT_STATUS_RANGE_NOT_LOCKED,		EIO},
287 	{NT_STATUS_REGISTRY_QUOTA_LIMIT,	EDQUOT},
288 	{NT_STATUS_REMOTE_DISCONNECT,		ESHUTDOWN},
289 	{NT_STATUS_REMOTE_NOT_LISTENING,	ECONNREFUSED},
290 	{NT_STATUS_REQUEST_NOT_ACCEPTED,	EACCES},
291 	{NT_STATUS_RETRY,			EAGAIN},
292 	{NT_STATUS_SHARING_VIOLATION,		EBUSY},
293 	{NT_STATUS_TIMER_NOT_CANCELED,		ETIME},
294 	{NT_STATUS_TOO_MANY_LINKS,		EMLINK},
295 	{NT_STATUS_TOO_MANY_OPENED_FILES,	EMFILE},
296 	{NT_STATUS_UNABLE_TO_FREE_VM,		EADDRINUSE},
297 	{NT_STATUS_UNSUCCESSFUL,		EINVAL},
298 	{NT_STATUS_WRONG_PASSWORD,		EACCES},
299 	{0,	0}
300 };
301 
302 /*
303  * Table for converting NT STATUS values to DOS class/code.
304  * Rows ordered by integer value of last column (NT STATUS)
305  */
306 typedef struct nt2doserr {
307 	unsigned short dclass;
308 	unsigned short derr;
309 	unsigned int nterr;
310 } nt2doserr_t;
311 
312 static const nt2doserr_t nt2doserr[] = {
313 	{ERRDOS,	ERRgeneral,	NT_STATUS_UNSUCCESSFUL},
314 	{ERRDOS,	ERRbadfunc,	NT_STATUS_NOT_IMPLEMENTED},
315 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_INFO_CLASS},
316 	{ERRDOS, ERROR_BAD_LENGTH,	NT_STATUS_INFO_LENGTH_MISMATCH},
317 	{ERRHRD,	ERRgeneral,	NT_STATUS_ACCESS_VIOLATION},
318 	{ERRHRD,	ERRgeneral,	NT_STATUS_IN_PAGE_ERROR},
319 	{ERRHRD,	ERRgeneral,	NT_STATUS_PAGEFILE_QUOTA},
320 	{ERRDOS,	ERRbadfid,	NT_STATUS_INVALID_HANDLE},
321 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_INITIAL_STACK},
322 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_BAD_INITIAL_PC},
323 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_CID},
324 	{ERRHRD,	ERRgeneral,	NT_STATUS_TIMER_NOT_CANCELED},
325 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER},
326 	{ERRDOS,	ERRbadfile,	NT_STATUS_NO_SUCH_DEVICE},
327 	{ERRDOS,	ERRbadfile,	NT_STATUS_NO_SUCH_FILE},
328 	{ERRDOS,	ERRbadfunc,	NT_STATUS_INVALID_DEVICE_REQUEST},
329 	{ERRDOS, ERROR_HANDLE_EOF,	NT_STATUS_END_OF_FILE},
330 	{ERRDOS, ERROR_WRONG_DISK,	NT_STATUS_WRONG_VOLUME},
331 	{ERRDOS, ERROR_NOT_READY,	NT_STATUS_NO_MEDIA_IN_DEVICE},
332 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNRECOGNIZED_MEDIA},
333 	{ERRDOS, ERROR_SECTOR_NOT_FOUND,	NT_STATUS_NONEXISTENT_SECTOR},
334 	{ERRDOS,	ERRnomem,	NT_STATUS_NO_MEMORY},
335 	{ERRDOS, ERROR_INVALID_ADDRESS,	NT_STATUS_CONFLICTING_ADDRESSES},
336 	{ERRDOS, ERROR_INVALID_ADDRESS,	NT_STATUS_NOT_MAPPED_VIEW},
337 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_UNABLE_TO_FREE_VM},
338 	{ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_UNABLE_TO_DELETE_SECTION},
339 	{ERRDOS, NERR_InvalidAPI,	NT_STATUS_INVALID_SYSTEM_SERVICE},
340 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILLEGAL_INSTRUCTION},
341 	{ERRDOS,	ERRnoaccess,	NT_STATUS_INVALID_LOCK_SEQUENCE},
342 	{ERRDOS,	ERRnoaccess,	NT_STATUS_INVALID_VIEW_SIZE},
343 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_INVALID_FILE_FOR_SECTION},
344 	{ERRDOS,	ERRnoaccess,	NT_STATUS_ALREADY_COMMITTED},
345 	{ERRDOS,	ERRnoaccess,	NT_STATUS_ACCESS_DENIED},
346 	{ERRDOS, ERROR_BUFFER_OVERFLOW,	NT_STATUS_BUFFER_TOO_SMALL},
347 	{ERRDOS,	ERRbadfid,	NT_STATUS_OBJECT_TYPE_MISMATCH},
348 	{ERRHRD,	ERRgeneral,	NT_STATUS_NONCONTINUABLE_EXCEPTION},
349 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_DISPOSITION},
350 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNWIND},
351 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_STACK},
352 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_UNWIND_TARGET},
353 	{ERRDOS, ERROR_NOT_LOCKED,	NT_STATUS_NOT_LOCKED},
354 	{ERRHRD,	ERRgeneral,	NT_STATUS_PARITY_ERROR},
355 	{ERRDOS, ERROR_INVALID_ADDRESS,	NT_STATUS_UNABLE_TO_DECOMMIT_VM},
356 	{ERRDOS, ERROR_INVALID_ADDRESS,	NT_STATUS_NOT_COMMITTED},
357 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_PORT_ATTRIBUTES},
358 	{ERRHRD,	ERRgeneral,	NT_STATUS_PORT_MESSAGE_TOO_LONG},
359 	{ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_MIX},
360 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_QUOTA_LOWER},
361 	{ERRHRD,	ERRgeneral,	NT_STATUS_DISK_CORRUPT_ERROR},
362 	{ERRDOS, ERROR_INVALID_NAME,	NT_STATUS_OBJECT_NAME_INVALID},
363 	{ERRDOS,	ERRbadfile,	NT_STATUS_OBJECT_NAME_NOT_FOUND},
364 	{ERRDOS, ERROR_ALREADY_EXISTS,	NT_STATUS_OBJECT_NAME_COLLISION},
365 	{ERRDOS,	ERRbadfid,	NT_STATUS_PORT_DISCONNECTED},
366 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEVICE_ALREADY_ATTACHED},
367 	{ERRDOS, ERROR_BAD_PATHNAME,	NT_STATUS_OBJECT_PATH_INVALID},
368 	{ERRDOS,	ERRbadpath,	NT_STATUS_OBJECT_PATH_NOT_FOUND},
369 	{ERRDOS, ERROR_BAD_PATHNAME,	NT_STATUS_OBJECT_PATH_SYNTAX_BAD},
370 	{ERRHRD,	ERRgeneral,	NT_STATUS_DATA_OVERRUN},
371 	{ERRHRD,	ERRgeneral,	NT_STATUS_DATA_LATE_ERROR},
372 	{ERRDOS, ERROR_CRC,		NT_STATUS_DATA_ERROR},
373 	{ERRDOS, ERROR_CRC,		NT_STATUS_CRC_ERROR},
374 	{ERRDOS,	ERRnomem,	NT_STATUS_SECTION_TOO_BIG},
375 	{ERRDOS,	ERRnoaccess,	NT_STATUS_PORT_CONNECTION_REFUSED},
376 	{ERRDOS,	ERRbadfid,	NT_STATUS_INVALID_PORT_HANDLE},
377 	{ERRDOS, ERROR_SHARING_VIOLATION,	NT_STATUS_SHARING_VIOLATION},
378 	{ERRHRD,	ERRgeneral,	NT_STATUS_QUOTA_EXCEEDED},
379 	{ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PAGE_PROTECTION},
380 	{ERRDOS, ERROR_NOT_OWNER,	NT_STATUS_MUTANT_NOT_OWNED},
381 	{ERRDOS, ERROR_TOO_MANY_POSTS,	NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED},
382 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_PORT_ALREADY_SET},
383 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_SECTION_NOT_IMAGE},
384 	{ERRDOS, ERROR_SIGNAL_REFUSED,	NT_STATUS_SUSPEND_COUNT_EXCEEDED},
385 	{ERRDOS,	ERRnoaccess,	NT_STATUS_THREAD_IS_TERMINATING},
386 	{ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_BAD_WORKING_SET_LIMIT},
387 	{ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INCOMPATIBLE_FILE_MAP},
388 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_SECTION_PROTECTION},
389 	{ERRDOS, ERROR_EAS_NOT_SUPPORTED,	NT_STATUS_EAS_NOT_SUPPORTED},
390 	{ERRDOS, ERROR_EA_LIST_INCONSISTENT,	NT_STATUS_EA_TOO_LARGE},
391 	{ERRHRD,	ERRgeneral,	NT_STATUS_NONEXISTENT_EA_ENTRY},
392 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_EAS_ON_FILE},
393 	{ERRHRD,	ERRgeneral,	NT_STATUS_EA_CORRUPT_ERROR},
394 	{ERRDOS, ERROR_LOCK_VIOLATION,	NT_STATUS_FILE_LOCK_CONFLICT},
395 	{ERRDOS, ERROR_LOCK_VIOLATION,	NT_STATUS_LOCK_NOT_GRANTED},
396 	{ERRDOS,	ERRnoaccess,	NT_STATUS_DELETE_PENDING},
397 	{ERRDOS, ERROR_NOT_SUPPORTED,	NT_STATUS_CTL_FILE_NOT_SUPPORTED},
398 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNKNOWN_REVISION},
399 	{ERRHRD,	ERRgeneral,	NT_STATUS_REVISION_MISMATCH},
400 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_OWNER},
401 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_PRIMARY_GROUP},
402 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_IMPERSONATION_TOKEN},
403 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_DISABLE_MANDATORY},
404 	{ERRDOS, NERR_LogonServerNotFound,	NT_STATUS_NO_LOGON_SERVERS},
405 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_LOGON_SESSION},
406 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_PRIVILEGE},
407 	{ERRDOS,	ERRnoaccess,	NT_STATUS_PRIVILEGE_NOT_HELD},
408 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ACCOUNT_NAME},
409 	{ERRHRD,	ERRgeneral,	NT_STATUS_USER_EXISTS},
410 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_SUCH_USER},
411 	{ERRHRD,	ERRgeneral,	NT_STATUS_GROUP_EXISTS},
412 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_GROUP},
413 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBER_IN_GROUP},
414 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBER_NOT_IN_GROUP},
415 	{ERRHRD,	ERRgeneral,	NT_STATUS_LAST_ADMIN},
416 	{ERRSRV,	ERRbadpw,	NT_STATUS_WRONG_PASSWORD},
417 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILL_FORMED_PASSWORD},
418 	{ERRHRD,	ERRgeneral,	NT_STATUS_PASSWORD_RESTRICTION},
419 	{ERRDOS,	ERRnoaccess,	NT_STATUS_LOGON_FAILURE},
420 	{ERRHRD,	ERRgeneral,	NT_STATUS_ACCOUNT_RESTRICTION},
421 	{ERRSRV, NERR_InvalidLogonHours,	NT_STATUS_INVALID_LOGON_HOURS},
422 	{ERRSRV, NERR_InvalidWorkstation,	NT_STATUS_INVALID_WORKSTATION},
423 	{ERRSRV, NERR_PasswordExpired,	NT_STATUS_PASSWORD_EXPIRED},
424 	{ERRSRV, NERR_AccountExpired,	NT_STATUS_ACCOUNT_DISABLED},
425 	{ERRHRD,	ERRgeneral,	NT_STATUS_NONE_MAPPED},
426 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_LUIDS_REQUESTED},
427 	{ERRHRD,	ERRgeneral,	NT_STATUS_LUIDS_EXHAUSTED},
428 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_SUB_AUTHORITY},
429 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ACL},
430 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_SID},
431 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_SECURITY_DESCR},
432 	{ERRDOS, ERROR_PROC_NOT_FOUND,	NT_STATUS_PROCEDURE_NOT_FOUND},
433 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_INVALID_IMAGE_FORMAT},
434 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_TOKEN},
435 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_INHERITANCE_ACL},
436 	{ERRDOS, ERROR_NOT_LOCKED,	NT_STATUS_RANGE_NOT_LOCKED},
437 	{ERRDOS, ERROR_DISK_FULL,	NT_STATUS_DISK_FULL},
438 	{ERRHRD,	ERRgeneral,	NT_STATUS_SERVER_DISABLED},
439 	{ERRHRD,	ERRgeneral,	NT_STATUS_SERVER_NOT_DISABLED},
440 	{ERRDOS, ERROR_TOO_MANY_NAMES,	NT_STATUS_TOO_MANY_GUIDS_REQUESTED},
441 	{ERRDOS, ERROR_NO_MORE_ITEMS,	NT_STATUS_GUIDS_EXHAUSTED},
442 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ID_AUTHORITY},
443 	{ERRDOS, ERROR_NO_MORE_ITEMS,	NT_STATUS_AGENTS_EXHAUSTED},
444 	{ERRDOS, ERROR_LABEL_TOO_LONG,	NT_STATUS_INVALID_VOLUME_LABEL},
445 	{ERRDOS, ERROR_OUTOFMEMORY,	NT_STATUS_SECTION_NOT_EXTENDED},
446 	{ERRDOS, ERROR_INVALID_ADDRESS,	NT_STATUS_NOT_MAPPED_DATA},
447 	{ERRHRD,	ERRgeneral,	NT_STATUS_RESOURCE_DATA_NOT_FOUND},
448 	{ERRHRD,	ERRgeneral,	NT_STATUS_RESOURCE_TYPE_NOT_FOUND},
449 	{ERRHRD,	ERRgeneral,	NT_STATUS_RESOURCE_NAME_NOT_FOUND},
450 	{ERRHRD,	ERRgeneral,	NT_STATUS_ARRAY_BOUNDS_EXCEEDED},
451 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_DENORMAL_OPERAND},
452 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_DIVIDE_BY_ZERO},
453 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_INEXACT_RESULT},
454 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_INVALID_OPERATION},
455 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_OVERFLOW},
456 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_STACK_CHECK},
457 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_UNDERFLOW},
458 	{ERRHRD,	ERRgeneral,	NT_STATUS_INTEGER_DIVIDE_BY_ZERO},
459 	{ERRDOS, ERROR_ARITHMETIC_OVERFLOW,	NT_STATUS_INTEGER_OVERFLOW},
460 	{ERRHRD,	ERRgeneral,	NT_STATUS_PRIVILEGED_INSTRUCTION},
461 	{ERRDOS,	ERRnomem,	NT_STATUS_TOO_MANY_PAGING_FILES},
462 	{ERRHRD,	ERRgeneral,	NT_STATUS_FILE_INVALID},
463 	{ERRHRD,	ERRgeneral,	NT_STATUS_ALLOTTED_SPACE_EXCEEDED},
464 	{ERRDOS,	ERRnomem,	NT_STATUS_INSUFFICIENT_RESOURCES},
465 	{ERRDOS,	ERRbadpath,	NT_STATUS_DFS_EXIT_PATH_FOUND},
466 	{ERRDOS, ERROR_CRC,		NT_STATUS_DEVICE_DATA_ERROR},
467 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEVICE_NOT_CONNECTED},
468 	{ERRDOS, ERROR_NOT_READY,	NT_STATUS_DEVICE_POWER_FAILURE},
469 	{ERRDOS, ERROR_INVALID_ADDRESS,	NT_STATUS_FREE_VM_NOT_AT_BASE},
470 	{ERRDOS, ERROR_INVALID_ADDRESS,	NT_STATUS_MEMORY_NOT_ALLOCATED},
471 	{ERRHRD,	ERRgeneral,	NT_STATUS_WORKING_SET_QUOTA},
472 	{ERRDOS, ERROR_WRITE_PROTECT,	NT_STATUS_MEDIA_WRITE_PROTECTED},
473 	{ERRDOS, ERROR_NOT_READY,	NT_STATUS_DEVICE_NOT_READY},
474 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_GROUP_ATTRIBUTES},
475 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_IMPERSONATION_LEVEL},
476 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_OPEN_ANONYMOUS},
477 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_VALIDATION_CLASS},
478 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_TOKEN_TYPE},
479 	{ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_BAD_MASTER_BOOT_RECORD},
480 	{ERRHRD,	ERRgeneral,	NT_STATUS_INSTRUCTION_MISALIGNMENT},
481 	{ERRDOS, ERROR_PIPE_BUSY,	NT_STATUS_INSTANCE_NOT_AVAILABLE},
482 	{ERRDOS, ERROR_PIPE_BUSY,	NT_STATUS_PIPE_NOT_AVAILABLE},
483 	{ERRDOS, ERROR_BAD_PIPE,	NT_STATUS_INVALID_PIPE_STATE},
484 	{ERRDOS, ERROR_PIPE_BUSY,	NT_STATUS_PIPE_BUSY},
485 	{ERRDOS,	ERRbadfunc,	NT_STATUS_ILLEGAL_FUNCTION},
486 	{ERRDOS, ERROR_PIPE_NOT_CONNECTED,	NT_STATUS_PIPE_DISCONNECTED},
487 	{ERRDOS, ERROR_NO_DATA,	NT_STATUS_PIPE_CLOSING},
488 	{ERRHRD,	ERRgeneral,	NT_STATUS_PIPE_CONNECTED},
489 	{ERRHRD,	ERRgeneral,	NT_STATUS_PIPE_LISTENING},
490 	{ERRDOS, ERROR_BAD_PIPE,	NT_STATUS_INVALID_READ_MODE},
491 	{ERRDOS, ERROR_SEM_TIMEOUT,	NT_STATUS_IO_TIMEOUT},
492 	{ERRDOS, ERROR_HANDLE_EOF,	NT_STATUS_FILE_FORCED_CLOSED},
493 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROFILING_NOT_STARTED},
494 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROFILING_NOT_STOPPED},
495 	{ERRHRD,	ERRgeneral,	NT_STATUS_COULD_NOT_INTERPRET},
496 	{ERRDOS,	ERRnoaccess,	NT_STATUS_FILE_IS_A_DIRECTORY},
497 	{ERRDOS, ERROR_NOT_SUPPORTED,	NT_STATUS_NOT_SUPPORTED},
498 	{ERRDOS, ERROR_REM_NOT_LIST,	NT_STATUS_REMOTE_NOT_LISTENING},
499 	{ERRDOS, ERROR_DUP_NAME,	NT_STATUS_DUPLICATE_NAME},
500 	{ERRDOS, ERROR_BAD_NETPATH,	NT_STATUS_BAD_NETWORK_PATH},
501 	{ERRDOS, ERROR_NETWORK_BUSY,	NT_STATUS_NETWORK_BUSY},
502 	{ERRDOS, ERROR_DEV_NOT_EXIST,	NT_STATUS_DEVICE_DOES_NOT_EXIST},
503 	{ERRDOS, ERROR_TOO_MANY_CMDS,	NT_STATUS_TOO_MANY_COMMANDS},
504 	{ERRDOS, ERROR_ADAP_HDW_ERR,	NT_STATUS_ADAPTER_HARDWARE_ERROR},
505 	{ERRDOS, ERROR_BAD_NET_RESP,	NT_STATUS_INVALID_NETWORK_RESPONSE},
506 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_UNEXPECTED_NETWORK_ERROR},
507 	{ERRDOS, ERROR_BAD_REM_ADAP,	NT_STATUS_BAD_REMOTE_ADAPTER},
508 	{ERRDOS, ERROR_PRINTQ_FULL,	NT_STATUS_PRINT_QUEUE_FULL},
509 	{ERRDOS, ERROR_NO_SPOOL_SPACE,	NT_STATUS_NO_SPOOL_SPACE},
510 	{ERRDOS, ERROR_PRINT_CANCELLED,	NT_STATUS_PRINT_CANCELLED},
511 	{ERRDOS, ERROR_NETNAME_DELETED,	NT_STATUS_NETWORK_NAME_DELETED},
512 	{ERRDOS, ERROR_NETWORK_ACCESS_DENIED, NT_STATUS_NETWORK_ACCESS_DENIED},
513 	{ERRDOS, ERROR_BAD_DEV_TYPE,	NT_STATUS_BAD_DEVICE_TYPE},
514 	{ERRDOS, ERROR_BAD_NET_NAME,	NT_STATUS_BAD_NETWORK_NAME},
515 	{ERRDOS, ERROR_TOO_MANY_NAMES,	NT_STATUS_TOO_MANY_NAMES},
516 	{ERRDOS, ERROR_TOO_MANY_SESS,	NT_STATUS_TOO_MANY_SESSIONS},
517 	{ERRDOS, ERROR_SHARING_PAUSED,	NT_STATUS_SHARING_PAUSED},
518 	{ERRDOS, ERROR_REQ_NOT_ACCEP,	NT_STATUS_REQUEST_NOT_ACCEPTED},
519 	{ERRDOS, ERROR_REDIR_PAUSED,	NT_STATUS_REDIRECTOR_PAUSED},
520 	{ERRDOS, ERROR_NET_WRITE_FAULT,	NT_STATUS_NET_WRITE_FAULT},
521 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROFILING_AT_LIMIT},
522 	{ERRDOS, ERROR_NOT_SAME_DEVICE,	NT_STATUS_NOT_SAME_DEVICE},
523 	{ERRDOS,	ERRnoaccess,	NT_STATUS_FILE_RENAMED},
524 	{ERRDOS, ERROR_VC_DISCONNECTED,	NT_STATUS_VIRTUAL_CIRCUIT_CLOSED},
525 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SECURITY_ON_OBJECT},
526 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_WAIT},
527 	{ERRDOS, ERROR_NO_DATA,		NT_STATUS_PIPE_EMPTY},
528 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_ACCESS_DOMAIN_INFO},
529 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_TERMINATE_SELF},
530 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_SERVER_STATE},
531 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_DOMAIN_STATE},
532 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_DOMAIN_ROLE},
533 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_DOMAIN},
534 	{ERRHRD,	ERRgeneral,	NT_STATUS_DOMAIN_EXISTS},
535 	{ERRHRD,	ERRgeneral,	NT_STATUS_DOMAIN_LIMIT_EXCEEDED},
536 	{ERRDOS, ERROR_OPLOCK_NOT_GRANTED, NT_STATUS_OPLOCK_NOT_GRANTED},
537 	{ERRDOS, ERROR_INVALID_OPLOCK_PROTOCOL,
538 					NT_STATUS_INVALID_OPLOCK_PROTOCOL},
539 	{ERRHRD,	ERRgeneral,	NT_STATUS_INTERNAL_DB_CORRUPTION},
540 	{ERRHRD,	ERRgeneral,	NT_STATUS_INTERNAL_ERROR},
541 	{ERRHRD,	ERRgeneral,	NT_STATUS_GENERIC_NOT_MAPPED},
542 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_DESCRIPTOR_FORMAT},
543 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_USER_BUFFER},
544 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNEXPECTED_IO_ERROR},
545 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNEXPECTED_MM_CREATE_ERR},
546 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNEXPECTED_MM_MAP_ERROR},
547 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNEXPECTED_MM_EXTEND_ERR},
548 	{ERRHRD,	ERRgeneral,	NT_STATUS_NOT_LOGON_PROCESS},
549 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGON_SESSION_EXISTS},
550 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_1},
551 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_2},
552 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_3},
553 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_4},
554 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_5},
555 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_6},
556 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_7},
557 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_8},
558 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_9},
559 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_10},
560 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_11},
561 	{ERRDOS, ERROR_INVALID_PARAMETER,	NT_STATUS_INVALID_PARAMETER_12},
562 	{ERRDOS,	ERRbadpath,	NT_STATUS_REDIRECTOR_NOT_STARTED},
563 	{ERRHRD,	ERRgeneral,	NT_STATUS_REDIRECTOR_STARTED},
564 	{ERRHRD,	ERRgeneral,	NT_STATUS_STACK_OVERFLOW},
565 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_PACKAGE},
566 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_FUNCTION_TABLE},
567 	{ERRDOS, ERROR_ENVVAR_NOT_FOUND,	NT_STATUS_VARIABLE_NOT_FOUND},
568 	{ERRDOS, ERROR_DIR_NOT_EMPTY,	NT_STATUS_DIRECTORY_NOT_EMPTY},
569 	{ERRHRD,	ERRgeneral,	NT_STATUS_FILE_CORRUPT_ERROR},
570 	{ERRDOS, ERROR_DIRECTORY,	NT_STATUS_NOT_A_DIRECTORY},
571 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_LOGON_SESSION_STATE},
572 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGON_SESSION_COLLISION},
573 	{ERRDOS, ERROR_FILENAME_EXCED_RANGE,	NT_STATUS_NAME_TOO_LONG},
574 	{ERRDOS, NERR_OpenFiles,	NT_STATUS_FILES_OPEN},
575 	{ERRDOS, NERR_DevInUse,		NT_STATUS_CONNECTION_IN_USE},
576 	{ERRHRD,	ERRgeneral,	NT_STATUS_MESSAGE_NOT_FOUND},
577 	{ERRDOS,	ERRnoaccess,	NT_STATUS_PROCESS_IS_TERMINATING},
578 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_LOGON_TYPE},
579 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_GUID_TRANSLATION},
580 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANNOT_IMPERSONATE},
581 	{ERRHRD,	ERRgeneral,	NT_STATUS_IMAGE_ALREADY_LOADED},
582 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_NOT_PRESENT},
583 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_LID_NOT_EXIST},
584 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_LID_ALREADY_OWNED},
585 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_NOT_LID_OWNER},
586 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_INVALID_COMMAND},
587 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_INVALID_LID},
588 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE},
589 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_INVALID_SELECTOR},
590 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_LDT},
591 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_LDT_SIZE},
592 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_LDT_OFFSET},
593 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_LDT_DESCRIPTOR},
594 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_INVALID_IMAGE_NE_FORMAT},
595 	{ERRHRD,	ERRgeneral,	NT_STATUS_RXACT_INVALID_STATE},
596 	{ERRHRD,	ERRgeneral,	NT_STATUS_RXACT_COMMIT_FAILURE},
597 	{ERRHRD,	ERRgeneral,	NT_STATUS_MAPPED_FILE_SIZE_ZERO},
598 	{ERRDOS,	ERRnofids,	NT_STATUS_TOO_MANY_OPENED_FILES},
599 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANCELLED},
600 	{ERRDOS,	ERRnoaccess,	NT_STATUS_CANNOT_DELETE},
601 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_COMPUTER_NAME},
602 	{ERRDOS,	ERRnoaccess,	NT_STATUS_FILE_DELETED},
603 	{ERRHRD,	ERRgeneral,	NT_STATUS_SPECIAL_ACCOUNT},
604 	{ERRHRD,	ERRgeneral,	NT_STATUS_SPECIAL_GROUP},
605 	{ERRHRD,	ERRgeneral,	NT_STATUS_SPECIAL_USER},
606 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBERS_PRIMARY_GROUP},
607 	{ERRDOS,	ERRbadfid,	NT_STATUS_FILE_CLOSED},
608 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_THREADS},
609 	{ERRHRD,	ERRgeneral,	NT_STATUS_THREAD_NOT_IN_PROCESS},
610 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOKEN_ALREADY_IN_USE},
611 	{ERRHRD,	ERRgeneral,	NT_STATUS_PAGEFILE_QUOTA_EXCEEDED},
612 	{ERRHRD,	ERRgeneral,	NT_STATUS_COMMITMENT_LIMIT},
613 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_INVALID_IMAGE_LE_FORMAT},
614 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_INVALID_IMAGE_NOT_MZ},
615 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_INVALID_IMAGE_PROTECT},
616 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_INVALID_IMAGE_WIN_16},
617 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGON_SERVER_CONFLICT},
618 	{ERRHRD,	ERRgeneral,	NT_STATUS_TIME_DIFFERENCE_AT_DC},
619 	{ERRHRD,	ERRgeneral,	NT_STATUS_SYNCHRONIZATION_REQUIRED},
620 	{ERRDOS, ERROR_MOD_NOT_FOUND,	NT_STATUS_DLL_NOT_FOUND},
621 	{ERRHRD,	ERRgeneral,	NT_STATUS_OPEN_FAILED},
622 	{ERRHRD,	ERRgeneral,	NT_STATUS_IO_PRIVILEGE_FAILED},
623 	{ERRDOS, ERROR_INVALID_ORDINAL,	NT_STATUS_ORDINAL_NOT_FOUND},
624 	{ERRDOS, ERROR_PROC_NOT_FOUND,	NT_STATUS_ENTRYPOINT_NOT_FOUND},
625 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONTROL_C_EXIT},
626 	{ERRDOS, ERROR_NETNAME_DELETED,	NT_STATUS_LOCAL_DISCONNECT},
627 	{ERRDOS, ERROR_NETNAME_DELETED,	NT_STATUS_REMOTE_DISCONNECT},
628 	{ERRDOS, ERROR_REM_NOT_LIST,	NT_STATUS_REMOTE_RESOURCES},
629 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_LINK_FAILED},
630 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_LINK_TIMEOUT},
631 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_INVALID_CONNECTION},
632 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_INVALID_ADDRESS},
633 	{ERRHRD,	ERRgeneral,	NT_STATUS_DLL_INIT_FAILED},
634 	{ERRHRD,	ERRgeneral,	NT_STATUS_MISSING_SYSTEMFILE},
635 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNHANDLED_EXCEPTION},
636 	{ERRHRD,	ERRgeneral,	NT_STATUS_APP_INIT_FAILURE},
637 	{ERRHRD,	ERRgeneral,	NT_STATUS_PAGEFILE_CREATE_FAILED},
638 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_PAGEFILE},
639 	{ERRDOS, ERROR_INVALID_LEVEL,	NT_STATUS_INVALID_LEVEL},
640 	{ERRDOS, ERROR_INVALID_PASSWORD,	NT_STATUS_WRONG_PASSWORD_CORE},
641 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILLEGAL_FLOAT_CONTEXT},
642 	{ERRDOS, ERROR_BROKEN_PIPE,	NT_STATUS_PIPE_BROKEN},
643 	{ERRHRD,	ERRgeneral,	NT_STATUS_REGISTRY_CORRUPT},
644 	{ERRHRD,	ERRgeneral,	NT_STATUS_REGISTRY_IO_FAILED},
645 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_EVENT_PAIR},
646 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNRECOGNIZED_VOLUME},
647 	{ERRHRD,	ERRgeneral,	NT_STATUS_SERIAL_NO_DEVICE_INITED},
648 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_ALIAS},
649 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBER_NOT_IN_ALIAS},
650 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBER_IN_ALIAS},
651 	{ERRHRD,	ERRgeneral,	NT_STATUS_ALIAS_EXISTS},
652 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGON_NOT_GRANTED},
653 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_SECRETS},
654 	{ERRHRD,	ERRgeneral,	NT_STATUS_SECRET_TOO_LONG},
655 	{ERRHRD,	ERRgeneral,	NT_STATUS_INTERNAL_DB_ERROR},
656 	{ERRHRD,	ERRgeneral,	NT_STATUS_FULLSCREEN_MODE},
657 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_CONTEXT_IDS},
658 	{ERRDOS,	ERRnoaccess,	NT_STATUS_LOGON_TYPE_NOT_GRANTED},
659 	{ERRHRD,	ERRgeneral,	NT_STATUS_NOT_REGISTRY_FILE},
660 	{ERRHRD,	ERRgeneral,	NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED},
661 	{ERRHRD,	ERRgeneral,	NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR},
662 	{ERRHRD,	ERRgeneral,	NT_STATUS_FT_MISSING_MEMBER},
663 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILL_FORMED_SERVICE_ENTRY},
664 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILLEGAL_CHARACTER},
665 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNMAPPABLE_CHARACTER},
666 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNDEFINED_CHARACTER},
667 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_VOLUME},
668 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND},
669 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_WRONG_CYLINDER},
670 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_UNKNOWN_ERROR},
671 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_BAD_REGISTERS},
672 	{ERRHRD,	ERRgeneral,	NT_STATUS_DISK_RECALIBRATE_FAILED},
673 	{ERRHRD,	ERRgeneral,	NT_STATUS_DISK_OPERATION_FAILED},
674 	{ERRHRD,	ERRgeneral,	NT_STATUS_DISK_RESET_FAILED},
675 	{ERRHRD,	ERRgeneral,	NT_STATUS_SHARED_IRQ_BUSY},
676 	{ERRHRD,	ERRgeneral,	NT_STATUS_FT_ORPHANING},
677 	{ERRHRD,	ERRgeneral,
678 		NT_STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT},
679 	{ERRHRD,	ERRgeneral,	NT_STATUS_PARTITION_FAILURE},
680 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_BLOCK_LENGTH},
681 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEVICE_NOT_PARTITIONED},
682 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNABLE_TO_LOCK_MEDIA},
683 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNABLE_TO_UNLOAD_MEDIA},
684 	{ERRHRD,	ERRgeneral,	NT_STATUS_EOM_OVERFLOW},
685 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_MEDIA},
686 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_MEMBER},
687 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_MEMBER},
688 	{ERRHRD,	ERRgeneral,	NT_STATUS_KEY_DELETED},
689 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_LOG_SPACE},
690 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_SIDS},
691 	{ERRHRD,	ERRgeneral,	NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED},
692 	{ERRHRD,	ERRgeneral,	NT_STATUS_KEY_HAS_CHILDREN},
693 	{ERRHRD,	ERRgeneral,	NT_STATUS_CHILD_MUST_BE_VOLATILE},
694 	{ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_DEVICE_CONFIGURATION_ERROR},
695 	{ERRHRD,	ERRgeneral,	NT_STATUS_DRIVER_INTERNAL_ERROR},
696 	{ERRDOS, ERROR_BAD_COMMAND,	NT_STATUS_INVALID_DEVICE_STATE},
697 	{ERRHRD,	ERRgeneral,	NT_STATUS_IO_DEVICE_ERROR},
698 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEVICE_PROTOCOL_ERROR},
699 	{ERRHRD,	ERRgeneral,	NT_STATUS_BACKUP_CONTROLLER},
700 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOG_FILE_FULL},
701 	{ERRDOS, ERROR_WRITE_PROTECT,	NT_STATUS_TOO_LATE},
702 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_TRUST_LSA_SECRET},
703 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_TRUST_SAM_ACCOUNT},
704 	{ERRDOS,	ERRnoaccess,	NT_STATUS_TRUSTED_DOMAIN_FAILURE},
705 	{ERRDOS,	ERRnoaccess,	NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE},
706 	{ERRHRD,	ERRgeneral,	NT_STATUS_EVENTLOG_FILE_CORRUPT},
707 	{ERRHRD,	ERRgeneral,	NT_STATUS_EVENTLOG_CANT_START},
708 	{ERRDOS,	ERRnoaccess,	NT_STATUS_TRUST_FAILURE},
709 	{ERRHRD,	ERRgeneral,	NT_STATUS_MUTANT_LIMIT_EXCEEDED},
710 	{ERRDOS, NERR_NetlogonNotStarted,	NT_STATUS_NETLOGON_NOT_STARTED},
711 	{ERRSRV, NERR_AccountExpired,	NT_STATUS_ACCOUNT_EXPIRED},
712 	{ERRHRD,	ERRgeneral,	NT_STATUS_POSSIBLE_DEADLOCK},
713 	{ERRHRD,	ERRgeneral,	NT_STATUS_NETWORK_CREDENTIAL_CONFLICT},
714 	{ERRHRD,	ERRgeneral,	NT_STATUS_REMOTE_SESSION_LIMIT},
715 	{ERRHRD,	ERRgeneral,	NT_STATUS_EVENTLOG_FILE_CHANGED},
716 	{ERRDOS,	ERRnoaccess,
717 		NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT},
718 	{ERRDOS,	ERRnoaccess,
719 		NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT},
720 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT},
721 	{ERRDOS,	ERRnoaccess,	NT_STATUS_DOMAIN_TRUST_INCONSISTENT},
722 	{ERRHRD,	ERRgeneral,	NT_STATUS_FS_DRIVER_REQUIRED},
723 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_USER_SESSION_KEY},
724 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_USER_SESSION_DELETED},
725 	{ERRHRD,	ERRgeneral,	NT_STATUS_RESOURCE_LANG_NOT_FOUND},
726 	{ERRDOS,	ERRnomem,	NT_STATUS_INSUFF_SERVER_RESOURCES},
727 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_BUFFER_SIZE},
728 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ADDRESS_COMPONENT},
729 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ADDRESS_WILDCARD},
730 	{ERRDOS, ERROR_TOO_MANY_NAMES,	NT_STATUS_TOO_MANY_ADDRESSES},
731 	{ERRDOS, ERROR_DUP_NAME,	NT_STATUS_ADDRESS_ALREADY_EXISTS},
732 	{ERRDOS, ERROR_NETNAME_DELETED,	NT_STATUS_ADDRESS_CLOSED},
733 	{ERRDOS, ERROR_NETNAME_DELETED,	NT_STATUS_CONNECTION_DISCONNECTED},
734 	{ERRDOS, ERROR_NETNAME_DELETED,	NT_STATUS_CONNECTION_RESET},
735 	{ERRDOS, ERROR_TOO_MANY_NAMES,	NT_STATUS_TOO_MANY_NODES},
736 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_TRANSACTION_ABORTED},
737 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_TRANSACTION_TIMED_OUT},
738 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_TRANSACTION_NO_RELEASE},
739 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_TRANSACTION_NO_MATCH},
740 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_TRANSACTION_RESPONDED},
741 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_TRANSACTION_INVALID_ID},
742 	{ERRDOS, ERROR_UNEXP_NET_ERR,	NT_STATUS_TRANSACTION_INVALID_TYPE},
743 	{ERRDOS, ERROR_NOT_SUPPORTED,	NT_STATUS_NOT_SERVER_SESSION},
744 	{ERRDOS, ERROR_NOT_SUPPORTED,	NT_STATUS_NOT_CLIENT_SESSION},
745 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANNOT_LOAD_REGISTRY_FILE},
746 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEBUG_ATTACH_FAILED},
747 	{ERRHRD,	ERRgeneral,	NT_STATUS_SYSTEM_PROCESS_TERMINATED},
748 	{ERRHRD,	ERRgeneral,	NT_STATUS_DATA_NOT_ACCEPTED},
749 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_BROWSER_SERVERS_FOUND},
750 	{ERRHRD,	ERRgeneral,	NT_STATUS_VDM_HARD_ERROR},
751 	{ERRHRD,	ERRgeneral,	NT_STATUS_DRIVER_CANCEL_TIMEOUT},
752 	{ERRHRD,	ERRgeneral,	NT_STATUS_REPLY_MESSAGE_MISMATCH},
753 	{ERRHRD,	ERRgeneral,	NT_STATUS_MAPPED_ALIGNMENT},
754 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_IMAGE_CHECKSUM_MISMATCH},
755 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOST_WRITEBEHIND_DATA},
756 	{ERRHRD,	ERRgeneral, NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID},
757 	{ERRSRV, NERR_PasswordExpired,	NT_STATUS_PASSWORD_MUST_CHANGE},
758 	{ERRHRD,	ERRgeneral,	NT_STATUS_NOT_FOUND},
759 	{ERRHRD,	ERRgeneral,	NT_STATUS_NOT_TINY_STREAM},
760 	{ERRHRD,	ERRgeneral,	NT_STATUS_RECOVERY_FAILURE},
761 	{ERRHRD,	ERRgeneral,	NT_STATUS_STACK_OVERFLOW_READ},
762 	{ERRHRD,	ERRgeneral,	NT_STATUS_FAIL_CHECK},
763 	{ERRHRD,	ERRgeneral,	NT_STATUS_DUPLICATE_OBJECTID},
764 	{ERRHRD,	ERRgeneral,	NT_STATUS_OBJECTID_EXISTS},
765 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONVERT_TO_LARGE},
766 	{ERRHRD,	ERRgeneral,	NT_STATUS_RETRY},
767 	{ERRHRD,	ERRgeneral,	NT_STATUS_FOUND_OUT_OF_SCOPE},
768 	{ERRHRD,	ERRgeneral,	NT_STATUS_ALLOCATE_BUCKET},
769 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROPSET_NOT_FOUND},
770 	{ERRHRD,	ERRgeneral,	NT_STATUS_MARSHALL_OVERFLOW},
771 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_VARIANT},
772 	{ERRHRD,	ERRgeneral,	NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND},
773 	{ERRDOS,	ERRnoaccess,	NT_STATUS_ACCOUNT_LOCKED_OUT},
774 	{ERRDOS,	ERRbadfid,	NT_STATUS_HANDLE_NOT_CLOSABLE},
775 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_REFUSED},
776 	{ERRHRD,	ERRgeneral,	NT_STATUS_GRACEFUL_DISCONNECT},
777 	{ERRHRD,	ERRgeneral,	NT_STATUS_ADDRESS_ALREADY_ASSOCIATED},
778 	{ERRHRD,	ERRgeneral,	NT_STATUS_ADDRESS_NOT_ASSOCIATED},
779 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_INVALID},
780 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_ACTIVE},
781 	{ERRHRD,	ERRgeneral,	NT_STATUS_NETWORK_UNREACHABLE},
782 	{ERRHRD,	ERRgeneral,	NT_STATUS_HOST_UNREACHABLE},
783 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROTOCOL_UNREACHABLE},
784 	{ERRHRD,	ERRgeneral,	NT_STATUS_PORT_UNREACHABLE},
785 	{ERRHRD,	ERRgeneral,	NT_STATUS_REQUEST_ABORTED},
786 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_ABORTED},
787 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_COMPRESSION_BUFFER},
788 	{ERRHRD,	ERRgeneral,	NT_STATUS_USER_MAPPED_FILE},
789 	{ERRHRD,	ERRgeneral,	NT_STATUS_AUDIT_FAILED},
790 	{ERRHRD,	ERRgeneral,	NT_STATUS_TIMER_RESOLUTION_NOT_SET},
791 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_COUNT_LIMIT},
792 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGIN_TIME_RESTRICTION},
793 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGIN_WKSTA_RESTRICTION},
794 	{ERRDOS, ERROR_BAD_EXE_FORMAT,	NT_STATUS_IMAGE_MP_UP_MISMATCH},
795 	{ERRHRD,	ERRgeneral,	NT_STATUS_INSUFFICIENT_LOGON_INFO},
796 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_DLL_ENTRYPOINT},
797 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_SERVICE_ENTRYPOINT},
798 	{ERRHRD,	ERRgeneral,	NT_STATUS_LPC_REPLY_LOST},
799 	{ERRHRD,	ERRgeneral,	NT_STATUS_IP_ADDRESS_CONFLICT1},
800 	{ERRHRD,	ERRgeneral,	NT_STATUS_IP_ADDRESS_CONFLICT2},
801 	{ERRHRD,	ERRgeneral,	NT_STATUS_REGISTRY_QUOTA_LIMIT},
802 	{ERRSRV,	ERRbadtype,	NT_STATUS_PATH_NOT_COVERED},
803 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_CALLBACK_ACTIVE},
804 	{ERRHRD,	ERRgeneral,	NT_STATUS_LICENSE_QUOTA_EXCEEDED},
805 	{ERRHRD,	ERRgeneral,	NT_STATUS_PWD_TOO_SHORT},
806 	{ERRHRD,	ERRgeneral,	NT_STATUS_PWD_TOO_RECENT},
807 	{ERRHRD,	ERRgeneral,	NT_STATUS_PWD_HISTORY_CONFLICT},
808 	{ERRHRD,	ERRgeneral,	NT_STATUS_PLUGPLAY_NO_DEVICE},
809 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNSUPPORTED_COMPRESSION},
810 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_HW_PROFILE},
811 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH},
812 	{ERRDOS, ERROR_INVALID_ORDINAL,	NT_STATUS_DRIVER_ORDINAL_NOT_FOUND},
813 	{ERRDOS, ERROR_PROC_NOT_FOUND,	NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND},
814 	{ERRDOS, ERROR_NOT_OWNER,	NT_STATUS_RESOURCE_NOT_OWNED},
815 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_LINKS},
816 	{ERRHRD,	ERRgeneral,	NT_STATUS_QUOTA_LIST_INCONSISTENT},
817 	{ERRHRD,	ERRgeneral,	NT_STATUS_FILE_IS_OFFLINE},
818 	{ERRDOS, ERROR_NOT_READY,	NT_STATUS_VOLUME_DISMOUNTED},
819 	{ERRDOS, ERROR_BAD_PATHNAME,	NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT},
820 	{ERRDOS,	ERRnoaccess,	NT_STATUS_ENCRYPTION_FAILED},
821 	{ERRDOS,	ERRnoaccess,	NT_STATUS_DECRYPTION_FAILED},
822 	{ERRHRD,	ERRgeneral,	NT_STATUS_RANGE_NOT_FOUND},
823 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_RECOVERY_POLICY},
824 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_EFS},
825 	{ERRDOS,	ERRnoaccess,	NT_STATUS_WRONG_EFS},
826 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_USER_KEYS},
827 	{ERRDOS,	ERRbadfunc,	NT_STATUS_VOLUME_NOT_UPGRADED},
828 	{0, 0, 0}
829 };
830 
831 int
832 smb_maperr32(uint32_t nterr)
833 {
834 	const nt2errno_t *nt2e;
835 	const nt2doserr_t *nt2d;
836 
837 	switch (NT_SC_SEVERITY(nterr)) {
838 	case NT_STATUS_SEVERITY_SUCCESS:
839 	case NT_STATUS_SEVERITY_INFORMATIONAL:
840 		return (0);
841 	}
842 
843 	/* first try direct map to unix */
844 	for (nt2e = nt2errno; nt2e->errno; nt2e++)
845 		if (nt2e->nterr == nterr)
846 			return (nt2e->errno);
847 	SMBERROR("no direct map for 32 bit server error (0x%x)\n", nterr);
848 
849 	/* ok, then try mapping to dos to unix */
850 	for (nt2d = nt2doserr; nt2d->nterr; nt2d++)
851 		if (nt2d->nterr == nterr)
852 			return (smb_maperror(nt2d->dclass, nt2d->derr));
853 	return (EIO);
854 }
855 
856 
857 int
858 smb_maperror(int eclass, int eno)
859 {
860 	if (eclass == 0 && eno == 0)
861 		return (0);
862 	switch (eclass) {
863 	case ERRDOS:
864 		switch (eno) {
865 		case ERROR_INVALID_LEVEL:
866 			return (ENOTSUP);
867 		case ERRbadfunc:
868 		case ERRbadenv:
869 		case ERRbadformat:
870 		case ERRremcd:
871 		case ERRrmuns:
872 			return (EINVAL);
873 		case ERRbadfile:
874 		case ERRbadpath:
875 		case ERROR_BAD_DEV_TYPE:
876 		case ERROR_BAD_NET_NAME:
877 			return (ENOENT);
878 		case ERRnofids:
879 			return (EMFILE);
880 		case ERRnoaccess:
881 			/*
882 			 * XXX CSM Reported on samba-technical 12/7/2002
883 			 *
884 			 * There is a case for which server(s) return
885 			 * ERRnoaccess but should return ERRdiskfull: When
886 			 * the offset for a write is exactly the server
887 			 * file size limit then Samba (at least) thinks
888 			 * the reason for zero bytes having been written
889 			 * must have been "access denied" from the local
890 			 * filesystem.  This cannot be easily worked
891 			 * around since the server behaviour is
892 			 * indistinguishable from actual access denied.
893 			 * An incomplete workaround: attempt a 2 byte write
894 			 * from "offset-1".  (That may require reading at
895 			 * offset-1 first.)  The flaw is that reading or
896 			 * writing at offset-1 could cause an
897 			 * unrelated error (due to a byte range lock
898 			 * for instance) and we can't presume the
899 			 * order servers check errors in.
900 			 */
901 		case ERRbadaccess:
902 			return (EACCES);
903 		case ERRbadshare:
904 			return (EBUSY);
905 		case ERRbadfid:
906 			return (EBADF);
907 		case ERRbadmcb:
908 			return (EIO);
909 		case ERRnomem:
910 			return (ENOMEM);	/* actually remote no mem... */
911 		case ERRbadmem:
912 			return (EFAULT);
913 		case ERRbaddata:
914 			return (E2BIG);
915 		case ERRbaddrive:
916 		case ERRnotready:	/* nt */
917 			return (ENXIO);
918 		case ERRdiffdevice:
919 			return (EXDEV);
920 		case ERRnofiles:
921 			return (0);	/* eeof ? */
922 		case ERRlock:
923 			return (EAGAIN);
924 		case ERRfilexists:
925 			return (EEXIST);
926 		case ERROR_INVALID_NAME:
927 			return (ENOENT);
928 		case ERROR_DIR_NOT_EMPTY:
929 			return (ENOTEMPTY);
930 		case ERROR_NOT_LOCKED:
931 			return (0); /* we unlock on any close */
932 		case ERROR_ALREADY_EXISTS:
933 			return (EEXIST);
934 		case ERRmoredata:
935 			return (EMOREDATA);
936 		}
937 		break;
938 	case ERRSRV:
939 		switch (eno) {
940 		case ERRerror:
941 			return (EINVAL);
942 		case ERRbadpw:
943 			return (EAUTH);
944 		case ERRaccess:
945 		case ERRbaduid:
946 			return (EACCES);
947 		case ERRinvnid:
948 			return (ENETRESET);
949 		case ERRinvnetname:
950 			return (ENXIO);
951 		case ERRbadtype:		/* reserved and returned */
952 			return (EIO);
953 		case NERR_AccountExpired: /* account exists but disabled */
954 			return (EPERM);
955 		}
956 		break;
957 	case ERRHRD:
958 		switch (eno) {
959 		case ERRnowrite:
960 			return (EROFS);
961 		case ERRbadunit:
962 			return (ENODEV);
963 		case ERRbadreq:
964 			return (EBADRPC);
965 		case ERRbadshare:
966 			return (ETXTBSY);
967 		case ERRlock:
968 			return (EAGAIN);
969 		case ERRdiskfull:
970 			return (EFBIG);
971 		case ERRnotready:
972 		case ERRbadcmd:
973 		case ERRdata:
974 		case ERRgeneral:
975 			return (EIO);
976 		default:
977 			SMBERROR("Unmapped DOS error %d:%d\n", eclass, eno);
978 			return (EIO);
979 		}
980 	}
981 	SMBERROR("Unmapped DOS error %d:%d\n", eclass, eno);
982 	return (EBADRPC);
983 }
984 
985 #if defined(NOICONVSUPPORT) || defined(lint)
986 extern int iconv_conv(void *handle, const char **inbuf,
987     size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
988 #endif
989 
990 #define	SMALL_CONV 256
991 
992 /*ARGSUSED*/
993 int
994 smb_put_dmem(struct mbchain *mbp, struct smb_vc *vcp, const char *src,
995 	int size, int caseopt, int *lenp)
996 {
997 	uint16_t convbuf[SMALL_CONV];
998 	uint16_t *cbuf;
999 	size_t cbufalloc, inlen, outlen;
1000 	int error;
1001 
1002 	if (size <= 0)
1003 		return (0);
1004 
1005 	/*
1006 	 * Handle the easy case (non-unicode).
1007 	 * XXX: Technically, we should convert
1008 	 * the string to OEM codeset first...
1009 	 * Modern servers all use Unicode, so
1010 	 * this is good enough.
1011 	 */
1012 	if (SMB_UNICODE_STRINGS(vcp) == 0) {
1013 		error = mb_put_mem(mbp, src, size, MB_MSYSTEM);
1014 		if (!error && lenp)
1015 			*lenp += size;
1016 		return (error);
1017 	}
1018 
1019 	/*
1020 	 * Convert to UCS-2 (really UTF-16).
1021 	 * Use stack buffer if the string is
1022 	 * small enough, else allocate.
1023 	 */
1024 	if (size <= SMALL_CONV) {
1025 		cbufalloc = 0;
1026 		outlen = SMALL_CONV;
1027 		cbuf = convbuf;
1028 	} else {
1029 		outlen = size; /* in utf-16 characters */
1030 		cbufalloc = outlen * 2;
1031 		cbuf = kmem_alloc(cbufalloc, KM_SLEEP);
1032 	}
1033 
1034 	inlen = size;
1035 	error = uconv_u8tou16((uchar_t *)src, &inlen, cbuf, &outlen,
1036 	    UCONV_OUT_LITTLE_ENDIAN | UCONV_IGNORE_NULL);
1037 	outlen *= 2;  /* convert to bytes */
1038 
1039 	if (!error) {
1040 		(void) mb_put_padbyte(mbp); /* align */
1041 		error = mb_put_mem(mbp, (char *)cbuf, outlen, MB_MSYSTEM);
1042 	}
1043 	if (!error && lenp)
1044 		*lenp += outlen;
1045 
1046 	if (cbufalloc)
1047 		kmem_free(cbuf, cbufalloc);
1048 
1049 	return (error);
1050 }
1051 
1052 int
1053 smb_put_dstring(struct mbchain *mbp, struct smb_vc *vcp, const char *src,
1054 	int caseopt)
1055 {
1056 	int error, len;
1057 
1058 	/*
1059 	 * Let smb_put_dmem put both the string
1060 	 * and the terminating null.
1061 	 */
1062 	len = strlen(src) + 1;
1063 	error = smb_put_dmem(mbp, vcp, src, len, caseopt, NULL);
1064 	if (error)
1065 		return (error);
1066 
1067 	return (error);
1068 }
1069