Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

589 lines
15 KiB

  1. page ,132
  2. ; SCCSID = @(#)tucode.asm 4.2 85/05/31
  3. ; SCCSID = @(#)tucode.asm 4.2 85/05/31
  4. Title COMMAND Language midifiable Code Transient
  5. ;/*
  6. ; * Microsoft Confidential
  7. ; * Copyright (C) Microsoft Corporation 1991
  8. ; * All Rights Reserved.
  9. ; */
  10. .xlist
  11. .xcref
  12. include dossym.inc
  13. include syscall.inc
  14. include comsw.asm
  15. include comseg.asm
  16. include comequ.asm
  17. .list
  18. .cref
  19. DATARES SEGMENT PUBLIC BYTE ;AC000;
  20. EXTRN ECHOFLAG:BYTE
  21. DATARES ENDS
  22. TRANDATA SEGMENT PUBLIC BYTE ;AC000;
  23. EXTRN BAD_ON_OFF_ptr:word
  24. EXTRN ctrlcmes_ptr:word
  25. EXTRN DEL_Y_N_PTR:WORD
  26. EXTRN ECHOMES_ptr:word
  27. EXTRN extend_buf_ptr:word ;AC000;
  28. EXTRN offmes_ptr:word
  29. EXTRN onmes_ptr:word
  30. EXTRN PARSE_BREAK:BYTE ;AN000;
  31. EXTRN promptdat_moday:word ;AC000;
  32. EXTRN promptdat_ptr:word ;AC000;
  33. EXTRN promptdat_yr:word ;AC000;
  34. EXTRN string_buf_ptr:word
  35. EXTRN SUREMES_ptr:word
  36. EXTRN VERIMES_ptr:BYTE
  37. EXTRN WeekTab:word
  38. TRANDATA ENDS
  39. TRANSPACE SEGMENT PUBLIC BYTE ;AC000;
  40. EXTRN arg_buf:byte
  41. EXTRN BWDBUF:BYTE
  42. EXTRN DEST:BYTE
  43. EXTRN destdir:byte
  44. EXTRN dirchar:byte
  45. EXTRN PARSE1_CODE:BYTE ;AN000;
  46. EXTRN RESSEG:WORD
  47. EXTRN string_ptr_2:word
  48. TRANSPACE ENDS
  49. TRANCODE SEGMENT PUBLIC BYTE
  50. EXTRN CERROR:NEAR
  51. EXTRN CRLF2:NEAR
  52. EXTRN extend_setup:near ;AN022;
  53. PUBLIC CNTRLC
  54. PUBLIC ECHO
  55. PUBLIC GetDate
  56. PUBLIC NOTEST2
  57. PUBLIC PRINT_DATE
  58. PUBLIC SLASHP_ERASE ;AN000;
  59. PUBLIC VERIFY
  60. ASSUME CS:TRANGROUP,DS:TRANGROUP,ES:TRANGROUP,SS:NOTHING
  61. ; ****************************************************************
  62. ; *
  63. ; * ROUTINE: NOTEST2 - execution of DEL/ERASE command
  64. ; *
  65. ; * FUNCTION: Delete files based on user parsed input. Prompt
  66. ; * user for Y/N if necessary. If an error occurs,
  67. ; * set up an error message and go to CERROR.
  68. ; *
  69. ; * INPUT: FCB at 5ch set up with filename(s) entered
  70. ; * Current directory set to entered directory
  71. ; *
  72. ; * OUTPUT: none
  73. ; *
  74. ; ****************************************************************
  75. ;
  76. ; ARE YOU SURE prompt when deleting *.*
  77. NOTEST2:
  78. MOV CX,11
  79. MOV SI,FCB+1
  80. AMBSPEC:
  81. LODSB
  82. CMP AL,'?'
  83. JNZ ALLFIL
  84. LOOP AMBSPEC
  85. ALLFIL:
  86. CMP CX,0
  87. JNZ NOPRMPT
  88. ASKAGN:
  89. MOV DX,OFFSET TRANGROUP:SUREMES_ptr ; "Are you sure (Y/N)?"
  90. invoke std_printf
  91. MOV SI,80H
  92. MOV DX,SI
  93. MOV WORD PTR [SI],120 ; zero length
  94. MOV AX,(STD_CON_INPUT_FLUSH SHL 8) OR STD_CON_STRING_INPUT
  95. INT 21H
  96. LODSW
  97. OR AH,AH
  98. JZ ASKAGN
  99. INVOKE SCANOFF
  100. call char_in_xlat ;G Convert to upper case
  101. retc ;AN000; return if function not supported
  102. CMP AL,CAPITAL_N ;G
  103. retz
  104. CMP AL,CAPITAL_Y ;G
  105. PUSHF
  106. CALL CRLF2
  107. POPF
  108. JNZ ASKAGN
  109. NOPRMPT:
  110. MOV AH,FCB_DELETE
  111. MOV DX,FCB
  112. INT 21H
  113. INC AL
  114. jz eraerr
  115. invoke RESTUDIR
  116. ret ; If no error, return
  117. eraerr:
  118. invoke set_ext_error_msg ;AN022; set up the extended error
  119. push dx ;AN022; save message
  120. invoke RESTUDIR
  121. pop dx ;AN022; restore message
  122. cmp word ptr extend_buf_ptr,error_no_more_files ;AN022; convert no more files to
  123. jnz cerrorj2 ;AN022; file not found
  124. mov Extend_Buf_ptr,error_file_not_found ;AN000; get message number in control block
  125. cerrorj2:
  126. jmp cerror
  127. ; ****************************************************************
  128. ; *
  129. ; * ROUTINE: SLASHP_ERASE - execution of DEL/ERASE /P
  130. ; *
  131. ; * FUNCTION: Delete files based on user parsed input. Prompt
  132. ; * user for Y/N where necessary. If an error occurs
  133. ; * set up and error message and transfer control
  134. ; * to CERROR.
  135. ; *
  136. ; * INPUT: FCB at 5ch set up with filename(s) entered
  137. ; * Current directory set to entered directory
  138. ; *
  139. ; * OUTPUT: none
  140. ; *
  141. ; ****************************************************************
  142. ASSUME CS:TRANGROUP,DS:TRANGROUP,ES:TRANGROUP,SS:NOTHING
  143. SLASHP_ERASE: ;AN000; entry point
  144. invoke build_dir_string ;AN000; set up current directory string for output
  145. mov ah,Set_DMA ;AN000; issue set dta int 21h
  146. mov dx,offset trangroup:destdir ;AN000; use Destdir for target
  147. int 21H ;AN000;
  148. mov ah,Dir_Search_First ;AN000; do dir search first int 21h
  149. mov dx,FCB ;AN000; use FCB at 5Ch for target
  150. int 21H ;AN000;
  151. inc al ;AN000; did an error occur
  152. jz eraerr ;AN022; go to error exit
  153. delete_prompt_loop: ;AN000;
  154. mov si,offset trangroup:destdir+1 ;AN000; set up FCB as source
  155. mov di,offset trangroup:dest ;AN000; set up dest as target
  156. mov al,dirchar ;AN000; store a "\" in the first char
  157. stosb ;AN000; of DEST
  158. invoke fcb_to_ascz ;AN000; convert filename from FCB to ASCIIZ string
  159. slashp_askagn: ;AN000;
  160. call crlf2 ;AN000; print out carriage return, line feed
  161. mov dx,offset trangroup:bwdbuf ;AN000; print out current directory string
  162. mov bx,dx ;AN000; get string pointer in bx
  163. cmp byte ptr [bx+3],end_of_line_out ;AN000; see if only D:\,0
  164. jnz not_del_root ;AN000; no continue
  165. mov byte ptr [bx+2],end_of_line_out ;AN000; yes, get rid of \
  166. Not_del_root: ;AN000;
  167. mov string_ptr_2,dx ;AN000;
  168. mov dx,offset trangroup:string_buf_ptr ;AN000;
  169. invoke std_printf ;AN000;
  170. mov dx,offset trangroup:dest ;AN000; print out file name string
  171. mov string_ptr_2,dx ;AN000;
  172. mov dx,offset trangroup:string_buf_ptr ;AN000;
  173. invoke std_printf ;AN000;
  174. mov dx,offset trangroup:Del_Y_N_Ptr ;AN000; issue ", Delete (Y/N)?" message
  175. invoke std_printf ;AN000;
  176. ;;M029 mov si,80H ;AN000; set up buffer for input
  177. ;;M029 mov dx,si ;AN000;
  178. ;;M029 mov word ptr [si],combuflen ;AN000;
  179. ;;M029 mov ax,(std_con_input_flush shl 8) or std_con_string_input ;AN000;
  180. ;;M029 int 21h ;AN000; get input from the user
  181. ;;M029 lodsw ;AN000;
  182. ;;M029 or ah,ah ;AN000; was a character entered?
  183. ;;M029 jz slashp_askagn ;AN000; no - ask again
  184. ;;M029 invoke scanoff ;AN000; scan off leading delimiters
  185. ; Get a single character input.
  186. mov ax,(std_con_input_flush shl 8) or std_con_input ;M029
  187. int 21h ;M029
  188. call char_in_xlat ;AN000; yes - upper case it
  189. retc ;AN000; return if function not supported
  190. cmp al,capital_n ;AN000; was it no?
  191. jz next_del_file ;AN000; yes - don't delete file
  192. cmp al,capital_y ;AN000; was it yes?
  193. jz delete_this_file ;AN000; yes - delete the file
  194. jmp short slashp_askagn ;AN000; it was neither - ask again
  195. delete_this_file: ;AN000;
  196. mov ah,fcb_delete ;AN000; delete the file
  197. mov dx,offset trangroup:destdir ;AN000; use Destdir for target
  198. int 21h ;AN000;
  199. inc al ;AN000; did an error occur?
  200. jnz next_del_file ;AN000; no - get next file
  201. ;
  202. ;M041; Begin changes
  203. ; We got an error deleting the file. If this is access denied, we can go on
  204. ;to the next file after printing an error message.
  205. ;
  206. invoke Get_ext_error_number ;see what error we got
  207. cmp ax,error_access_denied ;is it access denied?
  208. jne stop_del ;no, some other error
  209. invoke CrLf2 ;print a CR-LF
  210. invoke set_ext_error_msg ;error message
  211. invoke std_eprintf ;"Access denied"
  212. jmp short next_del_file ;try next file
  213. stop_del:
  214. ;
  215. ;M041; End changes
  216. ;
  217. jmp eraerr ;AN022; go to error exit - need long jmp
  218. next_del_file: ;AN000;
  219. ;
  220. ; M050 - begin
  221. ; Norton Utilities 5.0 has a bug. DiskMon when invoked
  222. ; with /protect+ and /light+ makes it intercept all
  223. ; deletes. This hook does not save and restore the DTA correctly.
  224. ; They save the DWORD in a WORD by mistake! They save both the
  225. ; segment and the offset in the SAME variable (WORD)!!!
  226. ;
  227. mov ah,Set_DMA
  228. mov dx,offset trangroup:destdir
  229. int 21H
  230. ;
  231. ; M050 - end
  232. mov ah,dir_search_next ;AN000; search for another file
  233. mov dx,FCB ;AN000;
  234. int 21h ;AN000;
  235. inc al ;AN000; was a file found?
  236. jz slash_p_exit ;AN000; no - exit
  237. jmp delete_prompt_loop ;AN000; yes - continue (need long jump)
  238. slash_p_exit:
  239. invoke get_ext_error_number ;AN022; get the extended error number
  240. cmp ax,error_no_more_files ;AN022; was error file not found?
  241. jz good_erase_exit ;AN022; yes - clean exit
  242. jmp extend_setup ;AN022; go issue error message
  243. good_erase_exit:
  244. invoke restudir ;AN000; we're finished - restore user's dir
  245. call crlf2 ;AN000; print out carriage return, line feed
  246. ret ;AN000; exit
  247. ;************************************************
  248. ; ECHO, BREAK, and VERIFY commands. Check for "ON" and "OFF"
  249. break Echo
  250. assume ds:trangroup,es:trangroup
  251. ECHO:
  252. CALL ON_OFF
  253. JC DOEMES
  254. MOV DS,[RESSEG]
  255. ASSUME DS:RESGROUP
  256. JNZ ECH_OFF
  257. OR [ECHOFLAG],1
  258. RET
  259. ECH_OFF:
  260. AND [ECHOFLAG],NOT 1
  261. RET
  262. CERRORJ:
  263. JMP CERROR
  264. ;
  265. ; There was no discrenable ON or OFF after the ECHO. If there is nothing but
  266. ; delimiters on the command line, we issue the ECHO is ON/OFF message.
  267. ;
  268. ASSUME DS:TRANGROUP
  269. DOEMES:
  270. cmp cl,0 ;AC000; was anything on the line?
  271. jz PEcho ; just display current state.
  272. MOV DX,82H ; Skip one char after "ECHO"
  273. invoke CRPRINT
  274. JMP CRLF2
  275. PECHO:
  276. MOV DS,[RESSEG]
  277. ASSUME DS:RESGROUP
  278. MOV BL,[ECHOFLAG]
  279. PUSH CS
  280. POP DS
  281. ASSUME DS:TRANGROUP
  282. AND BL,1
  283. MOV DX,OFFSET TRANGROUP:ECHOMES_ptr
  284. JMP SHORT PYN
  285. break Break
  286. assume ds:trangroup,es:trangroup
  287. CNTRLC:
  288. CALL ON_OFF
  289. MOV AX,(SET_CTRL_C_TRAPPING SHL 8) OR 1
  290. JC PCNTRLC
  291. JNZ CNTRLC_OFF
  292. MOV DL,1
  293. INT 21H ; Set ^C
  294. RET
  295. CNTRLC_OFF:
  296. XOR DL,DL
  297. INT 21H ; Turn off ^C check
  298. RET
  299. PCNTRLC:
  300. CMP CL,0 ;AC000; rest of line blank?
  301. JNZ CERRORJ ; no, oops!
  302. pccont:
  303. XOR AL,AL
  304. INT 21H
  305. MOV BL,DL
  306. MOV DX,OFFSET TRANGROUP:CTRLCMES_ptr
  307. PYN:
  308. mov si,offset trangroup:onmes_ptr ;AC000; get ON pointer
  309. OR BL,BL
  310. JNZ PRINTVAL
  311. mov si,offset trangroup:offmes_ptr ;AC000; get OFF pointer
  312. PRINTVAL:
  313. push dx ;AN000; save offset of message block
  314. mov bx,dx ;AN000; save offset value
  315. lodsw ;AN000; get message number of on or off
  316. mov dh,util_msg_class ;AN000; this is a utility message
  317. invoke Tsysgetmsg ;AN000; get the address of the message
  318. add bx,ptr_off_pos ;AN000; point to offset of ON/OFF
  319. mov word ptr [bx],si ;AN000; put the offset in the message block
  320. pop dx ;AN000; get message back
  321. invoke std_printf ;AC000; go print message
  322. mov word ptr [bx],0 ;AN000; zero out message pointer
  323. ret ;AN000; exit
  324. break Verify
  325. assume ds:trangroup,es:trangroup
  326. VERIFY:
  327. CALL ON_OFF
  328. MOV AX,(SET_VERIFY_ON_WRITE SHL 8) OR 1
  329. JC PVERIFY
  330. JNZ VER_OFF
  331. INT 21H ; Set verify
  332. RET
  333. VER_OFF:
  334. DEC AL
  335. INT 21H ; Turn off verify after write
  336. RET
  337. PVERIFY:
  338. CMP CL,0 ;AC000; is rest of line blank?
  339. JNZ CERRORJ ; nope...
  340. MOV AH,GET_VERIFY_ON_WRITE
  341. INT 21H
  342. MOV BL,AL
  343. MOV DX,OFFSET TRANGROUP:VERIMES_ptr
  344. JMP PYN
  345. ; ****************************************************************
  346. ; *
  347. ; * ROUTINE: ON_OFF
  348. ; *
  349. ; * FUNCTION: Parse the command line for an optional ON or
  350. ; * OFF string for the BREAK, VERIFY, and ECHO
  351. ; * routines.
  352. ; *
  353. ; * INPUT: command line at offset 81H
  354. ; * PARSE_BREAK control block
  355. ; *
  356. ; * OUTPUT: If carry is clear
  357. ; * If ON is found
  358. ; * Zero flag set
  359. ; * If OFF is found
  360. ; * Zero flag clear
  361. ; * If carry set
  362. ; * If nothing on command line
  363. ; * CL set to zero
  364. ; * If error
  365. ; * CL contains error value from parse
  366. ; *
  367. ; ****************************************************************
  368. assume ds:trangroup,es:trangroup
  369. ON_OFF:
  370. MOV SI,81h
  371. scan_on_off: ;AN032; scan off leading blanks & equal
  372. lodsb ;AN032; get a char
  373. cmp al,blank ;AN032; if whitespace
  374. jz scan_on_off ;AN032; keep scanning
  375. cmp al,tab_chr ;AN032; if tab
  376. jz scan_on_off ;AN032; keep scanning
  377. cmp al,equal_chr ;AN032; if equal char
  378. jz parse_on_off ;AN032; start parsing
  379. dec si ;AN032; if none of above - back up
  380. parse_on_off: ;AN032; and start parsing
  381. mov di,offset trangroup:parse_break ;AN000; Get adderss of PARSE_BREAK
  382. xor cx,cx ;AN000; clear cx,dx
  383. xor dx,dx ;AN000;
  384. invoke cmd_parse ;AC000; call parser
  385. cmp ax,end_of_line ;AC000; are we at end of line?
  386. jz BADONF ;AC000; yes, return error
  387. cmp ax,result_no_error ;AN000; did an error occur
  388. jz on_off_there ;AN000; no - continue
  389. mov cx,ax ;AN000; yes - set cl to error code
  390. jmp short BADONF ;AN000; return error
  391. on_off_there:
  392. cmp parse1_code,-1 ;AN014; was a valid positional present?
  393. jnz good_on_off ;AN014; yes - continue
  394. mov cx,badparm_ptr ;AN014; something other than ON/OFF
  395. jmp short BADONF ;AN014; return error
  396. good_on_off: ;AN014;
  397. xor ax,ax ;AC000; set up return code for
  398. or al,parse1_code ;AC000; ON or OFF in AX
  399. pushf ;AN000; save flags
  400. mov di,offset trangroup:parse_break ;AN000; Get adderss of PARSE_BREAK
  401. xor dx,dx ;AN000;
  402. invoke cmd_parse ;AN000; call parser
  403. cmp ax,end_of_line ;AN000; are we at end of line?
  404. jnz BADONF_flags ;AN000; NO, return error
  405. popf ;AN000; restore flags
  406. clc ;AC000; no error
  407. jmp short on_off_end ;AN000; return to caller
  408. BADONF_flags:
  409. mov cx,ax
  410. popf
  411. ;
  412. ; No discernable ON or OFF has been found. Put an error message pointer in DX
  413. ; and return the error
  414. ;
  415. BADONF:
  416. MOV DX,OFFSET TRANGROUP:BAD_ON_OFF_ptr
  417. STC
  418. ON_OFF_END:
  419. RET
  420. ;*************************************************************************
  421. ; print date
  422. PRINT_DATE:
  423. PUSH ES
  424. PUSH DI
  425. PUSH CS
  426. POP ES
  427. CALL GetDate ; get date
  428. xchg dh,dl ;AN000; switch month & day
  429. mov promptDat_yr,cx ;AC000; put year into message control block
  430. mov promptDat_moday,dx ;AC000; put month and day into message control block
  431. mov dx,offset trangroup:promptDat_ptr ;AC000; set up message for output
  432. invoke std_printf
  433. ;AD061; mov promptDat_yr,0 ;AC000; reset year, month and day
  434. ;AD061; mov promptDat_moday,0 ;AC000; pointers in control block
  435. POP DI ;AC000; restore di,es
  436. POP ES ;AC000;
  437. return
  438. ;
  439. ; Do GET DATE system call and set up 3 character day of week in ARG_BUF
  440. ; for output. Date will be returned in CX,DX.
  441. ;
  442. GetDate:
  443. mov di,offset trangroup:arg_buf ;AC000; target for day of week
  444. MOV AH,GET_DATE ;AC000; get current date
  445. INT 21h ;AC000; Get date in CX:DX
  446. CBW ;AC000;
  447. push cx ;AN000; save date returned in
  448. push dx ;AN000; CX:DX
  449. MOV SI,AX
  450. IFNDEF DBCS
  451. SHL SI,1
  452. ADD SI,AX ; SI=AX*3
  453. ELSE
  454. ifdef JAPAN ; MSKK01 07/14/89
  455. shl si,1
  456. shl si,1 ; SI=AX*4
  457. endif
  458. IFDEF TAIWAN
  459. SHL SI,1
  460. ADD SI,AX
  461. SHL SI,1 ; SI=AX*6
  462. ENDIF
  463. ifdef KOREA
  464. shl si,1
  465. endif
  466. ENDIF
  467. mov cx,si ;AN000; save si
  468. mov ax,weektab ;AN000; get message number of weektab
  469. mov dh,util_msg_class ;AN000; this is a utility message
  470. push di ;AN000; save argument buffer
  471. invoke Tsysgetmsg ;AN000; get the address of the message
  472. pop di ;AN000; retrieve argument buffer
  473. add si,cx ;AC000; get day of week
  474. IFNDEF DBCS
  475. MOV CX,3
  476. ELSE
  477. ifdef JAPAN ; MSKK01 07/14/89
  478. mov cx,4
  479. endif
  480. IFDEF TAIWAN
  481. MOV CX,6
  482. ENDIF
  483. ifdef KOREA
  484. mov cx,2 ; MSCH 90/9/6
  485. endif
  486. ENDIF
  487. REP MOVSB
  488. mov al,end_of_line_out ;AC000; terminate the string
  489. stosb
  490. pop dx ;AN000; get back date
  491. pop cx ;AN000;
  492. return
  493. ;g
  494. ;g This routine determines whether the character in AL is a
  495. ;g Yes or No character. On return, if AL=0, the character is
  496. ;g No, if AL=1, the character is Yes.
  497. ;g
  498. assume ds:trangroup
  499. char_in_xlat proc near
  500. mov dl,al ;AC000; get character into DX
  501. xor dh,dh ;AC000;
  502. mov ax,(getextcntry SHL 8) + 35 ;AC000; Yes/No char call
  503. int 21h ;AC000;
  504. ret
  505. char_in_xlat endp
  506. TRANCODE ENDS
  507. END
  508.