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.

745 lines
21 KiB

  1. page ,132
  2. title COMMAND - resident code for COMMAND.COM
  3. name COMMAND
  4. ;/*
  5. ; * Microsoft Confidential
  6. ; * Copyright (C) Microsoft Corporation 1991
  7. ; * All Rights Reserved.
  8. ; */
  9. ;*****************************************************************************
  10. ;
  11. ; MODULE: COMMAND.COM
  12. ;
  13. ; DESCRIPTIVE NAME: Default DOS command interpreter
  14. ;
  15. ; FUNCTION: This version of COMMAND is divided into three distinct
  16. ; parts. First is the resident portion, which includes
  17. ; handlers for interrupts 23H (Cntrl-C), 24H (fatal
  18. ; error), and 2EH (command line execute); it also has
  19. ; code to test and, if necessary, reload the transient
  20. ; portion. Following the resident is the init code, which
  21. ; is overwritten after use. Then comes the transient
  22. ; portion, which includes all command processing (whether
  23. ; internal or external). The transient portion loads at
  24. ; the end of physical memory, and it may be overlayed by
  25. ; programs that need as much memory as possible. When the
  26. ; resident portion of command regains control from a user
  27. ; program, a check sum is performed on the transient
  28. ; portion to see if it must be reloaded. Thus programs
  29. ; which do not need maximum memory will save the time
  30. ; required to reload COMMAND when they terminate.
  31. ;
  32. ; ENTRY POINT: PROGSTART
  33. ;
  34. ; INPUT: command line at offset 81H
  35. ;
  36. ; EXIT_NORMAL: No exit from root level command processor. Can exit
  37. ; from a secondary command processor via the EXIT
  38. ; internal command.
  39. ;
  40. ; EXIT_ERROR: Exit to prior command processor if possible, otherwise
  41. ; hang the system.
  42. ;
  43. ; INTERNAL REFERENCES:
  44. ;
  45. ; ROUTINES: See the COMMAND Subroutine Description Document
  46. ; (COMMAND.DOC)
  47. ;
  48. ; DATA AREAS: See the COMMAND Subroutine Description Document
  49. ; (COMMAND.DOC)
  50. ;
  51. ; EXTERNAL REFERENCES:
  52. ;
  53. ; ROUTINES: none
  54. ;
  55. ; DATA AREAS: none
  56. ;
  57. ;*****************************************************************************
  58. ;
  59. ; REVISION HISTORY
  60. ; ----------------
  61. ;
  62. ; DOS 1.00 to DOS 3.30
  63. ; --------------------------
  64. ; SEE REVISION LOG IN COPY.ASM ALSO
  65. ;
  66. ; REV 1.17
  67. ; 05/19/82 Fixed bug in BADEXE error (relocation error must return to
  68. ; resident since the EXELOAD may have overwritten the transient.
  69. ;
  70. ; REV 1.18
  71. ; 05/21/82 IBM version always looks on drive A
  72. ; MSVER always looks on default drive
  73. ;
  74. ; REV 1.19
  75. ; 06/03/82 Drive spec now entered in command line
  76. ; 06/07/82 Added VER command (print DOS version number) and VOL command
  77. ; (print volume label)
  78. ;
  79. ; REV 1.20
  80. ; 06/09/82 Prints "directory" after directories
  81. ; 06/13/82 MKDIR, CHDIR, PWD, RMDIR added
  82. ;
  83. ; REV 1.50
  84. ; Some code for new 2.0 DOS, sort of HACKey. Not enough time to
  85. ; do it right.
  86. ;
  87. ; REV 1.70
  88. ; EXEC used to fork off new processes
  89. ;
  90. ; REV 1.80
  91. ; C switch for single command execution
  92. ;
  93. ; REV 1.90
  94. ; Batch uses XENIX
  95. ;
  96. ; Rev 2.00
  97. ; Lots of neato stuff
  98. ; IBM 2.00 level
  99. ;
  100. ; Rev 2.01
  101. ; 'D' switch for date time suppression
  102. ;
  103. ; Rev 2.02
  104. ; Default userpath is NUL rather than BIN
  105. ; same as IBM
  106. ; COMMAND split into pieces
  107. ;
  108. ; Rev 2.10
  109. ; INTERNATIONAL SUPPORT
  110. ;
  111. ; Rev 2.50
  112. ; all the 2.x new stuff -MU
  113. ;
  114. ; Rev 3.30 (Ellen G)
  115. ; CALL internal command (TBATCH2.ASM)
  116. ; CHCP internal command (TCMD2B.ASM)
  117. ; INT 24H support of abort, retry, ignore, and fail prompt
  118. ; @ sign suppression of batch file line
  119. ; Replaceable environment value support in batch files
  120. ; INT 2FH calls for APPEND
  121. ; Lots of PTR fixes!
  122. ;
  123. ; Beyond 3.30 to forever (Ellen G)
  124. ; ----------------------
  125. ;
  126. ; A000 DOS 4.00 - Use SYSPARSE for internal commands
  127. ; Use Message Retriever services
  128. ; /MSG switch for resident extended error msg
  129. ; Convert to new capitalization support
  130. ; Better error recovery on CHCP command
  131. ; Code page file tag support
  132. ; TRUENAME internal command
  133. ; Extended screen line support
  134. ; /P switch on DEL/ERASE command
  135. ; Improved file redirection error recovery
  136. ; (removed) Improved batch file performance
  137. ; Unconditional DBCS support
  138. ; Volume serial number support
  139. ; (removed) COMMENT=?? support
  140. ;
  141. ; A001 PTM P20 Move system_cpage from TDATA to TSPC
  142. ;
  143. ; A002 PTM P74 Fix PRESCAN so that redirection symbols do not
  144. ; require delimiters.
  145. ;
  146. ; A003 PTM P5,P9,P111 Included in A000 development
  147. ;
  148. ; A004 PTM P86 Fix IF command to turn off piping before
  149. ; executing
  150. ;
  151. ; A005 DCR D17 If user specifies an extension on the command
  152. ; line search for that extension only.
  153. ;
  154. ; A006 DCR D15 New message for MkDir - "Directory already
  155. ; exists"
  156. ;
  157. ; A007 DCR D2 Change CTTY so that a write is done before XDUP
  158. ;
  159. ; A008 PTM P182 Change COPY to set default if invalid function
  160. ; returned from code page call.
  161. ;
  162. ; A009 PTM P179 Add CRLF to invalid disk change message
  163. ;
  164. ; A010 DCR D43 Allow APPEND to do a far call to SYSPARSE in
  165. ; transient COMMAND.
  166. ;
  167. ; A011 DCR D130 Change redirection to overwrite an EOF mark
  168. ; before appending to a file.
  169. ;
  170. ; A012 PTM P189 Fix redirection error recovery.
  171. ;
  172. ; A013 PTM P330 Change date format
  173. ;
  174. ; A014 PTM P455 Fix echo parsing
  175. ;
  176. ; A015 PTM P517 Fix DIR problem with * vs *.
  177. ;
  178. ; A016 PTM P354 Fix extended error message addressing
  179. ;
  180. ; A017 PTM P448 Fix appending to 0 length files
  181. ;
  182. ; A018 PTM P566,P3903 Fix parse error messages to print out parameter
  183. ; the parser fails on. Fail on duplicate switches.
  184. ;
  185. ; A019 PTM P542 Fix device name to be printed correctly during
  186. ; critical error
  187. ;
  188. ; A020 DCR D43 Set append state off while in DIR
  189. ;
  190. ; A021 PTM P709 Fix CTTY printing ascii characters.
  191. ;
  192. ; A022 DCR D209 Enhanced error recovery
  193. ;
  194. ; A023 PTM P911 Fix ANSI.SYS IOCTL structure.
  195. ;
  196. ; A024 PTM P899 Fix EXTOPEN open modes.
  197. ;
  198. ; A025 PTM P922 Fix messages and optimize PARSE switches
  199. ;
  200. ; A026 DCR D191 Change redirection error recovery support.
  201. ;
  202. ; A027 PTM P991 Fix so that KAUTOBAT & AUTOEXEC are terminated
  203. ; with a carriage return.
  204. ;
  205. ; A028 PTM P1076 Print a blank line before printing invalid
  206. ; date and invalid time messages.
  207. ;
  208. ; A029 PTM P1084 Eliminate calls to parse_check_eol in DATE
  209. ; and TIME.
  210. ;
  211. ; A030 DCR D201 New extended attribute format.
  212. ;
  213. ; A031 PTM P1149 Fix DATE/TIME add blank before prompt.
  214. ;
  215. ; A032 PTM P931 Fix =ON, =OFF for BREAK, VERIFY, ECHO
  216. ;
  217. ; A033 PTM P1298 Fix problem with system crashes on ECHO >""
  218. ;
  219. ; A034 PTM P1387 Fix COPY D:fname+,, to work
  220. ;
  221. ; A035 PTM P1407 Fix so that >> (appending) to a device does
  222. ; do a read to determine eof.
  223. ;
  224. ; A036 PTM P1406 Use 69h instead of 44h to get volume serial
  225. ; so that ASSIGN works correctly.
  226. ;
  227. ; A037 PTM P1335 Fix COMMAND /C with FOR
  228. ;
  229. ; A038 PTM P1635 Fix COPY so that it doesn't accept /V /V
  230. ;
  231. ; A039 DCR D284 Change invalid code page tag from -1 to 0.
  232. ;
  233. ; A040 PTM P1787 Fix redirection to cause error when no file is
  234. ; specified.
  235. ;
  236. ; A041 PTM P1705 Close redirected files after internal APPEND
  237. ; executes.
  238. ;
  239. ; A042 PTM P1276 Fix problem of APPEND paths changes in batch
  240. ; files causing loss of batch file.
  241. ;
  242. ; A043 PTM P2208 Make sure redirection is not set up twice for
  243. ; CALL'ed batch files.
  244. ;
  245. ; A044 PTM P2315 Set switch on PARSE so that 0ah is not used
  246. ; as an end of line character
  247. ;
  248. ; A045 PTM P2560 Make sure we don't lose parse, critical error,
  249. ; and extended message pointers when we EXIT if
  250. ; COMMAND /P is the top level process.
  251. ;
  252. ; A046 PTM P2690 Change COPY message "fn File not found" to
  253. ; "File not found - fn"
  254. ;
  255. ; A047 PTM P2819 Fix transient reload prompt message
  256. ;
  257. ; A048 PTM P2824 Fix COPY path to be upper cased. This was broken
  258. ; when DBCS code was added.
  259. ;
  260. ; A049 PTM P2891 Fix PATH so that it doesn't accept extra characters
  261. ; on line.
  262. ;
  263. ; A050 PTM P3030 Fix TYPE to work properly on files > 64K
  264. ;
  265. ; A051 PTM P3011 Fix DIR header to be compatible with prior releases.
  266. ;
  267. ; A052 PTM P3063,P3228 Fix COPY message for invalid filename on target.
  268. ;
  269. ; A053 PTM P2865 Fix DIR to work in 40 column mode.
  270. ;
  271. ; A054 PTM P3407 Code reduction and critical error on single line
  272. ; PTM P3672 (Change to single parser exported under P3407)
  273. ;
  274. ; A055 PTM P3282 Reset message service variables in INT 23h to fix
  275. ; problems with breaking out of INT 24h
  276. ;
  277. ; A056 PTM P3389 Fix problem of environment overlaying transient.
  278. ;
  279. ; A057 PTM P3384 Fix COMMAND /C so that it works if there is no space
  280. ; before the "string". EX: COMMAND /CDIR
  281. ;
  282. ; A058 PTM P3493 Fix DBCS so that CPARSE eats second character of
  283. ; DBCS switch.
  284. ;
  285. ; A059 PTM P3394 Change the TIME command to right align the display of
  286. ; the time.
  287. ;
  288. ; A060 PTM P3672 Code reduction - change PARSE and EXTENDED ERROR
  289. ; messages to be disk based. Only keep them if /MSG
  290. ; is used.
  291. ;
  292. ; A061 PTM P3928 Fix so that transient doesn't reload when breaking
  293. ; out of internal commands, due to substitution blocks
  294. ; not being reset.
  295. ;
  296. ; A062 PTM P4079 Fix segment override for fetching address of environment
  297. ; of parent copy of COMMAND when no COMSPEC exists in
  298. ; secondary copy of environment. Change default slash in
  299. ; default comspec string to backslash.
  300. ;
  301. ; A063 PTM P4140 REDIRECTOR and IFSFUNC changed interface for getting
  302. ; text for critical error messages.
  303. ;
  304. ; A064 PTM P4934 Multiplex number for ANSI.SYS changed due to conflict
  305. ; 5/20/88 with Microsoft product already shipped.
  306. ;
  307. ; A065 PTM P4935 Multiplex number for SHELL changed due to conflict
  308. ; 5/20/88 with Microsoft product already shipped.
  309. ;
  310. ; A066 PTM P4961 DIR /W /P scrolled first line off the screen in some
  311. ; 5/24/88 cases; where the listing would barely fit without the
  312. ; header and space remaining.
  313. ;
  314. ; A067 PTM P5011 For /E: values of 993 to 1024 the COMSPEC was getting
  315. ; 6/6/88 trashed. Turns out that the SETBLOCK for the new
  316. ; environment was putting a "Z block" marker in the old
  317. ; environment. The fix is to move to the old environment
  318. ; to the new environment before doing the SETBLOCK.
  319. ;
  320. ; A068 PTM P5568 IR79754 APPEND /x:on not working properly with DIR/VOL
  321. ; 09/19/88 because the check for APPEND needed to be performed
  322. ; before the DIR's findfirst.
  323. ;
  324. ; A069 PTM P5726 IR80540 COMSPEC_flag not properly initialized and
  325. ; 10/30/88 executed. Causing AUSTIN problem testing LAN/DW4 re-
  326. ; loading trans w/new comspec with no user change comspec.
  327. ;
  328. ; A070 PTM P5734 IR80484 Batch file causes sys workspace to be corrupted.
  329. ; 11/05/88 Expansion of environment variables into batch line of
  330. ; 128 chars was not being counted and "%" which should be
  331. ; ignored were being counted.
  332. ;
  333. ; A071 PTM P5854 IR82061 Invalid COMMAND.COM when Word Perfect, Prompt
  334. ; 03/02/89 used. Comspec_flag was not in protected data file be-
  335. ; ing included in checksum and was being overwritten by
  336. ; WP. Moved var from Tspc to Tdata so Trans would reload.
  337. ; Also removed fix A069 (because flag now protected).
  338. ;
  339. ; C001 VERSION 4.1 Add new internal command - SERVICE - to display the DOS
  340. ; 07/25/89 version and CSD version in U.S. date format. Files
  341. ; changed - TRANMSG,.SKL,COMMAND1,TDATA,TCMD2A,USA.MSG
  342. ;
  343. ;***********************************************************************************
  344. ;
  345. ; Revision History
  346. ; ================
  347. ;
  348. ; M021 SR 08/23/90 Fixed Ctrl-C handler to handle Ctrl-C
  349. ; at init time (date/time prompt)
  350. ;
  351. .xcref
  352. .xlist
  353. include dossym.inc ; basic DOS symbol set
  354. include syscall.inc ; DOS function names
  355. include comsw.asm ; build version info
  356. include comequ.asm ; common command.com symbols
  357. include resmsg.equ ; resident message names
  358. include comseg.asm ;segment ordering
  359. .list
  360. .cref
  361. CODERES segment public byte
  362. CODERES ends
  363. DATARES segment public byte
  364. extrn AccDen:byte
  365. extrn Batch:word
  366. extrn EchoFlag:byte
  367. extrn ExeBad:byte
  368. extrn ExecEMes:byte
  369. extrn ExecErrSubst:byte
  370. extrn ExtCom:byte
  371. extrn ForFlag:byte
  372. extrn IfFlag:byte
  373. extrn InitFlag:BYTE
  374. extrn Nest:word
  375. extrn PipeFlag:byte
  376. extrn RBadNam:byte
  377. extrn RetCode:word
  378. extrn SingleCom:word
  379. extrn TooBig:byte
  380. extrn OldDS:word
  381. EXTRN SCS_REENTERED:BYTE
  382. EXTRN SCS_CMDPROMPT:BYTE
  383. DATARES ends
  384. INIT segment public para
  385. extrn ConProc:near
  386. extrn Init_Contc_SpecialCase:near
  387. INIT ends
  388. include envdata.asm
  389. Prompt32 equ 1
  390. ;*** START OF RESIDENT PORTION
  391. CODERES segment public byte
  392. public Ext_Exec
  393. public ContC
  394. public Exec_Wait
  395. public Exec_Ret
  396. assume cs:CODERES,ds:NOTHING,es:NOTHING,ss:NOTHING
  397. extrn LodCom:near
  398. extrn LodCom1:near
  399. org 0
  400. Zero = $
  401. ;; org 80h - 1
  402. ;;ResCom label byte
  403. ;; public ResCom
  404. ;; org 100h
  405. public StartCode
  406. StartCode:
  407. ;; jmp RESGROUP:ConProc
  408. ;*** EXEC error handling
  409. ;
  410. ; COMMAND has issued an EXEC system call and it has returned an error.
  411. ; We examine the error code and select an appropriate message.
  412. ; Bugbug: optimize reg usage in following code? Careful of DX!
  413. ; Condense the error scan?
  414. ; RBADNAM is checked by transient, no need here?
  415. ; Move below Ext_Exec.
  416. Exec_Err:
  417. ;SR;
  418. ; ds,es are setup when the transient jumps to Ext_Exec. So segment regs are
  419. ;in order here
  420. assume ds:DATARES,es:DATARES
  421. ; Bugbug: can we use byte compares here?
  422. ; Might be able to use byte msg#s, too.
  423. ; Store errors in a 3 or 4 byte table. Msg #s in another.
  424. ; Speed not high priority here.
  425. ; Move this to transient.
  426. mov bx,offset DATARES:RBadNam
  427. cmp al,ERROR_FILE_NOT_FOUND
  428. je GotExecEMes ; bad command
  429. mov bx,offset DATARES:TooBig
  430. cmp al,ERROR_NOT_ENOUGH_MEMORY
  431. je GotExecEMes ; file not found
  432. mov bx,offset DATARES:ExeBad
  433. cmp al,ERROR_BAD_FORMAT
  434. je GotExecEMes ; bad exe file
  435. mov bx,offset DATARES:AccDen
  436. cmp al,ERROR_ACCESS_DENIED
  437. je GotExecEMes ; access denied
  438. Default_Message:
  439. mov bx,offset DATARES:ExecEMes ; default message
  440. mov si,offset DATARES:ExecErrSubst ; get address of subst block
  441. GotExecEMes:
  442. mov dx,bx ; DX = ptr to msg
  443. ;; williamh: no reason of doing this. When command.com receives a command,
  444. ;; it means the VDM process has been created successfully and there
  445. ;; is no way for the parent process to know that we are not able
  446. ;; to launch the program and therefore, it won't display any error
  447. ;; message for us.
  448. ;; cmp byte ptr [scs_reentered],1
  449. ;; jne NoErrMsg
  450. ;; cmp byte ptr [scs_cmdprompt],Prompt32
  451. ;; je NoErrMsg
  452. invoke RPrint
  453. NoErrMsg:
  454. jmp short NoExec
  455. ;*** EXEC call
  456. ;
  457. ; The transient has set up everything for an EXEC system call.
  458. ; For cleanliness, we issue the EXEC here in the resident
  459. ; so that we may be able to recover cleanly upon success.
  460. ;
  461. ; CS,DS,ES,SS = DATARES seg addr
  462. Ext_Exec:
  463. ;SR;
  464. ; The words put on the stack by the stub will be popped off when we finally
  465. ;jump to LodCom ( by LodCom).
  466. ;
  467. ;; int 21h ; do the exec
  468. Exec_Ret:
  469. jc Exec_Err ; exec failed
  470. ; The exec has completed. Retrieve the exit code.
  471. Exec_Wait:
  472. mov ah,WAITPROCESS ; get errorlevel
  473. int 21h ; get the return code
  474. mov RetCode,ax
  475. ; See if we can reload the transient. The external command
  476. ; may have overwritten part of the transient.
  477. NoExec:
  478. ;SR;
  479. ; ds = es = ss = DATARES when we jump to LodCom
  480. ;
  481. jmp LodCom
  482. ;*** Int 23 (ctrl-c) handler
  483. ;
  484. ; This is the default system INT 23 handler. All processes
  485. ; (including COMMAND) get it by default. There are some
  486. ; games that are played: We ignore ^C during most of the
  487. ; INIT code. This is because we may perform an ALLOC and
  488. ; diddle the header! Also, if we are prompting for date/time
  489. ; in the init code, we are to treat ^C as empty responses.
  490. ; Bugbug: put init ctrl-c handling in init module.
  491. ;SR;
  492. ; The stub has pushed the previous ds and DATARES onto the stack. We get
  493. ;both these values off the stack now
  494. ;
  495. ContC proc far
  496. assume cs:CODERES,ds:NOTHING,es:NOTHING,ss:NOTHING
  497. pop ds ;ds = DATARES
  498. assume ds:DATARES
  499. ; pop OldDS ;OldDS = old ds
  500. test InitFlag,INITINIT ; in initialization?
  501. jz NotAtInit ; no
  502. test InitFlag,INITSPECIAL ; doing special stuff?
  503. jz CmdIRet ; no, ignore ^C
  504. pop ds ; restore before jumping; M021
  505. jmp RESGROUP:Init_ContC_SpecialCase ; Yes, go handle it
  506. CmdIret:
  507. ;SR;
  508. ; Restore ds to its previous value
  509. ;
  510. ; mov ds,OLdDS ;
  511. pop ds
  512. iret ; yes, ignore the ^C
  513. NotAtInit:
  514. test InitFlag,INITCTRLC ; are we already in a ^C?
  515. jz NotInit ; nope too.
  516. ;* We are interrupting ourselves in this ^C handler. We need
  517. ; to set carry and return to the user sans flags only if the
  518. ; system call was a 1-12 one. Otherwise, we ignore the ^C.
  519. cmp ah,1
  520. jb CmdIRet
  521. cmp ah,12
  522. ja CmdIRet
  523. pop ds ;restore ds to old value
  524. add sp,6 ; remove int frame
  525. stc
  526. ; mov ds,OldDS ;restore ds to its old value
  527. ret 2 ; remove those flags...
  528. NotInit:
  529. ;* We have now received a ^C for some process (maybe ourselves
  530. ; but not at INIT).
  531. ;
  532. ; Note that we are running on the user's stack!!! Bad news if
  533. ; any of the system calls below go and issue another INT
  534. ; 24... Massive stack overflow! Another bad point is that
  535. ; SavHand will save an already saved handle, thus losing a
  536. ; possible redirection...
  537. ;
  538. ; All we need to do is set the flag to indicate nested ^C.
  539. ; The above code will correctly flag the ^C diring the
  540. ; message output and prompting while ignoring the ^C the rest
  541. ; of the time.
  542. ;
  543. ; Clean up: flush disk. If we are in the middle of a batch
  544. ; file, we ask if he wants to terminate it. If he does, then
  545. ; we turn off all internal flags and let the DOS abort.
  546. or InitFlag,INITCTRLC ; nested ^c is on
  547. sti
  548. ;; push cs ; el yucko! change the user's ds!!
  549. ;; pop ds
  550. ;; assume ds:RESGROUP
  551. pop ax ;discard the old ds value
  552. mov ax,SingleCom
  553. or ax,ax
  554. jnz NoReset
  555. push ax
  556. mov ah,DISK_RESET
  557. int 21h ; reset disks in case files were open
  558. pop ax
  559. NoReset:
  560. ; In the generalized version of FOR, PIPE and BATCH, we would
  561. ; walk the entire active list and free each segment. Here,
  562. ; we just free the single batch segment.
  563. test Batch,-1
  564. jz ContCTerm
  565. or ax,ax
  566. jnz ContCTerm
  567. invoke SavHand
  568. invoke AskEnd ; ask if user wants to end batch
  569. ; If the carry flag is clear, we do NOT free up the batch file
  570. jnc ContBatch
  571. mov cl,EchoFlag ; get current echo flag
  572. push bx
  573. ClearBatch:
  574. mov es,Batch ; get batch segment
  575. mov di,BatFile ; get offset of batch file name
  576. ; Bugbug: verify the following shell interface still works
  577. ;; mov ax,MULT_SHELL_BRK ; does the SHELL want this terminated?
  578. ;; int 2Fh ; call the SHELL
  579. ;; cmp al,SHELL_ACTION ; does shell want this batch?
  580. ;; je Shell_Bat_Cont ; yes - keep it
  581. mov bx,es:BatForPtr ; get old FOR segment
  582. cmp bx,0 ; is a FOR in progress
  583. je no_bat_for ; no - don't deallocate
  584. push es ;
  585. mov es,bx ; yes - free it up...
  586. mov ah,DEALLOC ;
  587. int 21h ;
  588. pop es ; restore to batch segment
  589. No_Bat_For:
  590. mov cl,es:BatEchoFlag ; get old echo flag
  591. mov bx,es:BatLast ; get old batch segment
  592. mov ah,DEALLOC ; free it up...
  593. int 21h
  594. mov Batch,bx ; get ready to deallocate next batch
  595. dec nest ; is there another batch file?
  596. jnz ClearBatch ; keep going until no batch file
  597. ; We are terminating a batch file; restore the echo status
  598. Shell_Bat_Cont: ; continue batch for SHELL
  599. pop bx
  600. mov EchoFlag,cl ; reset echo status
  601. mov PipeFlag,0 ; turn off pipeflag
  602. ContBatch:
  603. invoke Crlf ; print out crlf before returning
  604. invoke RestHand
  605. ; Yes, we are terminating. Turn off flags and allow the DOS to abort.
  606. ContCTerm:
  607. xor ax,ax ; indicate no read
  608. mov bp,ax
  609. ; The following resetting of the state flags is good for the
  610. ; generalized batch processing.
  611. mov IfFlag,al ; turn off iffing
  612. mov ForFlag,al ; turn off for processing
  613. call ResPipeOff
  614. cmp SingleCom,ax ; see if we need to set singlecom
  615. jz NoSetSing
  616. mov SingleCom,-1 ; cause termination on
  617. ; pipe, batch, for
  618. NoSetSing:
  619. ; If we are doing an internal command, go through the reload process.
  620. ; If we are doing an external, let DOS abort the process.
  621. ; In both cases, we are now done with the ^C processing.
  622. and InitFlag,not INITCTRLC
  623. cmp ExtCom,al
  624. jnz DoDAb ; internal ^c
  625. jmp LodCom1
  626. DoDAb:
  627. stc ; tell dos to abort
  628. ;SR;
  629. ;We dont need to restore ds here because we are forcing DOS to do an abort
  630. ;by setting carry and leaving flags on the stack
  631. ;
  632. ret ; Leave flags on stack
  633. ContC endp
  634. ;SR;
  635. ; ds = DATARES on entry. This routine is called from DskErr and LodCom1 and
  636. ;both have ds = DATARES
  637. ;
  638. ResPipeOff:
  639. public ResPipeOff
  640. assume ds:DATARES,es:NOTHING
  641. savereg <ax>
  642. xor ax,ax
  643. xchg PipeFlag,al
  644. or al,al
  645. jz NoPipePop
  646. shr EchoFlag,1
  647. NoPipePop:
  648. restorereg <ax>
  649. return
  650. CODERES ends
  651. end
  652.