6 * Copyright (C) 2016 by Olaf `Olsen' Barthel <obarthel -at- gmx -dot- net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /*****************************************************************************/
29 /*****************************************************************************/
32 #include "quad_math.h"
34 /*****************************************************************************/
36 /* The following is an attempt to decode the data that is received
37 * and sent. Because so much of smbfs was created by reverse-engineering
38 * the protocol it is difficult to say what works, and how.
41 /*****************************************************************************/
43 extern VOID VARARGS68K
SPrintf(STRPTR buffer
, STRPTR formatString
,...);
45 /*****************************************************************************/
47 /* This can be used to enable or disable the SMB packet dump output. */
48 static int dump_smb_enabled
;
50 /*****************************************************************************/
52 /* This keeps track of which SMB_COM_TRANSACTION2 subcommand was last
53 * sent to the server. The server will respond to it, but the message does
54 * not contain the subcommand code of the request which started it.
56 static int last_smb_com_transaction_subcommand
= -1;
58 /* This keeps track of the information level specified when directory
59 * contents were to be retrieved by the TRANS2_FIND_FIRST2 command.
60 * The data will be returned, but it's not repeated in the
61 * server response message.
63 static int last_trans2_find_information_level
= -1;
65 /*****************************************************************************/
67 static unsigned long next_data_dword(const unsigned char * data
,int * offset_ptr
)
69 int offset
= (*offset_ptr
);
73 (((unsigned long)data
[offset
+ 3]) << 24) |
74 (((unsigned long)data
[offset
+ 2]) << 16) |
75 (((unsigned long)data
[offset
+ 1]) << 8) |
76 (unsigned long)data
[offset
+ 0];
78 (*offset_ptr
) = offset
+ 4;
83 static void next_data_qword(const unsigned char * data
,unsigned long *qwords
,int * offset_ptr
)
85 qwords
[1] = next_data_dword(data
,offset_ptr
);
86 qwords
[0] = next_data_dword(data
,offset_ptr
);
89 static unsigned short next_data_word(const unsigned char * data
,int * offset_ptr
)
91 int offset
= (*offset_ptr
);
92 unsigned short result
;
95 (((unsigned short)data
[offset
+1]) << 8) |
96 (unsigned short)data
[offset
+0];
98 (*offset_ptr
) = offset
+ 2;
103 static unsigned char next_data_byte(const unsigned char * data
,int * offset_ptr
)
105 int offset
= (*offset_ptr
);
106 unsigned char result
;
108 result
= data
[offset
];
110 (*offset_ptr
) = offset
+ 1;
115 static const unsigned char * next_data_bytes(const unsigned char * data
,int num_bytes
,int * offset_ptr
)
117 int offset
= (*offset_ptr
);
118 const unsigned char * result
;
120 result
= &data
[offset
];
122 (*offset_ptr
) = offset
+ num_bytes
;
127 static const unsigned char * next_data_words(const unsigned char * data
,int num_words
,int * offset_ptr
)
129 return(next_data_bytes(data
,2 * num_words
,offset_ptr
));
132 static void skip_data_bytes(const unsigned char * data
,int num_bytes
,int * offset_ptr
)
134 (*offset_ptr
) = (*offset_ptr
) + num_bytes
;
137 static void skip_data_words(const unsigned char * data
,int num_words
,int * offset_ptr
)
139 skip_data_bytes(data
,2 * num_words
,offset_ptr
);
142 /*****************************************************************************/
145 fill_header(const unsigned char * packet
,int length
,struct smb_header
* header
)
150 memset(header
,0,sizeof(header
));
152 header
->raw_packet_size
= length
;
153 header
->raw_packet
= (char *)packet
;
155 memcpy(header
->signature
,next_data_bytes(packet
,4,&offset
),4);
156 header
->command
= next_data_byte(packet
,&offset
);
157 header
->status
= next_data_dword(packet
,&offset
);
158 header
->flags
= next_data_byte(packet
,&offset
);
159 header
->flags2
= next_data_word(packet
,&offset
);
160 header
->extra
.pid_high
= next_data_word(packet
,&offset
);
161 memcpy(header
->extra
.signature
,next_data_words(packet
,4,&offset
),sizeof(unsigned short) * 4);
162 skip_data_words(packet
,1,&offset
);
163 header
->tid
= next_data_word(packet
,&offset
);
164 header
->pid
= next_data_word(packet
,&offset
);
165 header
->uid
= next_data_word(packet
,&offset
);
166 header
->mid
= next_data_word(packet
,&offset
);
168 header
->num_parameter_words
= next_data_byte(packet
,&offset
);
169 header
->parameter_offset
= offset
;
170 header
->parameters
= (unsigned char *)next_data_words(packet
,header
->num_parameter_words
,&offset
);
172 header
->num_data_bytes
= next_data_word(packet
,&offset
);
173 header
->data_offset
= offset
;
174 header
->data
= (unsigned char *)next_data_bytes(packet
,header
->num_data_bytes
,&offset
);
176 num_bytes_read
= offset
;
178 return(num_bytes_read
);
181 /*****************************************************************************/
184 is_smb_andx_command(unsigned char command
)
186 static const unsigned char andx_commands
[9] =
188 SMB_COM_LOCKING_ANDX
,
192 SMB_COM_SESSION_SETUP_ANDX
,
194 SMB_COM_TREE_CONNECT_ANDX
,
195 SMB_COM_SECURITY_PACKAGE_ANDX
,
196 SMB_COM_NT_CREATE_ANDX
202 for(i
= 0 ; i
< 9 ; i
++)
204 if(command
== andx_commands
[i
])
214 /*****************************************************************************/
217 get_smb_transaction2_subcommand_name(int command
)
219 static const struct { int code
; const char * name
; } code_name_tab
[] =
221 { TRANS2_OPEN2
, "TRANS2_OPEN2" },
222 { TRANS2_FIND_FIRST2
, "TRANS2_FIND_FIRST2" },
223 { TRANS2_FIND_NEXT2
, "TRANS2_FIND_NEXT2" },
224 { TRANS2_QUERY_FS_INFORMATION
, "TRANS2_QUERY_FS_INFORMATION" },
225 { TRANS2_QUERY_PATH_INFORMATION
, "TRANS2_QUERY_PATH_INFORMATION" },
226 { TRANS2_SET_PATH_INFORMATION
, "TRANS2_SET_PATH_INFORMATION" },
227 { TRANS2_QUERY_FILE_INFORMATION
, "TRANS2_QUERY_FILE_INFORMATION" },
228 { TRANS2_SET_FILE_INFORMATION
, "TRANS2_SET_FILE_INFORMATION" },
229 { TRANS2_FSCTL
, "TRANS2_FSCTL" },
230 { TRANS2_IOCTL2
, "TRANS2_IOCTL2" },
231 { TRANS2_FIND_NOTIFY_FIRST
, "TRANS2_FIND_NOTIFY_FIRST" },
232 { TRANS2_FIND_NOTIFY_NEXT
, "TRANS2_FIND_NOTIFY_NEXT" },
233 { TRANS2_CREATE_DIRECTORY
, "TRANS2_CREATE_DIRECTORY" },
234 { TRANS2_SESSION_SETUP
, "TRANS2_SESSION_SETUP" },
238 const char * result
= NULL
;
241 for(i
= 0 ; code_name_tab
[i
].code
!= -1 ; i
++)
243 if(command
== code_name_tab
[i
].code
)
245 result
= code_name_tab
[i
].name
;
253 /*****************************************************************************/
256 get_smb_command_name(unsigned char command
)
258 static const struct { int code
; const char * name
; } code_name_tab
[] =
260 { SMB_COM_CREATE_DIRECTORY
, "CREATE_DIRECTORY" },
261 { SMB_COM_DELETE_DIRECTORY
, "DELETE_DIRECTORY" },
262 { SMB_COM_OPEN
, "OPEN" },
263 { SMB_COM_CREATE
, "CREATE" },
264 { SMB_COM_CLOSE
, "CLOSE" },
265 { SMB_COM_FLUSH
, "FLUSH" },
266 { SMB_COM_DELETE
, "DELETE" },
267 { SMB_COM_RENAME
, "RENAME" },
268 { SMB_COM_QUERY_INFORMATION
, "QUERY_INFORMATION" },
269 { SMB_COM_SET_INFORMATION
, "SET_INFORMATION" },
270 { SMB_COM_READ
, "READ" },
271 { SMB_COM_WRITE
, "WRITE" },
272 { SMB_COM_LOCK_BYTE_RANGE
, "LOCK_BYTE_RANGE" },
273 { SMB_COM_UNLOCK_BYTE_RANGE
, "UNLOCK_BYTE_RANGE" },
274 { SMB_COM_CREATE_TEMPORARY
, "CREATE_TEMPORARY" },
275 { SMB_COM_CREATE_NEW
, "CREATE_NEW" },
276 { SMB_COM_CHECK_DIRECTORY
, "CHECK_DIRECTORY" },
277 { SMB_COM_PROCESS_EXIT
, "PROCESS_EXIT" },
278 { SMB_COM_SEEK
, "SEEK" },
279 { SMB_COM_LOCK_AND_READ
, "LOCK_AND_READ" },
280 { SMB_COM_WRITE_AND_UNLOCK
, "WRITE_AND_UNLOCK" },
281 { SMB_COM_READ_RAW
, "READ_RAW" },
282 { SMB_COM_READ_MPX
, "READ_MPX" },
283 { SMB_COM_READ_MPX_SECONDARY
, "READ_MPX_SECONDARY" },
284 { SMB_COM_WRITE_RAW
, "WRITE_RAW" },
285 { SMB_COM_WRITE_MPX
, "WRITE_MPX" },
286 { SMB_COM_WRITE_MPX_SECONDARY
, "WRITE_MPX_SECONDARY" },
287 { SMB_COM_WRITE_COMPLETE
, "WRITE_COMPLETE" },
288 { SMB_COM_QUERY_SERVER
, "QUERY_SERVER" },
289 { SMB_COM_SET_INFORMATION2
, "SET_INFORMATION2" },
290 { SMB_COM_QUERY_INFORMATION2
, "QUERY_INFORMATION2" },
291 { SMB_COM_LOCKING_ANDX
, "LOCKING_ANDX" },
292 { SMB_COM_TRANSACTION
, "TRANSACTION" },
293 { SMB_COM_TRANSACTION_SECONDARY
, "TRANSACTION_SECONDARY" },
294 { SMB_COM_IOCTL
, "IOCTL" },
295 { SMB_COM_IOCTL_SECONDARY
, "IOCTL_SECONDARY" },
296 { SMB_COM_COPY
, "COPY" },
297 { SMB_COM_MOVE
, "MOVE" },
298 { SMB_COM_ECHO
, "ECHO" },
299 { SMB_COM_WRITE_AND_CLOSE
, "WRITE_AND_CLOSE" },
300 { SMB_COM_OPEN_ANDX
, "OPEN_ANDX" },
301 { SMB_COM_READ_ANDX
, "READ_ANDX" },
302 { SMB_COM_WRITE_ANDX
, "WRITE_ANDX" },
303 { SMB_COM_NEW_FILE_SIZE
, "NEW_FILE_SIZE" },
304 { SMB_COM_CLOSE_AND_TREE_DISC
, "CLOSE_AND_TREE_DISC" },
305 { SMB_COM_TRANSACTION2
, "TRANSACTION2" },
306 { SMB_COM_TRANSACTION2_SECONDARY
, "TRANSACTION2_SECONDARY" },
307 { SMB_COM_FIND_CLOSE2
, "FIND_CLOSE2" },
308 { SMB_COM_FIND_NOTIFY_CLOSE
, "FIND_NOTIFY_CLOSE" },
309 { SMB_COM_TREE_CONNECT
, "TREE_CONNECT" },
310 { SMB_COM_TREE_DISCONNECT
, "TREE_DISCONNECT" },
311 { SMB_COM_NEGOTIATE
, "NEGOTIATE" },
312 { SMB_COM_SESSION_SETUP_ANDX
, "SESSION_SETUP_ANDX" },
313 { SMB_COM_LOGOFF_ANDX
, "LOGOFF_ANDX" },
314 { SMB_COM_TREE_CONNECT_ANDX
, "TREE_CONNECT_ANDX" },
315 { SMB_COM_SECURITY_PACKAGE_ANDX
, "SECURITY_PACKAGE_ANDX" },
316 { SMB_COM_QUERY_INFORMATION_DISK
, "QUERY_INFORMATION_DISK" },
317 { SMB_COM_SEARCH
, "SEARCH" },
318 { SMB_COM_FIND
, "FIND" },
319 { SMB_COM_FIND_UNIQUE
, "FIND_UNIQUE" },
320 { SMB_COM_FIND_CLOSE
, "FIND_CLOSE" },
321 { SMB_COM_NT_TRANSACT
, "NT_TRANSACT" },
322 { SMB_COM_NT_TRANSACT_SECONDARY
, "NT_TRANSACT_SECONDARY" },
323 { SMB_COM_NT_CREATE_ANDX
, "NT_CREATE_ANDX" },
324 { SMB_COM_NT_CANCEL
, "NT_CANCEL" },
325 { SMB_COM_NT_RENAME
, "NT_RENAME" },
326 { SMB_COM_OPEN_PRINT_FILE
, "OPEN_PRINT_FILE" },
327 { SMB_COM_WRITE_PRINT_FILE
, "WRITE_PRINT_FILE" },
328 { SMB_COM_CLOSE_PRINT_FILE
, "CLOSE_PRINT_FILE" },
329 { SMB_COM_GET_PRINT_QUEUE
, "GET_PRINT_QUEUE" },
330 { SMB_COM_READ_BULK
, "READ_BULK" },
331 { SMB_COM_WRITE_BULK
, "WRITE_BULK" },
332 { SMB_COM_WRITE_BULK_DATA
, "WRITE_BULK_DATA" },
333 { SMB_COM_INVALID
, "INVALID" },
334 { SMB_COM_NO_ANDX_COMMAND
, "NO_ANDX_COMMAND" },
338 const char * result
= NULL
;
341 for(i
= 0 ; code_name_tab
[i
].code
!= -1 ; i
++)
343 if(command
== code_name_tab
[i
].code
)
345 result
= code_name_tab
[i
].name
;
353 /*****************************************************************************/
361 /*****************************************************************************/
364 init_line_buffer(struct line_buffer
*lb
)
367 lb
->line
[lb
->length
] = '\0';
371 set_line_buffer(struct line_buffer
*lb
,int c
,size_t len
)
373 if(len
> sizeof(lb
->line
)-1)
374 len
= sizeof(lb
->line
)-1;
376 memset(lb
->line
,c
,len
);
379 lb
->line
[lb
->length
] = '\0';
383 copy_string_to_line_buffer(struct line_buffer
*lb
,const char *str
,size_t len
,size_t pos
)
385 if(pos
+len
> sizeof(lb
->line
)-1)
387 if(pos
< sizeof(lb
->line
)-1)
388 len
= sizeof(lb
->line
)-1 - pos
;
395 memmove(&lb
->line
[pos
],str
,len
);
397 if(lb
->length
< pos
+len
)
399 lb
->length
= pos
+len
;
400 lb
->line
[lb
->length
] = '\0';
406 add_lb_flag(struct line_buffer
*lb
,const char * str
)
408 size_t len
= strlen(str
);
412 if(lb
->length
+ len
< sizeof(lb
->line
)-1)
414 memcpy(&lb
->line
[lb
->length
],str
,len
);
417 lb
->line
[lb
->length
] = '\0';
422 if(lb
->length
+ 2 + len
< sizeof(lb
->line
)-1)
424 memcpy(&lb
->line
[lb
->length
],", ",2);
427 memcpy(&lb
->line
[lb
->length
],str
,len
);
430 lb
->line
[lb
->length
] = '\0';
435 /*****************************************************************************/
438 print_smb_data(struct line_buffer
* lb
,int num_data_bytes_left
,const unsigned char * data_bytes
)
440 if(num_data_bytes_left
> 0)
443 char format_buffer
[20];
444 char dword_buffer
[20];
445 int num_bytes_per_row
,dword_pos
;
446 size_t dword_buffer_len
;
450 while(num_data_bytes_left
> 0)
452 /* The output line should be filled with blank spaces. */
453 set_line_buffer(lb
,' ',60);
455 /* Print the row offset (in bytes) at the start of the
458 SPrintf(format_buffer
,"%04lx:",row_offset
);
460 copy_string_to_line_buffer(lb
,format_buffer
,5,0);
462 /* Print up to 16 bytes per row. */
463 if(num_data_bytes_left
> 16)
464 num_bytes_per_row
= 16;
466 num_bytes_per_row
= num_data_bytes_left
;
469 dword_buffer
[0] = '\0';
470 dword_buffer_len
= 0;
473 /* Print the bytes in hex format, followed by a column
474 * of the same data bytes interpreted as printable
477 while(num_bytes_per_row
> 0)
482 num_data_bytes_left
--;
484 /* Convert this data byte to hexadecimal
487 SPrintf(format_buffer
,"%02lx",c
);
489 strcat(dword_buffer
,format_buffer
);
490 dword_buffer_len
+= 2;
492 /* Is this not a printable character? If so,
493 * substitute it with '.'.
495 if(c
< ' ' || c
== 127 || (128 <= c
&& c
<= 160))
498 copy_string_to_line_buffer(lb
,(char *)&c
,1,c_pos
);
501 /* If we have converted four bytes to hexadecimal
502 * format, put them into the output buffer.
504 if(dword_buffer_len
>= 8)
506 copy_string_to_line_buffer(lb
,dword_buffer
,8,dword_pos
);
509 dword_buffer
[0] = '\0';
510 dword_buffer_len
= 0;
514 /* If we did not convert a multiple of 32 bytes per row,
515 * add the last conversion buffer contents.
517 if(dword_buffer_len
> 0)
518 copy_string_to_line_buffer(lb
,dword_buffer
,dword_buffer_len
,dword_pos
);
520 Printf(" %s\n",lb
->line
);
525 /*****************************************************************************/
527 static const struct tm
*
528 convert_smb_date_time_to_tm(unsigned short smb_date
,unsigned short smb_time
)
532 memset(&tm
,0,sizeof(tm
));
534 tm
.tm_sec
= (smb_time
& 0x001f) * 2;
535 tm
.tm_min
= (smb_time
& 0x07e0) >> 5;
536 tm
.tm_hour
= (smb_time
& 0xf800) >> 11;
538 tm
.tm_mday
= smb_date
& 0x001f;
539 tm
.tm_mon
= ((smb_date
& 0x01e0) >> 5) - 1;
540 tm
.tm_year
= 80 + ((smb_date
& 0xfe00) >> 9);
545 /*****************************************************************************/
547 static const struct tm
*
548 convert_filetime_to_tm(const unsigned long * qword
)
550 const QUAD adjust_by_369_years
= { 0x00000002,0xb6109100 };
554 long_date
.High
= qword
[0];
555 long_date
.Low
= qword
[1];
557 /* Divide by 10,000,000 to convert the time from 100ns
558 * units into seconds.
560 divide_64_by_32(&long_date
,10000000,&long_date
);
562 /* Adjust by 369 years (11,644,473,600 seconds) to convert
563 * from the epoch beginning on January 1st 1601 to the one
564 * beginning on January 1st 1970 (the Unix epoch).
566 if(subtract_64_from_64_to_64(&long_date
,&adjust_by_369_years
,&long_date
) == 0)
567 when
= (time_t)long_date
.Low
;
571 return(gmtime(&when
));
574 /*****************************************************************************/
577 convert_filetime_to_string(const unsigned long * qword
)
579 static char string
[40];
580 const struct tm
* tm
;
582 tm
= convert_filetime_to_tm(qword
);
584 SPrintf(string
,"%ld-%02ld-%02ldT%02ld:%02ld:%02ldZ",
585 tm
->tm_year
+1900,tm
->tm_mon
+1,tm
->tm_mday
,
586 tm
->tm_hour
,tm
->tm_min
,tm
->tm_sec
);
591 /*****************************************************************************/
594 convert_smb_date_time_to_string(unsigned short smb_date
,unsigned short smb_time
)
596 static char string
[40];
597 const struct tm
* tm
;
599 tm
= convert_smb_date_time_to_tm(smb_date
,smb_time
);
601 SPrintf(string
,"%ld-%02ld-%02ldT%02ld:%02ld:%02ldZ",
602 tm
->tm_year
+1900,tm
->tm_mon
+1,tm
->tm_mday
,
603 tm
->tm_hour
,tm
->tm_min
,tm
->tm_sec
);
608 /*****************************************************************************/
611 convert_utime_to_string(unsigned long utime
)
613 static char string
[40];
614 const struct tm
* tm
;
615 time_t when
= (time_t)utime
;
619 SPrintf(string
,"%ld-%02ld-%02ldT%02ld:%02ld:%02ldZ",
620 tm
->tm_year
+1900,tm
->tm_mon
+1,tm
->tm_mday
,
621 tm
->tm_hour
,tm
->tm_min
,tm
->tm_sec
);
626 /*****************************************************************************/
629 convert_qword_to_string(const unsigned long *qword
)
631 static char string
[40];
636 number
.High
= qword
[0];
637 number
.Low
= qword
[1];
639 memset(string
,0,sizeof(string
));
641 for(len
= sizeof(string
)-2 ; len
>= 0 ; )
643 n
= divide_64_by_32(&number
,10,&number
);
645 string
[len
--] = '0'+n
;
647 if(number
.High
== 0 && number
.Low
== 0)
651 return(&string
[len
+1]);
654 /*****************************************************************************/
657 print_smb_transaction2_subcommand(int command
,enum smb_packet_source_t smb_packet_source
,int num_parameter_bytes
,
658 const unsigned char * parameters
,int num_data_bytes
,const unsigned char * data
)
660 if(command
== TRANS2_FIND_FIRST2
&& smb_packet_source
== smb_packet_from_consumer
)
662 int search_attributes
;
665 int information_level
;
666 unsigned long search_storage_type
;
667 const char * file_name
;
670 search_attributes
= next_data_word(parameters
,&offset
);
671 Printf("search attributes = 0x%04lx\n",search_attributes
);
673 if(search_attributes
& 0x0100)
674 Printf(" SMB_SEARCH_ATTRIBUTE_READONLY\n");
676 if(search_attributes
& 0x0200)
677 Printf(" SMB_SEARCH_ATTRIBUTE_HIDDEN\n");
679 if(search_attributes
& 0x0400)
680 Printf(" SMB_SEARCH_ATTRIBUTE_SYSTEM\n");
682 if(search_attributes
& 0x1000)
683 Printf(" SMB_SEARCH_ATTRIBUTE_DIRECTORY\n");
685 if(search_attributes
& 0x2000)
686 Printf(" SMB_SEARCH_ATTRIBUTE_ARCHIVE\n");
688 search_count
= next_data_word(parameters
,&offset
);
689 Printf("search count = %ld\n",search_count
);
691 flags
= next_data_word(parameters
,&offset
);
692 Printf("flags = 0x%04lx\n",flags
);
695 Printf(" SMB_FIND_CLOSE_AFTER_REQUEST\n");
698 Printf(" SMB_FIND_CLOSE_AT_EOS\n");
701 Printf(" SMB_FIND_RETURN_RESUME_KEYS\n");
704 Printf(" SMB_FIND_CONTINUE_FROM_LAST\n");
707 Printf(" SMB_FIND_WITH_BACKUP_INTENT\n");
709 information_level
= next_data_word(parameters
,&offset
);
710 Printf("information level = 0x%04lx\n",information_level
);
712 last_trans2_find_information_level
= information_level
;
714 if (information_level
== 0x0001)
715 Printf(" SMB_INFO_STANDARD\n");
716 else if (information_level
== 0x0002)
717 Printf(" SMB_INFO_QUERY_EA_SIZE\n");
718 else if (information_level
== 0x0003)
719 Printf(" SMB_INFO_QUERY_EAS_FROM_LIST\n");
720 else if (information_level
== 0x0101)
721 Printf(" SMB_FIND_FILE_DIRECTORY_INFO\n");
722 else if (information_level
== 0x0102)
723 Printf(" SMB_FIND_FILE_FULL_DIRECTORY_INFO\n");
724 else if (information_level
== 0x0103)
725 Printf(" SMB_FIND_FILE_NAMES_INFO\n");
726 else if (information_level
== 0x0104)
727 Printf(" SMB_FIND_FILE_BOTH_DIRECTORY_INFO\n");
729 search_storage_type
= next_data_dword(parameters
,&offset
);
730 Printf("search_storage_type = 0x%08lx\n",search_storage_type
);
732 if(search_storage_type
== 0x00000001)
733 Printf(" FILE_DIRECTORY_ONLY\n");
735 if(search_storage_type
== 0x00000040)
736 Printf(" FILE_NON_DIRECTORY_FILE\n");
738 file_name
= next_data_bytes(parameters
,0,&offset
);
740 Printf("file name = '%s'\n",file_name
);
742 /* ZZZ need to deal with the 'data' provided if
743 * information_level == SMB_INFO_QUERY_EAS_FROM_LIST.
746 else if (command
== TRANS2_FIND_NEXT2
&& smb_packet_source
== smb_packet_from_consumer
)
750 unsigned long resume_key
;
752 int information_level
;
753 const char * file_name
;
756 sid
= next_data_word(parameters
,&offset
);
758 Printf("sid = 0x%04lx\n",sid
);
760 search_count
= next_data_word(parameters
,&offset
);
761 Printf("search count = %ld\n",search_count
);
763 information_level
= next_data_word(parameters
,&offset
);
764 Printf("information level = 0x%04lx\n",information_level
);
766 last_trans2_find_information_level
= information_level
;
768 if (information_level
== 0x0001)
769 Printf(" SMB_INFO_STANDARD\n");
770 else if (information_level
== 0x0002)
771 Printf(" SMB_INFO_QUERY_EA_SIZE\n");
772 else if (information_level
== 0x0003)
773 Printf(" SMB_INFO_QUERY_EAS_FROM_LIST\n");
774 else if (information_level
== 0x0101)
775 Printf(" SMB_FIND_FILE_DIRECTORY_INFO\n");
776 else if (information_level
== 0x0102)
777 Printf(" SMB_FIND_FILE_FULL_DIRECTORY_INFO\n");
778 else if (information_level
== 0x0103)
779 Printf(" SMB_FIND_FILE_NAMES_INFO\n");
780 else if (information_level
== 0x0104)
781 Printf(" SMB_FIND_FILE_BOTH_DIRECTORY_INFO\n");
783 resume_key
= next_data_dword(parameters
,&offset
);
784 Printf("resume_key = 0x%08lx\n",resume_key
);
786 flags
= next_data_word(parameters
,&offset
);
787 Printf("flags = 0x%04lx\n",flags
);
790 Printf(" SMB_FIND_CLOSE_AFTER_REQUEST\n");
793 Printf(" SMB_FIND_CLOSE_AT_EOS\n");
796 Printf(" SMB_FIND_RETURN_RESUME_KEYS\n");
799 Printf(" SMB_FIND_CONTINUE_FROM_LAST\n");
802 Printf(" SMB_FIND_WITH_BACKUP_INTENT\n");
804 file_name
= next_data_bytes(parameters
,0,&offset
);
806 Printf("file name = '%s'\n",file_name
);
808 /* ZZZ need to deal with the 'data' provided if
809 * information_level == SMB_INFO_QUERY_EAS_FROM_LIST.
812 else if (smb_packet_source
== smb_packet_to_consumer
&& (command
== TRANS2_FIND_FIRST2
|| command
== TRANS2_FIND_NEXT2
))
818 int last_name_offset
;
821 if(command
== TRANS2_FIND_FIRST2
)
823 sid
= next_data_word(parameters
,&offset
);
824 Printf("sid = %ld\n",sid
);
827 search_count
= next_data_word(parameters
,&offset
);
828 Printf("search count = %ld\n",search_count
);
830 end_of_search
= next_data_word(parameters
,&offset
);
831 Printf("end of search = 0x%04lx\n",end_of_search
);
833 ea_error_offset
= next_data_word(parameters
,&offset
);
834 Printf("ea error offset = 0x%04lx\n",ea_error_offset
);
836 last_name_offset
= next_data_word(parameters
,&offset
);
837 Printf("last name offset = 0x%04lx\n",last_name_offset
);
839 /* SMB_FIND_FILE_BOTH_DIRECTORY_INFO */
840 if(num_data_bytes
> 0 && last_trans2_find_information_level
== 0x0104)
842 unsigned long next_entry_offset
;
843 unsigned long file_index
;
844 unsigned long creation_time
[2]; // FILETIME
845 unsigned long last_access_time
[2]; // FILETIME
846 unsigned long last_write_time
[2]; // FILETIME
847 unsigned long last_change_time
[2]; // FILETIME
848 unsigned long end_of_file
[2]; // LARGE_INTEGER
849 unsigned long allocation_size
[2]; // LARGE_INTEGER
850 unsigned long ext_file_attributes
; // SMB_EXT_FILE_ATTR
851 unsigned long file_name_length
;
852 unsigned long ea_size
;
853 int short_name_length
; // UCHAR
854 int reserved
; // UCHAR
855 const char * short_name
; // WCHAR
856 const char * file_name
; // SMB_STRING
857 struct line_buffer lb
;
862 int entry_offset
= 0;
865 while(entry_offset
< num_data_bytes
&& entry_count
< search_count
)
867 Printf("directory entry [%ld]:\n",entry_count
++);
869 next_offset
= entry_offset
;
871 next_entry_offset
= next_data_dword(data
,&entry_offset
);
873 next_offset
+= next_entry_offset
;
875 file_index
= next_data_dword(data
,&entry_offset
);
876 next_data_qword(data
,creation_time
,&entry_offset
);
877 next_data_qword(data
,last_access_time
,&entry_offset
);
878 next_data_qword(data
,last_write_time
,&entry_offset
);
879 next_data_qword(data
,last_change_time
,&entry_offset
);
880 next_data_qword(data
,end_of_file
,&entry_offset
);
881 next_data_qword(data
,allocation_size
,&entry_offset
);
882 ext_file_attributes
= next_data_dword(data
,&entry_offset
);
883 file_name_length
= next_data_dword(data
,&entry_offset
);
884 ea_size
= next_data_dword(data
,&entry_offset
);
885 short_name_length
= next_data_byte(data
,&entry_offset
);
886 reserved
= next_data_byte(data
,&entry_offset
);
887 short_name
= next_data_bytes(data
,24,&entry_offset
);
888 file_name
= next_data_bytes(data
,0,&entry_offset
);
890 Printf("\tnext entry offset = %ld\n",next_entry_offset
);
891 Printf("\tfile index = 0x%08lx\n",file_index
);
892 Printf("\tcreation time = 0x%08lx%08lx\n",creation_time
[0],creation_time
[1]); /* ZZZ this is actually a signed value */
893 Printf("\t %s\n",convert_filetime_to_string(creation_time
));
894 Printf("\tlast access time = 0x%08lx%08lx\n",last_access_time
[0],last_access_time
[1]);
895 Printf("\t %s\n",convert_filetime_to_string(last_access_time
));
896 Printf("\tlast change time = 0x%08lx%08lx\n",last_change_time
[0],last_change_time
[1]);
897 Printf("\t %s\n",convert_filetime_to_string(last_change_time
));
898 Printf("\tend of file = %ls (0x%08lx%08lx)\n",convert_qword_to_string(end_of_file
),end_of_file
[0],end_of_file
[1]);
899 Printf("\tallocation size = %s (0x%08lx%08lx)\n",convert_qword_to_string(allocation_size
),allocation_size
[0],allocation_size
[1]);
901 Printf("\text file attributes = 0x%08lx\n",ext_file_attributes
);
903 if(ext_file_attributes
& 0x00000001)
904 Printf("\t ATTR_READONLY\n");
906 if(ext_file_attributes
& 0x00000002)
907 Printf("\t ATTR_HIDDEN\n");
909 if(ext_file_attributes
& 0x00000004)
910 Printf("\t ATTR_SYSTEM\n");
912 if(ext_file_attributes
& 0x00000010)
913 Printf("\t ATTR_DIRECTORY\n");
915 if(ext_file_attributes
& 0x00000020)
916 Printf("\t ATTR_ARCHIVE\n");
918 if(ext_file_attributes
& 0x00000080)
919 Printf("\t ATTR_NORMAL\n");
921 if(ext_file_attributes
& 0x00000100)
922 Printf("\t ATTR_TEMPORARY\n");
924 if(ext_file_attributes
& 0x00000800)
925 Printf("\t ATTR_COMPRESSED\n");
927 if(ext_file_attributes
& 0x01000000)
928 Printf("\t POSIX_SEMANTICS\n");
930 if(ext_file_attributes
& 0x02000000)
931 Printf("\t BACKUP_SEMANTICS\n");
933 if(ext_file_attributes
& 0x04000000)
934 Printf("\t DELETE_ON_CLOSE\n");
936 if(ext_file_attributes
& 0x08000000)
937 Printf("\t SEQUENTIAL_SCAN\n");
939 if(ext_file_attributes
& 0x10000000)
940 Printf("\t RANDOM_ACCESS\n");
942 if(ext_file_attributes
& 0x20000000)
943 Printf("\t NO_BUFFERING\n");
945 if(ext_file_attributes
& 0x80000000)
946 Printf("\t WRITE_THROUGH\n");
948 Printf("\tfile name length = %ld\n",file_name_length
);
949 Printf("\tea size = %ld\n",ea_size
);
950 Printf("\tshort name length = %ld\n",short_name_length
);
951 Printf("\treserved = 0x%02lx\n",reserved
);
953 if(short_name_length
> 0)
957 init_line_buffer(&lb
);
959 while(unicode_offset
< short_name_length
)
961 unicode_char
= next_data_word(short_name
,&unicode_offset
);
962 if(unicode_char
== 0)
965 if(' ' <= unicode_char
&& unicode_char
< 127)
967 char c
= unicode_char
;
969 copy_string_to_line_buffer(&lb
,&c
,1,output_offset
);
974 char code_string
[40];
976 SPrintf(code_string
,"<%02lx%02ld>",unicode_char
>> 8,unicode_char
& 0xff);
978 copy_string_to_line_buffer(&lb
,code_string
,strlen(code_string
),output_offset
);
979 output_offset
+= strlen(code_string
);
983 Printf("\tshort name = '%s'\n",lb
.line
);
986 if(file_name_length
> 0)
987 Printf("\tfile name = '%s'\n",file_name
);
989 entry_offset
= next_offset
;
992 /* SMB_INFO_STANDARD */
993 else if (num_data_bytes
> 0 && last_trans2_find_information_level
== 0x0001)
995 unsigned long resume_key
;
996 unsigned short creation_date
;
997 unsigned short creation_time
;
998 unsigned short last_access_date
;
999 unsigned short last_access_time
;
1000 unsigned short last_write_date
;
1001 unsigned short last_write_time
;
1002 unsigned long file_data_size
;
1003 unsigned long allocation_size
;
1004 unsigned short file_attributes
;
1005 unsigned char file_name_length
;
1006 const char * file_name
;
1007 int entry_count
= 0;
1008 int entry_offset
= 0;
1010 while(entry_offset
< num_data_bytes
&& entry_count
< search_count
)
1012 Printf("directory entry [%ld]:\n",entry_count
++);
1014 resume_key
= next_data_dword(data
,&entry_offset
);
1015 creation_date
= next_data_word(data
,&entry_offset
);
1016 creation_time
= next_data_word(data
,&entry_offset
);
1017 last_access_date
= next_data_word(data
,&entry_offset
);
1018 last_access_time
= next_data_word(data
,&entry_offset
);
1019 last_write_date
= next_data_word(data
,&entry_offset
);
1020 last_write_time
= next_data_word(data
,&entry_offset
);
1021 file_data_size
= next_data_dword(data
,&entry_offset
);
1022 allocation_size
= next_data_dword(data
,&entry_offset
);
1023 file_attributes
= next_data_dword(data
,&entry_offset
);
1024 file_name_length
= next_data_byte(data
,&entry_offset
);
1025 file_name
= (char *)next_data_bytes(data
,file_name_length
,&entry_offset
);
1027 Printf("\tresume key = 0x%08lx\n",resume_key
);
1028 Printf("\tcreation date = 0x%04lx\n",creation_date
);
1029 Printf("\tcreation time = 0x%04lx\n",creation_time
);
1030 Printf("\tcreation = %s\n",convert_smb_date_time_to_string(creation_date
,creation_time
));
1031 Printf("\tlast access date = 0x%04lx\n",last_access_date
);
1032 Printf("\tlast access time = 0x%04lx\n",last_access_time
);
1033 Printf("\tlast access = %s\n",convert_smb_date_time_to_string(last_access_date
,last_access_time
));
1034 Printf("\tlast write date = 0x%04lx\n",last_write_date
);
1035 Printf("\tlast write time = 0x%04lx\n",last_write_time
);
1036 Printf("\tlast write = %s\n",convert_smb_date_time_to_string(last_write_date
,last_write_time
));
1037 Printf("\tfile data size = %lu\n",file_data_size
);
1038 Printf("\tallocation size = %lu\n",allocation_size
);
1039 Printf("\tfile attributes = 0x%08lx\n",file_attributes
);
1041 if((file_attributes
& 0x001f) == 0)
1042 Printf("\t SMB_FILE_ATTRIBUTE_NORMAL\n");
1044 if(file_attributes
& 0x0001)
1045 Printf("\t SMB_FILE_ATTRIBUTE_READ_ONLY\n");
1047 if(file_attributes
& 0x0002)
1048 Printf("\t SMB_FILE_ATTRIBUTE_HIDDEN\n");
1050 if(file_attributes
& 0x0004)
1051 Printf("\t SMB_FILE_ATTRIBUTE_SYSTEM\n");
1053 if(file_attributes
& 0x0008)
1054 Printf("\t SMB_FILE_ATTRIBUTE_VOLUME\n");
1056 if(file_attributes
& 0x0010)
1057 Printf("\t SMB_FILE_ATTRIBUTE_DIRECTORY\n");
1059 if(file_attributes
& 0x0020)
1060 Printf("\t SMB_FILE_ATTRIBUTE_ARCHIVE\n");
1062 Printf("\tfile name length = %ld\n",file_name_length
);
1063 Printf("\tfile name = '%s'\n",file_name
);
1069 /*****************************************************************************/
1071 /* SMB commands used by smbfs 1.60 and beyond
1073 #define SMBmkdir 0x00 // create directory
1074 #define SMBrmdir 0x01 // delete directory
1075 #define SMBopen 0x02 // open file
1076 #define SMBcreate 0x03 // create file
1077 #define SMBclose 0x04 // close file
1078 #define SMBunlink 0x06 // delete file
1079 #define SMBmv 0x07 // rename file
1080 #define SMBgetatr 0x08 // get file attributes
1081 #define SMBsetatr 0x09 // set file attributes
1082 #define SMBread 0x0A // read from file
1083 #define SMBwrite 0x0B // write to file
1084 #define SMBlseek 0x12 // seek
1085 #define SMBtcon 0x70 // tree connect
1086 #define SMBtconX 0x75 // tree connect and X
1087 #define SMBnegprot 0x72 // negotiate protocol
1088 #define SMBdskattr 0x80 // get disk attributes
1089 #define SMBsearch 0x81 // search directory
1092 #define SMBreadbraw 0x1a // read a block of data with no smb header
1093 #define SMBwritebraw 0x1d // write a block of data with no smb header
1094 #define SMBwritec 0x20 // secondary write request
1096 // dos extended protocol
1097 #define SMBsetattrE 0x22 // set file attributes expanded
1098 #define SMBgetattrE 0x23 // get file attributes expanded
1099 #define SMBlockingX 0x24 // lock/unlock byte ranges and X
1100 #define SMBsesssetupX 0x73 // Session Set Up & X (including User Logon)
1102 // Extended 2.0 protocol
1103 #define SMBtrans2 0x32 // TRANS2 protocol set
1105 // these are the TRANS2 sub commands
1106 #define TRANSACT2_FINDFIRST 1
1107 #define TRANSACT2_FINDNEXT 2
1110 /*****************************************************************************/
1112 /* SMB commands supported so far:
1114 * CREATE_DIRECTORY (SMBmkdir, 0x00)
1115 * DELETE_DIRECTORY (SMBrmdir, 0x01)
1116 * OPEN (SMBopen, 0x02)
1117 * CREATE (SMBcreate, 0x03)
1118 * CLOSE (SMBclose, 0x04)
1119 * DELETE (SMBunlink, 0x06)
1120 * RENAME (SMBmv, 0x07)
1121 * QUERY_INFORMATION (SMBgetatr, 0x08)
1122 * SET_INFORMATION (SMBsetatr, 0x09)
1123 * READ (SMBread, 0x0A)
1124 * WRITE (SMBwrite, 0x0B)
1125 * SEEK (SMBlseek, 0x12)
1126 * READ_RAW (SMBreadbraw, 0x1A)
1127 * SMB_COM_WRITE_RAW (SMBwritebraw, 0x1D)
1128 * SMB_COM_WRITE_COMPLETE (SMBwritec, 0x20)
1129 * SET_INFORMATION2 (SMBsetattrE, 0x22)
1130 * QUERY_INFORMATION2 (SMBgetattrE, 0x23)
1131 * LOCKING_ANDX (SMBlockingX, 0x24)
1132 * TRANSACTION2 (SMBtrans2, 0x32)
1133 * TREE_CONNECT (SMBtcon, 0x70)
1134 * NEGOTIATE (SMBnegprot, 0x72)
1135 * SESSION_SETUP_AND (SMBsesssetupX, 0x73)
1136 * TREE_CONNECT_ANDX (SMBtconX, 0x75)
1137 * QUERY_INFORMATION_DISK (SMBdskattr, 0x80)
1138 * SEARCH (SMBsearch, 0x81)
1141 print_smb_contents(const struct smb_header
* header
,int command
,enum smb_packet_source_t smb_packet_source
,
1142 int num_parameter_words
,const unsigned char * parameters
,int num_data_bytes
,const unsigned char * data
)
1144 unsigned short vwv
[256];
1147 if(num_parameter_words
< 0)
1148 num_parameter_words
= 0;
1149 else if (num_parameter_words
> 255)
1150 num_parameter_words
= 255;
1152 if(num_data_bytes
< 0)
1155 for(i
= j
= 0 ; i
< num_parameter_words
; i
++, j
+= 2)
1156 vwv
[i
] = (((int)parameters
[j
+1]) << 8) + parameters
[j
];
1158 if (command
== SMB_COM_CREATE_DIRECTORY
)
1160 if(smb_packet_source
== smb_packet_from_consumer
)
1164 if(num_data_bytes
> 255)
1165 num_data_bytes
= 255;
1167 memmove(filename
,data
,num_data_bytes
);
1168 filename
[num_data_bytes
] = '\0';
1170 Printf("buffer format = %ld\n",filename
[0]);
1171 Printf("directory name = '%s'\n",filename
+1);
1174 else if (command
== SMB_COM_DELETE_DIRECTORY
)
1176 if(smb_packet_source
== smb_packet_from_consumer
)
1180 if(num_data_bytes
> 255)
1181 num_data_bytes
= 255;
1183 memmove(filename
,data
,num_data_bytes
);
1184 filename
[num_data_bytes
] = '\0';
1186 Printf("buffer format = %ld\n",filename
[0]);
1187 Printf("directory name = '%s'\n",filename
+1);
1190 else if (command
== SMB_COM_OPEN
)
1192 if(smb_packet_source
== smb_packet_from_consumer
)
1196 int search_attribute
;
1198 if(num_data_bytes
> 255)
1199 num_data_bytes
= 255;
1201 memmove(filename
,data
,num_data_bytes
);
1202 filename
[num_data_bytes
] = '\0';
1204 access_mode
= vwv
[0];
1205 Printf("access mode = 0x%04lx\n",access_mode
);
1207 switch(access_mode
& 0x0007)
1211 Printf(" Open for reading\n");
1216 Printf(" Open for writing\n");
1221 Printf(" Open for reading and writing\n");
1226 Printf(" Open for execution\n");
1234 switch((access_mode
& 0x0070) >> 4)
1238 Printf(" Compatibility mode\n");
1243 Printf(" Deny read/write/execute others (exclusive use requested)\n");
1248 Printf(" Deny write to others\n");
1253 Printf(" Deny read/execute to others\n");
1258 Printf(" Deny nothing to others\n");
1266 switch((access_mode
& 0x0700) >> 8)
1270 Printf(" Unknown locality of reference\n");
1275 Printf(" Mainly sequential access\n");
1280 Printf(" Mainly random access\n");
1285 Printf(" Random access with some locality\n");
1293 if(access_mode
& 0x1000)
1294 Printf(" Perform caching on file\n");
1296 Printf(" Do not cache the file\n");
1298 if(access_mode
& 0x4000)
1299 Printf(" No read ahead or write behind is allowed on this file or device\n");
1301 search_attribute
= vwv
[1];
1302 Printf("search attribute = 0x%04lx\n",search_attribute
);
1304 if(search_attribute
& 0x0100)
1305 Printf(" SMB_SEARCH_ATTRIBUTE_READONLY\n");
1307 if(search_attribute
& 0x0200)
1308 Printf(" SMB_SEARCH_ATTRIBUTE_HIDDEN\n");
1310 if(search_attribute
& 0x0400)
1311 Printf(" SMB_SEARCH_ATTRIBUTE_SYSTEM\n");
1313 if(search_attribute
& 0x1000)
1314 Printf(" SMB_SEARCH_ATTRIBUTE_DIRECTORY\n");
1316 if(search_attribute
& 0x2000)
1317 Printf(" SMB_SEARCH_ATTRIBUTE_ARCHIVE\n");
1319 Printf("buffer format = %ld\n",filename
[0]);
1320 Printf("file pathname = '%s'\n",filename
+1);
1325 int file_attributes
;
1327 if(num_parameter_words
<= 0)
1330 Printf("file handle = 0x%04lx\n",vwv
[0]);
1332 file_attributes
= vwv
[1];
1333 Printf("file attributes = 0x%04lx\n",file_attributes
);
1335 if((file_attributes
& 0x001f) == 0)
1336 Printf(" SMB_FILE_ATTRIBUTE_NORMAL\n");
1338 if(file_attributes
& 0x0001)
1339 Printf(" SMB_FILE_ATTRIBUTE_READ_ONLY\n");
1341 if(file_attributes
& 0x0002)
1342 Printf(" SMB_FILE_ATTRIBUTE_HIDDEN\n");
1344 if(file_attributes
& 0x0004)
1345 Printf(" SMB_FILE_ATTRIBUTE_SYSTEM\n");
1347 if(file_attributes
& 0x0008)
1348 Printf(" SMB_FILE_ATTRIBUTE_VOLUME\n");
1350 if(file_attributes
& 0x0010)
1351 Printf(" SMB_FILE_ATTRIBUTE_DIRECTORY\n");
1353 if(file_attributes
& 0x0020)
1354 Printf(" SMB_FILE_ATTRIBUTE_ARCHIVE\n");
1356 Printf("last modified = 0x%08lx\n",(((unsigned long)vwv
[3]) << 16) | vwv
[2]);
1357 Printf(" %s\n",convert_utime_to_string((((unsigned long)vwv
[3]) << 16) | vwv
[2]));
1359 Printf("file size = %lu\n",(((unsigned long )vwv
[5]) << 16) | vwv
[4]);
1361 access_mode
= vwv
[6];
1362 Printf("access mode = 0x%04lx\n",access_mode
);
1364 switch(access_mode
& 0x0007)
1368 Printf(" Open for reading\n");
1373 Printf(" Open for writing\n");
1378 Printf(" Open for reading and writing\n");
1383 Printf(" Open for execution\n");
1391 switch((access_mode
& 0x0070) >> 4)
1395 Printf(" Compatibility mode\n");
1400 Printf(" Deny read/write/execute others (exclusive use requested)\n");
1405 Printf(" Deny write to others\n");
1410 Printf(" Deny read/execute to others\n");
1415 Printf(" Deny nothing to others\n");
1423 switch((access_mode
& 0x0700) >> 8)
1427 Printf(" Unknown locality of reference\n");
1432 Printf(" Mainly sequential access\n");
1437 Printf(" Mainly random access\n");
1442 Printf(" Random access with some locality\n");
1450 if(access_mode
& 0x1000)
1451 Printf(" Perform caching on file\n");
1453 Printf(" Do not cache the file\n");
1455 if(access_mode
& 0x4000)
1456 Printf(" No read ahead or write behind is allowed on this file or device\n");
1459 else if (command
== SMB_COM_CREATE
)
1461 if(smb_packet_source
== smb_packet_from_consumer
)
1464 int file_attributes
;
1466 if(num_data_bytes
> 255)
1467 num_data_bytes
= 255;
1469 memmove(filename
,data
,num_data_bytes
);
1470 filename
[num_data_bytes
] = '\0';
1472 file_attributes
= vwv
[0];
1473 Printf("file attributes = 0x%04lx\n",file_attributes
);
1475 if((file_attributes
& 0x001f) == 0)
1476 Printf(" SMB_FILE_ATTRIBUTE_NORMAL\n");
1478 if(file_attributes
& 0x0001)
1479 Printf(" SMB_FILE_ATTRIBUTE_READ_ONLY\n");
1481 if(file_attributes
& 0x0002)
1482 Printf(" SMB_FILE_ATTRIBUTE_HIDDEN\n");
1484 if(file_attributes
& 0x0004)
1485 Printf(" SMB_FILE_ATTRIBUTE_SYSTEM\n");
1487 if(file_attributes
& 0x0008)
1488 Printf(" SMB_FILE_ATTRIBUTE_VOLUME\n");
1490 if(file_attributes
& 0x0010)
1491 Printf(" SMB_FILE_ATTRIBUTE_DIRECTORY\n");
1493 if(file_attributes
& 0x0020)
1494 Printf(" SMB_FILE_ATTRIBUTE_ARCHIVE\n");
1496 Printf("creation time = 0x%08lx\n",(((unsigned long)vwv
[2]) << 16) | vwv
[1]);
1497 Printf(" %s\n",convert_utime_to_string((((unsigned long)vwv
[2]) << 16) | vwv
[1]));
1498 Printf("buffer format = %ld\n",filename
[0]);
1499 Printf("file pathname = '%s'\n",filename
+1);
1503 if(num_parameter_words
<= 0)
1506 Printf("file handle = 0x%04lx\n",vwv
[0]);
1509 else if (command
== SMB_COM_CLOSE
)
1511 if(smb_packet_source
== smb_packet_from_consumer
)
1513 Printf("file handle = 0x%04lx\n",vwv
[0]);
1514 Printf("last time modified = 0x%08lx\n",(((unsigned long)vwv
[2]) << 16) | vwv
[1]);
1515 Printf(" %s\n",convert_utime_to_string((((unsigned long)vwv
[2]) << 16) | vwv
[1]));
1518 else if (command
== SMB_COM_DELETE
)
1520 if(smb_packet_source
== smb_packet_from_consumer
)
1523 int search_attributes
;
1525 if(num_data_bytes
> 255)
1526 num_data_bytes
= 255;
1528 memmove(filename
,data
,num_data_bytes
);
1529 filename
[num_data_bytes
] = '\0';
1531 search_attributes
= vwv
[0];
1532 Printf("search attributes = 0x%04lx\n",search_attributes
);
1534 if(search_attributes
& 0x0100)
1535 Printf(" SMB_SEARCH_ATTRIBUTE_READONLY\n");
1537 if(search_attributes
& 0x0200)
1538 Printf(" SMB_SEARCH_ATTRIBUTE_HIDDEN\n");
1540 if(search_attributes
& 0x0400)
1541 Printf(" SMB_SEARCH_ATTRIBUTE_SYSTEM\n");
1543 if(search_attributes
& 0x1000)
1544 Printf(" SMB_SEARCH_ATTRIBUTE_DIRECTORY\n");
1546 if(search_attributes
& 0x2000)
1547 Printf(" SMB_SEARCH_ATTRIBUTE_ARCHIVE\n");
1549 Printf("buffer format = %ld\n",filename
[0]);
1550 Printf("file name = '%s'\n",filename
+1);
1553 else if (command
== SMB_COM_RENAME
)
1555 if(smb_packet_source
== smb_packet_from_consumer
)
1557 int search_attributes
;
1558 const char * old_file_name
;
1559 const char * new_file_name
;
1562 search_attributes
= vwv
[0];
1563 Printf("search attributes = 0x%04lx\n",search_attributes
);
1565 if(search_attributes
& 0x0100)
1566 Printf(" SMB_SEARCH_ATTRIBUTE_READONLY\n");
1568 if(search_attributes
& 0x0200)
1569 Printf(" SMB_SEARCH_ATTRIBUTE_HIDDEN\n");
1571 if(search_attributes
& 0x0400)
1572 Printf(" SMB_SEARCH_ATTRIBUTE_SYSTEM\n");
1574 if(search_attributes
& 0x1000)
1575 Printf(" SMB_SEARCH_ATTRIBUTE_DIRECTORY\n");
1577 if(search_attributes
& 0x2000)
1578 Printf(" SMB_SEARCH_ATTRIBUTE_ARCHIVE\n");
1580 old_file_name
= data
;
1581 len
= strlen(old_file_name
);
1583 new_file_name
= &old_file_name
[len
+1];
1585 Printf("buffer format 1 = %ld\n",old_file_name
[0]);
1586 Printf("old file name = '%s'\n",old_file_name
+1);
1588 Printf("buffer format 2 = %ld\n",new_file_name
[0]);
1589 Printf("new file name = '%s'\n",new_file_name
+1);
1592 else if (command
== SMB_COM_QUERY_INFORMATION
)
1594 if(smb_packet_source
== smb_packet_from_consumer
)
1598 if(num_data_bytes
> 255)
1599 num_data_bytes
= 255;
1601 memmove(filename
,data
,num_data_bytes
);
1602 filename
[num_data_bytes
] = '\0';
1604 Printf("buffer format = 0x%02lx\n",filename
[0]);
1605 Printf("file pathname = '%s'\n",filename
+1);
1609 int file_attributes
;
1611 if(num_parameter_words
<= 0)
1614 file_attributes
= vwv
[0];
1615 Printf("file attributes = 0x%04lx\n",file_attributes
);
1617 if((file_attributes
& 0x001f) == 0)
1618 Printf(" SMB_FILE_ATTRIBUTE_NORMAL\n");
1620 if(file_attributes
& 0x0001)
1621 Printf(" SMB_FILE_ATTRIBUTE_READ_ONLY\n");
1623 if(file_attributes
& 0x0002)
1624 Printf(" SMB_FILE_ATTRIBUTE_HIDDEN\n");
1626 if(file_attributes
& 0x0004)
1627 Printf(" SMB_FILE_ATTRIBUTE_SYSTEM\n");
1629 if(file_attributes
& 0x0008)
1630 Printf(" SMB_FILE_ATTRIBUTE_VOLUME\n");
1632 if(file_attributes
& 0x0010)
1633 Printf(" SMB_FILE_ATTRIBUTE_DIRECTORY\n");
1635 if(file_attributes
& 0x0020)
1636 Printf(" SMB_FILE_ATTRIBUTE_ARCHIVE\n");
1638 Printf("last write time = 0x%08lx\n",(((unsigned long)vwv
[2]) << 16) | vwv
[1]);
1639 Printf(" %s\n",convert_utime_to_string((((unsigned long)vwv
[2]) << 16) | vwv
[1]));
1640 Printf("file size = %lu\n",(((unsigned long)vwv
[4]) << 16) | vwv
[3]);
1643 else if (command
== SMB_COM_SET_INFORMATION
)
1645 if(smb_packet_source
== smb_packet_from_consumer
)
1648 int file_attributes
;
1650 if(num_data_bytes
> 255)
1651 num_data_bytes
= 255;
1653 memmove(filename
,data
,num_data_bytes
);
1654 filename
[num_data_bytes
] = '\0';
1656 file_attributes
= vwv
[0];
1657 Printf("file attributes = 0x%04lx\n",file_attributes
);
1659 if((file_attributes
& 0x001f) == 0)
1660 Printf(" SMB_FILE_ATTRIBUTE_NORMAL\n");
1662 if(file_attributes
& 0x0001)
1663 Printf(" SMB_FILE_ATTRIBUTE_READ_ONLY\n");
1665 if(file_attributes
& 0x0002)
1666 Printf(" SMB_FILE_ATTRIBUTE_HIDDEN\n");
1668 if(file_attributes
& 0x0004)
1669 Printf(" SMB_FILE_ATTRIBUTE_SYSTEM\n");
1671 if(file_attributes
& 0x0008)
1672 Printf(" SMB_FILE_ATTRIBUTE_VOLUME\n");
1674 if(file_attributes
& 0x0010)
1675 Printf(" SMB_FILE_ATTRIBUTE_DIRECTORY\n");
1677 if(file_attributes
& 0x0020)
1678 Printf(" SMB_FILE_ATTRIBUTE_ARCHIVE\n");
1680 Printf("creation time = 0x%08lx\n",(((unsigned long)vwv
[2]) << 16) | vwv
[1]);
1681 Printf(" %s\n",convert_utime_to_string((((unsigned long)vwv
[2]) << 16) | vwv
[1]));
1682 Printf("file pathname = '%s'\n",filename
+1);
1685 else if (command
== SMB_COM_READ
)
1687 if(smb_packet_source
== smb_packet_from_consumer
)
1689 Printf("file handle = 0x%04lx\n",(signed short)vwv
[0]);
1690 Printf("count of bytes to read = %ld\n",vwv
[1]);
1691 Printf("read offset in bytes = %lu\n",(((unsigned long)vwv
[3]) << 16) | vwv
[2]);
1692 Printf("estimate of remaining bytes to be read = %ld\n",vwv
[4]);
1696 unsigned char buffer_format
;
1697 unsigned short count_of_bytes_read
;
1700 if(num_parameter_words
<= 0)
1703 Printf("count of bytes returned = %ld\n",vwv
[0]);
1705 buffer_format
= next_data_byte(data
,&offset
);
1706 count_of_bytes_read
= next_data_word(data
,&offset
);
1708 Printf("buffer format = %lu\n",buffer_format
);
1709 Printf("count of bytes read = %lu\n",count_of_bytes_read
);
1711 if(count_of_bytes_read
> 0)
1713 struct line_buffer lb
;
1715 Printf("raw data (%ld bytes) =\n",count_of_bytes_read
);
1717 print_smb_data(&lb
,count_of_bytes_read
,next_data_bytes(data
,count_of_bytes_read
,&offset
));
1721 else if (command
== SMB_COM_WRITE
)
1723 if(smb_packet_source
== smb_packet_from_consumer
)
1725 unsigned char buffer_format
;
1726 unsigned short data_length
;
1729 Printf("file handle = 0x%04lx\n",vwv
[0]);
1730 Printf("count of bytes to write = %ld\n",vwv
[1]);
1731 Printf("write offset in bytes = %lu\n",(((unsigned long)vwv
[3]) << 16) | vwv
[2]);
1732 Printf("estimate of remaining bytes to be written = %ld\n",vwv
[4]);
1734 buffer_format
= next_data_byte(data
,&offset
);
1735 data_length
= next_data_word(data
,&offset
);
1737 Printf("buffer format = %lu\n",buffer_format
);
1738 Printf("data length = %lu\n",data_length
);
1742 struct line_buffer lb
;
1744 Printf("raw data (%ld bytes) =\n",data_length
);
1746 print_smb_data(&lb
,data_length
,next_data_bytes(data
,data_length
,&offset
));
1751 if(num_parameter_words
<= 0)
1754 Printf("count of bytes written = %ld\n",vwv
[0]);
1757 else if (command
== SMB_COM_SEEK
)
1759 if(smb_packet_source
== smb_packet_from_consumer
)
1763 Printf("file handle = 0x%04lx\n",vwv
[0]);
1766 Printf("mode = 0x%04lx\n",mode
);
1772 Printf(" Seek from the start of the file\n");
1777 Printf(" Seek from the current position\n");
1782 Printf(" Seek from the end of the file\n");
1786 Printf("offset = %ld\n",(long)((((unsigned long)vwv
[3]) << 16) | vwv
[2]));
1790 if(num_parameter_words
<= 0)
1793 Printf("absolute position = %lu\n",(((unsigned long)vwv
[1]) << 16) | vwv
[0]);
1796 else if (command
== SMB_COM_READ_RAW
)
1798 if(smb_packet_source
== smb_packet_from_consumer
)
1800 Printf("file handle = 0x%04lx\n",(signed short)vwv
[0]);
1801 Printf("offset = %lu\n",(((unsigned long)vwv
[2]) << 16) | vwv
[1]);
1802 Printf("maximum count of bytes to return = %ld\n",vwv
[3]);
1803 Printf("minimum count of byte to return = %ld\n",vwv
[4]);
1804 Printf("timeout = %lu\n",(((unsigned long)vwv
[6]) << 16) | vwv
[5]);
1806 if(num_parameter_words
== 0x0A)
1807 Printf("offset high = %lu\n",(((unsigned long)vwv
[9]) << 16) | vwv
[8]);
1810 else if (command
== SMB_COM_WRITE_RAW
)
1812 if(smb_packet_source
== smb_packet_from_consumer
)
1814 unsigned short data_length
;
1815 unsigned short data_offset
;
1817 Printf("file handle = 0x%04lx\n",vwv
[0]);
1818 Printf("cound of bytes = %lu\n",vwv
[1]);
1819 Printf("offset = %lu\n",(((unsigned long)vwv
[4]) << 16) | vwv
[3]);
1820 Printf("timeout = %lu\n",(((unsigned long)vwv
[6]) << 16) | vwv
[5]);
1821 Printf("write mode = %ld\n",vwv
[7]);
1824 Printf(" Writethrough mode\n");
1827 Printf(" Read bytes available\n");
1830 Printf(" Named pipe raw\n");
1833 Printf(" Named pipe start\n");
1835 data_length
= vwv
[8];
1836 data_offset
= vwv
[9];
1838 Printf("data length = %lu\n",data_length
);
1839 Printf("data offset = %lu\n",data_offset
);
1841 if(num_parameter_words
== 0x0E)
1842 Printf("offset high = %lu\n",(((unsigned long)vwv
[11]) << 16) | vwv
[10]);
1846 struct line_buffer lb
;
1848 if(header
->data_offset
< data_offset
)
1849 Printf("padding bytes = %ld\n",data_offset
- header
->data_offset
);
1851 Printf("raw data (%ld bytes) =\n",data_length
);
1853 print_smb_data(&lb
,num_data_bytes
,&header
->raw_packet
[data_offset
]);
1858 if(num_parameter_words
> 0)
1859 Printf("number of bytes remaining to be written = %lu\n",vwv
[0]);
1862 else if (command
== SMB_COM_WRITE_COMPLETE
)
1864 if(smb_packet_source
== smb_packet_to_consumer
&& num_parameter_words
> 0)
1865 Printf("total number of bytes written = %lu\n",vwv
[0]);
1867 else if (command
== SMB_COM_SET_INFORMATION2
)
1869 if(smb_packet_source
== smb_packet_from_consumer
)
1871 Printf("fid = %ld\n",vwv
[0]);
1872 Printf("creation date = 0x%04lx\n",vwv
[1]);
1873 Printf("creation time = 0x%04lx\n",vwv
[2]);
1874 Printf("creation = %s\n",convert_smb_date_time_to_string(vwv
[1],vwv
[2]));
1875 Printf("last access date = 0x%04lx\n",vwv
[3]);
1876 Printf("last access time = 0x%04lx\n",vwv
[4]);
1877 Printf("last access = %s\n",convert_smb_date_time_to_string(vwv
[3],vwv
[4]));
1878 Printf("last write date = 0x%04lx\n",vwv
[5]);
1879 Printf("last write time = 0x%04lx\n",vwv
[6]);
1880 Printf("last write = %s\n",convert_smb_date_time_to_string(vwv
[5],vwv
[6]));
1883 else if (command
== SMB_COM_QUERY_INFORMATION2
)
1885 if(smb_packet_source
== smb_packet_to_consumer
&& num_parameter_words
> 0x11)
1887 int file_attributes
;
1889 Printf("fid = %ld\n",vwv
[0]);
1890 Printf("creation date = 0x%04lx\n",vwv
[1]);
1891 Printf("creation time = 0x%04lx\n",vwv
[2]);
1892 Printf("creation = %s\n",convert_smb_date_time_to_string(vwv
[1],vwv
[2]));
1893 Printf("last access date = 0x%04lx\n",vwv
[3]);
1894 Printf("last access time = 0x%04lx\n",vwv
[4]);
1895 Printf("last access = %s\n",convert_smb_date_time_to_string(vwv
[3],vwv
[4]));
1896 Printf("last write date = 0x%04lx\n",vwv
[5]);
1897 Printf("last write time = 0x%04lx\n",vwv
[6]);
1898 Printf("last write = %s\n",convert_smb_date_time_to_string(vwv
[5],vwv
[6]));
1899 Printf("file data size = %lu\n",(((unsigned long)vwv
[8]) << 16) | vwv
[7]);
1900 Printf("file allocation size = %lu\n",(((unsigned long)vwv
[10]) << 16) | vwv
[9]);
1902 file_attributes
= vwv
[11];
1903 Printf("file attributes = 0x%04lx\n",file_attributes
);
1905 if((file_attributes
& 0x001f) == 0)
1906 Printf(" SMB_FILE_ATTRIBUTE_NORMAL\n");
1908 if(file_attributes
& 0x0001)
1909 Printf(" SMB_FILE_ATTRIBUTE_READ_ONLY\n");
1911 if(file_attributes
& 0x0002)
1912 Printf(" SMB_FILE_ATTRIBUTE_HIDDEN\n");
1914 if(file_attributes
& 0x0004)
1915 Printf(" SMB_FILE_ATTRIBUTE_SYSTEM\n");
1917 if(file_attributes
& 0x0008)
1918 Printf(" SMB_FILE_ATTRIBUTE_VOLUME\n");
1920 if(file_attributes
& 0x0010)
1921 Printf(" SMB_FILE_ATTRIBUTE_DIRECTORY\n");
1923 if(file_attributes
& 0x0020)
1924 Printf(" SMB_FILE_ATTRIBUTE_ARCHIVE\n");
1927 else if (command
== SMB_COM_LOCKING_ANDX
)
1929 if(smb_packet_source
== smb_packet_from_consumer
)
1932 int number_of_requested_unlocks
;
1933 int number_of_requested_locks
;
1937 Printf("fid = %ld\n",vwv
[0]);
1939 type_of_lock
= vwv
[1] & 0xff;
1940 Printf("type of lock = %ld\n",type_of_lock
);
1942 if(type_of_lock
& 0x01)
1943 Printf(" SHARED_LOCK\n");
1945 Printf(" READ_WRITE_LOCK\n");
1947 if(type_of_lock
& 0x02)
1948 Printf(" OPLOCK_RELEASE\n");
1950 if(type_of_lock
& 0x04)
1951 Printf(" CHANGE_LOCK_TYPE\n");
1953 if(type_of_lock
& 0x08)
1954 Printf(" CANCEL_LOCK\n");
1956 if(type_of_lock
& 0x10)
1957 Printf(" LARGE_FILES\n");
1959 Printf("new oplock level = 0x%02lx\n",(vwv
[1] >> 8) & 0xff);
1961 Printf("timeout = %lu\n",(((unsigned long)vwv
[3]) << 16) | vwv
[2]);
1963 number_of_requested_unlocks
= vwv
[4];
1965 Printf("number of requested unlocks = %ld\n",number_of_requested_unlocks
);
1967 number_of_requested_locks
= vwv
[5];
1969 Printf("number of requested locks = %ld\n",number_of_requested_locks
);
1973 for(i
= 0 ; i
< number_of_requested_unlocks
; i
++)
1975 Printf("unlock range[%ld] pid=%ld, byte offset = %lu, length in bytes = %lu\n",
1976 i
,next_data_word(data
,&offset
),next_data_dword(data
,&offset
),next_data_dword(data
,&offset
));
1979 for(i
= 0 ; i
< number_of_requested_locks
; i
++)
1981 Printf("lock range[%ld] pid=%ld, byte offset = %lu, length in bytes = %lu\n",
1982 i
,next_data_word(data
,&offset
),next_data_dword(data
,&offset
),next_data_dword(data
,&offset
));
1986 else if (command
== SMB_COM_TRANSACTION2
)
1988 const unsigned short * setup_words
;
1989 const char * subcommand_name
;
1991 if(smb_packet_source
== smb_packet_from_consumer
)
1993 int transaction_parameter_count
;
1994 int transaction_parameter_offset
;
1995 int transaction_data_count
;
1996 int transaction_data_offset
;
2001 Printf("total parameter count = %ld\n",vwv
[0]);
2002 Printf("total data count = %ld\n",vwv
[1]);
2003 Printf("max parameter count = %ld\n",vwv
[2]);
2004 Printf("max data count = %ld\n",vwv
[3]);
2005 Printf("max setup count = %ld\n",vwv
[4] & 0xff);
2008 Printf("flags = 0x%04lx\n",flags
);
2011 Printf(" DISCONNECT_TID\n");
2014 Printf(" NO_RESPONSE\n");
2016 Printf("timeout = %lu\n",(((unsigned long)vwv
[7]) << 16) | vwv
[6]);
2018 transaction_parameter_count
= vwv
[9];
2019 Printf("parameter count = %ld\n",transaction_parameter_count
);
2021 transaction_parameter_offset
= vwv
[10];
2022 Printf("parameter offset = %ld (header parameter offset = %ld)\n",transaction_parameter_offset
,header
->parameter_offset
);
2024 transaction_data_count
= vwv
[11];
2025 Printf("data count = %ld\n",transaction_data_count
);
2027 transaction_data_offset
= vwv
[12];
2028 Printf("data offset = %ld (header data offset = %ld)\n",transaction_data_offset
,header
->data_offset
);
2030 setup_count
= vwv
[13] & 0xff;
2031 Printf("setup count = %ld\n",setup_count
);
2033 setup_words
= &vwv
[14];
2037 last_smb_com_transaction_subcommand
= setup_words
[0];
2039 subcommand_name
= get_smb_transaction2_subcommand_name(setup_words
[0]);
2040 if(subcommand_name
!= NULL
)
2041 Printf("subcommand = %s\n",subcommand_name
);
2043 Printf("subcommand = %ld\n",setup_words
[0]);
2045 for(i
= 0 ; i
< setup_count
; i
++)
2046 Printf("setup word [%ld] = 0x%04lx\n",i
,setup_words
[i
]);
2050 last_smb_com_transaction_subcommand
= -1;
2053 if(transaction_parameter_count
> 0 && transaction_parameter_offset
+ transaction_parameter_count
<= header
->raw_packet_size
)
2055 const unsigned char * transaction_parameter_contents
= (unsigned char *)&header
->raw_packet
[transaction_parameter_offset
];
2056 struct line_buffer lb
;
2058 Printf("transaction parameters =\n");
2060 print_smb_data(&lb
,transaction_parameter_count
,transaction_parameter_contents
);
2063 if(transaction_data_count
> 0 && transaction_data_offset
+ transaction_data_count
<= header
->raw_packet_size
)
2065 const unsigned char * transaction_data_contents
= (unsigned char *)&header
->raw_packet
[transaction_data_offset
];
2066 struct line_buffer lb
;
2068 Printf("transaction data =\n");
2070 print_smb_data(&lb
,transaction_data_count
,transaction_data_contents
);
2073 print_smb_transaction2_subcommand(last_smb_com_transaction_subcommand
,smb_packet_source
,
2074 transaction_parameter_count
,(unsigned char *)&header
->raw_packet
[transaction_parameter_offset
],
2075 transaction_data_count
,(unsigned char *)&header
->raw_packet
[transaction_data_offset
]);
2077 else if (num_parameter_words
> 0 || num_data_bytes
> 0)
2079 int transaction_parameter_count
;
2080 int transaction_parameter_offset
;
2081 int transaction_data_count
;
2082 int transaction_data_offset
;
2086 Printf("total parameter count = %ld\n",vwv
[0]);
2087 Printf("total data count = %ld\n",vwv
[1]);
2089 transaction_parameter_count
= vwv
[3];
2090 Printf("parameter count = %ld\n",transaction_parameter_count
);
2092 transaction_parameter_offset
= vwv
[4];
2093 Printf("parameter offset = %ld\n",transaction_parameter_offset
);
2095 Printf("parameter displacement = %ld\n",vwv
[5]);
2097 transaction_data_count
= vwv
[6];
2098 Printf("data count = %ld\n",transaction_data_count
);
2100 transaction_data_offset
= vwv
[7];
2101 Printf("data offset = %ld\n",transaction_data_offset
);
2103 setup_count
= vwv
[8] & 0xff;
2104 Printf("setup count = %ld\n",setup_count
);
2106 setup_words
= &vwv
[9];
2110 subcommand_name
= get_smb_transaction2_subcommand_name(setup_words
[0]);
2111 if(subcommand_name
!= NULL
)
2112 Printf("subcommand = %s\n",subcommand_name
);
2114 Printf("subcommand = %ld\n",setup_words
[0]);
2116 for(i
= 0 ; i
< setup_count
; i
++)
2117 Printf("setup word [%ld] = 0x%04lx\n",i
,setup_words
[i
]);
2120 if(transaction_parameter_count
> 0 && transaction_parameter_offset
+ transaction_parameter_count
<= header
->raw_packet_size
)
2122 const unsigned char * transaction_parameter_contents
= (unsigned char *)&header
->raw_packet
[transaction_parameter_offset
];
2123 struct line_buffer lb
;
2125 Printf("transaction parameters =\n");
2127 print_smb_data(&lb
,transaction_parameter_count
,transaction_parameter_contents
);
2130 if(transaction_data_count
> 0 && transaction_data_offset
+ transaction_data_count
<= header
->raw_packet_size
)
2132 const unsigned char * transaction_data_contents
= (unsigned char *)&header
->raw_packet
[transaction_data_offset
];
2133 struct line_buffer lb
;
2135 Printf("transaction data =\n");
2137 print_smb_data(&lb
,transaction_data_count
,transaction_data_contents
);
2140 print_smb_transaction2_subcommand(last_smb_com_transaction_subcommand
,smb_packet_source
,
2141 transaction_parameter_count
,(unsigned char *)&header
->raw_packet
[transaction_parameter_offset
],
2142 transaction_data_count
,(unsigned char *)&header
->raw_packet
[transaction_data_offset
]);
2145 else if (command
== SMB_COM_TREE_CONNECT
)
2147 if(smb_packet_source
== smb_packet_from_consumer
)
2150 const char * password
;
2151 const char * service
;
2154 path
= (char *)data
;
2157 password
= &path
[len
+1];
2158 len
= strlen(password
);
2160 service
= &password
[len
+1];
2162 Printf("buffer format 1 = %ld\n",path
[0]);
2163 Printf("path = '%s'\n",path
+1);
2164 Printf("buffer format 2 = %ld\n",password
[0]);
2165 Printf("password = '%s'\n",password
+1);
2166 Printf("buffer format 3 = %ld\n",service
[0]);
2167 Printf("service = '%s'\n",service
+1);
2171 if(num_parameter_words
<= 0)
2174 Printf("max buffer size = %ld\n",vwv
[0]);
2175 Printf("tid = %ld\n",vwv
[1]);
2178 else if (command
== SMB_COM_NEGOTIATE
)
2180 if(smb_packet_source
== smb_packet_from_consumer
)
2183 const char * dialect
;
2187 if(num_data_bytes
> 1023)
2188 num_data_bytes
= 1023;
2190 memmove(args
,data
,num_data_bytes
);
2191 args
[num_data_bytes
] = '\0';
2196 while(dialect
< &args
[num_data_bytes
])
2198 Printf("dialect[%ld] = '%s'\n",dialect_index
++,&dialect
[1]);
2200 len
= strlen(&dialect
[1]);
2202 dialect
= &dialect
[1+len
+1];
2207 /* Assuming that the data returned is for
2208 * the "NT LAN MANAGER" dialect.
2210 if(num_parameter_words
== 0x11)
2213 int challenge_length
;
2215 unsigned long capabilities
;
2216 struct line_buffer lb
;
2219 unsigned long system_time
[2];
2221 Printf("dialect index = %ld\n",next_data_word(parameters
,&offset
));
2223 security_mode
= next_data_byte(parameters
,&offset
);
2224 Printf("security mode = %ld\n",security_mode
);
2226 if(security_mode
& 0x01)
2227 Printf(" NEGOTIATE_USER_SECURITY\n");
2229 if(security_mode
& 0x02)
2230 Printf(" NEGOTIATE_ENCRYPT_PASSWORDS\n");
2232 if(security_mode
& 0x04)
2233 Printf(" NEGOTIATE_SECURITY_SIGNATURES_ENABLE\n");
2235 if(security_mode
& 0x08)
2236 Printf(" NEGOTIATE_SECURITY_SIGNATURES_REQUIRED\n");
2238 if(security_mode
& 0xF0)
2239 Printf(" Reserved = 0x%lx\n",security_mode
>> 4);
2241 Printf("max mpx count = %ld\n",next_data_word(parameters
,&offset
));
2242 Printf("max number cvs = %ld\n",next_data_word(parameters
,&offset
));
2243 Printf("max buffer size = %lu\n",next_data_dword(parameters
,&offset
));
2244 Printf("max raw size = %lu\n",next_data_dword(parameters
,&offset
));
2245 Printf("session key = %lu\n",next_data_dword(parameters
,&offset
));
2247 capabilities
= next_data_dword(parameters
,&offset
);
2248 Printf("capabilities = 0x%08lx\n",capabilities
);
2250 if(capabilities
& 0x00000001)
2251 Printf(" CAP_RAW_MODE\n");
2253 if(capabilities
& 0x00000002)
2254 Printf(" CAP_MPX_MODE\n");
2256 if(capabilities
& 0x00000004)
2257 Printf(" CAP_UNICODE\n");
2259 if(capabilities
& 0x00000008)
2260 Printf(" CAP_LARGE_FILES\n");
2262 if(capabilities
& 0x00000010)
2263 Printf(" CAP_NT_SMBS\n");
2265 if(capabilities
& 0x00000020)
2266 Printf(" CAP_RPC_REMOTE_APIS\n");
2268 if(capabilities
& 0x00000040)
2269 Printf(" CAP_STATUS32\n");
2271 if(capabilities
& 0x00000080)
2272 Printf(" CAP_LEVEL_II_OPLOCKS\n");
2274 if(capabilities
& 0x00000100)
2275 Printf(" CAP_LOCK_AND_READ\n");
2277 if(capabilities
& 0x00000200)
2278 Printf(" CAP_NT_FIND\n");
2280 if(capabilities
& 0x00000400)
2281 Printf(" CAP_BULK_TRANSFER\n");
2283 if(capabilities
& 0x00000800)
2284 Printf(" CAP_COMPRESSED_DATA\n");
2286 if(capabilities
& 0x00001000)
2287 Printf(" CAP_DFS\n");
2289 if(capabilities
& 0x00002000)
2290 Printf(" CAP_QUADWORD_ALIGNED\n");
2292 if(capabilities
& 0x00004000)
2293 Printf(" CAP_LARGE_READX\n");
2295 if(capabilities
& 0x00008000)
2296 Printf(" CAP_LARGE_WRITEX\n");
2298 if(capabilities
& 0x00800000)
2299 Printf(" CAP_UNIX\n");
2301 if(capabilities
& 0x20000000)
2302 Printf(" CAP_BULK_TRANSFER\n");
2304 if(capabilities
& 0x40000000)
2305 Printf(" CAP_COMPRESSED_DATA\n");
2307 if(capabilities
& 0x80000000)
2308 Printf(" CAP_EXTENDED_SECURITY\n");
2310 next_data_qword(parameters
,system_time
,&offset
);
2312 Printf("system time = 0x%08lx%08lx\n",system_time
[0],system_time
[1]);
2313 Printf(" %s\n",convert_filetime_to_string(system_time
));
2314 Printf("server time zone = %ld\n",(signed short)next_data_word(parameters
,&offset
)); /* ZZZ this is a signed 16 bit integer */
2316 challenge_length
= next_data_byte(parameters
,&offset
);
2317 Printf("challenge length = %ld\n",challenge_length
);
2319 if(challenge_length
> 0)
2321 if(challenge_length
== 8)
2323 Printf("challenge = %02lx %02lx %02lx %02lx %02lx %02lx %02lx %02lx\n",
2324 data
[0],data
[1],data
[2],data
[3],
2325 data
[4],data
[5],data
[6],data
[7]);
2329 init_line_buffer(&lb
);
2331 offset
= challenge_length
;
2334 while(offset
< num_data_bytes
)
2336 unicode_char
= next_data_word(data
,&offset
);
2337 if(unicode_char
== 0)
2340 if(' ' <= unicode_char
&& unicode_char
< 127)
2342 char c
= unicode_char
;
2344 copy_string_to_line_buffer(&lb
,&c
,1,output_offset
);
2349 char code_string
[40];
2351 SPrintf(code_string
,"<%02lx%02ld>",unicode_char
>> 8,unicode_char
& 0xff);
2353 copy_string_to_line_buffer(&lb
,code_string
,strlen(code_string
),output_offset
);
2354 output_offset
+= strlen(code_string
);
2358 Printf("Domain name = '%s'\n",lb
.line
);
2362 if(num_parameter_words
<= 0)
2365 Printf("dialect index = %ld\n",vwv
[0]);
2369 else if (command
== SMB_COM_SESSION_SETUP_ANDX
)
2374 const char * oem_password
= "";
2375 const char * unicode_password
= "";
2376 const char * account_name
= "";
2377 const char * primary_domain
= "";
2378 const char * native_os
= "";
2379 const char * native_lan_man
= "";
2381 if(num_data_bytes
> 1023)
2382 num_data_bytes
= 1023;
2384 memmove(args
,data
,num_data_bytes
);
2385 args
[num_data_bytes
] = '\0';
2387 args_end
= &args
[num_data_bytes
];
2389 if(smb_packet_source
== smb_packet_from_consumer
)
2391 int oem_password_length
;
2392 int unicode_password_length
;
2393 unsigned long capabilities
;
2395 Printf("consumer's maximum buffer size = %ld\n",vwv
[0]);
2396 Printf("actual maximum multiplexed pending requests = %ld\n",vwv
[1]);
2397 Printf("vc number = %ld\n",vwv
[2]);
2398 Printf("session key = 0x%08lx\n",(((unsigned long)vwv
[4]) << 16) | vwv
[3]);
2400 oem_password_length
= vwv
[5];
2401 Printf("oem password length = %ld\n",oem_password_length
);
2403 unicode_password_length
= vwv
[6];
2404 Printf("unicode password length = %ld\n",unicode_password_length
);
2406 capabilities
= (((unsigned long)vwv
[10]) << 16) | vwv
[9];
2408 Printf("capabilities = 0x%08lx\n",capabilities
);
2410 if(capabilities
& 0x00000001)
2411 Printf(" CAP_RAW_MODE\n");
2413 if(capabilities
& 0x00000002)
2414 Printf(" CAP_MPX_MODE\n");
2416 if(capabilities
& 0x00000004)
2417 Printf(" CAP_UNICODE\n");
2419 if(capabilities
& 0x00000008)
2420 Printf(" CAP_LARGE_FILES\n");
2422 if(capabilities
& 0x00000010)
2423 Printf(" CAP_NT_SMBS\n");
2425 if(capabilities
& 0x00000020)
2426 Printf(" CAP_RPC_REMOTE_APIS\n");
2428 if(capabilities
& 0x00000040)
2429 Printf(" CAP_STATUS32\n");
2431 if(capabilities
& 0x00000080)
2432 Printf(" CAP_LEVEL_II_OPLOCKS\n");
2434 if(capabilities
& 0x00000100)
2435 Printf(" CAP_LOCK_AND_READ\n");
2437 if(capabilities
& 0x00000200)
2438 Printf(" CAP_NT_FIND\n");
2440 if(capabilities
& 0x00000400)
2441 Printf(" CAP_BULK_TRANSFER\n");
2443 if(capabilities
& 0x00000800)
2444 Printf(" CAP_COMPRESSED_DATA\n");
2446 if(capabilities
& 0x00001000)
2447 Printf(" CAP_DFS\n");
2449 if(capabilities
& 0x00002000)
2450 Printf(" CAP_QUADWORD_ALIGNED\n");
2452 if(capabilities
& 0x00004000)
2453 Printf(" CAP_LARGE_READX\n");
2455 if(capabilities
& 0x00800000)
2456 Printf(" CAP_UNIX\n");
2458 if(capabilities
& 0x80000000)
2459 Printf(" CAP_EXTENDED_SECURITY\n");
2461 if(num_data_bytes
> 0)
2463 oem_password
= args
;
2465 len
= oem_password_length
;
2467 unicode_password
= &oem_password
[len
];
2468 if(unicode_password
< args_end
)
2470 len
= unicode_password_length
;
2472 /* There could be a padding byte here which
2473 * aligns the account name to a word
2476 if((header
->flags2
& SMB_FLAGS2_UNICODE_STRINGS
) && (len
% 2) == 1)
2479 account_name
= &unicode_password
[len
];
2480 if(account_name
< args_end
)
2482 len
= strlen(account_name
);
2484 /* ZZZ could be Unicode if SMB_FLAGS2_UNICODE_STRINGS is set. */
2485 primary_domain
= &account_name
[len
+1];
2486 if(primary_domain
< args_end
)
2488 len
= strlen(primary_domain
);
2490 /* ZZZ could be Unicode if SMB_FLAGS2_UNICODE_STRINGS is set. */
2491 native_os
= &primary_domain
[len
+1];
2492 if(native_os
< args_end
)
2494 len
= strlen(native_os
);
2496 /* ZZZ could be Unicode if SMB_FLAGS2_UNICODE_STRINGS is set. */
2497 native_lan_man
= &native_os
[len
+1];
2504 Printf("account name = '%s'\n",account_name
);
2505 Printf("primary domain = '%s'\n",primary_domain
);
2506 Printf("native os = '%s'\n",native_os
);
2507 Printf("native lan man = '%s'\n",native_lan_man
);
2513 if(num_parameter_words
<= 0)
2516 request_mode
= vwv
[0];
2517 Printf("request mode = 0x%04lx\n",request_mode
);
2519 if(request_mode
& 0x0001)
2520 Printf(" SMB_SETUP_GUEST\n");
2522 if(request_mode
& 0x0002)
2523 Printf(" SMB_SETUP_USE_LANMAN_KEY\n");
2525 if(num_data_bytes
> 0)
2527 /* ZZZ could be Unicode if SMB_FLAGS2_UNICODE_STRINGS is set. */
2530 len
= strlen(native_os
);
2532 /* ZZZ could be Unicode if SMB_FLAGS2_UNICODE_STRINGS is set. */
2533 native_lan_man
= &native_os
[len
+1];
2534 if(native_lan_man
< args_end
)
2536 len
= strlen(native_lan_man
);
2538 /* ZZZ could be Unicode if SMB_FLAGS2_UNICODE_STRINGS is set. */
2539 primary_domain
= &native_lan_man
[len
+1];
2542 Printf("native os = '%s'\n",native_os
);
2543 Printf("native lan man = '%s'\n",native_lan_man
);
2544 Printf("primary domain = '%s'\n",primary_domain
);
2548 else if (command
== SMB_COM_TREE_CONNECT_ANDX
)
2552 if(num_data_bytes
> 1023)
2553 num_data_bytes
= 1023;
2555 memmove(args
,data
,num_data_bytes
);
2556 args
[num_data_bytes
] = '\0';
2558 if(smb_packet_source
== smb_packet_from_consumer
)
2561 const char * password
;
2562 const char * dev_name
;
2565 int password_length
;
2568 Printf("flags = 0x%04lx\n",flags
);
2571 Printf(" TREE_CONNECT_ANDX_DISCONNECT_TID\n");
2573 password_length
= vwv
[1];
2575 Printf("password length = %ld\n",password_length
);
2578 len
= password_length
;
2580 /* There could be a padding byte here which
2581 * aligns the account name to a word
2584 if((header
->flags2
& SMB_FLAGS2_UNICODE_STRINGS
) && (len
% 2) == 1)
2587 /* ZZZ could be a Unicode string. */
2588 path
= &password
[len
];
2589 len
= (int)strlen(path
)+1;
2591 dev_name
= &path
[len
];
2593 Printf("path = '%s'\n",path
);
2594 // Printf("password = '%s'\n",password);
2595 Printf("dev name = '%s'\n",dev_name
);
2600 const char * service
;
2601 const char * native_file_system
;
2603 if(num_data_bytes
<= 0)
2607 len
= strlen(service
)+1;
2609 /* ZZZ this could be Unicode text. */
2610 native_file_system
= &service
[len
];
2612 Printf("service = '%s'\n",service
);
2613 Printf("native file system = '%s'\n",native_file_system
);
2616 else if (command
== SMB_COM_QUERY_INFORMATION_DISK
)
2618 if(smb_packet_source
== smb_packet_to_consumer
&& num_parameter_words
> 3)
2620 Printf("allocation units/server = %ld\n",vwv
[0]);
2621 Printf("blocks/allocation unit = %ld\n",vwv
[1]);
2622 Printf("block size (in bytes) = %ld\n",vwv
[2]);
2623 Printf("free allocation units = %ld\n",vwv
[3]);
2626 else if (command
== SMB_COM_SEARCH
)
2628 if(smb_packet_source
== smb_packet_from_consumer
)
2630 int search_attributes
;
2631 const char * file_name
;
2632 const unsigned char * resume_key_data
;
2633 int resume_key_length
;
2637 Printf("max count = %ld\n",vwv
[0]);
2639 search_attributes
= vwv
[1];
2640 Printf("search attributes = 0x%04lx\n",search_attributes
);
2642 if(search_attributes
& 0x0100)
2643 Printf(" SMB_SEARCH_ATTRIBUTE_READONLY\n");
2645 if(search_attributes
& 0x0200)
2646 Printf(" SMB_SEARCH_ATTRIBUTE_HIDDEN\n");
2648 if(search_attributes
& 0x0400)
2649 Printf(" SMB_SEARCH_ATTRIBUTE_SYSTEM\n");
2651 if(search_attributes
& 0x1000)
2652 Printf(" SMB_SEARCH_ATTRIBUTE_DIRECTORY\n");
2654 if(search_attributes
& 0x2000)
2655 Printf(" SMB_SEARCH_ATTRIBUTE_ARCHIVE\n");
2657 file_name
= (char *)data
;
2658 len
= strlen(file_name
);
2660 Printf("buffer format = %ld\n",file_name
[0]);
2661 Printf("file name = '%s'\n",file_name
+1);
2663 resume_key_data
= (unsigned char *)&file_name
[len
+1];
2666 resume_key_length
= next_data_word(resume_key_data
,&offset
);
2668 Printf("resume key length = %ld\n",resume_key_length
);
2670 if(resume_key_length
== 21)
2672 unsigned char reserved
;
2673 const unsigned char * server_state
;
2674 const unsigned char * client_state
;
2676 reserved
= next_data_byte(resume_key_data
,&offset
);
2677 server_state
= next_data_bytes(resume_key_data
,16,&offset
);
2678 client_state
= next_data_bytes(resume_key_data
,4,&offset
);
2680 Printf("resume key reserved = %02lx\n",reserved
);
2682 Printf("resume key server state = ");
2684 for(i
= 0 ; i
< 16 ; i
++)
2685 Printf("%02lx",server_state
[i
]);
2689 Printf("resume key client state = ");
2691 for(i
= 0 ; i
< 4 ; i
++)
2692 Printf("%02lx",client_state
[i
]);
2699 unsigned char reserved
;
2700 const unsigned char * server_state
;
2701 const unsigned char * client_state
;
2703 unsigned short last_write_date
;
2704 unsigned short last_write_time
;
2710 int file_attributes
;
2711 const char * file_name
;
2713 if(num_parameter_words
<= 0)
2718 Printf("count = %ld\n",count
);
2722 buffer_format
= next_data_byte(data
,&offset
);
2724 Printf("buffer format = %ld\n",buffer_format
);
2726 data_length
= next_data_word(data
,&offset
);
2728 Printf("data length = %ld\n",data_length
);
2730 for(j
= 0 ; j
< count
; j
++)
2732 Printf("directory entry [%ld]:\n",j
);
2734 reserved
= next_data_byte(data
,&offset
);
2735 server_state
= next_data_bytes(data
,16,&offset
);
2736 client_state
= next_data_bytes(data
,4,&offset
);
2738 Printf("\tresume key reserved = %02lx\n",reserved
);
2740 Printf("\tresume key server state = ");
2742 for(i
= 0 ; i
< 16 ; i
++)
2743 Printf("%02lx",server_state
[i
]);
2747 Printf("\tresume key client state = ");
2749 for(i
= 0 ; i
< 4 ; i
++)
2750 Printf("%02lx",client_state
[i
]);
2754 file_attributes
= next_data_byte(data
,&offset
);
2756 Printf("file attributes = 0x%04lx\n",file_attributes
);
2758 if((file_attributes
& 0x001f) == 0)
2759 Printf("\t SMB_FILE_ATTRIBUTE_NORMAL\n");
2761 if(file_attributes
& 0x0001)
2762 Printf("\t SMB_FILE_ATTRIBUTE_READ_ONLY\n");
2764 if(file_attributes
& 0x0002)
2765 Printf("\t SMB_FILE_ATTRIBUTE_HIDDEN\n");
2767 if(file_attributes
& 0x0004)
2768 Printf("\t SMB_FILE_ATTRIBUTE_SYSTEM\n");
2770 if(file_attributes
& 0x0008)
2771 Printf("\t SMB_FILE_ATTRIBUTE_VOLUME\n");
2773 if(file_attributes
& 0x0010)
2774 Printf("\t SMB_FILE_ATTRIBUTE_DIRECTORY\n");
2776 if(file_attributes
& 0x0020)
2777 Printf("\t SMB_FILE_ATTRIBUTE_ARCHIVE\n");
2779 last_write_time
= next_data_word(data
,&offset
);
2780 last_write_date
= next_data_word(data
,&offset
);
2782 Printf("\tlast write time = 0x%04lx\n",last_write_time
);
2783 Printf("\tlast write date = 0x%04lx\n",last_write_date
);
2784 Printf("\tlast write = %s\n",convert_smb_date_time_to_string(last_write_date
,last_write_time
));
2785 Printf("\tfile size = %lu\n",next_data_dword(data
,&offset
));
2787 file_name
= (const char *)next_data_bytes(data
,13,&offset
);
2789 Printf("\tfile name = '%s'\n",file_name
);
2795 /*****************************************************************************/
2798 print_smb_parameters(int num_parameter_words
,const unsigned char *parameters
)
2800 if(num_parameter_words
> 0)
2805 for(i
= j
= 0 ; i
< num_parameter_words
; i
++, j
++)
2807 word_value
= parameters
[j
] + (((int)parameters
[j
+1]) << 8);
2809 Printf(" %04lx: %04lx (bytes: %02lx%02lx)\n",i
,word_value
,parameters
[j
],parameters
[j
+1]);
2814 /*****************************************************************************/
2817 print_smb_header(const struct smb_header
* header
,int header_length
,const unsigned char *packet
,
2818 int packet_size
,enum smb_packet_source_t smb_packet_source
,int max_buffer_size
)
2832 errdos_badformat
=11,
2833 errdos_badaccess
=12,
2837 errdos_diffdevice
=17,
2841 errdos_filexists
=80,
2843 errdos_notALink
=513,
2852 errsrv_invnetname
=6,
2861 errsrv_filespecs
=67,
2863 errsrv_badpermits
=69,
2865 errsrv_setattrmode
=71,
2871 errsrv_noresource
=89,
2872 errsrv_toomanyuids
=90,
2877 errsrv_badPassword
=254,
2878 errsrv_notifyEnumDir
=1024,
2879 errsrv_accountExpired
=2239,
2880 errsrv_badClient
=2240,
2881 errsrv_badLogonTime
=2241,
2882 errsrv_passwordExpired
=2242,
2883 errsrv_nosupport
=65535,
2896 errhrd_badsector
=27,
2903 errhrd_wrongdisk
=34,
2904 errhrd_FCBUnavail
=35,
2905 errhrd_sharebufexc
=36,
2910 nt_status_unsuccessful
=1,
2911 nt_status_not_implemented
=2,
2912 nt_status_invalid_info_class
=3,
2913 nt_status_info_length_mismatch
=4,
2914 nt_status_access_violation
=5,
2915 nt_status_in_page_error
=6,
2916 nt_status_pagefile_quota
=7,
2917 nt_status_invalid_handle
=8,
2918 nt_status_bad_initial_stack
=9,
2919 nt_status_bad_initial_pc
=10,
2920 nt_status_invalid_cid
=11,
2921 nt_status_timer_not_canceled
=12,
2922 nt_status_invalid_parameter
=13,
2923 nt_status_no_such_device
=14,
2924 nt_status_no_such_file
=15,
2925 nt_status_invalid_device_request
=16,
2926 nt_status_end_of_file
=17,
2927 nt_status_wrong_volume
=18,
2928 nt_status_no_media_in_device
=19,
2929 nt_status_unrecognized_media
=20,
2930 nt_status_nonexistent_sector
=21,
2931 nt_status_more_processing_required
=22,
2932 nt_status_no_memory
=23,
2933 nt_status_conflicting_addresses
=24,
2934 nt_status_not_mapped_view
=25,
2935 nt_status_unable_to_free_vm
=26,
2936 nt_status_unable_to_delete_section
=27,
2937 nt_status_invalid_system_service
=28,
2938 nt_status_illegal_instruction
=29,
2939 nt_status_invalid_lock_sequence
=30,
2940 nt_status_invalid_view_size
=31,
2941 nt_status_invalid_file_for_section
=32,
2942 nt_status_already_committed
=33,
2943 nt_status_access_denied
=34,
2944 nt_status_buffer_too_small
=35,
2945 nt_status_object_type_mismatch
=36,
2946 nt_status_noncontinuable_exception
=37,
2947 nt_status_invalid_disposition
=38,
2948 nt_status_unwind
=39,
2949 nt_status_bad_stack
=40,
2950 nt_status_invalid_unwind_target
=41,
2951 nt_status_not_locked
=42,
2952 nt_status_parity_error
=43,
2953 nt_status_unable_to_decommit_vm
=44,
2954 nt_status_not_committed
=45,
2955 nt_status_invalid_port_attributes
=46,
2956 nt_status_port_message_too_long
=47,
2957 nt_status_invalid_parameter_mix
=48,
2958 nt_status_invalid_quota_lower
=49,
2959 nt_status_disk_corrupt_error
=50,
2960 nt_status_object_name_invalid
=51,
2961 nt_status_object_name_not_found
=52,
2962 nt_status_object_name_collision
=53,
2963 nt_status_handle_not_waitable
=54,
2964 nt_status_port_disconnected
=55,
2965 nt_status_device_already_attached
=56,
2966 nt_status_object_path_invalid
=57,
2967 nt_status_object_path_not_found
=58,
2968 nt_status_object_path_syntax_bad
=59,
2969 nt_status_data_overrun
=60,
2970 nt_status_data_late_error
=61,
2971 nt_status_data_error
=62,
2972 nt_status_crc_error
=63,
2973 nt_status_section_too_big
=64,
2974 nt_status_port_connection_refused
=65,
2975 nt_status_invalid_port_handle
=66,
2976 nt_status_sharing_violation
=67,
2977 nt_status_quota_exceeded
=68,
2978 nt_status_invalid_page_protection
=69,
2979 nt_status_mutant_not_owned
=70,
2980 nt_status_semaphore_limit_exceeded
=71,
2981 nt_status_port_already_set
=72,
2982 nt_status_section_not_image
=73,
2983 nt_status_suspend_count_exceeded
=74,
2984 nt_status_thread_is_terminating
=75,
2985 nt_status_bad_working_set_limit
=76,
2986 nt_status_incompatible_file_map
=77,
2987 nt_status_section_protection
=78,
2988 nt_status_eas_not_supported
=79,
2989 nt_status_ea_too_large
=80,
2990 nt_status_nonexistent_ea_entry
=81,
2991 nt_status_no_eas_on_file
=82,
2992 nt_status_ea_corrupt_error
=83,
2993 nt_status_file_lock_conflict
=84,
2994 nt_status_lock_not_granted
=85,
2995 nt_status_delete_pending
=86,
2996 nt_status_ctl_file_not_supported
=87,
2997 nt_status_unknown_revision
=88,
2998 nt_status_revision_mismatch
=89,
2999 nt_status_invalid_owner
=90,
3000 nt_status_invalid_primary_group
=91,
3001 nt_status_no_impersonation_token
=92,
3002 nt_status_cant_disable_mandatory
=93,
3003 nt_status_no_logon_servers
=94,
3004 nt_status_no_such_logon_session
=95,
3005 nt_status_no_such_privilege
=96,
3006 nt_status_privilege_not_held
=97,
3007 nt_status_invalid_account_name
=98,
3008 nt_status_user_exists
=99,
3009 nt_status_no_such_user
=100,
3010 nt_status_group_exists
=101,
3011 nt_status_no_such_group
=102,
3012 nt_status_member_in_group
=103,
3013 nt_status_member_not_in_group
=104,
3014 nt_status_last_admin
=105,
3015 nt_status_wrong_password
=106,
3016 nt_status_ill_formed_password
=107,
3017 nt_status_password_restriction
=108,
3018 nt_status_logon_failure
=109,
3019 nt_status_account_restriction
=110,
3020 nt_status_invalid_logon_hours
=111,
3021 nt_status_invalid_workstation
=112,
3022 nt_status_password_expired
=113,
3023 nt_status_account_disabled
=114,
3024 nt_status_none_mapped
=115,
3025 nt_status_too_many_luids_requested
=116,
3026 nt_status_luids_exhausted
=117,
3027 nt_status_invalid_sub_authority
=118,
3028 nt_status_invalid_acl
=119,
3029 nt_status_invalid_sid
=120,
3030 nt_status_invalid_security_descr
=121,
3031 nt_status_procedure_not_found
=122,
3032 nt_status_invalid_image_format
=123,
3033 nt_status_no_token
=124,
3034 nt_status_bad_inheritance_acl
=125,
3035 nt_status_range_not_locked
=126,
3036 nt_status_disk_full
=127,
3037 nt_status_server_disabled
=128,
3038 nt_status_server_not_disabled
=129,
3039 nt_status_too_many_guids_requested
=130,
3040 nt_status_guids_exhausted
=131,
3041 nt_status_invalid_id_authority
=132,
3042 nt_status_agents_exhausted
=133,
3043 nt_status_invalid_volume_label
=134,
3044 nt_status_section_not_extended
=135,
3045 nt_status_not_mapped_data
=136,
3046 nt_status_resource_data_not_found
=137,
3047 nt_status_resource_type_not_found
=138,
3048 nt_status_resource_name_not_found
=139,
3049 nt_status_array_bounds_exceeded
=140,
3050 nt_status_float_denormal_operand
=141,
3051 nt_status_float_divide_by_zero
=142,
3052 nt_status_float_inexact_result
=143,
3053 nt_status_float_invalid_operation
=144,
3054 nt_status_float_overflow
=145,
3055 nt_status_float_stack_check
=146,
3056 nt_status_float_underflow
=147,
3057 nt_status_integer_divide_by_zero
=148,
3058 nt_status_integer_overflow
=149,
3059 nt_status_privileged_instruction
=150,
3060 nt_status_too_many_paging_files
=151,
3061 nt_status_file_invalid
=152,
3062 nt_status_allotted_space_exceeded
=153,
3063 nt_status_insufficient_resources
=154,
3064 nt_status_dfs_exit_path_found
=155,
3065 nt_status_device_data_error
=156,
3066 nt_status_device_not_connected
=157,
3067 nt_status_device_power_failure
=158,
3068 nt_status_free_vm_not_at_base
=159,
3069 nt_status_memory_not_allocated
=160,
3070 nt_status_working_set_quota
=161,
3071 nt_status_media_write_protected
=162,
3072 nt_status_device_not_ready
=163,
3073 nt_status_invalid_group_attributes
=164,
3074 nt_status_bad_impersonation_level
=165,
3075 nt_status_cant_open_anonymous
=166,
3076 nt_status_bad_validation_class
=167,
3077 nt_status_bad_token_type
=168,
3078 nt_status_bad_master_boot_record
=169,
3079 nt_status_instruction_misalignment
=170,
3080 nt_status_instance_not_available
=171,
3081 nt_status_pipe_not_available
=172,
3082 nt_status_invalid_pipe_state
=173,
3083 nt_status_pipe_busy
=174,
3084 nt_status_illegal_function
=175,
3085 nt_status_pipe_disconnected
=176,
3086 nt_status_pipe_closing
=177,
3087 nt_status_pipe_connected
=178,
3088 nt_status_pipe_listening
=179,
3089 nt_status_invalid_read_mode
=180,
3090 nt_status_io_timeout
=181,
3091 nt_status_file_forced_closed
=182,
3092 nt_status_profiling_not_started
=183,
3093 nt_status_profiling_not_stopped
=184,
3094 nt_status_could_not_interpret
=185,
3095 nt_status_file_is_a_directory
=186,
3096 nt_status_not_supported
=187,
3097 nt_status_remote_not_listening
=188,
3098 nt_status_duplicate_name
=189,
3099 nt_status_bad_network_path
=190,
3100 nt_status_network_busy
=191,
3101 nt_status_device_does_not_exist
=192,
3102 nt_status_too_many_commands
=193,
3103 nt_status_adapter_hardware_error
=194,
3104 nt_status_invalid_network_response
=195,
3105 nt_status_unexpected_network_error
=196,
3106 nt_status_bad_remote_adapter
=197,
3107 nt_status_print_queue_full
=198,
3108 nt_status_no_spool_space
=199,
3109 nt_status_print_cancelled
=200,
3110 nt_status_network_name_deleted
=201,
3111 nt_status_network_access_denied
=202,
3112 nt_status_bad_device_type
=203,
3113 nt_status_bad_network_name
=204,
3114 nt_status_too_many_names
=205,
3115 nt_status_too_many_sessions
=206,
3116 nt_status_sharing_paused
=207,
3117 nt_status_request_not_accepted
=208,
3118 nt_status_redirector_paused
=209,
3119 nt_status_net_write_fault
=210,
3120 nt_status_profiling_at_limit
=211,
3121 nt_status_not_same_device
=212,
3122 nt_status_file_renamed
=213,
3123 nt_status_virtual_circuit_closed
=214,
3124 nt_status_no_security_on_object
=215,
3125 nt_status_cant_wait
=216,
3126 nt_status_pipe_empty
=217,
3127 nt_status_cant_access_domain_info
=218,
3128 nt_status_cant_terminate_self
=219,
3129 nt_status_invalid_server_state
=220,
3130 nt_status_invalid_domain_state
=221,
3131 nt_status_invalid_domain_role
=222,
3132 nt_status_no_such_domain
=223,
3133 nt_status_domain_exists
=224,
3134 nt_status_domain_limit_exceeded
=225,
3135 nt_status_oplock_not_granted
=226,
3136 nt_status_invalid_oplock_protocol
=227,
3137 nt_status_internal_db_corruption
=228,
3138 nt_status_internal_error
=229,
3139 nt_status_generic_not_mapped
=230,
3140 nt_status_bad_descriptor_format
=231,
3141 nt_status_invalid_user_buffer
=232,
3142 nt_status_unexpected_io_error
=233,
3143 nt_status_unexpected_mm_create_err
=234,
3144 nt_status_unexpected_mm_map_error
=235,
3145 nt_status_unexpected_mm_extend_err
=236,
3146 nt_status_not_logon_process
=237,
3147 nt_status_logon_session_exists
=238,
3148 nt_status_invalid_parameter_1
=239,
3149 nt_status_invalid_parameter_2
=240,
3150 nt_status_invalid_parameter_3
=241,
3151 nt_status_invalid_parameter_4
=242,
3152 nt_status_invalid_parameter_5
=243,
3153 nt_status_invalid_parameter_6
=244,
3154 nt_status_invalid_parameter_7
=245,
3155 nt_status_invalid_parameter_8
=246,
3156 nt_status_invalid_parameter_9
=247,
3157 nt_status_invalid_parameter_10
=248,
3158 nt_status_invalid_parameter_11
=249,
3159 nt_status_invalid_parameter_12
=250,
3160 nt_status_redirector_not_started
=251,
3161 nt_status_redirector_started
=252,
3162 nt_status_stack_overflow
=253,
3163 nt_status_no_such_package
=254,
3164 nt_status_bad_function_table
=255,
3165 nt_status_directory_not_empty
=257,
3166 nt_status_file_corrupt_error
=258,
3167 nt_status_not_a_directory
=259,
3168 nt_status_bad_logon_session_state
=260,
3169 nt_status_logon_session_collision
=261,
3170 nt_status_name_too_long
=262,
3171 nt_status_files_open
=263,
3172 nt_status_connection_in_use
=264,
3173 nt_status_message_not_found
=265,
3174 nt_status_process_is_terminating
=266,
3175 nt_status_invalid_logon_type
=267,
3176 nt_status_no_guid_translation
=268,
3177 nt_status_cannot_impersonate
=269,
3178 nt_status_image_already_loaded
=270,
3179 nt_status_abios_not_present
=271,
3180 nt_status_abios_lid_not_exist
=272,
3181 nt_status_abios_lid_already_owned
=273,
3182 nt_status_abios_not_lid_owner
=274,
3183 nt_status_abios_invalid_command
=275,
3184 nt_status_abios_invalid_lid
=276,
3185 nt_status_abios_selector_not_available
=277,
3186 nt_status_abios_invalid_selector
=278,
3187 nt_status_no_ldt
=279,
3188 nt_status_invalid_ldt_size
=280,
3189 nt_status_invalid_ldt_offset
=281,
3190 nt_status_invalid_ldt_descriptor
=282,
3191 nt_status_invalid_image_ne_format
=283,
3192 nt_status_rxact_invalid_state
=284,
3193 nt_status_rxact_commit_failure
=285,
3194 nt_status_mapped_file_size_zero
=286,
3195 nt_status_too_many_opened_files
=287,
3196 nt_status_cancelled
=288,
3197 nt_status_cannot_delete
=289,
3198 nt_status_invalid_computer_name
=290,
3199 nt_status_file_deleted
=291,
3200 nt_status_special_account
=292,
3201 nt_status_special_group
=293,
3202 nt_status_special_user
=294,
3203 nt_status_members_primary_group
=295,
3204 nt_status_file_closed
=296,
3205 nt_status_too_many_threads
=297,
3206 nt_status_thread_not_in_process
=298,
3207 nt_status_token_already_in_use
=299,
3208 nt_status_pagefile_quota_exceeded
=300,
3209 nt_status_commitment_limit
=301,
3210 nt_status_invalid_image_le_format
=302,
3211 nt_status_invalid_image_not_mz
=303,
3212 nt_status_invalid_image_protect
=304,
3213 nt_status_invalid_image_win_16
=305,
3214 nt_status_logon_server_conflict
=306,
3215 nt_status_time_difference_at_dc
=307,
3216 nt_status_synchronization_required
=308,
3217 nt_status_dll_not_found
=309,
3218 nt_status_open_failed
=310,
3219 nt_status_io_privilege_failed
=311,
3220 nt_status_ordinal_not_found
=312,
3221 nt_status_entrypoint_not_found
=313,
3222 nt_status_control_c_exit
=314,
3223 nt_status_local_disconnect
=315,
3224 nt_status_remote_disconnect
=316,
3225 nt_status_remote_resources
=317,
3226 nt_status_link_failed
=318,
3227 nt_status_link_timeout
=319,
3228 nt_status_invalid_connection
=320,
3229 nt_status_invalid_address
=321,
3230 nt_status_dll_init_failed
=322,
3231 nt_status_missing_systemfile
=323,
3232 nt_status_unhandled_exception
=324,
3233 nt_status_app_init_failure
=325,
3234 nt_status_pagefile_create_failed
=326,
3235 nt_status_no_pagefile
=327,
3236 nt_status_invalid_level
=328,
3237 nt_status_wrong_password_core
=329,
3238 nt_status_illegal_float_context
=330,
3239 nt_status_pipe_broken
=331,
3240 nt_status_registry_corrupt
=332,
3241 nt_status_registry_io_failed
=333,
3242 nt_status_no_event_pair
=334,
3243 nt_status_unrecognized_volume
=335,
3244 nt_status_serial_no_device_inited
=336,
3245 nt_status_no_such_alias
=337,
3246 nt_status_member_not_in_alias
=338,
3247 nt_status_member_in_alias
=339,
3248 nt_status_alias_exists
=340,
3249 nt_status_logon_not_granted
=341,
3250 nt_status_too_many_secrets
=342,
3251 nt_status_secret_too_long
=343,
3252 nt_status_internal_db_error
=344,
3253 nt_status_fullscreen_mode
=345,
3254 nt_status_too_many_context_ids
=346,
3255 nt_status_logon_type_not_granted
=347,
3256 nt_status_not_registry_file
=348,
3257 nt_status_nt_cross_encryption_required
=349,
3258 nt_status_domain_ctrlr_config_error
=350,
3259 nt_status_ft_missing_member
=351,
3260 nt_status_ill_formed_service_entry
=352,
3261 nt_status_illegal_character
=353,
3262 nt_status_unmappable_character
=354,
3263 nt_status_undefined_character
=355,
3264 nt_status_floppy_volume
=356,
3265 nt_status_floppy_id_mark_not_found
=357,
3266 nt_status_floppy_wrong_cylinder
=358,
3267 nt_status_floppy_unknown_error
=359,
3268 nt_status_floppy_bad_registers
=360,
3269 nt_status_disk_recalibrate_failed
=361,
3270 nt_status_disk_operation_failed
=362,
3271 nt_status_disk_reset_failed
=363,
3272 nt_status_shared_irq_busy
=364,
3273 nt_status_ft_orphaning
=365,
3274 nt_status_partition_failure
=370,
3275 nt_status_invalid_block_length
=371,
3276 nt_status_device_not_partitioned
=372,
3277 nt_status_unable_to_lock_media
=373,
3278 nt_status_unable_to_unload_media
=374,
3279 nt_status_eom_overflow
=375,
3280 nt_status_no_media
=376,
3281 nt_status_no_such_member
=378,
3282 nt_status_invalid_member
=379,
3283 nt_status_key_deleted
=380,
3284 nt_status_no_log_space
=381,
3285 nt_status_too_many_sids
=382,
3286 nt_status_lm_cross_encryption_required
=383,
3287 nt_status_key_has_children
=384,
3288 nt_status_child_must_be_volatile
=385,
3289 nt_status_device_configuration_error
=386,
3290 nt_status_driver_internal_error
=387,
3291 nt_status_invalid_device_state
=388,
3292 nt_status_io_device_error
=389,
3293 nt_status_device_protocol_error
=390,
3294 nt_status_backup_controller
=391,
3295 nt_status_log_file_full
=392,
3296 nt_status_too_late
=393,
3297 nt_status_no_trust_lsa_secret
=394,
3298 nt_status_no_trust_sam_account
=395,
3299 nt_status_trusted_domain_failure
=396,
3300 nt_status_trusted_relationship_failure
=397,
3301 nt_status_eventlog_file_corrupt
=398,
3302 nt_status_eventlog_cant_start
=399,
3303 nt_status_trust_failure
=400,
3304 nt_status_mutant_limit_exceeded
=401,
3305 nt_status_netlogon_not_started
=402,
3306 nt_status_account_expired
=403,
3307 nt_status_possible_deadlock
=404,
3308 nt_status_network_credential_conflict
=405,
3309 nt_status_remote_session_limit
=406,
3310 nt_status_eventlog_file_changed
=407,
3311 nt_status_nologon_interdomain_trust_account
=408,
3312 nt_status_nologon_workstation_trust_account
=409,
3313 nt_status_nologon_server_trust_account
=410,
3314 nt_status_domain_trust_inconsistent
=411,
3315 nt_status_fs_driver_required
=412,
3316 nt_status_no_user_session_key
=514,
3317 nt_status_user_session_deleted
=515,
3318 nt_status_resource_lang_not_found
=516,
3319 nt_status_insuff_server_resources
=517,
3320 nt_status_invalid_buffer_size
=518,
3321 nt_status_invalid_address_component
=519,
3322 nt_status_invalid_address_wildcard
=520,
3323 nt_status_too_many_addresses
=521,
3324 nt_status_address_already_exists
=522,
3325 nt_status_address_closed
=523,
3326 nt_status_connection_disconnected
=524,
3327 nt_status_connection_reset
=525,
3328 nt_status_too_many_nodes
=526,
3329 nt_status_transaction_aborted
=527,
3330 nt_status_transaction_timed_out
=528,
3331 nt_status_transaction_no_release
=529,
3332 nt_status_transaction_no_match
=530,
3333 nt_status_transaction_responded
=531,
3334 nt_status_transaction_invalid_id
=532,
3335 nt_status_transaction_invalid_type
=533,
3336 nt_status_not_server_session
=534,
3337 nt_status_not_client_session
=535,
3338 nt_status_cannot_load_registry_file
=536,
3339 nt_status_debug_attach_failed
=537,
3340 nt_status_system_process_terminated
=538,
3341 nt_status_data_not_accepted
=539,
3342 nt_status_no_browser_servers_found
=540,
3343 nt_status_vdm_hard_error
=541,
3344 nt_status_driver_cancel_timeout
=542,
3345 nt_status_reply_message_mismatch
=543,
3346 nt_status_mapped_alignment
=544,
3347 nt_status_image_checksum_mismatch
=545,
3348 nt_status_lost_writebehind_data
=546,
3349 nt_status_client_server_parameters_invalid
=547,
3350 nt_status_password_must_change
=548,
3351 nt_status_not_found
=549,
3352 nt_status_not_tiny_stream
=550,
3353 nt_status_recovery_failure
=551,
3354 nt_status_stack_overflow_read
=552,
3355 nt_status_fail_check
=553,
3356 nt_status_duplicate_objectid
=554,
3357 nt_status_objectid_exists
=555,
3358 nt_status_convert_to_large
=556,
3359 nt_status_retry
=557,
3360 nt_status_found_out_of_scope
=558,
3361 nt_status_allocate_bucket
=559,
3362 nt_status_propset_not_found
=560,
3363 nt_status_marshall_overflow
=561,
3364 nt_status_invalid_variant
=562,
3365 nt_status_domain_controller_not_found
=563,
3366 nt_status_account_locked_out
=564,
3367 nt_status_handle_not_closable
=565,
3368 nt_status_connection_refused
=566,
3369 nt_status_graceful_disconnect
=567,
3370 nt_status_address_already_associated
=568,
3371 nt_status_address_not_associated
=569,
3372 nt_status_connection_invalid
=570,
3373 nt_status_connection_active
=571,
3374 nt_status_network_unreachable
=572,
3375 nt_status_host_unreachable
=573,
3376 nt_status_protocol_unreachable
=574,
3377 nt_status_port_unreachable
=575,
3378 nt_status_request_aborted
=576,
3379 nt_status_connection_aborted
=577,
3380 nt_status_bad_compression_buffer
=578,
3381 nt_status_user_mapped_file
=579,
3382 nt_status_audit_failed
=580,
3383 nt_status_timer_resolution_not_set
=581,
3384 nt_status_connection_count_limit
=582,
3385 nt_status_login_time_restriction
=583,
3386 nt_status_login_wksta_restriction
=584,
3387 nt_status_image_mp_up_mismatch
=585,
3388 nt_status_insufficient_logon_info
=592,
3389 nt_status_bad_dll_entrypoint
=593,
3390 nt_status_bad_service_entrypoint
=594,
3391 nt_status_lpc_reply_lost
=595,
3392 nt_status_ip_address_conflict1
=596,
3393 nt_status_ip_address_conflict2
=597,
3394 nt_status_registry_quota_limit
=598,
3395 nt_status_path_not_covered
=599,
3396 nt_status_no_callback_active
=600,
3397 nt_status_license_quota_exceeded
=601,
3398 nt_status_pwd_too_short
=602,
3399 nt_status_pwd_too_recent
=603,
3400 nt_status_pwd_history_conflict
=604,
3401 nt_status_plugplay_no_device
=606,
3402 nt_status_unsupported_compression
=607,
3403 nt_status_invalid_hw_profile
=608,
3404 nt_status_invalid_plugplay_device_path
=609,
3405 nt_status_driver_ordinal_not_found
=610,
3406 nt_status_driver_entrypoint_not_found
=611,
3407 nt_status_resource_not_owned
=612,
3408 nt_status_too_many_links
=613,
3409 nt_status_quota_list_inconsistent
=614,
3410 nt_status_file_is_offline
=615,
3411 // nt_status_notify_enum_dir=268,
3414 struct error_label_entry
3420 static const struct error_label_entry dos_errors
[] =
3422 { 0, "not specified" },
3423 { errdos_badfunc
, "bad func" },
3424 { errdos_badfile
, "bad file" },
3425 { errdos_badpath
, "bad path" },
3426 { errdos_nofids
, "no fids" },
3427 { errdos_noaccess
, "no access" },
3428 { errdos_badfid
, "bad fid" },
3429 { errdos_badmcb
, "bad mcb" },
3430 { errdos_nomem
, "no mem" },
3431 { errdos_badmem
, "bad mem" },
3432 { errdos_badenv
, "bad env" },
3433 { errdos_badformat
, "bad format" },
3434 { errdos_badaccess
, "bad access" },
3435 { errdos_baddata
, "bad data" },
3436 { errdos_baddrive
, "bad drive" },
3437 { errdos_remcd
, "rem cd" },
3438 { errdos_diffdevice
, "diff device" },
3439 { errdos_nofiles
, "no files" },
3440 { errdos_badshare
, "bad share" },
3441 { errdos_lock
, "lock" },
3442 { errdos_filexists
, "file exists" },
3443 { errdos_quota
, "quota" },
3444 { errdos_notALink
, "not a link" },
3448 static const struct error_label_entry server_errors
[] =
3450 { 0, "not specified" },
3451 { errsrv_error
, "error" },
3452 { errsrv_badpw
, "bad pw" },
3453 { errsrv_access
, "access" },
3454 { errsrv_invtid
, "inv tid" },
3455 { errsrv_invnetname
, "inv net name" },
3456 { errsrv_invdevice
, "inv device" },
3457 { errsrv_qfull
, "q full" },
3458 { errsrv_qtoobig
, "q toobig" },
3459 { errsrv_qeof
, "q eof" },
3460 { errsrv_invpfid
, "inv pfid" },
3461 { errsrv_smbcmd
, "smb cmd" },
3462 { errsrv_srverror
, "srv error" },
3463 { errsrv_badBID
, "bad BID" },
3464 { errsrv_filespecs
, "file specs" },
3465 { errsrv_badLink
, "bad link" },
3466 { errsrv_badpermits
, "bad permits" },
3467 { errsrv_badPID
, "bad PID" },
3468 { errsrv_setattrmode
, "setattr mode" },
3469 { errsrv_paused
, "paused" },
3470 { errsrv_msgoff
, "msg off" },
3471 { errsrv_noroom
, "no room" },
3472 { errsrv_rmuns
, "rmuns" },
3473 { errsrv_timeout
, "timeout" },
3474 { errsrv_noresource
, "no resource" },
3475 { errsrv_toomanyuids
, "too many uids" },
3476 { errsrv_baduid
, "bad uid" },
3477 { errsrv_usempx
, "use mpx" },
3478 { errsrv_usestd
, "use std" },
3479 { errsrv_contmpx
, "cont mpx" },
3480 { errsrv_badPassword
, "ba DPassword" },
3481 { errsrv_notifyEnumDir
, "notify enum dir" },
3482 { errsrv_accountExpired
, "account expired" },
3483 { errsrv_badClient
, "bad client" },
3484 { errsrv_badLogonTime
, "bad logon time" },
3485 { errsrv_passwordExpired
, "password expired" },
3486 { errsrv_nosupport
, "no support" },
3490 static const struct error_label_entry hardware_errors
[] =
3492 { 0, "not specified" },
3493 { errhrd_nowrite
, "no write" },
3494 { errhrd_badunit
, "bad unit" },
3495 { errhrd_notready
, "not ready" },
3496 { errhrd_badcmd
, "bad cmd" },
3497 { errhrd_data
, "data" },
3498 { errhrd_badreq
, "bad req" },
3499 { errhrd_seek
, "seek" },
3500 { errhrd_badmedia
, "bad media" },
3501 { errhrd_badsector
, "bad sector" },
3502 { errhrd_nopaper
, "no paper" },
3503 { errhrd_write
, "write" },
3504 { errhrd_read
, "read" },
3505 { errhrd_general
, "general" },
3506 { errhrd_badshare
, "bad share" },
3507 { errhrd_lock
, "lock" },
3508 { errhrd_wrongdisk
, "wrong disk" },
3509 { errhrd_FCBUnavail
, "FCB unavail" },
3510 { errhrd_sharebufexc
, "share buf exc" },
3514 static const struct error_label_entry nt_error_codes
[] =
3516 { 0, "not specified" },
3517 { nt_status_unsuccessful
, "unsuccessful" },
3518 { nt_status_not_implemented
, "not implemented" },
3519 { nt_status_invalid_info_class
, "invalid info class" },
3520 { nt_status_info_length_mismatch
, "info length mismatch" },
3521 { nt_status_access_violation
, "access violation" },
3522 { nt_status_in_page_error
, "in page error" },
3523 { nt_status_pagefile_quota
, "pagefile quota" },
3524 { nt_status_invalid_handle
, "invalid handle" },
3525 { nt_status_bad_initial_stack
, "bad initial stack" },
3526 { nt_status_bad_initial_pc
, "bad initial pc" },
3527 { nt_status_invalid_cid
, "invalid cid" },
3528 { nt_status_timer_not_canceled
, "timer not canceled" },
3529 { nt_status_invalid_parameter
, "invalid parameter" },
3530 { nt_status_no_such_device
, "no such device" },
3531 { nt_status_no_such_file
, "no such file" },
3532 { nt_status_invalid_device_request
, "invalid device request" },
3533 { nt_status_end_of_file
, "end of file" },
3534 { nt_status_wrong_volume
, "wrong volume" },
3535 { nt_status_no_media_in_device
, "no media in device" },
3536 { nt_status_unrecognized_media
, "unrecognized media" },
3537 { nt_status_nonexistent_sector
, "nonexistent sector" },
3538 { nt_status_more_processing_required
, "more processing required" },
3539 { nt_status_no_memory
, "no memory" },
3540 { nt_status_conflicting_addresses
, "conflicting addresses" },
3541 { nt_status_not_mapped_view
, "not mapped view" },
3542 { nt_status_unable_to_free_vm
, "unable to free vm" },
3543 { nt_status_unable_to_delete_section
, "unable to delete section" },
3544 { nt_status_invalid_system_service
, "invalid system service" },
3545 { nt_status_illegal_instruction
, "illegal instruction" },
3546 { nt_status_invalid_lock_sequence
, "invalid lock sequence" },
3547 { nt_status_invalid_view_size
, "invalid view size" },
3548 { nt_status_invalid_file_for_section
, "invalid file for section" },
3549 { nt_status_already_committed
, "already committed" },
3550 { nt_status_access_denied
, "access denied" },
3551 { nt_status_buffer_too_small
, "buffer too small" },
3552 { nt_status_object_type_mismatch
, "object type mismatch" },
3553 { nt_status_noncontinuable_exception
, "noncontinuable exception" },
3554 { nt_status_invalid_disposition
, "invalid disposition" },
3555 { nt_status_unwind
, "unwind" },
3556 { nt_status_bad_stack
, "bad stack" },
3557 { nt_status_invalid_unwind_target
, "invalid unwind target" },
3558 { nt_status_not_locked
, "not locked" },
3559 { nt_status_parity_error
, "parity error" },
3560 { nt_status_unable_to_decommit_vm
, "unable to decommit vm" },
3561 { nt_status_not_committed
, "not committed" },
3562 { nt_status_invalid_port_attributes
, "invalid port attributes" },
3563 { nt_status_port_message_too_long
, "port message too long" },
3564 { nt_status_invalid_parameter_mix
, "invalid parameter mix" },
3565 { nt_status_invalid_quota_lower
, "invalid quota lower" },
3566 { nt_status_disk_corrupt_error
, "disk corrupt error" },
3567 { nt_status_object_name_invalid
, "object name invalid" },
3568 { nt_status_object_name_not_found
, "object name not found" },
3569 { nt_status_object_name_collision
, "object name collision" },
3570 { nt_status_handle_not_waitable
, "handle not waitable" },
3571 { nt_status_port_disconnected
, "port disconnected" },
3572 { nt_status_device_already_attached
, "device already attached" },
3573 { nt_status_object_path_invalid
, "object path invalid" },
3574 { nt_status_object_path_not_found
, "object path not found" },
3575 { nt_status_object_path_syntax_bad
, "object path syntax bad" },
3576 { nt_status_data_overrun
, "data overrun" },
3577 { nt_status_data_late_error
, "data late error" },
3578 { nt_status_data_error
, "data error" },
3579 { nt_status_crc_error
, "crc error" },
3580 { nt_status_section_too_big
, "section too big" },
3581 { nt_status_port_connection_refused
, "port connection refused" },
3582 { nt_status_invalid_port_handle
, "invalid port handle" },
3583 { nt_status_sharing_violation
, "sharing violation" },
3584 { nt_status_quota_exceeded
, "quota exceeded" },
3585 { nt_status_invalid_page_protection
, "invalid page protection" },
3586 { nt_status_mutant_not_owned
, "mutant not owned" },
3587 { nt_status_semaphore_limit_exceeded
, "semaphore limit exceeded" },
3588 { nt_status_port_already_set
, "port already set" },
3589 { nt_status_section_not_image
, "section not image" },
3590 { nt_status_suspend_count_exceeded
, "suspend count exceeded" },
3591 { nt_status_thread_is_terminating
, "thread is terminating" },
3592 { nt_status_bad_working_set_limit
, "bad working set limit" },
3593 { nt_status_incompatible_file_map
, "incompatible file map" },
3594 { nt_status_section_protection
, "section protection" },
3595 { nt_status_eas_not_supported
, "eas not supported" },
3596 { nt_status_ea_too_large
, "ea too large" },
3597 { nt_status_nonexistent_ea_entry
, "nonexistent ea entry" },
3598 { nt_status_no_eas_on_file
, "no eas on file" },
3599 { nt_status_ea_corrupt_error
, "ea corrupt error" },
3600 { nt_status_file_lock_conflict
, "file lock conflict" },
3601 { nt_status_lock_not_granted
, "lock not granted" },
3602 { nt_status_delete_pending
, "delete pending" },
3603 { nt_status_ctl_file_not_supported
, "ctl file not supported" },
3604 { nt_status_unknown_revision
, "unknown revision" },
3605 { nt_status_revision_mismatch
, "revision mismatch" },
3606 { nt_status_invalid_owner
, "invalid owner" },
3607 { nt_status_invalid_primary_group
, "invalid primary group" },
3608 { nt_status_no_impersonation_token
, "no impersonation token" },
3609 { nt_status_cant_disable_mandatory
, "cant disable mandatory" },
3610 { nt_status_no_logon_servers
, "no logon servers" },
3611 { nt_status_no_such_logon_session
, "no such logon session" },
3612 { nt_status_no_such_privilege
, "no such privilege" },
3613 { nt_status_privilege_not_held
, "privilege not held" },
3614 { nt_status_invalid_account_name
, "invalid account name" },
3615 { nt_status_user_exists
, "user exists" },
3616 { nt_status_no_such_user
, "no such user" },
3617 { nt_status_group_exists
, "group exists" },
3618 { nt_status_no_such_group
, "no such group" },
3619 { nt_status_member_in_group
, "member in group" },
3620 { nt_status_member_not_in_group
, "member not in group" },
3621 { nt_status_last_admin
, "last admin" },
3622 { nt_status_wrong_password
, "wrong password" },
3623 { nt_status_ill_formed_password
, "ill formed password" },
3624 { nt_status_password_restriction
, "password restriction" },
3625 { nt_status_logon_failure
, "logon failure" },
3626 { nt_status_account_restriction
, "account restriction" },
3627 { nt_status_invalid_logon_hours
, "invalid logon hours" },
3628 { nt_status_invalid_workstation
, "invalid workstation" },
3629 { nt_status_password_expired
, "password expired" },
3630 { nt_status_account_disabled
, "account disabled" },
3631 { nt_status_none_mapped
, "none mapped" },
3632 { nt_status_too_many_luids_requested
, "too many luids requested" },
3633 { nt_status_luids_exhausted
, "luids exhausted" },
3634 { nt_status_invalid_sub_authority
, "invalid sub authority" },
3635 { nt_status_invalid_acl
, "invalid acl" },
3636 { nt_status_invalid_sid
, "invalid sid" },
3637 { nt_status_invalid_security_descr
, "invalid security descr" },
3638 { nt_status_procedure_not_found
, "procedure not found" },
3639 { nt_status_invalid_image_format
, "invalid image format" },
3640 { nt_status_no_token
, "no token" },
3641 { nt_status_bad_inheritance_acl
, "bad inheritance acl" },
3642 { nt_status_range_not_locked
, "range not locked" },
3643 { nt_status_disk_full
, "disk full" },
3644 { nt_status_server_disabled
, "server disabled" },
3645 { nt_status_server_not_disabled
, "server not disabled" },
3646 { nt_status_too_many_guids_requested
, "too many guids requested" },
3647 { nt_status_guids_exhausted
, "guids exhausted" },
3648 { nt_status_invalid_id_authority
, "invalid id authority" },
3649 { nt_status_agents_exhausted
, "agents exhausted" },
3650 { nt_status_invalid_volume_label
, "invalid volume label" },
3651 { nt_status_section_not_extended
, "section not extended" },
3652 { nt_status_not_mapped_data
, "not mapped data" },
3653 { nt_status_resource_data_not_found
, "resource data not found" },
3654 { nt_status_resource_type_not_found
, "resource type not found" },
3655 { nt_status_resource_name_not_found
, "resource name not found" },
3656 { nt_status_array_bounds_exceeded
, "array bounds exceeded" },
3657 { nt_status_float_denormal_operand
, "float denormal operand" },
3658 { nt_status_float_divide_by_zero
, "float divide by zero" },
3659 { nt_status_float_inexact_result
, "float inexact result" },
3660 { nt_status_float_invalid_operation
, "float invalid operation" },
3661 { nt_status_float_overflow
, "float overflow" },
3662 { nt_status_float_stack_check
, "float stack check" },
3663 { nt_status_float_underflow
, "float underflow" },
3664 { nt_status_integer_divide_by_zero
, "integer divide by zero" },
3665 { nt_status_integer_overflow
, "integer overflow" },
3666 { nt_status_privileged_instruction
, "privileged instruction" },
3667 { nt_status_too_many_paging_files
, "too many paging files" },
3668 { nt_status_file_invalid
, "file invalid" },
3669 { nt_status_allotted_space_exceeded
, "allotted space exceeded" },
3670 { nt_status_insufficient_resources
, "insufficient resources" },
3671 { nt_status_dfs_exit_path_found
, "dfs exit path found" },
3672 { nt_status_device_data_error
, "device data error" },
3673 { nt_status_device_not_connected
, "device not connected" },
3674 { nt_status_device_power_failure
, "device power failure" },
3675 { nt_status_free_vm_not_at_base
, "free vm not at base" },
3676 { nt_status_memory_not_allocated
, "memory not allocated" },
3677 { nt_status_working_set_quota
, "working set quota" },
3678 { nt_status_media_write_protected
, "media write protected" },
3679 { nt_status_device_not_ready
, "device not ready" },
3680 { nt_status_invalid_group_attributes
, "invalid group attributes" },
3681 { nt_status_bad_impersonation_level
, "bad impersonation level" },
3682 { nt_status_cant_open_anonymous
, "cant open anonymous" },
3683 { nt_status_bad_validation_class
, "bad validation class" },
3684 { nt_status_bad_token_type
, "bad token type" },
3685 { nt_status_bad_master_boot_record
, "bad master boot record" },
3686 { nt_status_instruction_misalignment
, "instruction misalignment" },
3687 { nt_status_instance_not_available
, "instance not available" },
3688 { nt_status_pipe_not_available
, "pipe not available" },
3689 { nt_status_invalid_pipe_state
, "invalid pipe state" },
3690 { nt_status_pipe_busy
, "pipe busy" },
3691 { nt_status_illegal_function
, "illegal function" },
3692 { nt_status_pipe_disconnected
, "pipe disconnected" },
3693 { nt_status_pipe_closing
, "pipe closing" },
3694 { nt_status_pipe_connected
, "pipe connected" },
3695 { nt_status_pipe_listening
, "pipe listening" },
3696 { nt_status_invalid_read_mode
, "invalid read mode" },
3697 { nt_status_io_timeout
, "io timeout" },
3698 { nt_status_file_forced_closed
, "file forced closed" },
3699 { nt_status_profiling_not_started
, "profiling not started" },
3700 { nt_status_profiling_not_stopped
, "profiling not stopped" },
3701 { nt_status_could_not_interpret
, "could not interpret" },
3702 { nt_status_file_is_a_directory
, "file is a directory" },
3703 { nt_status_not_supported
, "not supported" },
3704 { nt_status_remote_not_listening
, "remote not listening" },
3705 { nt_status_duplicate_name
, "duplicate name" },
3706 { nt_status_bad_network_path
, "bad network path" },
3707 { nt_status_network_busy
, "network busy" },
3708 { nt_status_device_does_not_exist
, "device does not exist" },
3709 { nt_status_too_many_commands
, "too many commands" },
3710 { nt_status_adapter_hardware_error
, "adapter hardware error" },
3711 { nt_status_invalid_network_response
, "invalid network response" },
3712 { nt_status_unexpected_network_error
, "unexpected network error" },
3713 { nt_status_bad_remote_adapter
, "bad remote adapter" },
3714 { nt_status_print_queue_full
, "print queue full" },
3715 { nt_status_no_spool_space
, "no spool space" },
3716 { nt_status_print_cancelled
, "print cancelled" },
3717 { nt_status_network_name_deleted
, "network name deleted" },
3718 { nt_status_network_access_denied
, "network access denied" },
3719 { nt_status_bad_device_type
, "bad device type" },
3720 { nt_status_bad_network_name
, "bad network name" },
3721 { nt_status_too_many_names
, "too many names" },
3722 { nt_status_too_many_sessions
, "too many sessions" },
3723 { nt_status_sharing_paused
, "sharing paused" },
3724 { nt_status_request_not_accepted
, "request not accepted" },
3725 { nt_status_redirector_paused
, "redirector paused" },
3726 { nt_status_net_write_fault
, "net write fault" },
3727 { nt_status_profiling_at_limit
, "profiling at limit" },
3728 { nt_status_not_same_device
, "not same device" },
3729 { nt_status_file_renamed
, "file renamed" },
3730 { nt_status_virtual_circuit_closed
, "virtual circuit closed" },
3731 { nt_status_no_security_on_object
, "no security on object" },
3732 { nt_status_cant_wait
, "cant wait" },
3733 { nt_status_pipe_empty
, "pipe empty" },
3734 { nt_status_cant_access_domain_info
, "cant access domain info" },
3735 { nt_status_cant_terminate_self
, "cant terminate self" },
3736 { nt_status_invalid_server_state
, "invalid server state" },
3737 { nt_status_invalid_domain_state
, "invalid domain state" },
3738 { nt_status_invalid_domain_role
, "invalid domain role" },
3739 { nt_status_no_such_domain
, "no such domain" },
3740 { nt_status_domain_exists
, "domain exists" },
3741 { nt_status_domain_limit_exceeded
, "domain limit exceeded" },
3742 { nt_status_oplock_not_granted
, "oplock not granted" },
3743 { nt_status_invalid_oplock_protocol
, "invalid oplock protocol" },
3744 { nt_status_internal_db_corruption
, "internal db corruption" },
3745 { nt_status_internal_error
, "internal error" },
3746 { nt_status_generic_not_mapped
, "generic not mapped" },
3747 { nt_status_bad_descriptor_format
, "bad descriptor format" },
3748 { nt_status_invalid_user_buffer
, "invalid user buffer" },
3749 { nt_status_unexpected_io_error
, "unexpected io error" },
3750 { nt_status_unexpected_mm_create_err
, "unexpected mm create err" },
3751 { nt_status_unexpected_mm_map_error
, "unexpected mm map error" },
3752 { nt_status_unexpected_mm_extend_err
, "unexpected mm extend err" },
3753 { nt_status_not_logon_process
, "not logon process" },
3754 { nt_status_logon_session_exists
, "logon session exists" },
3755 { nt_status_invalid_parameter_1
, "invalid parameter 1" },
3756 { nt_status_invalid_parameter_2
, "invalid parameter 2" },
3757 { nt_status_invalid_parameter_3
, "invalid parameter 3" },
3758 { nt_status_invalid_parameter_4
, "invalid parameter 4" },
3759 { nt_status_invalid_parameter_5
, "invalid parameter 5" },
3760 { nt_status_invalid_parameter_6
, "invalid parameter 6" },
3761 { nt_status_invalid_parameter_7
, "invalid parameter 7" },
3762 { nt_status_invalid_parameter_8
, "invalid parameter 8" },
3763 { nt_status_invalid_parameter_9
, "invalid parameter 9" },
3764 { nt_status_invalid_parameter_10
, "invalid parameter 10" },
3765 { nt_status_invalid_parameter_11
, "invalid parameter 11" },
3766 { nt_status_invalid_parameter_12
, "invalid parameter 12" },
3767 { nt_status_redirector_not_started
, "redirector not started" },
3768 { nt_status_redirector_started
, "redirector started" },
3769 { nt_status_stack_overflow
, "stack overflow" },
3770 { nt_status_no_such_package
, "no such package" },
3771 { nt_status_bad_function_table
, "bad function table" },
3772 { nt_status_directory_not_empty
, "directory not empty" },
3773 { nt_status_file_corrupt_error
, "file corrupt error" },
3774 { nt_status_not_a_directory
, "not a directory" },
3775 { nt_status_bad_logon_session_state
, "bad logon session state" },
3776 { nt_status_logon_session_collision
, "logon session collision" },
3777 { nt_status_name_too_long
, "name too long" },
3778 { nt_status_files_open
, "files open" },
3779 { nt_status_connection_in_use
, "connection in use" },
3780 { nt_status_message_not_found
, "message not found" },
3781 { nt_status_process_is_terminating
, "process is terminating" },
3782 { nt_status_invalid_logon_type
, "invalid logon type" },
3783 { nt_status_no_guid_translation
, "no guid translation" },
3784 { nt_status_cannot_impersonate
, "cannot impersonate" },
3785 { nt_status_image_already_loaded
, "image already loaded" },
3786 { nt_status_abios_not_present
, "abios not present" },
3787 { nt_status_abios_lid_not_exist
, "abios lid not exist" },
3788 { nt_status_abios_lid_already_owned
, "abios lid already owned" },
3789 { nt_status_abios_not_lid_owner
, "abios not lid owner" },
3790 { nt_status_abios_invalid_command
, "abios invalid command" },
3791 { nt_status_abios_invalid_lid
, "abios invalid lid" },
3792 { nt_status_abios_selector_not_available
, "abios selector not available" },
3793 { nt_status_abios_invalid_selector
, "abios invalid selector" },
3794 { nt_status_no_ldt
, "no ldt" },
3795 { nt_status_invalid_ldt_size
, "invalid ldt size" },
3796 { nt_status_invalid_ldt_offset
, "invalid ldt offset" },
3797 { nt_status_invalid_ldt_descriptor
, "invalid ldt descriptor" },
3798 { nt_status_invalid_image_ne_format
, "invalid image ne format" },
3799 { nt_status_rxact_invalid_state
, "rxact invalid state" },
3800 { nt_status_rxact_commit_failure
, "rxact commit failure" },
3801 { nt_status_mapped_file_size_zero
, "mapped file size zero" },
3802 { nt_status_too_many_opened_files
, "too many opened files" },
3803 { nt_status_cancelled
, "cancelled" },
3804 { nt_status_cannot_delete
, "cannot delete" },
3805 { nt_status_invalid_computer_name
, "invalid computer name" },
3806 { nt_status_file_deleted
, "file deleted" },
3807 { nt_status_special_account
, "special account" },
3808 { nt_status_special_group
, "special group" },
3809 { nt_status_special_user
, "special user" },
3810 { nt_status_members_primary_group
, "members primary group" },
3811 { nt_status_file_closed
, "file closed" },
3812 { nt_status_too_many_threads
, "too many threads" },
3813 { nt_status_thread_not_in_process
, "thread not in process" },
3814 { nt_status_token_already_in_use
, "token already in use" },
3815 { nt_status_pagefile_quota_exceeded
, "pagefile quota exceeded" },
3816 { nt_status_commitment_limit
, "commitment limit" },
3817 { nt_status_invalid_image_le_format
, "invalid image le format" },
3818 { nt_status_invalid_image_not_mz
, "invalid image not mz" },
3819 { nt_status_invalid_image_protect
, "invalid image protect" },
3820 { nt_status_invalid_image_win_16
, "invalid image win 16" },
3821 { nt_status_logon_server_conflict
, "logon server conflict" },
3822 { nt_status_time_difference_at_dc
, "time difference at dc" },
3823 { nt_status_synchronization_required
, "synchronization required" },
3824 { nt_status_dll_not_found
, "dll not found" },
3825 { nt_status_open_failed
, "open failed" },
3826 { nt_status_io_privilege_failed
, "io privilege failed" },
3827 { nt_status_ordinal_not_found
, "ordinal not found" },
3828 { nt_status_entrypoint_not_found
, "entrypoint not found" },
3829 { nt_status_control_c_exit
, "control c exit" },
3830 { nt_status_local_disconnect
, "local disconnect" },
3831 { nt_status_remote_disconnect
, "remote disconnect" },
3832 { nt_status_remote_resources
, "remote resources" },
3833 { nt_status_link_failed
, "link failed" },
3834 { nt_status_link_timeout
, "link timeout" },
3835 { nt_status_invalid_connection
, "invalid connection" },
3836 { nt_status_invalid_address
, "invalid address" },
3837 { nt_status_dll_init_failed
, "dll init failed" },
3838 { nt_status_missing_systemfile
, "missing systemfile" },
3839 { nt_status_unhandled_exception
, "unhandled exception" },
3840 { nt_status_app_init_failure
, "app init failure" },
3841 { nt_status_pagefile_create_failed
, "pagefile create failed" },
3842 { nt_status_no_pagefile
, "no pagefile" },
3843 { nt_status_invalid_level
, "invalid level" },
3844 { nt_status_wrong_password_core
, "wrong password core" },
3845 { nt_status_illegal_float_context
, "illegal float context" },
3846 { nt_status_pipe_broken
, "pipe broken" },
3847 { nt_status_registry_corrupt
, "registry corrupt" },
3848 { nt_status_registry_io_failed
, "registry io failed" },
3849 { nt_status_no_event_pair
, "no event pair" },
3850 { nt_status_unrecognized_volume
, "unrecognized volume" },
3851 { nt_status_serial_no_device_inited
, "serial no device inited" },
3852 { nt_status_no_such_alias
, "no such alias" },
3853 { nt_status_member_not_in_alias
, "member not in alias" },
3854 { nt_status_member_in_alias
, "member in alias" },
3855 { nt_status_alias_exists
, "alias exists" },
3856 { nt_status_logon_not_granted
, "logon not granted" },
3857 { nt_status_too_many_secrets
, "too many secrets" },
3858 { nt_status_secret_too_long
, "secret too long" },
3859 { nt_status_internal_db_error
, "internal db error" },
3860 { nt_status_fullscreen_mode
, "fullscreen mode" },
3861 { nt_status_too_many_context_ids
, "too many context ids" },
3862 { nt_status_logon_type_not_granted
, "logon type not granted" },
3863 { nt_status_not_registry_file
, "not registry file" },
3864 { nt_status_nt_cross_encryption_required
, "nt cross encryption required" },
3865 { nt_status_domain_ctrlr_config_error
, "domain ctrlr config error" },
3866 { nt_status_ft_missing_member
, "ft missing member" },
3867 { nt_status_ill_formed_service_entry
, "ill formed service entry" },
3868 { nt_status_illegal_character
, "illegal character" },
3869 { nt_status_unmappable_character
, "unmappable character" },
3870 { nt_status_undefined_character
, "undefined character" },
3871 { nt_status_floppy_volume
, "floppy volume" },
3872 { nt_status_floppy_id_mark_not_found
, "floppy id mark not found" },
3873 { nt_status_floppy_wrong_cylinder
, "floppy wrong cylinder" },
3874 { nt_status_floppy_unknown_error
, "floppy unknown error" },
3875 { nt_status_floppy_bad_registers
, "floppy bad registers" },
3876 { nt_status_disk_recalibrate_failed
, "disk recalibrate failed" },
3877 { nt_status_disk_operation_failed
, "disk operation failed" },
3878 { nt_status_disk_reset_failed
, "disk reset failed" },
3879 { nt_status_shared_irq_busy
, "shared irq busy" },
3880 { nt_status_ft_orphaning
, "ft orphaning" },
3881 { nt_status_partition_failure
, "partition failure" },
3882 { nt_status_invalid_block_length
, "invalid block length" },
3883 { nt_status_device_not_partitioned
, "device not partitioned" },
3884 { nt_status_unable_to_lock_media
, "unable to lock media" },
3885 { nt_status_unable_to_unload_media
, "unable to unload media" },
3886 { nt_status_eom_overflow
, "eom overflow" },
3887 { nt_status_no_media
, "no media" },
3888 { nt_status_no_such_member
, "no such member" },
3889 { nt_status_invalid_member
, "invalid member" },
3890 { nt_status_key_deleted
, "key deleted" },
3891 { nt_status_no_log_space
, "no log space" },
3892 { nt_status_too_many_sids
, "too many sids" },
3893 { nt_status_lm_cross_encryption_required
, "lm cross encryption required" },
3894 { nt_status_key_has_children
, "key has children" },
3895 { nt_status_child_must_be_volatile
, "child must be volatile" },
3896 { nt_status_device_configuration_error
, "device configuration error" },
3897 { nt_status_driver_internal_error
, "driver internal error" },
3898 { nt_status_invalid_device_state
, "invalid device state" },
3899 { nt_status_io_device_error
, "io device error" },
3900 { nt_status_device_protocol_error
, "device protocol error" },
3901 { nt_status_backup_controller
, "backup controller" },
3902 { nt_status_log_file_full
, "log file full" },
3903 { nt_status_too_late
, "too late" },
3904 { nt_status_no_trust_lsa_secret
, "no trust lsa secret" },
3905 { nt_status_no_trust_sam_account
, "no trust sam account" },
3906 { nt_status_trusted_domain_failure
, "trusted domain failure" },
3907 { nt_status_trusted_relationship_failure
, "trusted relationship failure" },
3908 { nt_status_eventlog_file_corrupt
, "eventlog file corrupt" },
3909 { nt_status_eventlog_cant_start
, "eventlog cant start" },
3910 { nt_status_trust_failure
, "trust failure" },
3911 { nt_status_mutant_limit_exceeded
, "mutant limit exceeded" },
3912 { nt_status_netlogon_not_started
, "netlogon not started" },
3913 { nt_status_account_expired
, "account expired" },
3914 { nt_status_possible_deadlock
, "possible deadlock" },
3915 { nt_status_network_credential_conflict
, "network credential conflict" },
3916 { nt_status_remote_session_limit
, "remote session limit" },
3917 { nt_status_eventlog_file_changed
, "eventlog file changed" },
3918 { nt_status_nologon_interdomain_trust_account
, "nologon interdomain trust account" },
3919 { nt_status_nologon_workstation_trust_account
, "nologon workstation trust account" },
3920 { nt_status_nologon_server_trust_account
, "nologon server trust account" },
3921 { nt_status_domain_trust_inconsistent
, "domain trust inconsistent" },
3922 { nt_status_fs_driver_required
, "fs driver required" },
3923 { nt_status_no_user_session_key
, "no user session key" },
3924 { nt_status_user_session_deleted
, "user session deleted" },
3925 { nt_status_resource_lang_not_found
, "resource lang not found" },
3926 { nt_status_insuff_server_resources
, "insuff server resources" },
3927 { nt_status_invalid_buffer_size
, "invalid buffer size" },
3928 { nt_status_invalid_address_component
, "invalid address component" },
3929 { nt_status_invalid_address_wildcard
, "invalid address wildcard" },
3930 { nt_status_too_many_addresses
, "too many addresses" },
3931 { nt_status_address_already_exists
, "address already exists" },
3932 { nt_status_address_closed
, "address closed" },
3933 { nt_status_connection_disconnected
, "connection disconnected" },
3934 { nt_status_connection_reset
, "connection reset" },
3935 { nt_status_too_many_nodes
, "too many nodes" },
3936 { nt_status_transaction_aborted
, "transaction aborted" },
3937 { nt_status_transaction_timed_out
, "transaction timed out" },
3938 { nt_status_transaction_no_release
, "transaction no release" },
3939 { nt_status_transaction_no_match
, "transaction no match" },
3940 { nt_status_transaction_responded
, "transaction responded" },
3941 { nt_status_transaction_invalid_id
, "transaction invalid id" },
3942 { nt_status_transaction_invalid_type
, "transaction invalid type" },
3943 { nt_status_not_server_session
, "not server session" },
3944 { nt_status_not_client_session
, "not client session" },
3945 { nt_status_cannot_load_registry_file
, "cannot load registry file" },
3946 { nt_status_debug_attach_failed
, "debug attach failed" },
3947 { nt_status_system_process_terminated
, "system process terminated" },
3948 { nt_status_data_not_accepted
, "data not accepted" },
3949 { nt_status_no_browser_servers_found
, "no browser servers found" },
3950 { nt_status_vdm_hard_error
, "vdm hard error" },
3951 { nt_status_driver_cancel_timeout
, "driver cancel timeout" },
3952 { nt_status_reply_message_mismatch
, "reply message mismatch" },
3953 { nt_status_mapped_alignment
, "mapped alignment" },
3954 { nt_status_image_checksum_mismatch
, "image checksum mismatch" },
3955 { nt_status_lost_writebehind_data
, "lost writebehind data" },
3956 { nt_status_client_server_parameters_invalid
, "client server parameters invalid" },
3957 { nt_status_password_must_change
, "password must change" },
3958 { nt_status_not_found
, "not found" },
3959 { nt_status_not_tiny_stream
, "not tiny stream" },
3960 { nt_status_recovery_failure
, "recovery failure" },
3961 { nt_status_stack_overflow_read
, "stack overflow read" },
3962 { nt_status_fail_check
, "fail check" },
3963 { nt_status_duplicate_objectid
, "duplicate objectid" },
3964 { nt_status_objectid_exists
, "objectid exists" },
3965 { nt_status_convert_to_large
, "convert to large" },
3966 { nt_status_retry
, "retry" },
3967 { nt_status_found_out_of_scope
, "found out of scope" },
3968 { nt_status_allocate_bucket
, "allocate bucket" },
3969 { nt_status_propset_not_found
, "propset not found" },
3970 { nt_status_marshall_overflow
, "marshall overflow" },
3971 { nt_status_invalid_variant
, "invalid variant" },
3972 { nt_status_domain_controller_not_found
, "domain controller not found" },
3973 { nt_status_account_locked_out
, "account locked out" },
3974 { nt_status_handle_not_closable
, "handle not closable" },
3975 { nt_status_connection_refused
, "connection refused" },
3976 { nt_status_graceful_disconnect
, "graceful disconnect" },
3977 { nt_status_address_already_associated
, "address already associated" },
3978 { nt_status_address_not_associated
, "address not associated" },
3979 { nt_status_connection_invalid
, "connection invalid" },
3980 { nt_status_connection_active
, "connection active" },
3981 { nt_status_network_unreachable
, "network unreachable" },
3982 { nt_status_host_unreachable
, "host unreachable" },
3983 { nt_status_protocol_unreachable
, "protocol unreachable" },
3984 { nt_status_port_unreachable
, "port unreachable" },
3985 { nt_status_request_aborted
, "request aborted" },
3986 { nt_status_connection_aborted
, "connection aborted" },
3987 { nt_status_bad_compression_buffer
, "bad compression buffer" },
3988 { nt_status_user_mapped_file
, "user mapped file" },
3989 { nt_status_audit_failed
, "audit failed" },
3990 { nt_status_timer_resolution_not_set
, "timer resolution not set" },
3991 { nt_status_connection_count_limit
, "connection count limit" },
3992 { nt_status_login_time_restriction
, "login time restriction" },
3993 { nt_status_login_wksta_restriction
, "login wksta restriction" },
3994 { nt_status_image_mp_up_mismatch
, "image mp up mismatch" },
3995 { nt_status_insufficient_logon_info
, "insufficient logon info" },
3996 { nt_status_bad_dll_entrypoint
, "bad dll entrypoint" },
3997 { nt_status_bad_service_entrypoint
, "bad service entrypoint" },
3998 { nt_status_lpc_reply_lost
, "lpc reply lost" },
3999 { nt_status_ip_address_conflict1
, "ip address conflict1" },
4000 { nt_status_ip_address_conflict2
, "ip address conflict2" },
4001 { nt_status_registry_quota_limit
, "registry quota limit" },
4002 { nt_status_path_not_covered
, "path not covered" },
4003 { nt_status_no_callback_active
, "no callback active" },
4004 { nt_status_license_quota_exceeded
, "license quota exceeded" },
4005 { nt_status_pwd_too_short
, "pwd too short" },
4006 { nt_status_pwd_too_recent
, "pwd too recent" },
4007 { nt_status_pwd_history_conflict
, "pwd history conflict" },
4008 { nt_status_plugplay_no_device
, "plugplay no device" },
4009 { nt_status_unsupported_compression
, "unsupported compression" },
4010 { nt_status_invalid_hw_profile
, "invalid hw profile" },
4011 { nt_status_invalid_plugplay_device_path
, "invalid plugplay device path" },
4012 { nt_status_driver_ordinal_not_found
, "driver ordinal not found" },
4013 { nt_status_driver_entrypoint_not_found
, "driver entrypoint not found" },
4014 { nt_status_resource_not_owned
, "resource not owned" },
4015 { nt_status_too_many_links
, "too many links" },
4016 { nt_status_quota_list_inconsistent
, "quota list inconsistent" },
4017 { nt_status_file_is_offline
, "file is offline" },
4018 //{ nt_status_notify_enum_dir, "notify enum dir" },
4022 const char * command_name
;
4023 struct line_buffer lb
;
4025 if(smb_packet_source
== smb_packet_from_consumer
)
4026 Printf("message type = Request (client --> server)\n");
4028 Printf("message type = Response (server --> client)\n");
4030 if(header
->flags2
& SMB_FLAGS2_32BIT_STATUS
)
4032 int severity
,facility
,error_code
;
4033 const char * error_code_name
= "?";
4036 severity
= (header
->status
>> 30) & 1;
4037 facility
= (header
->status
>> 16) & 0x0fff;
4038 error_code
= header
->status
& 0xffff;
4040 for(i
= 0 ; nt_error_codes
[i
].code
!= -1 ; i
++)
4042 if(nt_error_codes
[i
].code
== error_code
)
4044 error_code_name
= nt_error_codes
[i
].label
;
4049 Printf("status = [%08lx] severity:%s, facility:%s (%ld), code:%s (%ld)\n",header
->status
,
4050 severity
? "failure" : "success",facility
? "?" : "default",facility
,error_code_name
,error_code
);
4054 const char * error_class_name
;
4055 int error_class_value
;
4056 const char * error_code_name
= "?";
4057 int error_code_value
;
4060 error_class_value
= header
->status
& 0xff;
4061 error_code_value
= (header
->status
>> 16) & 0xffff;
4063 switch(error_class_value
)
4067 error_class_name
= "success";
4068 error_code_name
= "no error";
4073 error_class_name
= "DOS error";
4075 for(i
= 0 ; dos_errors
[i
].code
!= -1 ; i
++)
4077 if(dos_errors
[i
].code
== error_code_value
)
4079 error_code_name
= dos_errors
[i
].label
;
4088 error_class_name
= "server error";
4090 for(i
= 0 ; server_errors
[i
].code
!= -1 ; i
++)
4092 if(server_errors
[i
].code
== error_code_value
)
4094 error_code_name
= server_errors
[i
].label
;
4103 error_class_name
= "hardware error";
4105 for(i
= 0 ; hardware_errors
[i
].code
!= -1 ; i
++)
4107 if(hardware_errors
[i
].code
== error_code_value
)
4109 error_code_name
= hardware_errors
[i
].label
;
4118 error_class_name
= "Command error";
4122 Printf("status = [%08lx] error:%s (%ld), code:%s (%ld)\n",header
->status
,
4123 error_class_name
,error_class_value
,
4124 error_code_name
,error_code_value
);
4129 init_line_buffer(&lb
);
4131 if(header
->flags
& SMB_FLAGS_SERVER_TO_REDIR
)
4132 add_lb_flag(&lb
,"type=reply");
4134 add_lb_flag(&lb
,"type=request");
4136 if(header
->flags
& SMB_FLAGS_REQUEST_BATCH_OPLOCK
)
4137 add_lb_flag(&lb
,"request-batch-oplock=batch");
4139 add_lb_flag(&lb
,"request-batch-oplock=exclusive");
4141 if(header
->flags
& SMB_FLAGS_REQUEST_OPLOCK
)
4142 add_lb_flag(&lb
,"request-oplock=yes");
4144 add_lb_flag(&lb
,"request-oplock=no");
4146 if(header
->flags
& SMB_FLAGS_CANONICAL_PATHNAMES
)
4147 add_lb_flag(&lb
,"canonical-pathnames=canonical");
4149 add_lb_flag(&lb
,"canonical-pathnames=host format");
4151 if(header
->flags
& SMB_FLAGS_CASELESS_PATHNAMES
)
4152 add_lb_flag(&lb
,"caseless-pathnames=yes");
4154 add_lb_flag(&lb
,"caseless-pathnames=no");
4156 if(header
->flags
& SMB_FLAGS_CLIENT_BUF_AVAIL
)
4157 add_lb_flag(&lb
,"client-buf-avail=yes");
4159 add_lb_flag(&lb
,"client-buf-avail=no");
4161 if(header
->flags
& SMB_FLAGS_SUPPORT_LOCKREAD
)
4162 add_lb_flag(&lb
,"support-lockread=yes");
4164 add_lb_flag(&lb
,"support-lockread=no");
4166 Printf("%s\n",lb
.line
);
4168 Printf("flags2 = ");
4170 init_line_buffer(&lb
);
4172 if(header
->flags2
& SMB_FLAGS2_UNICODE_STRINGS
)
4173 add_lb_flag(&lb
,"string-format=Unicode");
4175 add_lb_flag(&lb
,"string-format=ASCII");
4177 if(header
->flags2
& SMB_FLAGS2_32BIT_STATUS
)
4178 add_lb_flag(&lb
,"status-code=NT_STATUS format");
4180 add_lb_flag(&lb
,"status-code=DOS error format");
4182 if(header
->flags2
& SMB_FLAGS2_READ_IF_EXECUTE
)
4183 add_lb_flag(&lb
,"read-if-execute=yes");
4185 add_lb_flag(&lb
,"read-if-execute=no");
4187 if(header
->flags2
& SMB_FLAGS2_DFS_PATHNAME
)
4188 add_lb_flag(&lb
,"pathname=DFS");
4190 add_lb_flag(&lb
,"pathname=normal");
4192 if(header
->flags2
& SMB_FLAGS2_EXTENDED_SECURITY
)
4193 add_lb_flag(&lb
,"security=extended");
4195 add_lb_flag(&lb
,"security=normal");
4197 if(header
->flags2
& SMB_FLAGS2_IS_LONG_NAME
)
4198 add_lb_flag(&lb
,"name-format=long");
4200 add_lb_flag(&lb
,"name-format=8.3");
4202 if(header
->flags2
& SMB_FLAGS2_SECURITY_SIGNATURE
)
4203 add_lb_flag(&lb
,"security-signature=MAC");
4205 add_lb_flag(&lb
,"security-signature=none");
4207 if(header
->flags2
& SMB_FLAGS2_EAS
)
4208 add_lb_flag(&lb
,"extended-attributes=yes");
4210 add_lb_flag(&lb
,"extended-attributes=no");
4212 if(header
->flags2
& SMB_FLAGS2_KNOWS_LONG_NAMES
)
4213 add_lb_flag(&lb
,"client-names-supported=long");
4215 add_lb_flag(&lb
,"client-names-supported=8.3");
4217 Printf("%s\n",lb
.line
);
4219 Printf("signature = %04lx%04lx%04lx%04lx\n",header
->extra
.signature
[0],header
->extra
.signature
[1],
4220 header
->extra
.signature
[2],header
->extra
.signature
[3]);
4222 Printf("tid = %04lx\n",header
->tid
);
4223 Printf("pid = %04lx\n",header
->pid
);
4224 Printf("uid = %04lx\n",header
->uid
);
4225 Printf("mid = %04lx\n",header
->mid
);
4227 Printf("length = %ld (packet size:%ld, buffer size:%ld)\n",header_length
,packet_size
,max_buffer_size
);
4229 if(is_smb_andx_command(header
->command
))
4231 const unsigned char * andx_header
= (const unsigned char *)header
->parameters
;
4232 int offset
= (((int)andx_header
[3]) << 8) + andx_header
[2];
4233 int num_parameter_words
,num_data_bytes
;
4235 command_name
= get_smb_command_name(header
->command
);
4237 if(command_name
!= NULL
)
4238 Printf("command = %s (ANDX)\n",command_name
);
4240 Printf("command = 0x%02lx (ANDX)\n",header
->command
);
4242 Printf("parameter words = %ld\n",header
->num_parameter_words
- 2);
4244 if(header
->num_parameter_words
- 2 > 0)
4245 print_smb_parameters(header
->num_parameter_words
- 2,&header
->parameters
[4]);
4247 Printf("data bytes = %ld\n",header
->num_data_bytes
);
4249 /* If there are any data bytes, print them like "type hex .." would. */
4250 if(header
->num_data_bytes
> 0)
4251 print_smb_data(&lb
,header
->num_data_bytes
,header
->data
);
4253 print_smb_contents(header
, header
->command
, smb_packet_source
, header
->num_parameter_words
- 2,
4254 &header
->parameters
[4], header
->num_data_bytes
, header
->data
);
4256 while(andx_header
[0] != 0xff && offset
> 0 && offset
< packet_size
)
4258 andx_header
= &packet
[offset
];
4260 num_parameter_words
= (*andx_header
++);
4262 command_name
= get_smb_command_name(andx_header
[0]);
4264 if(command_name
!= NULL
)
4265 Printf("command = %s (ANDX)\n",command_name
);
4267 Printf("command = 0x%02lx (ANDX)\n",header
->command
);
4269 Printf("andx_offset = 0x%02lx\n",(((int)andx_header
[3]) << 8) + andx_header
[2]);
4271 Printf("parameter words = %ld\n",num_parameter_words
);
4273 if(num_parameter_words
> 0)
4274 print_smb_parameters(num_parameter_words
,&andx_header
[4]);
4276 num_data_bytes
= andx_header
[4 + num_parameter_words
* 2] + (((int)andx_header
[4 + num_parameter_words
* 2 + 1]) << 8);
4278 Printf("data bytes = %ld\n",num_data_bytes
);
4280 if(num_data_bytes
> 0)
4281 print_smb_data(&lb
,num_data_bytes
,&andx_header
[4 + num_parameter_words
* 2 + 2]);
4283 print_smb_contents(header
, andx_header
[0], smb_packet_source
, num_parameter_words
, &andx_header
[4],
4284 num_data_bytes
, &andx_header
[4 + num_parameter_words
* 2 + 2]);
4286 offset
= (((int)andx_header
[3]) << 8) + andx_header
[2];
4291 command_name
= get_smb_command_name(header
->command
);
4293 if(command_name
!= NULL
)
4294 Printf("command = %s\n",command_name
);
4296 Printf("command = 0x%02lx\n",header
->command
);
4298 Printf("parameter words = %ld\n",header
->num_parameter_words
);
4300 if(header
->num_parameter_words
> 0)
4301 print_smb_parameters(header
->num_parameter_words
,(unsigned char *)header
->parameters
);
4303 Printf("data bytes = %ld\n",header
->num_data_bytes
);
4305 /* If there are any data bytes, print them like "type hex .." would. */
4306 if(header
->num_data_bytes
> 0)
4307 print_smb_data(&lb
,header
->num_data_bytes
,header
->data
);
4309 print_smb_contents(header
, header
->command
, smb_packet_source
, header
->num_parameter_words
, header
->parameters
,
4310 header
->num_data_bytes
, header
->data
);
4314 /*****************************************************************************/
4317 dump_netbios_header(const char *file_name
,int line_number
,const unsigned char *netbios_session_header
,
4318 const unsigned char *netbios_payload
,int netbios_payload_size
)
4320 if(dump_smb_enabled
)
4322 unsigned char session_type
= netbios_session_header
[0];
4323 unsigned char session_flags
= netbios_session_header
[1] & 0xfe;
4324 unsigned long session_length
=
4325 ((netbios_session_header
[1] & 1) ? 0x10000 : 0) |
4326 (((unsigned long)netbios_session_header
[2]) << 8) |
4327 netbios_session_header
[3];
4329 const char * session_type_label
;
4331 switch(session_type
)
4335 session_type_label
= "session message";
4340 session_type_label
= "session request";
4345 session_type_label
= "positive session response";
4350 session_type_label
= "negative session response";
4355 session_type_label
= "retarget session response";
4360 session_type_label
= "session keep alive";
4365 session_type_label
= "?";
4370 Printf("%s:%ld\n",file_name
,line_number
);
4372 Printf("netbios session type=%s (0x%02lx), flags=0x%02lx, length=%ld\n",
4373 session_type_label
,session_type
,session_flags
,session_length
);
4375 if (session_type
== 0x83 && netbios_payload
!= NULL
&& netbios_payload_size
> 0)
4377 int error_code
= *netbios_payload
;
4379 Printf("error code = 0x%02lx\n",error_code
);
4385 Printf(" Not listening on called name\n");
4390 Printf(" Not listening for calling name\n");
4395 Printf(" Called name not present\n");
4400 Printf(" Insufficient resources\n");
4405 Printf(" Unspecific error\n");
4409 else if (session_type
!= 0x00 && netbios_payload
!= NULL
&& netbios_payload_size
> 0)
4411 struct line_buffer lb
;
4413 Printf("session data (%ld bytes) =\n",netbios_payload_size
);
4415 print_smb_data(&lb
,netbios_payload_size
,netbios_payload
);
4420 /*****************************************************************************/
4423 dump_smb(const char *file_name
,int line_number
,int is_raw_data
,
4424 const void * packet
,int length
,enum smb_packet_source_t smb_packet_source
,
4425 int max_buffer_size
)
4427 if(dump_smb_enabled
)
4431 struct line_buffer lb
;
4434 Printf("%s:%ld\n",file_name
,line_number
);
4436 Printf("raw data (%ld bytes) =\n",length
);
4438 print_smb_data(&lb
,length
,packet
);
4444 if(length
> 4 && memcmp(packet
,"\xffSMB",4) == 0)
4446 struct smb_header header
;
4449 num_bytes_read
= fill_header(packet
,length
,&header
);
4450 if(num_bytes_read
<= length
)
4453 Printf("%s:%ld\n",file_name
,line_number
);
4455 print_smb_header(&header
,num_bytes_read
,packet
,length
,
4456 smb_packet_source
,max_buffer_size
);
4465 /*****************************************************************************/
4468 control_smb_dump(int enable
)
4470 dump_smb_enabled
= enable
;
4473 /*****************************************************************************/
4475 #endif /* DUMP_SMB */