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.

708 lines
16 KiB

  1. page ,132
  2. ; SCCSID = @(#)tcmd2a.asm 4.1 85/06/25
  3. ; SCCSID = @(#)tcmd2a.asm 4.1 85/06/25
  4. TITLE PART5 COMMAND Transient routines.
  5. ;/*
  6. ; * Microsoft Confidential
  7. ; * Copyright (C) Microsoft Corporation 1991
  8. ; * All Rights Reserved.
  9. ; */
  10. ; Revision History
  11. ; ================
  12. ; M01 md 7/13/90 Changed CLS to access ROM BIOS data directly
  13. ;
  14. ; M013 SR 08/06/90 Changed Version to use new call to
  15. ; get info about DOS in HMA or ROM.
  16. ; M018 md 08/12/90 Increment screen height by 1 when
  17. ; obtained from ROM BIOS.
  18. ; M022 md 08/29/80 Set correct video page in REG_CLS
  19. INCLUDE comsw.asm
  20. .xlist
  21. .xcref
  22. include dossym.inc
  23. include bpb.inc
  24. include syscall.inc
  25. include filemode.inc
  26. include sf.inc
  27. include comequ.asm
  28. include comseg.asm
  29. include ioctl.inc
  30. include rombios.inc ;M01
  31. .list
  32. .cref
  33. CODERES SEGMENT PUBLIC BYTE ;AC000;
  34. CODERES ENDS
  35. DATARES SEGMENT PUBLIC BYTE ;AC000;
  36. DATARES ENDS
  37. TRANDATA SEGMENT PUBLIC BYTE ;AC000;
  38. EXTRN arg_buf_ptr:word
  39. EXTRN BadCurDrv:byte ;AC000;
  40. EXTRN clsstring:byte
  41. EXTRN dback_ptr:word
  42. EXTRN display_ioctl:word ;AN000;
  43. EXTRN display_width:word ;AN000;
  44. EXTRN DosHma_Ptr:word
  45. EXTRN DosLow_Ptr:word
  46. EXTRN DosRev_Ptr:word
  47. EXTRN DosRom_Ptr:word
  48. EXTRN Extend_buf_ptr:word ;AN049;
  49. EXTRN linperpag:word ;AN000;
  50. EXTRN msg_disp_class:byte ;AN049;
  51. EXTRN nulpath_ptr:word
  52. EXTRN Parse_Ver:byte
  53. EXTRN prompt_table:word
  54. EXTRN string_buf_ptr:word ;AC000;
  55. EXTRN vermes_ptr:word
  56. TRANDATA ENDS
  57. TRANSPACE SEGMENT PUBLIC BYTE ;AC000;
  58. EXTRN Arg_Buf:byte
  59. EXTRN bwdbuf:byte
  60. EXTRN curdrv:byte
  61. EXTRN dirchar:byte
  62. EXTRN major_ver_num:word
  63. EXTRN minor_ver_num:word
  64. EXTRN One_Char_Val:byte
  65. EXTRN srcxname:byte ;AN049;
  66. EXTRN string_ptr_2:word
  67. TRANSPACE ENDS
  68. TRANCODE SEGMENT PUBLIC BYTE
  69. ASSUME CS:TRANGROUP,DS:NOTHING,ES:NOTHING,SS:NOTHING
  70. ;---------------
  71. TRANSPACE SEGMENT PUBLIC BYTE ;AC000;
  72. EXTRN arg:byte ; the arg structure!
  73. transpace ends
  74. ;---------------
  75. EXTRN cerror:near ;AN049;
  76. EXTRN crlf2:near
  77. EXTRN drvbad:near
  78. EXTRN std_printf:near
  79. PUBLIC build_dir_for_chdir
  80. PUBLIC build_dir_for_prompt
  81. PUBLIC build_dir_string
  82. PUBLIC cls
  83. PUBLIC path
  84. PUBLIC print_char
  85. PUBLIC print_drive
  86. PUBLIC print_version
  87. PUBLIC print_b
  88. PUBLIC print_back
  89. PUBLIC print_eq
  90. PUBLIC print_esc
  91. PUBLIC print_g
  92. PUBLIC print_l
  93. PUBLIC print_prompt
  94. PUBLIC version
  95. break Version
  96. ;*** Version - display DOS version
  97. ;
  98. ; SYNTAX ver [/debug]
  99. ;
  100. ; /debug - display additional DOS configuration info
  101. ;
  102. ; ENTRY command-line tail is in PSP
  103. ;
  104. ; EXIT if successful, nothing
  105. ; if parse fails,
  106. ; parse error message is set up (for Std_EPrintf)
  107. ; AX = system parser error code
  108. ; DX = ptr to message block
  109. ; we jump to CError
  110. ;
  111. ; EFFECTS
  112. ; If parse fails, a parse error message is displayed.
  113. ; Otherwise, version message is displayed.
  114. ; If /debug is specified, additional DOS info is displayed.
  115. Version:
  116. assume ds:TRANGROUP,es:TRANGROUP
  117. ; Parse command line for /debug switch.
  118. mov si,81h ; DS:SI = ptr to command tail
  119. mov di,offset TRANGROUP:Parse_Ver ; ES:DI = ptr to parse block
  120. xor cx,cx ; CX = # positional param's found
  121. invoke Parse_With_Msg
  122. mov bl,1 ; BL = flag = /debug present
  123. cmp ax,RESULT_NO_ERROR
  124. je verPrintVer ; something parsed - must be /debug
  125. dec bl ; BL = flag = no /debug present
  126. cmp ax,END_OF_LINE
  127. je verPrintVer ; reached end of line - ok
  128. ; The parse failed. Error message has been set up.
  129. jmp CError
  130. verPrintVer:
  131. push bx ; save /debug flag
  132. call Crlf2
  133. call Print_Version
  134. call Crlf2
  135. pop bx ; BL = /debug flag
  136. or bl,bl
  137. jz verDone ; /debug is false - we're done
  138. ;* For /debug, display DOS internal revision and DOS location
  139. ; (low memory, HMA, or ROM).
  140. ; Bugbug: use symbols for bitmasks below.
  141. mov ax,(SET_CTRL_C_TRAPPING shl 8) + 6 ; M013
  142. int 21h
  143. mov al,dl ;revision number in dl; M013
  144. mov bh,dh ;flags in dh now; M013
  145. ;M032 and al,7 ; AL = DOS internal revision
  146. cmp al,'Z'-'A' ;M032 ; revision in A-to-Z range?
  147. jbe @f ;M032 ; A-to-Z revision ok
  148. mov al,'*'-'A' ;M032 ; beyond Z, just say revision *
  149. @@: add al,'A' ; AL = DOS internal rev letter
  150. mov One_Char_Val,al
  151. mov dx,offset TRANGROUP:DosRev_Ptr
  152. invoke Std_Printf ; print DOS internal revision
  153. mov cl,4
  154. shr bh,cl ; CY = DOS in ROM
  155. jc verRom
  156. shr bh,1 ; CY = DOS in HMA
  157. jc verHma
  158. ; DOS isn't in ROM or HMA, so it must be in lower memory.
  159. mov dx,offset TRANGROUP:DosLow_Ptr
  160. jmp short verPrintLoc
  161. verRom: mov dx,offset TRANGROUP:DosRom_Ptr
  162. jmp short verPrintLoc
  163. verHma: mov dx,offset TRANGROUP:DosHma_Ptr
  164. verPrintLoc:
  165. invoke Std_Printf
  166. verDone:
  167. jmp Crlf2
  168. Print_Version:
  169. mov ah,GET_VERSION
  170. int 21h
  171. push ax
  172. xor ah,ah
  173. mov Major_Ver_Num,ax
  174. pop ax
  175. xchg ah,al
  176. xor ah,ah
  177. mov Minor_Ver_Num,ax
  178. mov dx,offset TRANGROUP:VerMes_Ptr
  179. jmp Std_Printf
  180. assume ds:TRANGROUP,es:TRANGROUP
  181. print_prompt:
  182. push ds
  183. push cs
  184. pop ds ; MAKE SURE DS IS IN TRANGROUP
  185. push es
  186. invoke find_prompt ; LOOK FOR PROMPT STRING
  187. jc PP0 ; CAN'T FIND ONE
  188. cmp byte ptr es:[di],0
  189. jnz PP1
  190. PP0:
  191. call print_drive ; USE DEFAULT PROMPT
  192. mov al,sym
  193. call print_char
  194. jmp short PP5
  195. PP1:
  196. mov al,es:[di] ; GET A CHAR
  197. inc di
  198. or al,al
  199. jz PP5 ; NUL TERMINATED
  200. cmp al,dollar ; META CHARACTER?
  201. jz PP2 ; NOPE
  202. PPP1:
  203. call print_char
  204. jmp PP1
  205. PP2:
  206. mov al,es:[di]
  207. inc di
  208. mov bx,offset trangroup:prompt_table-3
  209. or al,al
  210. jz PP5
  211. PP3:
  212. add bx,3
  213. invoke upconv
  214. cmp al,[bx]
  215. jz PP4
  216. cmp byte ptr [bx],0
  217. jnz PP3
  218. jmp PP1
  219. PP4:
  220. push es
  221. push di
  222. push cs
  223. pop es
  224. call [bx+1]
  225. pop di
  226. pop es
  227. jmp PP1
  228. PP5:
  229. pop es ; RESTORE SEGMENTS
  230. pop ds
  231. return
  232. print_back:
  233. mov dx,offset trangroup:dback_ptr
  234. jmp std_printf
  235. print_EQ:
  236. mov al,'='
  237. jmp short print_char
  238. print_esc:
  239. mov al,1BH
  240. jmp short print_char
  241. print_G:
  242. mov al,rabracket
  243. jmp short print_char
  244. print_L:
  245. mov al,labracket
  246. jmp short print_char
  247. print_B:
  248. mov al,vbar
  249. print_char:
  250. ; Bugbug: Why bother with ds,es here?
  251. push es
  252. push ds
  253. pop es
  254. push di
  255. push dx
  256. mov dl,al ;AC000; Get char into al
  257. mov ah,Std_CON_output ;AC000; print the char to stdout
  258. int 21h ;AC000;
  259. pop dx
  260. pop di
  261. pop es
  262. ret
  263. print_drive:
  264. mov ah,Get_Default_drive
  265. int 21h
  266. add al,capital_A
  267. call print_char
  268. ret
  269. ASSUME DS:TRANGROUP,ES:TRANGROUP
  270. build_dir_for_prompt:
  271. xor dl,dl
  272. mov si,offset trangroup:bwdbuf
  273. mov di,SI
  274. mov al,CurDrv
  275. add al,'A'
  276. mov ah,':'
  277. stosw
  278. mov al,[dirchar]
  279. stosb
  280. xchg si,di
  281. mov string_ptr_2,di
  282. mov ah,Current_dir
  283. int 21h
  284. mov dx,offset trangroup:string_buf_ptr
  285. jnc DoPrint
  286. mov dx,offset trangroup:BadCurDrv
  287. DoPrint:
  288. call std_printf
  289. ret
  290. build_dir_for_chdir:
  291. call build_dir_string
  292. mov dx,offset trangroup:bwdbuf
  293. mov string_ptr_2,dx
  294. mov dx,offset trangroup:string_buf_ptr
  295. call std_printf
  296. ret
  297. build_dir_string:
  298. mov dl,ds:[FCB]
  299. mov al,DL
  300. add al,'@'
  301. cmp al,'@'
  302. jnz gotdrive
  303. add al,[CURDRV]
  304. inc al
  305. gotdrive:
  306. push ax
  307. mov si,offset trangroup:bwdbuf+3
  308. mov ah,Current_dir
  309. int 21h
  310. jnc dpbisok
  311. push cs
  312. pop ds
  313. jmp drvbad
  314. dpbisok:
  315. mov di,offset trangroup:bwdbuf
  316. mov dx,di
  317. pop ax
  318. mov ah,':'
  319. stosw
  320. mov al,[dirchar]
  321. stosb
  322. ret
  323. break Path
  324. assume ds:trangroup,es:trangroup
  325. PATH:
  326. xor al,al ;AN049; Set up holding buffer
  327. mov di,offset Trangroup:srcxname ;AN049; for PATH while parsing
  328. stosb ;AN049; Initialize PATH to null
  329. dec di ;AN049; point to the start of buffer
  330. invoke PGetarg ; Pre scan for arguments
  331. jz disppath ; Print the current path
  332. cmp al,semicolon ;AC049; NUL path argument?
  333. jnz pathslp ;AC049;
  334. inc si ;AN049; point past semicolon
  335. jmp short scan_white ;AC049; Yes - make sure nothing else on line
  336. pathslp: ; Get the user specified path
  337. lodsb ; Get a character
  338. cmp al,end_of_line_in ;AC049; Is it end of line?
  339. jz path_eol ;AC049; yes - end of command
  340. invoke testkanj ;See if DBCS
  341. jz notkanj2 ;No - continue
  342. stosb ;AC049; Yes - store the first byte
  343. lodsb ;skip second byte of DBCS
  344. path_hold: ;AN049;
  345. stosb ;AC049; Store a byte in the PATH buffer
  346. jmp short pathslp ;continue parsing
  347. notkanj2:
  348. invoke upconv ;upper case the character
  349. cmp al,semicolon ;AC049; ';' not a delimiter on PATH
  350. jz path_hold ;AC049; go store it
  351. invoke delim ;delimiter?
  352. jnz path_hold ;AC049; no - go store character
  353. scan_white: ;AN049; make sure were at EOL
  354. lodsb ;AN049; get a character
  355. cmp al,end_of_line_in ;AN049; end of line?
  356. jz path_eol ;AN049; yes - go set path
  357. cmp al,blank ;AN049; whitespace?
  358. jz scan_white ;AN049; yes - continue scanning
  359. cmp al,tab_chr ;AN049; whitespace?
  360. jz scan_white ;AN049; yes - continue scanning
  361. mov dx,offset TranGroup:Extend_Buf_ptr ;AN049; no - set up error message
  362. mov Extend_Buf_ptr,MoreArgs_ptr ;AN049; get "Too many parameters" message number
  363. mov msg_disp_class,parse_msg_class ;AN049; set up parse error msg class
  364. jmp cerror ;AN049;
  365. path_eol: ;AN049; Parsing was clean
  366. xor al,al ;AN049; null terminate the PATH
  367. stosb ;AN049; buffer
  368. invoke find_path ;AN049; Find PATH in environment
  369. invoke delete_path ;AC049; Delete any offending name
  370. invoke scan_double_null ;AC049; Scan to end of environment
  371. invoke move_name ;AC049; move in PATH=
  372. mov si,offset Trangroup:srcxname ;AN049; Set up source as PATH buffer
  373. store_path: ;AN049; Store the PATH in the environment
  374. lodsb ;AN049; Get a character
  375. cmp al,end_of_line_out ;AN049; null character?
  376. jz got_paths ;AN049; yes - exit
  377. invoke store_char ;AN049; no - store character
  378. jmp short store_path ;AN049; continue
  379. got_paths: ;AN049; we're finished
  380. xor ax,ax ;null terminate the PATH in
  381. stosw ; the environment
  382. return
  383. disppath:
  384. invoke find_path ;AN049;
  385. call print_path
  386. call crlf2
  387. return
  388. print_path:
  389. cmp byte ptr es:[di],0
  390. jnz path1
  391. path0:
  392. mov dx,offset trangroup:nulpath_ptr
  393. push cs
  394. pop es
  395. push cs
  396. pop ds
  397. jmp std_printf
  398. path1:
  399. push es
  400. pop ds
  401. sub di,5
  402. mov si,di
  403. ASSUME DS:RESGROUP
  404. xor al,al ; count str len to copy
  405. mov cx,128 ; up to arg_bug len
  406. repnz scasb
  407. mov cx,di
  408. sub cx,si
  409. push cs
  410. pop es
  411. mov di,offset trangroup:arg_buf
  412. rep movsb
  413. mov dx,offset trangroup:arg_buf_ptr
  414. push cs
  415. pop ds
  416. jmp std_printf
  417. ASSUME DS:TRANGROUP
  418. break Cls
  419. ; ****************************************************************
  420. ; *
  421. ; * ROUTINE: CLS
  422. ; *
  423. ; * FUNCTION: Clear the screen using INT 10h. If ANSI.SYS is
  424. ; * installed, send a control string to clear the
  425. ; * screen.
  426. ; *
  427. ; * INPUT: command line at offset 81H
  428. ; *
  429. ; * OUTPUT: none
  430. ; *
  431. ; ****************************************************************
  432. assume ds:trangroup,es:trangroup
  433. ifndef NEC_98
  434. ANSI_installed equ 0ffh
  435. CLS:
  436. mov ah,Mult_ANSI ;AN000; see if ANSI.SYS installed
  437. mov al,0 ;AN000;
  438. int 2fh ;AN000;
  439. cmp al,ANSI_installed ;AN000;
  440. jz ansicls ;AN000; installed - go do ANSI CLS
  441. check_lines:
  442. mov ax,(IOCTL SHL 8) + generic_ioctl_handle ;AN000; get lines per page on display
  443. mov bx,stdout ;AN000; lines for stdout
  444. mov ch,ioc_sc ;AN000; type is display
  445. mov cl,get_generic ;AN000; get information
  446. mov dx,offset trangroup:display_ioctl ;AN000;
  447. int 21h ;AN000;
  448. jc no_variable ;AN000; function had error, use default
  449. mov ax,linperpag ;AN000; get number of rows returned
  450. mov dh,al ;AN000; set number of rows
  451. mov ax,display_width ;AN000; get number of columns returned
  452. mov dl,al ;AN000; set number of columns
  453. jmp short regcls ;AN000; go do cls
  454. no_variable:
  455. mov bx,stdout ;AC000; set handle as stdout
  456. mov ax,IOCTL SHL 8 ;AC000; do ioctl - get device
  457. int 21h ;AC000; info
  458. test dl,devid_ISDEV ;AC000; is handle a device
  459. jz ANSICLS ;AC000; If a file put out ANSI
  460. test dl,devid_SPECIAL ;AC000;
  461. jnz cls_normal ;AC000; If not special CON, do ANSI
  462. ansicls:
  463. call ansi_cls ;AN000; clear the screen
  464. jmp short cls_ret ;AN000; exit
  465. ;
  466. ; Get video mode
  467. ;
  468. cls_normal: ;AC000;
  469. mov ah,get_video_state ;AC000; set up to get video state
  470. int video_io_int ;AC000; do int 10h - BIOS video IO
  471. cmp al,video_alpha ;AC000; see if in text mode
  472. jbe DoAlpha
  473. cmp al,video_bw ;AC000; see if black & white card
  474. jz DoAlpha
  475. ;
  476. ; We are in graphics mode. Bogus IBM ROM does not scroll correctly. We will
  477. ; be just as bogus and set the mode that we just got. This will blank the
  478. ; screen too.
  479. ;
  480. mov ah,set_video_mode ;AC000; set video mode call
  481. int video_io_int ;AC000; do int 10h - BIOS video IO
  482. jmp short cls_ret ;AC000; exit
  483. DoAlpha:
  484. ;
  485. ; Get video mode and number of columns to scroll
  486. ;
  487. ;M01 - INT 10 Function 0F doesn't reliably return the number of rows on some
  488. ;M01 adaptors. We circumvent this by reaching directly into the BIOS data
  489. ;M01 area
  490. ;M01 Commented out code here is the original
  491. ;M01 mov ah,get_video_state ;AC000; set up to get current video state
  492. ;M01 int video_io_int ;AC000; do int 10h - BIOS video IO
  493. ;M01 mov dl,ah
  494. ;M01 mov dh,linesperpage ;AC000; have 25 rows on the screen
  495. ;M01 Following code lifted from a fix Compaq applied to ANSI
  496. push ds
  497. MOV AX,ROMBIOS_DATA ; GET ROM Data segment M01
  498. MOV DS,AX ; * M01
  499. Assume DS:ROMBIOS_DATA
  500. mov dx,CRT_Cols ; Get Columns - assume < 256 M01
  501. MOV dh,CRT_Rows ; GET MAX NUM OF ROWS M01
  502. pop ds ; M01
  503. Assume DS:Trangroup
  504. or dh,dh ; Q:ZERO M01
  505. jnz regcls ; *JMP IF NO M01
  506. MOV dh,LINESPERPAGE ; SET TO 24 ROWS M01
  507. regcls:
  508. inc dh ; height+1 M018
  509. call reg_cls ; go clear the screen
  510. cls_ret:
  511. ret ; exit
  512. ; ****************************************************************
  513. ; *
  514. ; * ROUTINE: REG_CLS
  515. ; *
  516. ; * FUNCTION: Clear the screen using INT 10H.
  517. ; *
  518. ; * INPUT: DL = NUMBER OF COLUMNS
  519. ; * DH = NUMBER OF ROWS
  520. ; *
  521. ; * OUTPUT: none
  522. ; *
  523. ; ****************************************************************
  524. reg_cls proc near
  525. ;
  526. ; Set overscan to black.
  527. ;
  528. dec dh ; decrement rows and columns
  529. dec dl ; to zero base
  530. push dx ; save rows,columns
  531. mov ah,set_color_palette ; set up to set the color to blank
  532. xor bx,bx
  533. int video_io_int ; do int 10h - BIOS video IO
  534. pop dx ; retore rows,colums
  535. xor ax,ax ; zero out ax
  536. mov CX,ax ; an cx
  537. ;
  538. ; Scroll active page
  539. ;
  540. mov ah,scroll_video_page ; set up to scroll page up
  541. mov bh,video_attribute ; attribute for blank line
  542. xor bl,bl ; set BL to 0
  543. int video_io_int ; do int 10h - BIOS video IO
  544. ;
  545. ; Seek to cursor to 0,0
  546. ;
  547. ;M022 following two lines added
  548. mov ah,get_video_state ; get current video page in BH
  549. int video_io_int
  550. mov ah,set_cursor_position ; set up to set cursor position
  551. xor dx,dx ; row and column 0
  552. ;M022 mov bh.0
  553. int video_io_int ; do into 10h - BIOS video IO
  554. ret
  555. reg_cls endp
  556. ; ****************************************************************
  557. ; *
  558. ; * ROUTINE: ANSI_CLS
  559. ; *
  560. ; * FUNCTION: Clear the screen using by writing a control code
  561. ; * to STDOUT.
  562. ; *
  563. ; * INPUT: none
  564. ; *
  565. ; * OUTPUT: none
  566. ; *
  567. ; ****************************************************************
  568. ansi_cls proc near ;AC000;
  569. mov si,offset trangroup:clsstring
  570. lodsb
  571. mov cl,al
  572. xor ch,ch
  573. mov ah,Raw_CON_IO
  574. clrloop:
  575. lodsb
  576. mov DL,al
  577. int 21h
  578. loop clrloop
  579. return
  580. ansi_cls endp ;AC000;
  581. else ;NEC_98
  582. CLS:
  583. mov si,offset trangroup:clsstring
  584. lodsb
  585. mov cl,al
  586. xor ch,ch
  587. mov ah,Raw_CON_IO
  588. clrloop:
  589. lodsb
  590. mov DL,al
  591. int 21h
  592. loop clrloop
  593. return
  594. endif ;NEC_98
  595. trancode ends
  596. end
  597.