xref: /illumos-gate/usr/src/uts/common/fs/smbclnt/netsmb/smb_subrs.c (revision 186f7fbf5e07d046b50e4e15c32b21f109b76c80)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
36 
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/kmem.h>
40 #include <sys/proc.h>
41 #include <sys/lock.h>
42 #include <sys/socket.h>
43 #include <sys/isa_defs.h>
44 #include <sys/stream.h>
45 #include <sys/strsun.h>
46 #include <sys/sunddi.h>
47 #include <sys/cmn_err.h>
48 #include <sys/sdt.h>
49 #include <sys/priv.h>
50 #include <sys/u8_textprep.h>
51 
52 #include <netsmb/smb_osdep.h>
53 #include <netsmb/smb.h>
54 #include <netsmb/smb_conn.h>
55 #include <netsmb/smb_rq.h>
56 #include <netsmb/smb_subr.h>
57 
58 /*
59  * XXX:This conversion might not be fully MS-Compatible
60  * for calculating hashes. The output length may differ
61  * for some locales and needs to be handled from where
62  * the call is made.
63  */
64 int
65 smb_toupper(const char *inbuf, char *outbuf, size_t outlen)
66 {
67 	int err = 0;
68 	size_t inlen, inrem, outrem;
69 
70 	inrem = inlen = strlen(inbuf);
71 	outrem = outlen;
72 	(void) u8_textprep_str((char *)inbuf, &inrem, outbuf, &outrem,
73 	    U8_TEXTPREP_TOUPPER, U8_UNICODE_LATEST, &err);
74 	/* inrem, outrem are bytes unused, remaining */
75 	if (inrem) {
76 		SMBSDEBUG("input %d remains: %s\n", (int)inrem, inbuf);
77 		inlen -= inrem;
78 	}
79 	if (outrem) {
80 		outlen -= outrem;
81 		outbuf[outlen] = '\0';
82 	}
83 	if (outlen > inlen) {
84 		SMBSDEBUG("outlen > inlen! (%d > %d)\n",
85 		    (int)outlen, (int)inlen);
86 		/* Truncate to inlen here? */
87 	}
88 
89 	return (err);
90 }
91 
92 void
93 smb_credinit(struct smb_cred *scred, struct proc *p, cred_t *icr)
94 {
95 	scred->vc_pid = p->p_pidp->pid_id;
96 	if (!icr)
97 		icr = p->p_cred;
98 	if (is_system_labeled()) {
99 		icr = crdup(icr);
100 		(void) setpflags(NET_MAC_AWARE, 1, icr);
101 	} else {
102 		crhold(icr);
103 	}
104 	scred->vc_ucred = icr;
105 }
106 
107 void
108 smb_credrele(struct smb_cred *scred)
109 {
110 	crfree(scred->vc_ucred);
111 	scred->vc_ucred = NULL;
112 }
113 
114 #ifdef APPLE
115 /*ARGSUSED*/
116 int
117 smb_sigintr(vfs_context_t vfsctx)
118 {
119 	/*
120 	 * I cannot find something to match vfs_context_issignal.
121 	 * It calls proc_pendingsignals() in Darwin code.
122 	 */
123 	if (vfsctx && vfs_context_issignal(vfsctx, SMB_SIGMASK))
124 		return (EINTR);
125 	return (0);
126 }
127 #endif
128 
129 char *
130 smb_strdup(const char *s)
131 {
132 	char *p;
133 	int len;
134 
135 	len = s ? strlen(s) + 1 : 1;
136 	p = kmem_alloc(len, KM_SLEEP);
137 	if (s)
138 		bcopy(s, p, len);
139 	else
140 		*p = 0;
141 	return (p);
142 }
143 
144 /*
145  * duplicate string from a user space.
146  */
147 char *
148 smb_strdupin(char *s, int maxlen)
149 {
150 	char *p, bt;
151 	int len = 0;
152 
153 	for (p = s; ; p++) {
154 		if (copyin(p, &bt, 1))
155 			return (NULL);
156 		len++;
157 		if (maxlen && len > maxlen)
158 			return (NULL);
159 		if (bt == 0)
160 			break;
161 	}
162 	p = kmem_alloc(len, KM_SLEEP);
163 	copyin(s, p, len);
164 	return (p);
165 }
166 
167 /*
168  * duplicate memory block from a user space.
169  */
170 void *
171 smb_memdupin(void *umem, int len)
172 {
173 	char *p;
174 
175 	if (len > 32 * 1024)
176 		return (NULL);
177 	p = kmem_alloc(len, KM_SLEEP);
178 	if (copyin(umem, p, len) == 0)
179 		return (p);
180 	kmem_free(p, len);
181 	return (NULL);
182 }
183 
184 /*
185  * duplicate memory block in the kernel space.
186  */
187 void *
188 smb_memdup(const void *umem, int len)
189 {
190 	char *p;
191 
192 	if (len > 32 * 1024)
193 		return (NULL);
194 	p = kmem_alloc(len, KM_SLEEP);
195 	if (p == NULL)
196 		return (NULL);
197 	bcopy(umem, p, len);
198 	return (p);
199 }
200 
201 void
202 smb_strfree(char *s)
203 {
204 	kmem_free(s, strlen(s) + 1);
205 }
206 
207 void
208 smb_memfree(void *s)
209 {
210 	kmem_free(s, strlen(s));
211 }
212 
213 void *
214 smb_zmalloc(unsigned long size)
215 {
216 	void *p = kmem_zalloc(size, KM_SLEEP);
217 	return (p);
218 }
219 
220 size_t
221 smb_strtouni(u_int16_t *dst, const char *src, size_t inlen, int flags)
222 {
223 	size_t outlen = 0;
224 
225 	if (!inlen)
226 		inlen = strlen(src);
227 
228 	/* Force output format to little-endian. */
229 	flags &= ~UCONV_OUT_BIG_ENDIAN;
230 	flags |= UCONV_OUT_LITTLE_ENDIAN;
231 
232 	outlen = inlen * 2;
233 	if (uconv_u8tou16((uchar_t *)src, &inlen, dst, &outlen, flags) != 0) {
234 		outlen = 0;
235 	}
236 	return (outlen * 2);
237 }
238 
239 /*
240  * Helper for the SMBERROR macro, etc.
241  * This is also a good place for a breakpoint
242  * or a dtrace probe, i.e. fbt:nsmb:smb_errmsg
243  */
244 void
245 smb_errmsg(int cel, const char *func_name, const char *fmt, ...)
246 {
247 	va_list adx;
248 	char buf[100];
249 
250 	va_start(adx, fmt);
251 	if (cel == CE_CONT) {
252 		/*
253 		 * This is one of our xxxDEBUG macros.
254 		 * Don't bother to log these, but just
255 		 * fire a dtrace probe with the message.
256 		 */
257 		vsnprintf(buf, sizeof (buf), fmt, adx);
258 		DTRACE_PROBE2(debugmsg2,
259 		    (char *), func_name,
260 		    (char *), buf);
261 	} else {
262 		/*
263 		 * This is one of our xxxERROR macros.
264 		 * Add a prefix to the fmt string,
265 		 * then let vcmn_err do the args.
266 		 */
267 		snprintf(buf, sizeof (buf), "?%s: %s", func_name, fmt);
268 		DTRACE_PROBE3(debugmsg3,
269 		    (char *), func_name,
270 		    (char *), buf,
271 		    va_list, adx);
272 		vcmn_err(cel, buf, adx);
273 	}
274 	va_end(adx);
275 }
276 
277 #if 1 /* def SMB_SOCKETDATA_DEBUG */
278 void
279 m_dumpm(mblk_t *m)
280 {
281 	int len, seg;
282 
283 	len = msgdsize(m);
284 	DTRACE_PROBE2(dsize, int, len, (mblk_t *), m);
285 
286 	for (seg = 0; m; seg++) {
287 		DTRACE_PROBE2(mblk, int, seg, (mblk_t *), m);
288 		m = m->b_cont;
289 	}
290 }
291 #endif
292 
293 /* all these need review XXX */
294 #ifndef EPROTO
295 #define	EPROTO ECONNABORTED
296 #endif
297 #ifndef ELIBACC
298 #define	ELIBACC ENOENT
299 #endif
300 #ifndef ENODATA
301 #define	ENODATA EINVAL
302 #endif
303 #ifndef ENOTUNIQ
304 #define	ENOTUNIQ EADDRINUSE
305 #endif
306 #ifndef ECOMM
307 #define	ECOMM EIO
308 #endif
309 #ifndef ENOMEDIUM
310 #define	ENOMEDIUM EIO
311 #endif
312 #ifndef ETIME
313 #define	ETIME ETIMEDOUT
314 #endif
315 
316 static struct {
317 	unsigned nterr;
318 	unsigned errno;
319 } nt2errno[] = {
320 	{NT_STATUS_ACCESS_DENIED,		EACCES},
321 	{NT_STATUS_ACCESS_VIOLATION,		EACCES},
322 	{NT_STATUS_ACCOUNT_DISABLED,		EACCES},
323 	{NT_STATUS_ACCOUNT_RESTRICTION,		EACCES},
324 	{NT_STATUS_ADDRESS_ALREADY_EXISTS,	EADDRINUSE},
325 	{NT_STATUS_BAD_NETWORK_NAME,		ENOENT},
326 	{NT_STATUS_BUFFER_TOO_SMALL,		EMOREDATA},
327 	{NT_STATUS_CANNOT_DELETE,		EACCES},
328 	{NT_STATUS_CONFLICTING_ADDRESSES,	EADDRINUSE},
329 	{NT_STATUS_CONNECTION_ABORTED,		ECONNABORTED},
330 	{NT_STATUS_CONNECTION_DISCONNECTED,	ECONNABORTED},
331 	{NT_STATUS_CONNECTION_REFUSED,		ECONNREFUSED},
332 	{NT_STATUS_CONNECTION_RESET,		ENETRESET},
333 	{NT_STATUS_DEVICE_DOES_NOT_EXIST,	ENODEV},
334 	{NT_STATUS_DEVICE_PROTOCOL_ERROR,	EPROTO},
335 	{NT_STATUS_DIRECTORY_NOT_EMPTY,		ENOTEMPTY},
336 	{NT_STATUS_DISK_FULL,			ENOSPC},
337 	{NT_STATUS_DLL_NOT_FOUND,		ELIBACC},
338 	{NT_STATUS_END_OF_FILE,			ENODATA},
339 	{NT_STATUS_FILE_IS_A_DIRECTORY,		EISDIR},
340 	{NT_STATUS_FLOAT_INEXACT_RESULT,	ERANGE},
341 	{NT_STATUS_FLOAT_OVERFLOW,		ERANGE},
342 	{NT_STATUS_FLOAT_UNDERFLOW,		ERANGE},
343 	{NT_STATUS_HOST_UNREACHABLE,		EHOSTUNREACH},
344 	{NT_STATUS_ILL_FORMED_PASSWORD,		EACCES},
345 	{NT_STATUS_INTEGER_OVERFLOW,		ERANGE},
346 	{NT_STATUS_INVALID_HANDLE,		EBADF},
347 	{NT_STATUS_INVALID_LOGON_HOURS,		EACCES},
348 	{NT_STATUS_INVALID_PARAMETER,		EINVAL},
349 	{NT_STATUS_INVALID_PIPE_STATE,		EPIPE},
350 	{NT_STATUS_INVALID_WORKSTATION,		EACCES},
351 	{NT_STATUS_IN_PAGE_ERROR,		EFAULT},
352 	{NT_STATUS_IO_TIMEOUT,			ETIMEDOUT},
353 	{NT_STATUS_IP_ADDRESS_CONFLICT1,	ENOTUNIQ},
354 	{NT_STATUS_IP_ADDRESS_CONFLICT2,	ENOTUNIQ},
355 	{NT_STATUS_LICENSE_QUOTA_EXCEEDED,	EDQUOT},
356 	{NT_STATUS_LOGON_FAILURE,		EACCES},
357 	{NT_STATUS_MEDIA_WRITE_PROTECTED,	EROFS},
358 	{NT_STATUS_MEMORY_NOT_ALLOCATED,	EFAULT},
359 	{NT_STATUS_NAME_TOO_LONG,		ENAMETOOLONG},
360 	{NT_STATUS_NETWORK_ACCESS_DENIED,	EACCES},
361 	{NT_STATUS_NETWORK_BUSY,		EBUSY},
362 	{NT_STATUS_NETWORK_UNREACHABLE,		ENETUNREACH},
363 	{NT_STATUS_NET_WRITE_FAULT,		ECOMM},
364 	{NT_STATUS_NONEXISTENT_SECTOR,		ESPIPE},
365 	{NT_STATUS_NOT_A_DIRECTORY,		ENOTDIR},
366 	{NT_STATUS_NOT_IMPLEMENTED,		ENOSYS},
367 	{NT_STATUS_NOT_MAPPED_VIEW,		EINVAL},
368 	{NT_STATUS_NOT_SUPPORTED,		ENOSYS},
369 	{NT_STATUS_NO_MEDIA,			ENOMEDIUM},
370 	{NT_STATUS_NO_MEDIA_IN_DEVICE,		ENOMEDIUM},
371 	{NT_STATUS_NO_MEMORY,			ENOMEM},
372 	{NT_STATUS_NO_SUCH_DEVICE,		ENODEV},
373 	{NT_STATUS_NO_SUCH_FILE,		ENOENT},
374 	{NT_STATUS_OBJECT_NAME_COLLISION,	EEXIST},
375 	{NT_STATUS_OBJECT_NAME_NOT_FOUND,	ENOENT},
376 	{NT_STATUS_OBJECT_NAME_INVALID,		EINVAL},
377 	{NT_STATUS_OBJECT_PATH_INVALID,		ENOTDIR},
378 	{NT_STATUS_PAGEFILE_QUOTA,		EDQUOT},
379 	{NT_STATUS_PASSWORD_EXPIRED,		EACCES},
380 	{NT_STATUS_PASSWORD_RESTRICTION,	EACCES},
381 	{NT_STATUS_PATH_NOT_COVERED,		ENOENT},
382 	{NT_STATUS_PIPE_BROKEN,			EPIPE},
383 	{NT_STATUS_PIPE_BUSY,			EPIPE},
384 	{NT_STATUS_PIPE_CONNECTED,		EISCONN},
385 	{NT_STATUS_PIPE_DISCONNECTED,		EPIPE},
386 	{NT_STATUS_PIPE_NOT_AVAILABLE,		ENOSYS},
387 	{NT_STATUS_PORT_CONNECTION_REFUSED,	ECONNREFUSED},
388 	{NT_STATUS_PORT_MESSAGE_TOO_LONG,	EMSGSIZE},
389 	{NT_STATUS_PORT_UNREACHABLE,		EHOSTUNREACH},
390 	{NT_STATUS_PROTOCOL_UNREACHABLE,	ENOPROTOOPT},
391 	{NT_STATUS_QUOTA_EXCEEDED,		EDQUOT},
392 	{NT_STATUS_REGISTRY_QUOTA_LIMIT,	EDQUOT},
393 	{NT_STATUS_REMOTE_DISCONNECT,		ESHUTDOWN},
394 	{NT_STATUS_REMOTE_NOT_LISTENING,	ECONNREFUSED},
395 	{NT_STATUS_REQUEST_NOT_ACCEPTED,	EACCES},
396 	{NT_STATUS_RETRY,			EAGAIN},
397 	{NT_STATUS_SHARING_VIOLATION,		EBUSY},
398 	{NT_STATUS_TIMER_NOT_CANCELED,		ETIME},
399 	{NT_STATUS_TOO_MANY_LINKS,		EMLINK},
400 	{NT_STATUS_TOO_MANY_OPENED_FILES,	EMFILE},
401 	{NT_STATUS_UNABLE_TO_FREE_VM,		EADDRINUSE},
402 	{NT_STATUS_UNSUCCESSFUL,		EINVAL},
403 	{NT_STATUS_WRONG_PASSWORD,		EACCES},
404 	{0,	0}
405 };
406 
407 static struct {
408 	unsigned dclass;
409 	unsigned derr;
410 	unsigned nterr;
411 } nt2doserr[] = {
412 	{ERRDOS,	ERRgeneral,	NT_STATUS_UNSUCCESSFUL},
413 	{ERRDOS,	ERRbadfunc,	NT_STATUS_NOT_IMPLEMENTED},
414 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_INFO_CLASS},
415 	{ERRDOS,	ERRbadlength,	NT_STATUS_INFO_LENGTH_MISMATCH},
416 	{ERRHRD,	ERRgeneral,	NT_STATUS_ACCESS_VIOLATION},
417 	{ERRHRD,	ERRgeneral,	NT_STATUS_IN_PAGE_ERROR},
418 	{ERRHRD,	ERRgeneral,	NT_STATUS_PAGEFILE_QUOTA},
419 	{ERRDOS,	ERRbadfid,	NT_STATUS_INVALID_HANDLE},
420 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_INITIAL_STACK},
421 	{ERRDOS,	193,	NT_STATUS_BAD_INITIAL_PC},
422 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_CID},
423 	{ERRHRD,	ERRgeneral,	NT_STATUS_TIMER_NOT_CANCELED},
424 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_PARAMETER},
425 	{ERRDOS,	ERRbadfile,	NT_STATUS_NO_SUCH_DEVICE},
426 	{ERRDOS,	ERRbadfile,	NT_STATUS_NO_SUCH_FILE},
427 	{ERRDOS,	ERRbadfunc,	NT_STATUS_INVALID_DEVICE_REQUEST},
428 	{ERRDOS,	ERRhandleeof,	NT_STATUS_END_OF_FILE},
429 	{ERRDOS,	ERRwrongdisk,	NT_STATUS_WRONG_VOLUME},
430 	{ERRDOS,	ERRnotready,	NT_STATUS_NO_MEDIA_IN_DEVICE},
431 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNRECOGNIZED_MEDIA},
432 	{ERRDOS,	ERRsectornotfound,	NT_STATUS_NONEXISTENT_SECTOR},
433 	{ERRDOS,	ERRnomem,	NT_STATUS_NO_MEMORY},
434 	{ERRDOS,	487,	NT_STATUS_CONFLICTING_ADDRESSES},
435 	{ERRDOS,	487,	NT_STATUS_NOT_MAPPED_VIEW},
436 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_UNABLE_TO_FREE_VM},
437 	{ERRDOS,	ERRinvalidparam, NT_STATUS_UNABLE_TO_DELETE_SECTION},
438 	{ERRDOS,	2142,	NT_STATUS_INVALID_SYSTEM_SERVICE},
439 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILLEGAL_INSTRUCTION},
440 	{ERRDOS,	ERRnoaccess,	NT_STATUS_INVALID_LOCK_SEQUENCE},
441 	{ERRDOS,	ERRnoaccess,	NT_STATUS_INVALID_VIEW_SIZE},
442 	{ERRDOS,	193,	NT_STATUS_INVALID_FILE_FOR_SECTION},
443 	{ERRDOS,	ERRnoaccess,	NT_STATUS_ALREADY_COMMITTED},
444 	{ERRDOS,	ERRnoaccess,	NT_STATUS_ACCESS_DENIED},
445 	{ERRDOS,	111,	NT_STATUS_BUFFER_TOO_SMALL},
446 	{ERRDOS,	ERRbadfid,	NT_STATUS_OBJECT_TYPE_MISMATCH},
447 	{ERRHRD,	ERRgeneral,	NT_STATUS_NONCONTINUABLE_EXCEPTION},
448 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_DISPOSITION},
449 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNWIND},
450 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_STACK},
451 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_UNWIND_TARGET},
452 	{ERRDOS,	158,	NT_STATUS_NOT_LOCKED},
453 	{ERRHRD,	ERRgeneral,	NT_STATUS_PARITY_ERROR},
454 	{ERRDOS,	487,	NT_STATUS_UNABLE_TO_DECOMMIT_VM},
455 	{ERRDOS,	487,	NT_STATUS_NOT_COMMITTED},
456 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_PORT_ATTRIBUTES},
457 	{ERRHRD,	ERRgeneral,	NT_STATUS_PORT_MESSAGE_TOO_LONG},
458 	{ERRDOS,	ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_MIX},
459 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_QUOTA_LOWER},
460 	{ERRHRD,	ERRgeneral,	NT_STATUS_DISK_CORRUPT_ERROR},
461 	{ERRDOS,	ERRinvalidname,	NT_STATUS_OBJECT_NAME_INVALID},
462 	{ERRDOS,	ERRbadfile,	NT_STATUS_OBJECT_NAME_NOT_FOUND},
463 	{ERRDOS,	183,	NT_STATUS_OBJECT_NAME_COLLISION},
464 	{ERRHRD,	ERRgeneral,	NT_STATUS_HANDLE_NOT_WAITABLE},
465 	{ERRDOS,	ERRbadfid,	NT_STATUS_PORT_DISCONNECTED},
466 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEVICE_ALREADY_ATTACHED},
467 	{ERRDOS,	161,	NT_STATUS_OBJECT_PATH_INVALID},
468 	{ERRDOS,	ERRbadpath,	NT_STATUS_OBJECT_PATH_NOT_FOUND},
469 	{ERRDOS,	161,	NT_STATUS_OBJECT_PATH_SYNTAX_BAD},
470 	{ERRHRD,	ERRgeneral,	NT_STATUS_DATA_OVERRUN},
471 	{ERRHRD,	ERRgeneral,	NT_STATUS_DATA_LATE_ERROR},
472 	{ERRDOS,	ERRcrc,	NT_STATUS_DATA_ERROR},
473 	{ERRDOS,	ERRcrc,	NT_STATUS_CRC_ERROR},
474 	{ERRDOS,	ERRnomem,	NT_STATUS_SECTION_TOO_BIG},
475 	{ERRDOS,	ERRnoaccess,	NT_STATUS_PORT_CONNECTION_REFUSED},
476 	{ERRDOS,	ERRbadfid,	NT_STATUS_INVALID_PORT_HANDLE},
477 	{ERRDOS,	ERRbadshare,	NT_STATUS_SHARING_VIOLATION},
478 	{ERRHRD,	ERRgeneral,	NT_STATUS_QUOTA_EXCEEDED},
479 	{ERRDOS,	ERRinvalidparam, NT_STATUS_INVALID_PAGE_PROTECTION},
480 	{ERRDOS,	288,	NT_STATUS_MUTANT_NOT_OWNED},
481 	{ERRDOS,	298,	NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED},
482 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_PORT_ALREADY_SET},
483 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_SECTION_NOT_IMAGE},
484 	{ERRDOS,	156,	NT_STATUS_SUSPEND_COUNT_EXCEEDED},
485 	{ERRDOS,	ERRnoaccess,	NT_STATUS_THREAD_IS_TERMINATING},
486 	{ERRDOS,	ERRinvalidparam, NT_STATUS_BAD_WORKING_SET_LIMIT},
487 	{ERRDOS,	ERRinvalidparam, NT_STATUS_INCOMPATIBLE_FILE_MAP},
488 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_SECTION_PROTECTION},
489 	{ERRDOS,	282,	NT_STATUS_EAS_NOT_SUPPORTED},
490 	{ERRDOS,	255,	NT_STATUS_EA_TOO_LARGE},
491 	{ERRHRD,	ERRgeneral,	NT_STATUS_NONEXISTENT_EA_ENTRY},
492 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_EAS_ON_FILE},
493 	{ERRHRD,	ERRgeneral,	NT_STATUS_EA_CORRUPT_ERROR},
494 	{ERRDOS,	ERRlock,	NT_STATUS_FILE_LOCK_CONFLICT},
495 	{ERRDOS,	ERRlock,	NT_STATUS_LOCK_NOT_GRANTED},
496 	{ERRDOS,	ERRnoaccess,	NT_STATUS_DELETE_PENDING},
497 	{ERRDOS,	ERRunsup,	NT_STATUS_CTL_FILE_NOT_SUPPORTED},
498 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNKNOWN_REVISION},
499 	{ERRHRD,	ERRgeneral,	NT_STATUS_REVISION_MISMATCH},
500 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_OWNER},
501 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_PRIMARY_GROUP},
502 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_IMPERSONATION_TOKEN},
503 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_DISABLE_MANDATORY},
504 	{ERRDOS,	2215,	NT_STATUS_NO_LOGON_SERVERS},
505 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_LOGON_SESSION},
506 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_PRIVILEGE},
507 	{ERRDOS,	ERRnoaccess,	NT_STATUS_PRIVILEGE_NOT_HELD},
508 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ACCOUNT_NAME},
509 	{ERRHRD,	ERRgeneral,	NT_STATUS_USER_EXISTS},
510 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_SUCH_USER},
511 	{ERRHRD,	ERRgeneral,	NT_STATUS_GROUP_EXISTS},
512 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_GROUP},
513 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBER_IN_GROUP},
514 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBER_NOT_IN_GROUP},
515 	{ERRHRD,	ERRgeneral,	NT_STATUS_LAST_ADMIN},
516 	{ERRSRV,	ERRbadpw,	NT_STATUS_WRONG_PASSWORD},
517 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILL_FORMED_PASSWORD},
518 	{ERRHRD,	ERRgeneral,	NT_STATUS_PASSWORD_RESTRICTION},
519 	{ERRDOS,	ERRnoaccess,	NT_STATUS_LOGON_FAILURE},
520 	{ERRHRD,	ERRgeneral,	NT_STATUS_ACCOUNT_RESTRICTION},
521 	{ERRSRV,	2241,	NT_STATUS_INVALID_LOGON_HOURS},
522 	{ERRSRV,	2240,	NT_STATUS_INVALID_WORKSTATION},
523 	{ERRSRV,	2242,	NT_STATUS_PASSWORD_EXPIRED},
524 	{ERRSRV,	2239,	NT_STATUS_ACCOUNT_DISABLED},
525 	{ERRHRD,	ERRgeneral,	NT_STATUS_NONE_MAPPED},
526 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_LUIDS_REQUESTED},
527 	{ERRHRD,	ERRgeneral,	NT_STATUS_LUIDS_EXHAUSTED},
528 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_SUB_AUTHORITY},
529 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ACL},
530 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_SID},
531 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_SECURITY_DESCR},
532 	{ERRDOS,	127,	NT_STATUS_PROCEDURE_NOT_FOUND},
533 	{ERRDOS,	193,	NT_STATUS_INVALID_IMAGE_FORMAT},
534 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_TOKEN},
535 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_INHERITANCE_ACL},
536 	{ERRDOS,	158,	NT_STATUS_RANGE_NOT_LOCKED},
537 	{ERRDOS,	112,	NT_STATUS_DISK_FULL},
538 	{ERRHRD,	ERRgeneral,	NT_STATUS_SERVER_DISABLED},
539 	{ERRHRD,	ERRgeneral,	NT_STATUS_SERVER_NOT_DISABLED},
540 	{ERRDOS,	ERRtoomanynames, NT_STATUS_TOO_MANY_GUIDS_REQUESTED},
541 	{ERRDOS,	259,	NT_STATUS_GUIDS_EXHAUSTED},
542 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ID_AUTHORITY},
543 	{ERRDOS,	259,	NT_STATUS_AGENTS_EXHAUSTED},
544 	{ERRDOS,	154,	NT_STATUS_INVALID_VOLUME_LABEL},
545 	{ERRDOS,	ERRoutofmem,	NT_STATUS_SECTION_NOT_EXTENDED},
546 	{ERRDOS,	487,	NT_STATUS_NOT_MAPPED_DATA},
547 	{ERRHRD,	ERRgeneral,	NT_STATUS_RESOURCE_DATA_NOT_FOUND},
548 	{ERRHRD,	ERRgeneral,	NT_STATUS_RESOURCE_TYPE_NOT_FOUND},
549 	{ERRHRD,	ERRgeneral,	NT_STATUS_RESOURCE_NAME_NOT_FOUND},
550 	{ERRHRD,	ERRgeneral,	NT_STATUS_ARRAY_BOUNDS_EXCEEDED},
551 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_DENORMAL_OPERAND},
552 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_DIVIDE_BY_ZERO},
553 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_INEXACT_RESULT},
554 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_INVALID_OPERATION},
555 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_OVERFLOW},
556 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_STACK_CHECK},
557 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOAT_UNDERFLOW},
558 	{ERRHRD,	ERRgeneral,	NT_STATUS_INTEGER_DIVIDE_BY_ZERO},
559 	{ERRDOS,	534,	NT_STATUS_INTEGER_OVERFLOW},
560 	{ERRHRD,	ERRgeneral,	NT_STATUS_PRIVILEGED_INSTRUCTION},
561 	{ERRDOS,	ERRnomem,	NT_STATUS_TOO_MANY_PAGING_FILES},
562 	{ERRHRD,	ERRgeneral,	NT_STATUS_FILE_INVALID},
563 	{ERRHRD,	ERRgeneral,	NT_STATUS_ALLOTTED_SPACE_EXCEEDED},
564 	{ERRDOS,	ERRnomem,	NT_STATUS_INSUFFICIENT_RESOURCES},
565 	{ERRDOS,	ERRbadpath,	NT_STATUS_DFS_EXIT_PATH_FOUND},
566 	{ERRDOS,	ERRcrc,	NT_STATUS_DEVICE_DATA_ERROR},
567 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEVICE_NOT_CONNECTED},
568 	{ERRDOS,	ERRnotready,	NT_STATUS_DEVICE_POWER_FAILURE},
569 	{ERRDOS,	487,	NT_STATUS_FREE_VM_NOT_AT_BASE},
570 	{ERRDOS,	487,	NT_STATUS_MEMORY_NOT_ALLOCATED},
571 	{ERRHRD,	ERRgeneral,	NT_STATUS_WORKING_SET_QUOTA},
572 	{ERRDOS,	ERRwriteprotect, NT_STATUS_MEDIA_WRITE_PROTECTED},
573 	{ERRDOS,	ERRnotready,	NT_STATUS_DEVICE_NOT_READY},
574 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_GROUP_ATTRIBUTES},
575 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_IMPERSONATION_LEVEL},
576 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_OPEN_ANONYMOUS},
577 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_VALIDATION_CLASS},
578 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_TOKEN_TYPE},
579 	{ERRDOS,	ERRinvalidparam, NT_STATUS_BAD_MASTER_BOOT_RECORD},
580 	{ERRHRD,	ERRgeneral,	NT_STATUS_INSTRUCTION_MISALIGNMENT},
581 	{ERRDOS,	ERRpipebusy,	NT_STATUS_INSTANCE_NOT_AVAILABLE},
582 	{ERRDOS,	ERRpipebusy,	NT_STATUS_PIPE_NOT_AVAILABLE},
583 	{ERRDOS,	ERRbadpipe,	NT_STATUS_INVALID_PIPE_STATE},
584 	{ERRDOS,	ERRpipebusy,	NT_STATUS_PIPE_BUSY},
585 	{ERRDOS,	ERRbadfunc,	NT_STATUS_ILLEGAL_FUNCTION},
586 	{ERRDOS,	ERRnotconnected,	NT_STATUS_PIPE_DISCONNECTED},
587 	{ERRDOS,	ERRpipeclosing,	NT_STATUS_PIPE_CLOSING},
588 	{ERRHRD,	ERRgeneral,	NT_STATUS_PIPE_CONNECTED},
589 	{ERRHRD,	ERRgeneral,	NT_STATUS_PIPE_LISTENING},
590 	{ERRDOS,	ERRbadpipe,	NT_STATUS_INVALID_READ_MODE},
591 	{ERRDOS,	121,	NT_STATUS_IO_TIMEOUT},
592 	{ERRDOS,	ERRhandleeof,	NT_STATUS_FILE_FORCED_CLOSED},
593 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROFILING_NOT_STARTED},
594 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROFILING_NOT_STOPPED},
595 	{ERRHRD,	ERRgeneral,	NT_STATUS_COULD_NOT_INTERPRET},
596 	{ERRDOS,	ERRnoaccess,	NT_STATUS_FILE_IS_A_DIRECTORY},
597 	{ERRDOS,	ERRunsup,	NT_STATUS_NOT_SUPPORTED},
598 	{ERRDOS,	51,	NT_STATUS_REMOTE_NOT_LISTENING},
599 	{ERRDOS,	52,	NT_STATUS_DUPLICATE_NAME},
600 	{ERRDOS,	53,	NT_STATUS_BAD_NETWORK_PATH},
601 	{ERRDOS,	54,	NT_STATUS_NETWORK_BUSY},
602 	{ERRDOS,	55,	NT_STATUS_DEVICE_DOES_NOT_EXIST},
603 	{ERRDOS,	56,	NT_STATUS_TOO_MANY_COMMANDS},
604 	{ERRDOS,	57,	NT_STATUS_ADAPTER_HARDWARE_ERROR},
605 	{ERRDOS,	58,	NT_STATUS_INVALID_NETWORK_RESPONSE},
606 	{ERRDOS,	59,	NT_STATUS_UNEXPECTED_NETWORK_ERROR},
607 	{ERRDOS,	60,	NT_STATUS_BAD_REMOTE_ADAPTER},
608 	{ERRDOS,	61,	NT_STATUS_PRINT_QUEUE_FULL},
609 	{ERRDOS,	62,	NT_STATUS_NO_SPOOL_SPACE},
610 	{ERRDOS,	63,	NT_STATUS_PRINT_CANCELLED},
611 	{ERRDOS,	64,	NT_STATUS_NETWORK_NAME_DELETED},
612 	{ERRDOS,	65,	NT_STATUS_NETWORK_ACCESS_DENIED},
613 	{ERRDOS,	66,	NT_STATUS_BAD_DEVICE_TYPE},
614 	{ERRDOS,	ERRnosuchshare,	NT_STATUS_BAD_NETWORK_NAME},
615 	{ERRDOS,	68,	NT_STATUS_TOO_MANY_NAMES},
616 	{ERRDOS,	69,	NT_STATUS_TOO_MANY_SESSIONS},
617 	{ERRDOS,	70,	NT_STATUS_SHARING_PAUSED},
618 	{ERRDOS,	71,	NT_STATUS_REQUEST_NOT_ACCEPTED},
619 	{ERRDOS,	72,	NT_STATUS_REDIRECTOR_PAUSED},
620 	{ERRDOS,	88,	NT_STATUS_NET_WRITE_FAULT},
621 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROFILING_AT_LIMIT},
622 	{ERRDOS,	ERRdiffdevice,	NT_STATUS_NOT_SAME_DEVICE},
623 	{ERRDOS,	ERRnoaccess,	NT_STATUS_FILE_RENAMED},
624 	{ERRDOS,	240,	NT_STATUS_VIRTUAL_CIRCUIT_CLOSED},
625 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SECURITY_ON_OBJECT},
626 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_WAIT},
627 	{ERRDOS,	ERRpipeclosing,	NT_STATUS_PIPE_EMPTY},
628 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_ACCESS_DOMAIN_INFO},
629 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANT_TERMINATE_SELF},
630 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_SERVER_STATE},
631 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_DOMAIN_STATE},
632 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_DOMAIN_ROLE},
633 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_DOMAIN},
634 	{ERRHRD,	ERRgeneral,	NT_STATUS_DOMAIN_EXISTS},
635 	{ERRHRD,	ERRgeneral,	NT_STATUS_DOMAIN_LIMIT_EXCEEDED},
636 	{ERRDOS,	300,	NT_STATUS_OPLOCK_NOT_GRANTED},
637 	{ERRDOS,	301,	NT_STATUS_INVALID_OPLOCK_PROTOCOL},
638 	{ERRHRD,	ERRgeneral,	NT_STATUS_INTERNAL_DB_CORRUPTION},
639 	{ERRHRD,	ERRgeneral,	NT_STATUS_INTERNAL_ERROR},
640 	{ERRHRD,	ERRgeneral,	NT_STATUS_GENERIC_NOT_MAPPED},
641 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_DESCRIPTOR_FORMAT},
642 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_USER_BUFFER},
643 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNEXPECTED_IO_ERROR},
644 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNEXPECTED_MM_CREATE_ERR},
645 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNEXPECTED_MM_MAP_ERROR},
646 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNEXPECTED_MM_EXTEND_ERR},
647 	{ERRHRD,	ERRgeneral,	NT_STATUS_NOT_LOGON_PROCESS},
648 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGON_SESSION_EXISTS},
649 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_PARAMETER_1},
650 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_PARAMETER_2},
651 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_PARAMETER_3},
652 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_PARAMETER_4},
653 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_PARAMETER_5},
654 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_PARAMETER_6},
655 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_PARAMETER_7},
656 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_PARAMETER_8},
657 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_PARAMETER_9},
658 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_PARAMETER_10},
659 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_PARAMETER_11},
660 	{ERRDOS,	ERRinvalidparam,	NT_STATUS_INVALID_PARAMETER_12},
661 	{ERRDOS,	ERRbadpath,	NT_STATUS_REDIRECTOR_NOT_STARTED},
662 	{ERRHRD,	ERRgeneral,	NT_STATUS_REDIRECTOR_STARTED},
663 	{ERRHRD,	ERRgeneral,	NT_STATUS_STACK_OVERFLOW},
664 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_PACKAGE},
665 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_FUNCTION_TABLE},
666 	{ERRDOS,	203,	NT_STATUS_VARIABLE_NOT_FOUND},
667 	{ERRDOS,	145,	NT_STATUS_DIRECTORY_NOT_EMPTY},
668 	{ERRHRD,	ERRgeneral,	NT_STATUS_FILE_CORRUPT_ERROR},
669 	{ERRDOS,	267,	NT_STATUS_NOT_A_DIRECTORY},
670 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_LOGON_SESSION_STATE},
671 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGON_SESSION_COLLISION},
672 	{ERRDOS,	206,	NT_STATUS_NAME_TOO_LONG},
673 	{ERRDOS,	2401,	NT_STATUS_FILES_OPEN},
674 	{ERRDOS,	2404,	NT_STATUS_CONNECTION_IN_USE},
675 	{ERRHRD,	ERRgeneral,	NT_STATUS_MESSAGE_NOT_FOUND},
676 	{ERRDOS,	ERRnoaccess,	NT_STATUS_PROCESS_IS_TERMINATING},
677 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_LOGON_TYPE},
678 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_GUID_TRANSLATION},
679 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANNOT_IMPERSONATE},
680 	{ERRHRD,	ERRgeneral,	NT_STATUS_IMAGE_ALREADY_LOADED},
681 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_NOT_PRESENT},
682 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_LID_NOT_EXIST},
683 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_LID_ALREADY_OWNED},
684 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_NOT_LID_OWNER},
685 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_INVALID_COMMAND},
686 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_INVALID_LID},
687 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE},
688 	{ERRHRD,	ERRgeneral,	NT_STATUS_ABIOS_INVALID_SELECTOR},
689 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_LDT},
690 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_LDT_SIZE},
691 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_LDT_OFFSET},
692 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_LDT_DESCRIPTOR},
693 	{ERRDOS,	193,	NT_STATUS_INVALID_IMAGE_NE_FORMAT},
694 	{ERRHRD,	ERRgeneral,	NT_STATUS_RXACT_INVALID_STATE},
695 	{ERRHRD,	ERRgeneral,	NT_STATUS_RXACT_COMMIT_FAILURE},
696 	{ERRHRD,	ERRgeneral,	NT_STATUS_MAPPED_FILE_SIZE_ZERO},
697 	{ERRDOS,	ERRnofids,	NT_STATUS_TOO_MANY_OPENED_FILES},
698 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANCELLED},
699 	{ERRDOS,	ERRnoaccess,	NT_STATUS_CANNOT_DELETE},
700 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_COMPUTER_NAME},
701 	{ERRDOS,	ERRnoaccess,	NT_STATUS_FILE_DELETED},
702 	{ERRHRD,	ERRgeneral,	NT_STATUS_SPECIAL_ACCOUNT},
703 	{ERRHRD,	ERRgeneral,	NT_STATUS_SPECIAL_GROUP},
704 	{ERRHRD,	ERRgeneral,	NT_STATUS_SPECIAL_USER},
705 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBERS_PRIMARY_GROUP},
706 	{ERRDOS,	ERRbadfid,	NT_STATUS_FILE_CLOSED},
707 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_THREADS},
708 	{ERRHRD,	ERRgeneral,	NT_STATUS_THREAD_NOT_IN_PROCESS},
709 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOKEN_ALREADY_IN_USE},
710 	{ERRHRD,	ERRgeneral,	NT_STATUS_PAGEFILE_QUOTA_EXCEEDED},
711 	{ERRHRD,	ERRgeneral,	NT_STATUS_COMMITMENT_LIMIT},
712 	{ERRDOS,	193,	NT_STATUS_INVALID_IMAGE_LE_FORMAT},
713 	{ERRDOS,	193,	NT_STATUS_INVALID_IMAGE_NOT_MZ},
714 	{ERRDOS,	193,	NT_STATUS_INVALID_IMAGE_PROTECT},
715 	{ERRDOS,	193,	NT_STATUS_INVALID_IMAGE_WIN_16},
716 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGON_SERVER_CONFLICT},
717 	{ERRHRD,	ERRgeneral,	NT_STATUS_TIME_DIFFERENCE_AT_DC},
718 	{ERRHRD,	ERRgeneral,	NT_STATUS_SYNCHRONIZATION_REQUIRED},
719 	{ERRDOS,	126,	NT_STATUS_DLL_NOT_FOUND},
720 	{ERRHRD,	ERRgeneral,	NT_STATUS_OPEN_FAILED},
721 	{ERRHRD,	ERRgeneral,	NT_STATUS_IO_PRIVILEGE_FAILED},
722 	{ERRDOS,	182,	NT_STATUS_ORDINAL_NOT_FOUND},
723 	{ERRDOS,	127,	NT_STATUS_ENTRYPOINT_NOT_FOUND},
724 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONTROL_C_EXIT},
725 	{ERRDOS,	64,	NT_STATUS_LOCAL_DISCONNECT},
726 	{ERRDOS,	64,	NT_STATUS_REMOTE_DISCONNECT},
727 	{ERRDOS,	51,	NT_STATUS_REMOTE_RESOURCES},
728 	{ERRDOS,	59,	NT_STATUS_LINK_FAILED},
729 	{ERRDOS,	59,	NT_STATUS_LINK_TIMEOUT},
730 	{ERRDOS,	59,	NT_STATUS_INVALID_CONNECTION},
731 	{ERRDOS,	59,	NT_STATUS_INVALID_ADDRESS},
732 	{ERRHRD,	ERRgeneral,	NT_STATUS_DLL_INIT_FAILED},
733 	{ERRHRD,	ERRgeneral,	NT_STATUS_MISSING_SYSTEMFILE},
734 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNHANDLED_EXCEPTION},
735 	{ERRHRD,	ERRgeneral,	NT_STATUS_APP_INIT_FAILURE},
736 	{ERRHRD,	ERRgeneral,	NT_STATUS_PAGEFILE_CREATE_FAILED},
737 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_PAGEFILE},
738 	{ERRDOS,	124,	NT_STATUS_INVALID_LEVEL},
739 	{ERRDOS,	86,	NT_STATUS_WRONG_PASSWORD_CORE},
740 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILLEGAL_FLOAT_CONTEXT},
741 	{ERRDOS,	109,	NT_STATUS_PIPE_BROKEN},
742 	{ERRHRD,	ERRgeneral,	NT_STATUS_REGISTRY_CORRUPT},
743 	{ERRHRD,	ERRgeneral,	NT_STATUS_REGISTRY_IO_FAILED},
744 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_EVENT_PAIR},
745 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNRECOGNIZED_VOLUME},
746 	{ERRHRD,	ERRgeneral,	NT_STATUS_SERIAL_NO_DEVICE_INITED},
747 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_ALIAS},
748 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBER_NOT_IN_ALIAS},
749 	{ERRHRD,	ERRgeneral,	NT_STATUS_MEMBER_IN_ALIAS},
750 	{ERRHRD,	ERRgeneral,	NT_STATUS_ALIAS_EXISTS},
751 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGON_NOT_GRANTED},
752 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_SECRETS},
753 	{ERRHRD,	ERRgeneral,	NT_STATUS_SECRET_TOO_LONG},
754 	{ERRHRD,	ERRgeneral,	NT_STATUS_INTERNAL_DB_ERROR},
755 	{ERRHRD,	ERRgeneral,	NT_STATUS_FULLSCREEN_MODE},
756 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_CONTEXT_IDS},
757 	{ERRDOS,	ERRnoaccess,	NT_STATUS_LOGON_TYPE_NOT_GRANTED},
758 	{ERRHRD,	ERRgeneral,	NT_STATUS_NOT_REGISTRY_FILE},
759 	{ERRHRD,	ERRgeneral,	NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED},
760 	{ERRHRD,	ERRgeneral,	NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR},
761 	{ERRHRD,	ERRgeneral,	NT_STATUS_FT_MISSING_MEMBER},
762 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILL_FORMED_SERVICE_ENTRY},
763 	{ERRHRD,	ERRgeneral,	NT_STATUS_ILLEGAL_CHARACTER},
764 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNMAPPABLE_CHARACTER},
765 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNDEFINED_CHARACTER},
766 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_VOLUME},
767 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND},
768 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_WRONG_CYLINDER},
769 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_UNKNOWN_ERROR},
770 	{ERRHRD,	ERRgeneral,	NT_STATUS_FLOPPY_BAD_REGISTERS},
771 	{ERRHRD,	ERRgeneral,	NT_STATUS_DISK_RECALIBRATE_FAILED},
772 	{ERRHRD,	ERRgeneral,	NT_STATUS_DISK_OPERATION_FAILED},
773 	{ERRHRD,	ERRgeneral,	NT_STATUS_DISK_RESET_FAILED},
774 	{ERRHRD,	ERRgeneral,	NT_STATUS_SHARED_IRQ_BUSY},
775 	{ERRHRD,	ERRgeneral,	NT_STATUS_FT_ORPHANING},
776 	{ERRHRD,	ERRgeneral, NT_STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT},
777 	{ERRHRD,	ERRgeneral,	NT_STATUS_16F},
778 	{ERRHRD,	ERRgeneral,	NT_STATUS_170},
779 	{ERRHRD,	ERRgeneral,	NT_STATUS_171},
780 	{ERRHRD,	ERRgeneral,	NT_STATUS_PARTITION_FAILURE},
781 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_BLOCK_LENGTH},
782 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEVICE_NOT_PARTITIONED},
783 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNABLE_TO_LOCK_MEDIA},
784 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNABLE_TO_UNLOAD_MEDIA},
785 	{ERRHRD,	ERRgeneral,	NT_STATUS_EOM_OVERFLOW},
786 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_MEDIA},
787 	{ERRHRD,	ERRgeneral,	NT_STATUS_179},
788 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_SUCH_MEMBER},
789 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_MEMBER},
790 	{ERRHRD,	ERRgeneral,	NT_STATUS_KEY_DELETED},
791 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_LOG_SPACE},
792 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_SIDS},
793 	{ERRHRD,	ERRgeneral,	NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED},
794 	{ERRHRD,	ERRgeneral,	NT_STATUS_KEY_HAS_CHILDREN},
795 	{ERRHRD,	ERRgeneral,	NT_STATUS_CHILD_MUST_BE_VOLATILE},
796 	{ERRDOS,	ERRinvalidparam, NT_STATUS_DEVICE_CONFIGURATION_ERROR},
797 	{ERRHRD,	ERRgeneral,	NT_STATUS_DRIVER_INTERNAL_ERROR},
798 	{ERRDOS,	ERRbadcmd,	NT_STATUS_INVALID_DEVICE_STATE},
799 	{ERRHRD,	ERRgeneral,	NT_STATUS_IO_DEVICE_ERROR},
800 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEVICE_PROTOCOL_ERROR},
801 	{ERRHRD,	ERRgeneral,	NT_STATUS_BACKUP_CONTROLLER},
802 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOG_FILE_FULL},
803 	{ERRDOS,	ERRwriteprotect,	NT_STATUS_TOO_LATE},
804 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_TRUST_LSA_SECRET},
805 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_TRUST_SAM_ACCOUNT},
806 	{ERRDOS,	ERRnoaccess,	NT_STATUS_TRUSTED_DOMAIN_FAILURE},
807 	{ERRDOS,	ERRnoaccess,	NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE},
808 	{ERRHRD,	ERRgeneral,	NT_STATUS_EVENTLOG_FILE_CORRUPT},
809 	{ERRHRD,	ERRgeneral,	NT_STATUS_EVENTLOG_CANT_START},
810 	{ERRDOS,	ERRnoaccess,	NT_STATUS_TRUST_FAILURE},
811 	{ERRHRD,	ERRgeneral,	NT_STATUS_MUTANT_LIMIT_EXCEEDED},
812 	{ERRDOS,	ERRinvgroup,	NT_STATUS_NETLOGON_NOT_STARTED},
813 	{ERRSRV,	2239,	NT_STATUS_ACCOUNT_EXPIRED},
814 	{ERRHRD,	ERRgeneral,	NT_STATUS_POSSIBLE_DEADLOCK},
815 	{ERRHRD,	ERRgeneral,	NT_STATUS_NETWORK_CREDENTIAL_CONFLICT},
816 	{ERRHRD,	ERRgeneral,	NT_STATUS_REMOTE_SESSION_LIMIT},
817 	{ERRHRD,	ERRgeneral,	NT_STATUS_EVENTLOG_FILE_CHANGED},
818 	{ERRDOS,	ERRnoaccess,
819 	    NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT},
820 	{ERRDOS,	ERRnoaccess,
821 		NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT},
822 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT},
823 	{ERRDOS,	ERRnoaccess,	NT_STATUS_DOMAIN_TRUST_INCONSISTENT},
824 	{ERRHRD,	ERRgeneral,	NT_STATUS_FS_DRIVER_REQUIRED},
825 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_USER_SESSION_KEY},
826 	{ERRDOS,	59,	NT_STATUS_USER_SESSION_DELETED},
827 	{ERRHRD,	ERRgeneral,	NT_STATUS_RESOURCE_LANG_NOT_FOUND},
828 	{ERRDOS,	ERRnomem,	NT_STATUS_INSUFF_SERVER_RESOURCES},
829 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_BUFFER_SIZE},
830 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ADDRESS_COMPONENT},
831 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_ADDRESS_WILDCARD},
832 	{ERRDOS,	68,	NT_STATUS_TOO_MANY_ADDRESSES},
833 	{ERRDOS,	52,	NT_STATUS_ADDRESS_ALREADY_EXISTS},
834 	{ERRDOS,	64,	NT_STATUS_ADDRESS_CLOSED},
835 	{ERRDOS,	64,	NT_STATUS_CONNECTION_DISCONNECTED},
836 	{ERRDOS,	64,	NT_STATUS_CONNECTION_RESET},
837 	{ERRDOS,	68,	NT_STATUS_TOO_MANY_NODES},
838 	{ERRDOS,	59,	NT_STATUS_TRANSACTION_ABORTED},
839 	{ERRDOS,	59,	NT_STATUS_TRANSACTION_TIMED_OUT},
840 	{ERRDOS,	59,	NT_STATUS_TRANSACTION_NO_RELEASE},
841 	{ERRDOS,	59,	NT_STATUS_TRANSACTION_NO_MATCH},
842 	{ERRDOS,	59,	NT_STATUS_TRANSACTION_RESPONDED},
843 	{ERRDOS,	59,	NT_STATUS_TRANSACTION_INVALID_ID},
844 	{ERRDOS,	59,	NT_STATUS_TRANSACTION_INVALID_TYPE},
845 	{ERRDOS,	ERRunsup,	NT_STATUS_NOT_SERVER_SESSION},
846 	{ERRDOS,	ERRunsup,	NT_STATUS_NOT_CLIENT_SESSION},
847 	{ERRHRD,	ERRgeneral,	NT_STATUS_CANNOT_LOAD_REGISTRY_FILE},
848 	{ERRHRD,	ERRgeneral,	NT_STATUS_DEBUG_ATTACH_FAILED},
849 	{ERRHRD,	ERRgeneral,	NT_STATUS_SYSTEM_PROCESS_TERMINATED},
850 	{ERRHRD,	ERRgeneral,	NT_STATUS_DATA_NOT_ACCEPTED},
851 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_BROWSER_SERVERS_FOUND},
852 	{ERRHRD,	ERRgeneral,	NT_STATUS_VDM_HARD_ERROR},
853 	{ERRHRD,	ERRgeneral,	NT_STATUS_DRIVER_CANCEL_TIMEOUT},
854 	{ERRHRD,	ERRgeneral,	NT_STATUS_REPLY_MESSAGE_MISMATCH},
855 	{ERRHRD,	ERRgeneral,	NT_STATUS_MAPPED_ALIGNMENT},
856 	{ERRDOS,	193,	NT_STATUS_IMAGE_CHECKSUM_MISMATCH},
857 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOST_WRITEBEHIND_DATA},
858 	{ERRHRD,	ERRgeneral, NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID},
859 	{ERRSRV,	2242,	NT_STATUS_PASSWORD_MUST_CHANGE},
860 	{ERRHRD,	ERRgeneral,	NT_STATUS_NOT_FOUND},
861 	{ERRHRD,	ERRgeneral,	NT_STATUS_NOT_TINY_STREAM},
862 	{ERRHRD,	ERRgeneral,	NT_STATUS_RECOVERY_FAILURE},
863 	{ERRHRD,	ERRgeneral,	NT_STATUS_STACK_OVERFLOW_READ},
864 	{ERRHRD,	ERRgeneral,	NT_STATUS_FAIL_CHECK},
865 	{ERRHRD,	ERRgeneral,	NT_STATUS_DUPLICATE_OBJECTID},
866 	{ERRHRD,	ERRgeneral,	NT_STATUS_OBJECTID_EXISTS},
867 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONVERT_TO_LARGE},
868 	{ERRHRD,	ERRgeneral,	NT_STATUS_RETRY},
869 	{ERRHRD,	ERRgeneral,	NT_STATUS_FOUND_OUT_OF_SCOPE},
870 	{ERRHRD,	ERRgeneral,	NT_STATUS_ALLOCATE_BUCKET},
871 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROPSET_NOT_FOUND},
872 	{ERRHRD,	ERRgeneral,	NT_STATUS_MARSHALL_OVERFLOW},
873 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_VARIANT},
874 	{ERRHRD,	ERRgeneral,	NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND},
875 	{ERRDOS,	ERRnoaccess,	NT_STATUS_ACCOUNT_LOCKED_OUT},
876 	{ERRDOS,	ERRbadfid,	NT_STATUS_HANDLE_NOT_CLOSABLE},
877 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_REFUSED},
878 	{ERRHRD,	ERRgeneral,	NT_STATUS_GRACEFUL_DISCONNECT},
879 	{ERRHRD,	ERRgeneral,	NT_STATUS_ADDRESS_ALREADY_ASSOCIATED},
880 	{ERRHRD,	ERRgeneral,	NT_STATUS_ADDRESS_NOT_ASSOCIATED},
881 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_INVALID},
882 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_ACTIVE},
883 	{ERRHRD,	ERRgeneral,	NT_STATUS_NETWORK_UNREACHABLE},
884 	{ERRHRD,	ERRgeneral,	NT_STATUS_HOST_UNREACHABLE},
885 	{ERRHRD,	ERRgeneral,	NT_STATUS_PROTOCOL_UNREACHABLE},
886 	{ERRHRD,	ERRgeneral,	NT_STATUS_PORT_UNREACHABLE},
887 	{ERRHRD,	ERRgeneral,	NT_STATUS_REQUEST_ABORTED},
888 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_ABORTED},
889 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_COMPRESSION_BUFFER},
890 	{ERRHRD,	ERRgeneral,	NT_STATUS_USER_MAPPED_FILE},
891 	{ERRHRD,	ERRgeneral,	NT_STATUS_AUDIT_FAILED},
892 	{ERRHRD,	ERRgeneral,	NT_STATUS_TIMER_RESOLUTION_NOT_SET},
893 	{ERRHRD,	ERRgeneral,	NT_STATUS_CONNECTION_COUNT_LIMIT},
894 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGIN_TIME_RESTRICTION},
895 	{ERRHRD,	ERRgeneral,	NT_STATUS_LOGIN_WKSTA_RESTRICTION},
896 	{ERRDOS,	193,	NT_STATUS_IMAGE_MP_UP_MISMATCH},
897 	{ERRHRD,	ERRgeneral,	0x000024a},
898 	{ERRHRD,	ERRgeneral,	0x000024b},
899 	{ERRHRD,	ERRgeneral,	0x000024c},
900 	{ERRHRD,	ERRgeneral,	0x000024d},
901 	{ERRHRD,	ERRgeneral,	0x000024e},
902 	{ERRHRD,	ERRgeneral,	0x000024f},
903 	{ERRHRD,	ERRgeneral,	NT_STATUS_INSUFFICIENT_LOGON_INFO},
904 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_DLL_ENTRYPOINT},
905 	{ERRHRD,	ERRgeneral,	NT_STATUS_BAD_SERVICE_ENTRYPOINT},
906 	{ERRHRD,	ERRgeneral,	NT_STATUS_LPC_REPLY_LOST},
907 	{ERRHRD,	ERRgeneral,	NT_STATUS_IP_ADDRESS_CONFLICT1},
908 	{ERRHRD,	ERRgeneral,	NT_STATUS_IP_ADDRESS_CONFLICT2},
909 	{ERRHRD,	ERRgeneral,	NT_STATUS_REGISTRY_QUOTA_LIMIT},
910 	{ERRSRV,	ERRbadtype,	NT_STATUS_PATH_NOT_COVERED},
911 	{ERRHRD,	ERRgeneral,	NT_STATUS_NO_CALLBACK_ACTIVE},
912 	{ERRHRD,	ERRgeneral,	NT_STATUS_LICENSE_QUOTA_EXCEEDED},
913 	{ERRHRD,	ERRgeneral,	NT_STATUS_PWD_TOO_SHORT},
914 	{ERRHRD,	ERRgeneral,	NT_STATUS_PWD_TOO_RECENT},
915 	{ERRHRD,	ERRgeneral,	NT_STATUS_PWD_HISTORY_CONFLICT},
916 	{ERRHRD,	ERRgeneral,	0x000025d},
917 	{ERRHRD,	ERRgeneral,	NT_STATUS_PLUGPLAY_NO_DEVICE},
918 	{ERRHRD,	ERRgeneral,	NT_STATUS_UNSUPPORTED_COMPRESSION},
919 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_HW_PROFILE},
920 	{ERRHRD,	ERRgeneral,	NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH},
921 	{ERRDOS,	182,		NT_STATUS_DRIVER_ORDINAL_NOT_FOUND},
922 	{ERRDOS,	127,		NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND},
923 	{ERRDOS,	288,		NT_STATUS_RESOURCE_NOT_OWNED},
924 	{ERRHRD,	ERRgeneral,	NT_STATUS_TOO_MANY_LINKS},
925 	{ERRHRD,	ERRgeneral,	NT_STATUS_QUOTA_LIST_INCONSISTENT},
926 	{ERRHRD,	ERRgeneral,	NT_STATUS_FILE_IS_OFFLINE},
927 	{ERRDOS,	ERRnotready,		NT_STATUS_VOLUME_DISMOUNTED},
928 	{ERRDOS,	161,		NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT},
929 	{ERRDOS,	ERRnoaccess,	NT_STATUS_ENCRYPTION_FAILED},
930 	{ERRDOS,	ERRnoaccess,	NT_STATUS_DECRYPTION_FAILED},
931 	{ERRHRD,	ERRgeneral,	NT_STATUS_RANGE_NOT_FOUND},
932 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_RECOVERY_POLICY},
933 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_EFS},
934 	{ERRDOS,	ERRnoaccess,	NT_STATUS_WRONG_EFS},
935 	{ERRDOS,	ERRnoaccess,	NT_STATUS_NO_USER_KEYS},
936 	{ERRDOS,	ERRbadfunc,	NT_STATUS_VOLUME_NOT_UPGRADED},
937 };
938 
939 u_int32_t
940 smb_maperr32(u_int32_t eno)
941 {
942 	int	i;
943 	unsigned	orig = eno;
944 
945 	/*
946 	 * Hi two bits are "severity".  Ignore "success" (0) and
947 	 * "informational" (1) values.
948 	 */
949 	if (!(eno & 0x80000000))
950 		return (0);
951 	/* mask off "severity" and the "component"  bit */
952 	eno &= ~(0xe0000000);
953 
954 	/* first try direct map to unix */
955 	for (i = 0; nt2errno[i].errno; i++)
956 		if (nt2errno[i].nterr == eno)
957 			return (nt2errno[i].errno);
958 	SMBERROR("no direct map for 32 bit server error (0x%x)\n", orig);
959 
960 	/* ok, then try mapping to dos to unix */
961 	for (i = 0; nt2doserr[i].derr; i++)
962 		if (nt2doserr[i].nterr == eno)
963 			return (smb_maperror(nt2doserr[i].dclass,
964 			    nt2doserr[i].derr));
965 	return (smb_maperror(ERRHRD, ERRgeneral));
966 }
967 
968 
969 int
970 smb_maperror(int eclass, int eno)
971 {
972 	if (eclass == 0 && eno == 0)
973 		return (0);
974 	switch (eclass) {
975 	case ERRDOS:
976 		switch (eno) {
977 		case ERRbadfunc:
978 		case ERRbadenv:
979 		case ERRbadformat:
980 		case ERRremcd:
981 		case ERRrmuns:
982 		case ERRunknownlevel:
983 			return (EINVAL);
984 		case ERRbadfile:
985 		case ERRbadpath:
986 		case ERRnoipc:
987 		case ERRnosuchshare:
988 			return (ENOENT);
989 		case ERRnofids:
990 			return (EMFILE);
991 		case ERRnoaccess:
992 			/*
993 			 * XXX CSM Reported on samba-technical 12/7/2002
994 			 *
995 			 * There is a case for which server(s) return
996 			 * ERRnoaccess but should return ERRdiskfull: When
997 			 * the offset for a write is exactly the server
998 			 * file size limit then Samba (at least) thinks
999 			 * the reason for zero bytes having been written
1000 			 * must have been "access denied" from the local
1001 			 * filesystem.  This cannot be easily worked
1002 			 * around since the server behaviour is
1003 			 * indistinguishable from actual access denied.
1004 			 * An incomplete workaround: attempt a 2 byte write
1005 			 * from "offset-1".  (That may require reading at
1006 			 * offset-1 first.)  The flaw is that reading or
1007 			 * writing at offset-1 could cause an
1008 			 * unrelated error (due to a byte range lock
1009 			 * for instance) and we can't presume the
1010 			 * order servers check errors in.
1011 			 */
1012 		case ERRbadaccess:
1013 			return (EACCES);
1014 		case ERRbadshare:
1015 			return (EBUSY);
1016 		case ERRbadfid:
1017 			return (EBADF);
1018 		case ERRbadmcb:
1019 			return (EIO);
1020 		case ERRnomem:
1021 			return (ENOMEM);	/* actually remote no mem... */
1022 		case ERRbadmem:
1023 			return (EFAULT);
1024 		case ERRbaddata:
1025 			return (E2BIG);
1026 		case ERRbaddrive:
1027 		case ERRnotready:	/* nt */
1028 			return (ENXIO);
1029 		case ERRdiffdevice:
1030 			return (EXDEV);
1031 		case ERRnofiles:
1032 			return (0);	/* eeof ? */
1033 		case ERRlock:
1034 			return (EDEADLK);
1035 		case ERRfilexists:
1036 			return (EEXIST);
1037 		case ERRinvalidname:	/* samba maps as noent */
1038 			return (ENOENT);
1039 		case ERRdirnotempty:		/* samba */
1040 			return (ENOTEMPTY);
1041 		case ERRnotlocked:
1042 			return (0); /* 0 since bsd unlocks on any close */
1043 		case ERRrename:
1044 			return (EEXIST);
1045 		case ERRmoredata:
1046 			return (EMOREDATA);
1047 		}
1048 		break;
1049 	case ERRSRV:
1050 		switch (eno) {
1051 		case ERRerror:
1052 			return (EINVAL);
1053 		case ERRbadpw:
1054 			return (EAUTH);
1055 		case ERRaccess:
1056 		case ERRbaduid:
1057 			return (EACCES);
1058 		case ERRinvnid:
1059 			return (ENETRESET);
1060 		case ERRinvnetname:
1061 			SMBERROR("NetBIOS name is invalid: %d\n",
1062 			    ERRinvnetname);
1063 			return (EAUTH);
1064 		case ERRbadtype:		/* reserved and returned */
1065 			return (EIO);
1066 		case ERRacctexpired: /* NT: account exists but disabled */
1067 			return (EPERM);
1068 		}
1069 		break;
1070 	case ERRHRD:
1071 		switch (eno) {
1072 		case ERRnowrite:
1073 			return (EROFS);
1074 		case ERRbadunit:
1075 			return (ENODEV);
1076 		case ERRbadreq:
1077 			return (EBADRPC);
1078 		case ERRbadshare:
1079 			return (ETXTBSY);
1080 		case ERRlock:
1081 			return (EDEADLK);
1082 		case ERRdiskfull:
1083 			return (EFBIG);
1084 		case ERRnotready:
1085 		case ERRbadcmd:
1086 		case ERRdata:
1087 		case ERRgeneral:
1088 			return (EIO);
1089 		default:
1090 			SMBERROR("Unmapped DOS error %d:%d\n", eclass, eno);
1091 			return (EIO);
1092 		}
1093 	}
1094 	SMBERROR("Unmapped DOS error %d:%d\n", eclass, eno);
1095 	return (EBADRPC);
1096 }
1097 
1098 #if defined(NOICONVSUPPORT) || defined(lint)
1099 extern int iconv_conv(void *handle, const char **inbuf,
1100     size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
1101 #endif
1102 
1103 #define	SMALL_CONV 256
1104 
1105 /*ARGSUSED*/
1106 int
1107 smb_put_dmem(struct mbchain *mbp, struct smb_vc *vcp, const char *src,
1108 	int size, int caseopt, int *lenp)
1109 {
1110 	uint16_t convbuf[SMALL_CONV];
1111 	uint16_t *cbuf;
1112 	size_t cbufalloc, inlen, outlen;
1113 	int error;
1114 
1115 	if (size <= 0)
1116 		return (0);
1117 
1118 	/*
1119 	 * Handle the easy case (non-unicode).
1120 	 * XXX: Technically, we should convert
1121 	 * the string to OEM codeset first...
1122 	 * Modern servers all use Unicode, so
1123 	 * this is good enough.
1124 	 */
1125 	if (SMB_UNICODE_STRINGS(vcp) == 0) {
1126 		error = mb_put_mem(mbp, src, size, MB_MSYSTEM);
1127 		if (!error && lenp)
1128 			*lenp += size;
1129 		return (error);
1130 	}
1131 
1132 	/*
1133 	 * Convert to UCS-2 (really UTF-16).
1134 	 * Use stack buffer if the string is
1135 	 * small enough, else allocate.
1136 	 */
1137 	if (size <= SMALL_CONV) {
1138 		cbufalloc = 0;
1139 		outlen = SMALL_CONV;
1140 		cbuf = convbuf;
1141 	} else {
1142 		outlen = size; /* in utf-16 characters */
1143 		cbufalloc = outlen * 2;
1144 		cbuf = kmem_alloc(cbufalloc, KM_SLEEP);
1145 	}
1146 
1147 	inlen = size;
1148 	error = uconv_u8tou16((uchar_t *)src, &inlen, cbuf, &outlen,
1149 	    UCONV_OUT_LITTLE_ENDIAN | UCONV_IGNORE_NULL);
1150 	outlen *= 2;  /* convert to bytes */
1151 
1152 	if (!error) {
1153 		(void) mb_put_padbyte(mbp); /* align */
1154 		error = mb_put_mem(mbp, (char *)cbuf, outlen, MB_MSYSTEM);
1155 	}
1156 	if (!error && lenp)
1157 		*lenp += outlen;
1158 
1159 	if (cbufalloc)
1160 		kmem_free(cbuf, cbufalloc);
1161 
1162 	return (error);
1163 }
1164 
1165 int
1166 smb_put_dstring(struct mbchain *mbp, struct smb_vc *vcp, const char *src,
1167 	int caseopt)
1168 {
1169 	int error, len;
1170 
1171 	/*
1172 	 * Let smb_put_dmem put both the string
1173 	 * and the terminating null.
1174 	 */
1175 	len = strlen(src) + 1;
1176 	error = smb_put_dmem(mbp, vcp, src, len, caseopt, NULL);
1177 	if (error)
1178 		return (error);
1179 
1180 	return (error);
1181 }
1182