summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <>2003-12-03 17:17:23 +0000
committererdgeist <>2003-12-03 17:17:23 +0000
commit243841f9486c8b922b8e071ca4b96125808353fe (patch)
tree18eebff0bca0cd63694df1be35463916e067912e
parentff183bd51957027765d8930c4eccca418f26d1ad (diff)
Negotiation Packet handling works
-rwxr-xr-xsrc/nu_header.h645
-rwxr-xr-xsrc/nu_server.c99
2 files changed, 709 insertions, 35 deletions
diff --git a/src/nu_header.h b/src/nu_header.h
index 0afdbaf..de43a08 100755
--- a/src/nu_header.h
+++ b/src/nu_header.h
@@ -1,39 +1,27 @@
1typedef unsigned char BYTE; 1typedef unsigned char BYTE;
2typedef unsigned short WORD; 2typedef unsigned short WORD;
3typedef unsigned long DWORD; 3typedef unsigned long DWORD;
4typedef int64_t QWORD;
4 5
5typedef struct { 6typedef struct {
6 BYTE netbios_command; 7 BYTE netbios_command;
7 BYTE netbios_flags; 8 BYTE netbios_flags;
8 WORD netbios_size; 9 WORD netbios_size;
9/*BYTE Protocol[4]; Protocol identifier 0xFF,"SMB" */ 10 BYTE Protocol[4]; /* Protocol identifier 0xFF,"SMB" */
10 DWORD Protocol; /* For faster compare */
11 BYTE Command; /* Command Code, look below */ 11 BYTE Command; /* Command Code, look below */
12 union { 12 BYTE Status[4];
13 struct {
14 BYTE ErrorClass;
15 BYTE Reserved;
16 WORD Error;
17 } DosError;
18 DWORD Status;
19 } Status;
20 BYTE Flags; 13 BYTE Flags;
21 WORD Flags2; 14 WORD Flags2;
22 union { 15 WORD Pad[6]; /* Ensure 12 bytes len */
23 WORD Pad[6]; /* Ensure 12 bytes len */
24 struct {
25 WORD PidHigh;
26 BYTE SecuritySignature[8];
27 } Extra;
28 };
29 WORD TreeID; 16 WORD TreeID;
30 WORD ProcessID; 17 WORD ProcessID;
31 WORD UserID; 18 WORD UserID;
32 WORD MultiplexID; 19 WORD MultiplexID;
33 BYTE WordCount; 20 BYTE WordCount;
34 WORD ParameterWords[0];
35} SMB_HEADER; 21} SMB_HEADER;
36 22
23#define SIZEOF_SMB_HEADER 37
24
37typedef struct { 25typedef struct {
38 WORD ByteCount; 26 WORD ByteCount;
39 BYTE Buffer[0]; 27 BYTE Buffer[0];
@@ -42,7 +30,7 @@ typedef struct {
42/* This is the protocol identifier, each smb 30/* This is the protocol identifier, each smb
43 request must begin with this double word 31 request must begin with this double word
44*/ 32*/
45#define SMB_HEADER_PROTOCOL_MAGIC 0xff534d42 33#define SMB_HEADER_PROTOCOL_MAGIC 0x424d53ff
46 34
47/* These are all valid SMB requests known from the document 35/* These are all valid SMB requests known from the document
48 http://www.snia.org/tech_activities/CIFS/CIFS_TR-1p00_FINAL.pdf 36 http://www.snia.org/tech_activities/CIFS/CIFS_TR-1p00_FINAL.pdf
@@ -142,3 +130,622 @@ enum {
142 SMB_COM_WRITE_BULK_DATA = 0xDA 130 SMB_COM_WRITE_BULK_DATA = 0xDA
143} SMB_COMMAND; 131} SMB_COMMAND;
144 132
133#define STATUS_SUCCESS 0x00000000
134#define STATUS_WAIT_0 0x00000000
135#define STATUS_WAIT_1 0x00000001
136#define STATUS_WAIT_2 0x00000002
137#define STATUS_WAIT_3 0x00000003
138#define STATUS_WAIT_63 0x0000003F
139#define STATUS_ABANDONED 0x00000080
140#define STATUS_ABANDONED_WAIT_0 0x00000080
141#define STATUS_ABANDONED_WAIT_63 0x000000BF
142#define STATUS_USER_APC 0x000000C0
143#define STATUS_KERNEL_APC 0x00000100
144#define STATUS_ALERTED 0x00000101
145#define STATUS_TIMEOUT 0x00000102
146#define STATUS_PENDING 0x00000103
147#define STATUS_REPARSE 0x00000104
148#define STATUS_MORE_ENTRIES 0x00000105
149#define STATUS_NOT_ALL_ASSIGNED 0x00000106
150#define STATUS_SOME_NOT_MAPPED 0x00000107
151#define STATUS_OPLOCK_BREAK_IN_PROGRESS 0x00000108
152#define STATUS_VOLUME_MOUNTED 0x00000109
153#define STATUS_RXACT_COMMITTED 0x0000010A
154#define STATUS_NOTIFY_CLEANUP 0x0000010B
155#define STATUS_NOTIFY_ENUM_DIR 0x0000010C
156#define STATUS_NO_QUOTAS_FOR_ACCOUNT 0x0000010D
157#define STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED 0x0000010E
158#define STATUS_PAGE_FAULT_TRANSITION 0x00000110
159#define STATUS_PAGE_FAULT_DEMAND_ZERO 0x00000111
160#define STATUS_PAGE_FAULT_COPY_ON_WRITE 0x00000112
161#define STATUS_PAGE_FAULT_GUARD_PAGE 0x00000113
162#define STATUS_PAGE_FAULT_PAGING_FILE 0x00000114
163#define STATUS_CACHE_PAGE_LOCKED 0x00000115
164#define STATUS_CRASH_DUMP 0x00000116
165#define STATUS_BUFFER_ALL_ZEROS 0x00000117
166#define STATUS_REPARSE_OBJECT 0x00000118
167#define STATUS_OBJECT_NAME_EXISTS 0x40000000
168#define STATUS_THREAD_WAS_SUSPENDED 0x40000001
169#define STATUS_WORKING_SET_LIMIT_RANGE 0x40000002
170#define STATUS_IMAGE_NOT_AT_BASE 0x40000003
171#define STATUS_RXACT_STATE_CREATED 0x40000004
172#define STATUS_SEGMENT_NOTIFICATION 0x40000005
173#define STATUS_LOCAL_USER_SESSION_KEY 0x40000006
174#define STATUS_BAD_CURRENT_DIRECTORY 0x40000007
175#define STATUS_SERIAL_MORE_WRITES 0x40000008
176#define STATUS_REGISTRY_RECOVERED 0x40000009
177#define STATUS_FT_READ_RECOVERY_FROM_BACKUP 0x4000000A
178#define STATUS_FT_WRITE_RECOVERY 0x4000000B
179#define STATUS_SERIAL_COUNTER_TIMEOUT 0x4000000C
180#define STATUS_NULL_LM_PASSWORD 0x4000000D
181#define STATUS_IMAGE_MACHINE_TYPE_MISMATCH 0x4000000E
182#define STATUS_RECEIVE_PARTIAL 0x4000000F
183#define STATUS_RECEIVE_EXPEDITED 0x40000010
184#define STATUS_RECEIVE_PARTIAL_EXPEDITED 0x40000011
185#define STATUS_EVENT_DONE 0x40000012
186#define STATUS_EVENT_PENDING 0x40000013
187#define STATUS_CHECKING_FILE_SYSTEM 0x40000014
188#define STATUS_FATAL_APP_EXIT 0x40000015
189#define STATUS_PREDEFINED_HANDLE 0x40000016
190#define STATUS_WAS_UNLOCKED 0x40000017
191#define STATUS_SERVICE_NOTIFICATION 0x40000018
192#define STATUS_WAS_LOCKED 0x40000019
193#define STATUS_LOG_HARD_ERROR 0x4000001A
194#define STATUS_ALREADY_WIN32 0x4000001B
195#define STATUS_WX86_UNSIMULATE 0x4000001C
196#define STATUS_WX86_CONTINUE 0x4000001D
197#define STATUS_WX86_SINGLE_STEP 0x4000001E
198#define STATUS_WX86_BREAKPOINT 0x4000001F
199#define STATUS_WX86_EXCEPTION_CONTINUE 0x40000020
200#define STATUS_WX86_EXCEPTION_LASTCHANCE 0x40000021
201#define STATUS_WX86_EXCEPTION_CHAIN 0x40000022
202#define STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE 0x40000023
203#define STATUS_NO_YIELD_PERFORMED 0x40000024
204#define STATUS_TIMER_RESUME_IGNORED 0x40000025
205#define STATUS_GUARD_PAGE_VIOLATION 0x80000001
206#define STATUS_DATATYPE_MISALIGNMENT 0x80000002
207#define STATUS_BREAKPOINT 0x80000003
208#define STATUS_SINGLE_STEP 0x80000004
209#define STATUS_BUFFER_OVERFLOW 0x80000005
210#define STATUS_NO_MORE_FILES 0x80000006
211#define STATUS_WAKE_SYSTEM_DEBUGGER 0x80000007
212#define STATUS_HANDLES_CLOSED 0x8000000A
213#define STATUS_NO_INHERITANCE 0x8000000B
214#define STATUS_GUID_SUBSTITUTION_MADE 0x8000000C
215#define STATUS_PARTIAL_COPY 0x8000000D
216#define STATUS_DEVICE_PAPER_EMPTY 0x8000000E
217#define STATUS_DEVICE_POWERED_OFF 0x8000000F
218#define STATUS_DEVICE_OFF_LINE 0x80000010
219#define STATUS_DEVICE_BUSY 0x80000011
220#define STATUS_NO_MORE_EAS 0x80000012
221#define STATUS_INVALID_EA_NAME 0x80000013
222#define STATUS_EA_LIST_INCONSISTENT 0x80000014
223#define STATUS_INVALID_EA_FLAG 0x80000015
224#define STATUS_VERIFY_REQUIRED 0x80000016
225#define STATUS_EXTRANEOUS_INFORMATION 0x80000017
226#define STATUS_RXACT_COMMIT_NECESSARY 0x80000018
227#define STATUS_NO_MORE_ENTRIES 0x8000001A
228#define STATUS_FILEMARK_DETECTED 0x8000001B
229#define STATUS_MEDIA_CHANGED 0x8000001C
230#define STATUS_BUS_RESET 0x8000001D
231#define STATUS_END_OF_MEDIA 0x8000001E
232#define STATUS_BEGINNING_OF_MEDIA 0x8000001F
233#define STATUS_MEDIA_CHECK 0x80000020
234#define STATUS_SETMARK_DETECTED 0x80000021
235#define STATUS_NO_DATA_DETECTED 0x80000022
236#define STATUS_REDIRECTOR_HAS_OPEN_HANDLES 0x80000023
237#define STATUS_SERVER_HAS_OPEN_HANDLES 0x80000024
238#define STATUS_ALREADY_DISCONNECTED 0x80000025
239#define STATUS_LONGJUMP 0x80000026
240#define STATUS_UNSUCCESSFUL 0xC0000001
241#define STATUS_NOT_IMPLEMENTED 0xC0000002
242#define STATUS_INVALID_INFO_CLASS 0xC0000003
243#define STATUS_INFO_LENGTH_MISMATCH 0xC0000004
244#define STATUS_ACCESS_VIOLATION 0xC0000005
245#define STATUS_IN_PAGE_ERROR 0xC0000006
246#define STATUS_PAGEFILE_QUOTA 0xC0000007
247#define STATUS_INVALID_HANDLE 0xC0000008
248#define STATUS_BAD_INITIAL_STACK 0xC0000009
249#define STATUS_BAD_INITIAL_PC 0xC000000A
250#define STATUS_INVALID_CID 0xC000000B
251#define STATUS_TIMER_NOT_CANCELED 0xC000000C
252#define STATUS_INVALID_PARAMETER 0xC000000D
253#define STATUS_NO_SUCH_DEVICE 0xC000000E
254#define STATUS_NO_SUCH_FILE 0xC000000F
255#define STATUS_INVALID_DEVICE_REQUEST 0xC0000010
256#define STATUS_END_OF_FILE 0xC0000011
257#define STATUS_WRONG_VOLUME 0xC0000012
258#define STATUS_NO_MEDIA_IN_DEVICE 0xC0000013
259#define STATUS_UNRECOGNIZED_MEDIA 0xC0000014
260#define STATUS_NONEXISTENT_SECTOR 0xC0000015
261#define STATUS_MORE_PROCESSING_REQUIRED 0xC0000016
262#define STATUS_NO_MEMORY 0xC0000017
263#define STATUS_CONFLICTING_ADDRESSES 0xC0000018
264#define STATUS_NOT_MAPPED_VIEW 0xC0000019
265#define STATUS_UNABLE_TO_FREE_VM 0xC000001A
266#define STATUS_UNABLE_TO_DELETE_SECTION 0xC000001B
267#define STATUS_INVALID_SYSTEM_SERVICE 0xC000001C
268#define STATUS_ILLEGAL_INSTRUCTION 0xC000001D
269#define STATUS_INVALID_LOCK_SEQUENCE 0xC000001E
270#define STATUS_INVALID_VIEW_SIZE 0xC000001F
271#define STATUS_INVALID_FILE_FOR_SECTION 0xC0000020
272#define STATUS_ALREADY_COMMITTED 0xC0000021
273#define STATUS_ACCESS_DENIED 0xC0000022
274#define STATUS_BUFFER_TOO_SMALL 0xC0000023
275#define STATUS_OBJECT_TYPE_MISMATCH 0xC0000024
276#define STATUS_NONCONTINUABLE_EXCEPTION 0xC0000025
277#define STATUS_INVALID_DISPOSITION 0xC0000026
278#define STATUS_UNWIND 0xC0000027
279#define STATUS_BAD_STACK 0xC0000028
280#define STATUS_INVALID_UNWIND_TARGET 0xC0000029
281#define STATUS_NOT_LOCKED 0xC000002A
282#define STATUS_PARITY_ERROR 0xC000002B
283#define STATUS_UNABLE_TO_DECOMMIT_VM 0xC000002C
284#define STATUS_NOT_COMMITTED 0xC000002D
285#define STATUS_INVALID_PORT_ATTRIBUTES 0xC000002E
286#define STATUS_PORT_MESSAGE_TOO_LONG 0xC000002F
287#define STATUS_INVALID_PARAMETER_MIX 0xC0000030
288#define STATUS_INVALID_QUOTA_LOWER 0xC0000031
289#define STATUS_DISK_CORRUPT_ERROR 0xC0000032
290#define STATUS_OBJECT_NAME_INVALID 0xC0000033
291#define STATUS_OBJECT_NAME_NOT_FOUND 0xC0000034
292#define STATUS_OBJECT_NAME_COLLISION 0xC0000035
293#define STATUS_PORT_DISCONNECTED 0xC0000037
294#define STATUS_DEVICE_ALREADY_ATTACHED 0xC0000038
295#define STATUS_OBJECT_PATH_INVALID 0xC0000039
296#define STATUS_OBJECT_PATH_NOT_FOUND 0xC000003A
297#define STATUS_OBJECT_PATH_SYNTAX_BAD 0xC000003B
298#define STATUS_DATA_OVERRUN 0xC000003C
299#define STATUS_DATA_LATE_ERROR 0xC000003D
300#define STATUS_DATA_ERROR 0xC000003E
301#define STATUS_CRC_ERROR 0xC000003F
302#define STATUS_SECTION_TOO_BIG 0xC0000040
303#define STATUS_PORT_CONNECTION_REFUSED 0xC0000041
304#define STATUS_INVALID_PORT_HANDLE 0xC0000042
305#define STATUS_SHARING_VIOLATION 0xC0000043
306#define STATUS_QUOTA_EXCEEDED 0xC0000044
307#define STATUS_INVALID_PAGE_PROTECTION 0xC0000045
308#define STATUS_MUTANT_NOT_OWNED 0xC0000046
309#define STATUS_SEMAPHORE_LIMIT_EXCEEDED 0xC0000047
310#define STATUS_PORT_ALREADY_SET 0xC0000048
311#define STATUS_SECTION_NOT_IMAGE 0xC0000049
312#define STATUS_SUSPEND_COUNT_EXCEEDED 0xC000004A
313#define STATUS_THREAD_IS_TERMINATING 0xC000004B
314#define STATUS_BAD_WORKING_SET_LIMIT 0xC000004C
315#define STATUS_INCOMPATIBLE_FILE_MAP 0xC000004D
316#define STATUS_SECTION_PROTECTION 0xC000004E
317#define STATUS_EAS_NOT_SUPPORTED 0xC000004F
318#define STATUS_EA_TOO_LARGE 0xC0000050
319#define STATUS_NONEXISTENT_EA_ENTRY 0xC0000051
320#define STATUS_NO_EAS_ON_FILE 0xC0000052
321#define STATUS_EA_CORRUPT_ERROR 0xC0000053
322#define STATUS_FILE_LOCK_CONFLICT 0xC0000054
323#define STATUS_LOCK_NOT_GRANTED 0xC0000055
324#define STATUS_DELETE_PENDING 0xC0000056
325#define STATUS_CTL_FILE_NOT_SUPPORTED 0xC0000057
326#define STATUS_UNKNOWN_REVISION 0xC0000058
327#define STATUS_REVISION_MISMATCH 0xC0000059
328#define STATUS_INVALID_OWNER 0xC000005A
329#define STATUS_INVALID_PRIMARY_GROUP 0xC000005B
330#define STATUS_NO_IMPERSONATION_TOKEN 0xC000005C
331#define STATUS_CANT_DISABLE_MANDATORY 0xC000005D
332#define STATUS_NO_LOGON_SERVERS 0xC000005E
333#define STATUS_NO_SUCH_LOGON_SESSION 0xC000005F
334#define STATUS_NO_SUCH_PRIVILEGE 0xC0000060
335#define STATUS_PRIVILEGE_NOT_HELD 0xC0000061
336#define STATUS_INVALID_ACCOUNT_NAME 0xC0000062
337#define STATUS_USER_EXISTS 0xC0000063
338#define STATUS_NO_SUCH_USER 0xC0000064
339#define STATUS_GROUP_EXISTS 0xC0000065
340#define STATUS_NO_SUCH_GROUP 0xC0000066
341#define STATUS_MEMBER_IN_GROUP 0xC0000067
342#define STATUS_MEMBER_NOT_IN_GROUP 0xC0000068
343#define STATUS_LAST_ADMIN 0xC0000069
344#define STATUS_WRONG_PASSWORD 0xC000006A
345#define STATUS_ILL_FORMED_PASSWORD 0xC000006B
346#define STATUS_PASSWORD_RESTRICTION 0xC000006C
347#define STATUS_LOGON_FAILURE 0xC000006D
348#define STATUS_ACCOUNT_RESTRICTION 0xC000006E
349#define STATUS_INVALID_LOGON_HOURS 0xC000006F
350#define STATUS_INVALID_WORKSTATION 0xC0000070
351#define STATUS_PASSWORD_EXPIRED 0xC0000071
352#define STATUS_ACCOUNT_DISABLED 0xC0000072
353#define STATUS_NONE_MAPPED 0xC0000073
354#define STATUS_TOO_MANY_LUIDS_REQUESTED 0xC0000074
355#define STATUS_LUIDS_EXHAUSTED 0xC0000075
356#define STATUS_INVALID_SUB_AUTHORITY 0xC0000076
357#define STATUS_INVALID_ACL 0xC0000077
358#define STATUS_INVALID_SID 0xC0000078
359#define STATUS_INVALID_SECURITY_DESCR 0xC0000079
360#define STATUS_PROCEDURE_NOT_FOUND 0xC000007A
361#define STATUS_INVALID_IMAGE_FORMAT 0xC000007B
362#define STATUS_NO_TOKEN 0xC000007C
363#define STATUS_BAD_INHERITANCE_ACL 0xC000007D
364#define STATUS_RANGE_NOT_LOCKED 0xC000007E
365#define STATUS_DISK_FULL 0xC000007F
366#define STATUS_SERVER_DISABLED 0xC0000080
367#define STATUS_SERVER_NOT_DISABLED 0xC0000081
368#define STATUS_TOO_MANY_GUIDS_REQUESTED 0xC0000082
369#define STATUS_GUIDS_EXHAUSTED 0xC0000083
370#define STATUS_INVALID_ID_AUTHORITY 0xC0000084
371#define STATUS_AGENTS_EXHAUSTED 0xC0000085
372#define STATUS_INVALID_VOLUME_LABEL 0xC0000086
373#define STATUS_SECTION_NOT_EXTENDED 0xC0000087
374#define STATUS_NOT_MAPPED_DATA 0xC0000088
375#define STATUS_RESOURCE_DATA_NOT_FOUND 0xC0000089
376#define STATUS_RESOURCE_TYPE_NOT_FOUND 0xC000008A
377#define STATUS_RESOURCE_NAME_NOT_FOUND 0xC000008B
378#define STATUS_ARRAY_BOUNDS_EXCEEDED 0xC000008C
379#define STATUS_FLOAT_DENORMAL_OPERAND 0xC000008D
380#define STATUS_FLOAT_DIVIDE_BY_ZERO 0xC000008E
381#define STATUS_FLOAT_INEXACT_RESULT 0xC000008F
382#define STATUS_FLOAT_INVALID_OPERATION 0xC0000090
383#define STATUS_FLOAT_OVERFLOW 0xC0000091
384#define STATUS_FLOAT_STACK_CHECK 0xC0000092
385#define STATUS_FLOAT_UNDERFLOW 0xC0000093
386#define STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000094
387#define STATUS_INTEGER_OVERFLOW 0xC0000095
388#define STATUS_PRIVILEGED_INSTRUCTION 0xC0000096
389#define STATUS_TOO_MANY_PAGING_FILES 0xC0000097
390#define STATUS_FILE_INVALID 0xC0000098
391#define STATUS_ALLOTTED_SPACE_EXCEEDED 0xC0000099
392#define STATUS_INSUFFICIENT_RESOURCES 0xC000009A
393#define STATUS_DFS_EXIT_PATH_FOUND 0xC000009B
394#define STATUS_DEVICE_DATA_ERROR 0xC000009C
395#define STATUS_DEVICE_NOT_CONNECTED 0xC000009D
396#define STATUS_DEVICE_POWER_FAILURE 0xC000009E
397#define STATUS_FREE_VM_NOT_AT_BASE 0xC000009F
398#define STATUS_MEMORY_NOT_ALLOCATED 0xC00000A0
399#define STATUS_WORKING_SET_QUOTA 0xC00000A1
400#define STATUS_MEDIA_WRITE_PROTECTED 0xC00000A2
401#define STATUS_DEVICE_NOT_READY 0xC00000A3
402#define STATUS_INVALID_GROUP_ATTRIBUTES 0xC00000A4
403#define STATUS_BAD_IMPERSONATION_LEVEL 0xC00000A5
404#define STATUS_CANT_OPEN_ANONYMOUS 0xC00000A6
405#define STATUS_BAD_VALIDATION_CLASS 0xC00000A7
406#define STATUS_BAD_TOKEN_TYPE 0xC00000A8
407#define STATUS_BAD_MASTER_BOOT_RECORD 0xC00000A9
408#define STATUS_INSTRUCTION_MISALIGNMENT 0xC00000AA
409#define STATUS_INSTANCE_NOT_AVAILABLE 0xC00000AB
410#define STATUS_PIPE_NOT_AVAILABLE 0xC00000AC
411#define STATUS_INVALID_PIPE_STATE 0xC00000AD
412#define STATUS_PIPE_BUSY 0xC00000AE
413#define STATUS_ILLEGAL_FUNCTION 0xC00000AF
414#define STATUS_PIPE_DISCONNECTED 0xC00000B0
415#define STATUS_PIPE_CLOSING 0xC00000B1
416#define STATUS_PIPE_CONNECTED 0xC00000B2
417#define STATUS_PIPE_LISTENING 0xC00000B3
418#define STATUS_INVALID_READ_MODE 0xC00000B4
419#define STATUS_IO_TIMEOUT 0xC00000B5
420#define STATUS_FILE_FORCED_CLOSED 0xC00000B6
421#define STATUS_PROFILING_NOT_STARTED 0xC00000B7
422#define STATUS_PROFILING_NOT_STOPPED 0xC00000B8
423#define STATUS_COULD_NOT_INTERPRET 0xC00000B9
424#define STATUS_FILE_IS_A_DIRECTORY 0xC00000BA
425#define STATUS_NOT_SUPPORTED 0xC00000BB
426#define STATUS_REMOTE_NOT_LISTENING 0xC00000BC
427#define STATUS_DUPLICATE_NAME 0xC00000BD
428#define STATUS_BAD_NETWORK_PATH 0xC00000BE
429#define STATUS_NETWORK_BUSY 0xC00000BF
430#define STATUS_DEVICE_DOES_NOT_EXIST 0xC00000C0
431#define STATUS_TOO_MANY_COMMANDS 0xC00000C1
432#define STATUS_ADAPTER_HARDWARE_ERROR 0xC00000C2
433#define STATUS_INVALID_NETWORK_RESPONSE 0xC00000C3
434#define STATUS_UNEXPECTED_NETWORK_ERROR 0xC00000C4
435#define STATUS_BAD_REMOTE_ADAPTER 0xC00000C5
436#define STATUS_PRINT_QUEUE_FULL 0xC00000C6
437#define STATUS_NO_SPOOL_SPACE 0xC00000C7
438#define STATUS_PRINT_CANCELLED 0xC00000C8
439#define STATUS_NETWORK_NAME_DELETED 0xC00000C9
440#define STATUS_NETWORK_ACCESS_DENIED 0xC00000CA
441#define STATUS_BAD_DEVICE_TYPE 0xC00000CB
442#define STATUS_BAD_NETWORK_NAME 0xC00000CC
443#define STATUS_TOO_MANY_NAMES 0xC00000CD
444#define STATUS_TOO_MANY_SESSIONS 0xC00000CE
445#define STATUS_SHARING_PAUSED 0xC00000CF
446#define STATUS_REQUEST_NOT_ACCEPTED 0xC00000D0
447#define STATUS_REDIRECTOR_PAUSED 0xC00000D1
448#define STATUS_NET_WRITE_FAULT 0xC00000D2
449#define STATUS_PROFILING_AT_LIMIT 0xC00000D3
450#define STATUS_NOT_SAME_DEVICE 0xC00000D4
451#define STATUS_FILE_RENAMED 0xC00000D5
452#define STATUS_VIRTUAL_CIRCUIT_CLOSED 0xC00000D6
453#define STATUS_NO_SECURITY_ON_OBJECT 0xC00000D7
454#define STATUS_CANT_WAIT 0xC00000D8
455#define STATUS_PIPE_EMPTY 0xC00000D9
456#define STATUS_CANT_ACCESS_DOMAIN_INFO 0xC00000DA
457#define STATUS_CANT_TERMINATE_SELF 0xC00000DB
458#define STATUS_INVALID_SERVER_STATE 0xC00000DC
459#define STATUS_INVALID_DOMAIN_STATE 0xC00000DD
460#define STATUS_INVALID_DOMAIN_ROLE 0xC00000DE
461#define STATUS_NO_SUCH_DOMAIN 0xC00000DF
462#define STATUS_DOMAIN_EXISTS 0xC00000E0
463#define STATUS_DOMAIN_LIMIT_EXCEEDED 0xC00000E1
464#define STATUS_OPLOCK_NOT_GRANTED 0xC00000E2
465#define STATUS_INVALID_OPLOCK_PROTOCOL 0xC00000E3
466#define STATUS_INTERNAL_DB_CORRUPTION 0xC00000E4
467#define STATUS_INTERNAL_ERROR 0xC00000E5
468#define STATUS_GENERIC_NOT_MAPPED 0xC00000E6
469#define STATUS_BAD_DESCRIPTOR_FORMAT 0xC00000E7
470#define STATUS_INVALID_USER_BUFFER 0xC00000E8
471#define STATUS_UNEXPECTED_IO_ERROR 0xC00000E9
472#define STATUS_UNEXPECTED_MM_CREATE_ERR 0xC00000EA
473#define STATUS_UNEXPECTED_MM_MAP_ERROR 0xC00000EB
474#define STATUS_UNEXPECTED_MM_EXTEND_ERR 0xC00000EC
475#define STATUS_NOT_LOGON_PROCESS 0xC00000ED
476#define STATUS_LOGON_SESSION_EXISTS 0xC00000EE
477#define STATUS_INVALID_PARAMETER_1 0xC00000EF
478#define STATUS_INVALID_PARAMETER_2 0xC00000F0
479#define STATUS_INVALID_PARAMETER_3 0xC00000F1
480#define STATUS_INVALID_PARAMETER_4 0xC00000F2
481#define STATUS_INVALID_PARAMETER_5 0xC00000F3
482#define STATUS_INVALID_PARAMETER_6 0xC00000F4
483#define STATUS_INVALID_PARAMETER_7 0xC00000F5
484#define STATUS_INVALID_PARAMETER_8 0xC00000F6
485#define STATUS_INVALID_PARAMETER_9 0xC00000F7
486#define STATUS_INVALID_PARAMETER_10 0xC00000F8
487#define STATUS_INVALID_PARAMETER_11 0xC00000F9
488#define STATUS_INVALID_PARAMETER_12 0xC00000FA
489#define STATUS_REDIRECTOR_NOT_STARTED 0xC00000FB
490#define STATUS_REDIRECTOR_STARTED 0xC00000FC
491#define STATUS_STACK_OVERFLOW 0xC00000FD
492#define STATUS_NO_SUCH_PACKAGE 0xC00000FE
493#define STATUS_BAD_FUNCTION_TABLE 0xC00000FF
494#define STATUS_VARIABLE_NOT_FOUND 0xC0000100
495#define STATUS_DIRECTORY_NOT_EMPTY 0xC0000101
496#define STATUS_FILE_CORRUPT_ERROR 0xC0000102
497#define STATUS_NOT_A_DIRECTORY 0xC0000103
498#define STATUS_BAD_LOGON_SESSION_STATE 0xC0000104
499#define STATUS_LOGON_SESSION_COLLISION 0xC0000105
500#define STATUS_NAME_TOO_LONG 0xC0000106
501#define STATUS_FILES_OPEN 0xC0000107
502#define STATUS_CONNECTION_IN_USE 0xC0000108
503#define STATUS_MESSAGE_NOT_FOUND 0xC0000109
504#define STATUS_PROCESS_IS_TERMINATING 0xC000010A
505#define STATUS_INVALID_LOGON_TYPE 0xC000010B
506#define STATUS_NO_GUID_TRANSLATION 0xC000010C
507#define STATUS_CANNOT_IMPERSONATE 0xC000010D
508#define STATUS_IMAGE_ALREADY_LOADED 0xC000010E
509#define STATUS_ABIOS_NOT_PRESENT 0xC000010F
510#define STATUS_ABIOS_LID_NOT_EXIST 0xC0000110
511#define STATUS_ABIOS_LID_ALREADY_OWNED 0xC0000111
512#define STATUS_ABIOS_NOT_LID_OWNER 0xC0000112
513#define STATUS_ABIOS_INVALID_COMMAND 0xC0000113
514#define STATUS_ABIOS_INVALID_LID 0xC0000114
515#define STATUS_ABIOS_SELECTOR_NOT_AVAILABLE 0xC0000115
516#define STATUS_ABIOS_INVALID_SELECTOR 0xC0000116
517#define STATUS_NO_LDT 0xC0000117
518#define STATUS_INVALID_LDT_SIZE 0xC0000118
519#define STATUS_INVALID_LDT_OFFSET 0xC0000119
520#define STATUS_INVALID_LDT_DESCRIPTOR 0xC000011A
521#define STATUS_INVALID_IMAGE_NE_FORMAT 0xC000011B
522#define STATUS_RXACT_INVALID_STATE 0xC000011C
523#define STATUS_RXACT_COMMIT_FAILURE 0xC000011D
524#define STATUS_MAPPED_FILE_SIZE_ZERO 0xC000011E
525#define STATUS_TOO_MANY_OPENED_FILES 0xC000011F
526#define STATUS_CANCELLED 0xC0000120
527#define STATUS_CANNOT_DELETE 0xC0000121
528#define STATUS_INVALID_COMPUTER_NAME 0xC0000122
529#define STATUS_FILE_DELETED 0xC0000123
530#define STATUS_SPECIAL_ACCOUNT 0xC0000124
531#define STATUS_SPECIAL_GROUP 0xC0000125
532#define STATUS_SPECIAL_USER 0xC0000126
533#define STATUS_MEMBERS_PRIMARY_GROUP 0xC0000127
534#define STATUS_FILE_CLOSED 0xC0000128
535#define STATUS_TOO_MANY_THREADS 0xC0000129
536#define STATUS_THREAD_NOT_IN_PROCESS 0xC000012A
537#define STATUS_TOKEN_ALREADY_IN_USE 0xC000012B
538#define STATUS_PAGEFILE_QUOTA_EXCEEDED 0xC000012C
539#define STATUS_COMMITMENT_LIMIT 0xC000012D
540#define STATUS_INVALID_IMAGE_LE_FORMAT 0xC000012E
541#define STATUS_INVALID_IMAGE_NOT_MZ 0xC000012F
542#define STATUS_INVALID_IMAGE_PROTECT 0xC0000130
543#define STATUS_INVALID_IMAGE_WIN_16 0xC0000131
544#define STATUS_LOGON_SERVER_CONFLICT 0xC0000132
545#define STATUS_TIME_DIFFERENCE_AT_DC 0xC0000133
546#define STATUS_SYNCHRONIZATION_REQUIRED 0xC0000134
547#define STATUS_DLL_NOT_FOUND 0xC0000135
548#define STATUS_OPEN_FAILED 0xC0000136
549#define STATUS_IO_PRIVILEGE_FAILED 0xC0000137
550#define STATUS_ORDINAL_NOT_FOUND 0xC0000138
551#define STATUS_ENTRYPOINT_NOT_FOUND 0xC0000139
552#define STATUS_CONTROL_C_EXIT 0xC000013A
553#define STATUS_LOCAL_DISCONNECT 0xC000013B
554#define STATUS_REMOTE_DISCONNECT 0xC000013C
555#define STATUS_REMOTE_RESOURCES 0xC000013D
556#define STATUS_LINK_FAILED 0xC000013E
557#define STATUS_LINK_TIMEOUT 0xC000013F
558#define STATUS_INVALID_CONNECTION 0xC0000140
559#define STATUS_INVALID_ADDRESS 0xC0000141
560#define STATUS_DLL_INIT_FAILED 0xC0000142
561#define STATUS_MISSING_SYSTEMFILE 0xC0000143
562#define STATUS_UNHANDLED_EXCEPTION 0xC0000144
563#define STATUS_APP_INIT_FAILURE 0xC0000145
564#define STATUS_PAGEFILE_CREATE_FAILED 0xC0000146
565#define STATUS_NO_PAGEFILE 0xC0000147
566#define STATUS_INVALID_LEVEL 0xC0000148
567#define STATUS_WRONG_PASSWORD_CORE 0xC0000149
568#define STATUS_ILLEGAL_FLOAT_CONTEXT 0xC000014A
569#define STATUS_PIPE_BROKEN 0xC000014B
570#define STATUS_REGISTRY_CORRUPT 0xC000014C
571#define STATUS_REGISTRY_IO_FAILED 0xC000014D
572#define STATUS_NO_EVENT_PAIR 0xC000014E
573#define STATUS_UNRECOGNIZED_VOLUME 0xC000014F
574#define STATUS_SERIAL_NO_DEVICE_INITED 0xC0000150
575#define STATUS_NO_SUCH_ALIAS 0xC0000151
576#define STATUS_MEMBER_NOT_IN_ALIAS 0xC0000152
577#define STATUS_MEMBER_IN_ALIAS 0xC0000153
578#define STATUS_ALIAS_EXISTS 0xC0000154
579#define STATUS_LOGON_NOT_GRANTED 0xC0000155
580#define STATUS_TOO_MANY_SECRETS 0xC0000156
581#define STATUS_SECRET_TOO_LONG 0xC0000157
582#define STATUS_INTERNAL_DB_ERROR 0xC0000158
583#define STATUS_FULLSCREEN_MODE 0xC0000159
584#define STATUS_TOO_MANY_CONTEXT_IDS 0xC000015A
585#define STATUS_LOGON_TYPE_NOT_GRANTED 0xC000015B
586#define STATUS_NOT_REGISTRY_FILE 0xC000015C
587#define STATUS_NT_CROSS_ENCRYPTION_REQUIRED 0xC000015D
588#define STATUS_DOMAIN_CTRLR_CONFIG_ERROR 0xC000015E
589#define STATUS_FT_MISSING_MEMBER 0xC000015F
590#define STATUS_ILL_FORMED_SERVICE_ENTRY 0xC0000160
591#define STATUS_ILLEGAL_CHARACTER 0xC0000161
592#define STATUS_UNMAPPABLE_CHARACTER 0xC0000162
593#define STATUS_UNDEFINED_CHARACTER 0xC0000163
594#define STATUS_FLOPPY_VOLUME 0xC0000164
595#define STATUS_FLOPPY_ID_MARK_NOT_FOUND 0xC0000165
596#define STATUS_FLOPPY_WRONG_CYLINDER 0xC0000166
597#define STATUS_FLOPPY_UNKNOWN_ERROR 0xC0000167
598#define STATUS_FLOPPY_BAD_REGISTERS 0xC0000168
599#define STATUS_DISK_RECALIBRATE_FAILED 0xC0000169
600#define STATUS_DISK_OPERATION_FAILED 0xC000016A
601#define STATUS_DISK_RESET_FAILED 0xC000016B
602#define STATUS_SHARED_IRQ_BUSY 0xC000016C
603#define STATUS_FT_ORPHANING 0xC000016D
604#define STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT 0xC000016E
605#define STATUS_PARTITION_FAILURE 0xC0000172
606#define STATUS_INVALID_BLOCK_LENGTH 0xC0000173
607#define STATUS_DEVICE_NOT_PARTITIONED 0xC0000174
608#define STATUS_UNABLE_TO_LOCK_MEDIA 0xC0000175
609#define STATUS_UNABLE_TO_UNLOAD_MEDIA 0xC0000176
610#define STATUS_EOM_OVERFLOW 0xC0000177
611#define STATUS_NO_MEDIA 0xC0000178
612#define STATUS_NO_SUCH_MEMBER 0xC000017A
613#define STATUS_INVALID_MEMBER 0xC000017B
614#define STATUS_KEY_DELETED 0xC000017C
615#define STATUS_NO_LOG_SPACE 0xC000017D
616#define STATUS_TOO_MANY_SIDS 0xC000017E
617#define STATUS_LM_CROSS_ENCRYPTION_REQUIRED 0xC000017F
618#define STATUS_KEY_HAS_CHILDREN 0xC0000180
619#define STATUS_CHILD_MUST_BE_VOLATILE 0xC0000181
620#define STATUS_DEVICE_CONFIGURATION_ERROR 0xC0000182
621#define STATUS_DRIVER_INTERNAL_ERROR 0xC0000183
622#define STATUS_INVALID_DEVICE_STATE 0xC0000184
623#define STATUS_IO_DEVICE_ERROR 0xC0000185
624#define STATUS_DEVICE_PROTOCOL_ERROR 0xC0000186
625#define STATUS_BACKUP_CONTROLLER 0xC0000187
626#define STATUS_LOG_FILE_FULL 0xC0000188
627#define STATUS_TOO_LATE 0xC0000189
628#define STATUS_NO_TRUST_LSA_SECRET 0xC000018A
629#define STATUS_NO_TRUST_SAM_ACCOUNT 0xC000018B
630#define STATUS_TRUSTED_DOMAIN_FAILURE 0xC000018C
631#define STATUS_TRUSTED_RELATIONSHIP_FAILURE 0xC000018D
632#define STATUS_EVENTLOG_FILE_CORRUPT 0xC000018E
633#define STATUS_EVENTLOG_CANT_START 0xC000018F
634#define STATUS_TRUST_FAILURE 0xC0000190
635#define STATUS_MUTANT_LIMIT_EXCEEDED 0xC0000191
636#define STATUS_NETLOGON_NOT_STARTED 0xC0000192
637#define STATUS_ACCOUNT_EXPIRED 0xC0000193
638#define STATUS_POSSIBLE_DEADLOCK 0xC0000194
639#define STATUS_NETWORK_CREDENTIAL_CONFLICT 0xC0000195
640#define STATUS_REMOTE_SESSION_LIMIT 0xC0000196
641#define STATUS_EVENTLOG_FILE_CHANGED 0xC0000197
642#define STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0xC0000198
643#define STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0xC0000199
644#define STATUS_NOLOGON_SERVER_TRUST_ACCOUNT 0xC000019A
645#define STATUS_DOMAIN_TRUST_INCONSISTENT 0xC000019B
646#define STATUS_FS_DRIVER_REQUIRED 0xC000019C
647#define STATUS_NO_USER_SESSION_KEY 0xC0000202
648#define STATUS_USER_SESSION_DELETED 0xC0000203
649#define STATUS_RESOURCE_LANG_NOT_FOUND 0xC0000204
650#define STATUS_INSUFF_SERVER_RESOURCES 0xC0000205
651#define STATUS_INVALID_BUFFER_SIZE 0xC0000206
652#define STATUS_INVALID_ADDRESS_COMPONENT 0xC0000207
653#define STATUS_INVALID_ADDRESS_WILDCARD 0xC0000208
654#define STATUS_TOO_MANY_ADDRESSES 0xC0000209
655#define STATUS_ADDRESS_ALREADY_EXISTS 0xC000020A
656#define STATUS_ADDRESS_CLOSED 0xC000020B
657#define STATUS_CONNECTION_DISCONNECTED 0xC000020C
658#define STATUS_CONNECTION_RESET 0xC000020D
659#define STATUS_TOO_MANY_NODES 0xC000020E
660#define STATUS_TRANSACTION_ABORTED 0xC000020F
661#define STATUS_TRANSACTION_TIMED_OUT 0xC0000210
662#define STATUS_TRANSACTION_NO_RELEASE 0xC0000211
663#define STATUS_TRANSACTION_NO_MATCH 0xC0000212
664#define STATUS_TRANSACTION_RESPONDED 0xC0000213
665#define STATUS_TRANSACTION_INVALID_ID 0xC0000214
666#define STATUS_TRANSACTION_INVALID_TYPE 0xC0000215
667#define STATUS_NOT_SERVER_SESSION 0xC0000216
668#define STATUS_NOT_CLIENT_SESSION 0xC0000217
669#define STATUS_CANNOT_LOAD_REGISTRY_FILE 0xC0000218
670#define STATUS_DEBUG_ATTACH_FAILED 0xC0000219
671#define STATUS_SYSTEM_PROCESS_TERMINATED 0xC000021A
672#define STATUS_DATA_NOT_ACCEPTED 0xC000021B
673#define STATUS_NO_BROWSER_SERVERS_FOUND 0xC000021C
674#define STATUS_VDM_HARD_ERROR 0xC000021D
675#define STATUS_DRIVER_CANCEL_TIMEOUT 0xC000021E
676#define STATUS_REPLY_MESSAGE_MISMATCH 0xC000021F
677#define STATUS_MAPPED_ALIGNMENT 0xC0000220
678#define STATUS_IMAGE_CHECKSUM_MISMATCH 0xC0000221
679#define STATUS_LOST_WRITEBEHIND_DATA 0xC0000222
680#define STATUS_CLIENT_SERVER_PARAMETERS_INVALID 0xC0000223
681#define STATUS_PASSWORD_MUST_CHANGE 0xC0000224
682#define STATUS_NOT_FOUND 0xC0000225
683#define STATUS_NOT_TINY_STREAM 0xC0000226
684#define STATUS_RECOVERY_FAILURE 0xC0000227
685#define STATUS_STACK_OVERFLOW_READ 0xC0000228
686#define STATUS_FAIL_CHECK 0xC0000229
687#define STATUS_DUPLICATE_OBJECTID 0xC000022A
688#define STATUS_OBJECTID_EXISTS 0xC000022B
689#define STATUS_CONVERT_TO_LARGE 0xC000022C
690#define STATUS_RETRY 0xC000022D
691#define STATUS_FOUND_OUT_OF_SCOPE 0xC000022E
692#define STATUS_ALLOCATE_BUCKET 0xC000022F
693#define STATUS_PROPSET_NOT_FOUND 0xC0000230
694#define STATUS_MARSHALL_OVERFLOW 0xC0000231
695#define STATUS_INVALID_VARIANT 0xC0000232
696#define STATUS_DOMAIN_CONTROLLER_NOT_FOUND 0xC0000233
697#define STATUS_ACCOUNT_LOCKED_OUT 0xC0000234
698#define STATUS_HANDLE_NOT_CLOSABLE 0xC0000235
699#define STATUS_CONNECTION_REFUSED 0xC0000236
700#define STATUS_GRACEFUL_DISCONNECT 0xC0000237
701#define STATUS_ADDRESS_ALREADY_ASSOCIATED 0xC0000238
702#define STATUS_ADDRESS_NOT_ASSOCIATED 0xC0000239
703#define STATUS_CONNECTION_INVALID 0xC000023A
704#define STATUS_CONNECTION_ACTIVE 0xC000023B
705#define STATUS_NETWORK_UNREACHABLE 0xC000023C
706#define STATUS_HOST_UNREACHABLE 0xC000023D
707#define STATUS_PROTOCOL_UNREACHABLE 0xC000023E
708#define STATUS_PORT_UNREACHABLE 0xC000023F
709#define STATUS_REQUEST_ABORTED 0xC0000240
710#define STATUS_CONNECTION_ABORTED 0xC0000241
711#define STATUS_BAD_COMPRESSION_BUFFER 0xC0000242
712#define STATUS_USER_MAPPED_FILE 0xC0000243
713#define STATUS_AUDIT_FAILED 0xC0000244
714#define STATUS_TIMER_RESOLUTION_NOT_SET 0xC0000245
715#define STATUS_CONNECTION_COUNT_LIMIT 0xC0000246
716#define STATUS_LOGIN_TIME_RESTRICTION 0xC0000247
717#define STATUS_LOGIN_WKSTA_RESTRICTION 0xC0000248
718#define STATUS_IMAGE_MP_UP_MISMATCH 0xC0000249
719#define STATUS_INSUFFICIENT_LOGON_INFO 0xC0000250
720#define STATUS_BAD_DLL_ENTRYPOINT 0xC0000251
721#define STATUS_BAD_SERVICE_ENTRYPOINT 0xC0000252
722#define STATUS_LPC_REPLY_LOST 0xC0000253
723#define STATUS_IP_ADDRESS_CONFLICT1 0xC0000254
724#define STATUS_IP_ADDRESS_CONFLICT2 0xC0000255
725#define STATUS_REGISTRY_QUOTA_LIMIT 0xC0000256
726#define STATUS_PATH_NOT_COVERED 0xC0000257
727#define STATUS_NO_CALLBACK_ACTIVE 0xC0000258
728#define STATUS_LICENSE_QUOTA_EXCEEDED 0xC0000259
729#define STATUS_PWD_TOO_SHORT 0xC000025A
730#define STATUS_PWD_TOO_RECENT 0xC000025B
731#define STATUS_PWD_HISTORY_CONFLICT 0xC000025C
732#define STATUS_PLUGPLAY_NO_DEVICE 0xC000025E
733#define STATUS_UNSUPPORTED_COMPRESSION 0xC000025F
734#define STATUS_INVALID_HW_PROFILE 0xC0000260
735#define STATUS_INVALID_PLUGPLAY_DEVICE_PATH 0xC0000261
736#define STATUS_DRIVER_ORDINAL_NOT_FOUND 0xC0000262
737#define STATUS_DRIVER_ENTRYPOINT_NOT_FOUND 0xC0000263
738#define STATUS_RESOURCE_NOT_OWNED 0xC0000264
739#define STATUS_TOO_MANY_LINKS 0xC0000265
740#define STATUS_QUOTA_LIST_INCONSISTENT 0xC0000266
741#define STATUS_FILE_IS_OFFLINE 0xC0000267
742#define STATUS_EVALUATION_EXPIRATION 0xC0000268
743#define STATUS_ILLEGAL_DLL_RELOCATION 0xC0000269
744#define STATUS_LICENSE_VIOLATION 0xC000026A
745#define STATUS_DLL_INIT_FAILED_LOGOFF 0xC000026B
746#define STATUS_DRIVER_UNABLE_TO_LOAD 0xC000026C
747#define STATUS_DFS_UNAVAILABLE 0xC000026D
748#define STATUS_VOLUME_DISMOUNTED 0xC000026E
749#define STATUS_WX86_INTERNAL_ERROR 0xC000026F
750#define STATUS_WX86_FLOAT_STACK_CHECK 0xC0000270
751#define STATUS_WOW_ASSERTION 0xC0009898
diff --git a/src/nu_server.c b/src/nu_server.c
index 942be1b..29819ee 100755
--- a/src/nu_server.c
+++ b/src/nu_server.c
@@ -1,3 +1,5 @@
1#include <time.h>
2#include <fcntl.h>
1#include <signal.h> 3#include <signal.h>
2#include <sys/types.h> 4#include <sys/types.h>
3#include <sys/socket.h> 5#include <sys/socket.h>
@@ -8,29 +10,64 @@
8#include "nu_header.h" 10#include "nu_header.h"
9 11
10static void bailout( char *reason ); 12static void bailout( char *reason );
13static void sigint( int reason ) { bailout( "User interrupt." ); }
14static void packet_dump( SMB_HEADER *buf );
11static mainsock = -1; 15static mainsock = -1;
12static childsock = -1; 16static childsock = -1;
13 17
18static QWORD getnttime( struct timeval *t ) {
19 return 10000000ll * ( t->tv_sec + 11644473600ll ) + t->tv_usec * 10ll;
20}
21
14static void netbios_read( SMB_HEADER **buf) { 22static void netbios_read( SMB_HEADER **buf) {
15 BYTE bytes[4]; 23 BYTE bytes[4];
16 ssize_t bytesread, bytestoread; 24 ssize_t bytestoread;
17 25
18 if( read( childsock, bytes, 4) < 4 ) 26 if( read( childsock, bytes, 4) < 4 )
19 bailout( "Short read." ); 27 bailout( "Short read." );
20 bytestoread = htons(*(WORD*)(2+bytes)); 28 bytestoread = htons(*(WORD*)(bytes+2));
21 if( (*buf = (SMB_HEADER*)realloc( *buf, 4 + bytestoread )) == NULL) 29 if( (*buf = (SMB_HEADER*)realloc( *buf, 4 + bytestoread )) == NULL)
22 bailout( "Out of memory"); 30 bailout( "Out of memory.");
23 *(DWORD*)*buf = *(DWORD*)bytes; 31 *(DWORD*)*buf = *(DWORD*)bytes;
24 bytesread = read( childsock, ((BYTE*)buf) + 4, bytestoread); 32 if( read( childsock, ((BYTE*)*buf) + 4, bytestoread) != bytestoread )
25 if( bytesread != bytestoread )
26 bailout( "Short read." ); 33 bailout( "Short read." );
27} 34}
28 35
29static void netbios_write( BYTE command, BYTE *buf, WORD size ) { 36static void netbios_write( BYTE cmd, SMB_HEADER *buf, SMB_HEADER2 *buf2 ) {
30 BYTE netbios_header[4] = { command, 0, size >> 8, size & 255 }; 37 const BYTE buf2_[2] = { 0, 0 };
31 if( write( childsock, netbios_header, 4 ) <= 0 || 38 if(!buf2 ) buf2 = (SMB_HEADER2*)buf2_;
32 write( childsock, buf, size ) < 0 ) 39 if( buf ) {
33 bailout( "Write failed." ); 40 struct iovec iov[2] = { {buf, SIZEOF_SMB_HEADER + 2*buf->WordCount},
41 {buf2, 2 + buf2->ByteCount} };
42
43 buf->netbios_command = cmd;
44 buf->netbios_flags = 0;
45 buf->netbios_size = htons( SIZEOF_SMB_HEADER - 4 +
46 2 * buf->WordCount +
47 2 + buf2->ByteCount );
48 buf->Flags = 0x88;
49 buf->Flags2 = 0x4001;
50
51 if( writev( childsock, iov, 2 ) < htons( buf->netbios_size ) + 4 )
52 bailout( "Write failed." );
53 } else {
54 const BYTE buf_[4] = { cmd, 0, 0, 0 };
55 if( write( childsock, buf_, 4 ) < 4)
56 bailout( "Write failed." );
57 }
58}
59
60static void packet_dump( SMB_HEADER *buf ) {
61 fprintf( stderr, "netbios_cmd, flag, size = %02X, %02X, %04X\n", buf->netbios_command, buf->netbios_flags, buf->netbios_size );
62 fprintf( stderr, "Protocol = %08X\n", *(DWORD*)&buf->Protocol);
63 fprintf( stderr, "Command = %02X\n", buf->Command);
64 fprintf( stderr, "Status = %08X\n", *(DWORD*)&buf->Status);
65 fprintf( stderr, "Flags, Flags2 = %02X, %04X\n", buf->Flags, buf->Flags2);
66 fprintf( stderr, "Pad = %04X %04X %04X %04X %04X %04X\n",
67 buf->Pad[0], buf->Pad[1], buf->Pad[2],
68 buf->Pad[3], buf->Pad[4], buf->Pad[5] );
69 fprintf( stderr, "TreeID,ProcessID,UserID = %04X, %04X, %04X\n", buf->TreeID, buf->ProcessID, buf->UserID);
70 fprintf( stderr, "MultiplexID, WordCount = %04X, %02X\n", buf->MultiplexID, buf->WordCount);
34} 71}
35 72
36static void child( ) { 73static void child( ) {
@@ -44,25 +81,53 @@ static void child( ) {
44 netbios_read( &inpacket ); 81 netbios_read( &inpacket );
45 if( inpacket->netbios_command != 0x81 ) 82 if( inpacket->netbios_command != 0x81 )
46 bailout( "No session request"); 83 bailout( "No session request");
47 netbios_write( 0x82, NULL, 0 ); 84 netbios_write( 0x82, NULL, NULL );
48 85
49 while( 1 ) { 86 while( 1 ) {
87 WORD *ParameterWords;
50 netbios_read( &inpacket ); 88 netbios_read( &inpacket );
89 packet_dump( inpacket );
90 ParameterWords = (WORD*)(((BYTE*)inpacket)+SIZEOF_SMB_HEADER);
91
51 if( inpacket->netbios_command != 0 ) 92 if( inpacket->netbios_command != 0 )
52 bailout( "Unhandled netbios command" ); 93 bailout( "Unhandled netbios command" );
53 if( inpacket->Protocol != SMB_HEADER_PROTOCOL_MAGIC ) 94 if( *(DWORD*)&inpacket->Protocol != SMB_HEADER_PROTOCOL_MAGIC )
54 bailout( "Protocol identifier mismatch"); 95 bailout( "Protocol identifier mismatch");
55 96
56 switch( inpacket->Command ) { 97 switch( inpacket->Command ) {
57 case SMB_COM_NEGOTIATE: 98 case SMB_COM_NEGOTIATE:
58 { 99 {
59 BYTE outblock[5] = { 0xff,0,0,0,0 }; 100 BYTE myself[] = { 8,0,0x67,0x61,0x74,0x6c,0x69,0x6e,0x67,0x00 };
60 netbios_write( 0, outblock, sizeof( outblock )); 101 struct timeval t; gettimeofday( &t, NULL );
102
103 inpacket = (SMB_HEADER*)realloc( inpacket, SIZEOF_SMB_HEADER + 17 * 2 );
104 *(DWORD*)&inpacket->Status = STATUS_SUCCESS;
105
106 ParameterWords = (WORD*)(((BYTE*)inpacket)+SIZEOF_SMB_HEADER-1);
107 ParameterWords[0] = 0x0511; /* Protocol Version 5, 17 bytes */
108 ParameterWords[1] = 0; /* security mode: share, no c/r */
109 ParameterWords[2] = 1; /* Max pending */
110 ParameterWords[3] = 1; /* Only one VC */
111 ParameterWords[4] = 0; /* Max Buffer Size */
112 ParameterWords[5] = 0x100; /* Max Buffer Size #2 */
113 ParameterWords[6] = 0; /* Max Raw Size */
114 ParameterWords[7] = 0x100; /* Max Raw Size #2 */
115 ParameterWords[8] = getpid(); /* unique id */
116 ParameterWords[9] = getppid(); /* unique id #2 */
117 ParameterWords[10] = 0; /* Capabilities */
118 ParameterWords[11] = 0; /* Capabilities #2 */
119*(QWORD*)&ParameterWords[12] = getnttime( &t );
120 ParameterWords[16] = 0;
121*(BYTE *)&ParameterWords[17] = 0;
122 netbios_write( 0, inpacket, (SMB_HEADER2*)myself);
61 break; 123 break;
62 } 124 }
63 default: 125 default:
64 { 126 {
65 fprintf( stderr, "Got message: %02X\n", inpacket->Command ); 127 fprintf( stderr, "Got message: %02X\n", inpacket->Command );
128 inpacket->WordCount = 0;
129*(DWORD*)&inpacket->Status = 0x00400002;
130 netbios_write( 0, inpacket, NULL );
66 break; 131 break;
67 } 132 }
68 } 133 }
@@ -70,8 +135,6 @@ static void child( ) {
70 } /* End main loop */ 135 } /* End main loop */
71} 136}
72 137
73void sigint( int reason ) { bailout( "User interrupt." ); }
74
75int main() 138int main()
76{ 139{
77 struct sockaddr_in sa; 140 struct sockaddr_in sa;
@@ -86,7 +149,11 @@ int main()
86 149
87 if( ( mainsock = socket( PF_INET, SOCK_STREAM, 0) ) == -1) 150 if( ( mainsock = socket( PF_INET, SOCK_STREAM, 0) ) == -1)
88 bailout( "Could not open socket"); 151 bailout( "Could not open socket");
152#ifdef SO_REUSEPORT
89 setsockopt( mainsock, SOL_SOCKET, SO_REUSEPORT, &l, sizeof(l)); 153 setsockopt( mainsock, SOL_SOCKET, SO_REUSEPORT, &l, sizeof(l));
154#else
155 setsockopt( mainsock, SOL_SOCKET, SO_REUSEADDR, &l, sizeof(l));
156#endif
90 if( bind( mainsock, (struct sockaddr *)&sa, sizeof( sa)) != 0) 157 if( bind( mainsock, (struct sockaddr *)&sa, sizeof( sa)) != 0)
91 bailout( "Could not bind socket"); 158 bailout( "Could not bind socket");
92 if( listen( mainsock, 1024) != 0 ) 159 if( listen( mainsock, 1024) != 0 )