Source code of Windows XP (NT5)
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.

1916 lines
59 KiB

  1. .xlist
  2. include kernel.inc
  3. include pdb.inc
  4. include tdb.inc
  5. include newexe.inc
  6. include eems.inc
  7. include protect.inc
  8. ifdef WOW
  9. include vint.inc
  10. endif
  11. .list
  12. ifdef WOW
  13. ;
  14. ; Int 21 tracing control. If TraceInt21 is defined, ifdef's cause
  15. ; extra debugging output before/after the DOS call.
  16. ;
  17. ; TraceInt21 equ 1 ; uncomment this line to log Int 21 operations.
  18. endif
  19. DataBegin
  20. externB PhantArray
  21. externB kernel_flags
  22. externB Kernel_InDOS
  23. externB Kernel_InINT24
  24. externB fInt21
  25. externB InScheduler
  26. externB CurDOSDrive
  27. externB DOSDrives
  28. externW curTDB
  29. externW curDTA
  30. ;externW headPDB
  31. ;externW topPDB
  32. externW Win_PDB
  33. externW cur_dos_PDB
  34. externW cur_drive_owner
  35. externW LastExtendedError
  36. ifndef WOW
  37. externB WinIniInfo
  38. externB PrivateProInfo
  39. externB fProfileMaybeStale
  40. externB fWriteOutProfilesReenter
  41. endif
  42. externB fBooting
  43. ;externD lpWinSftLink
  44. if ROM
  45. externD prevInt21Proc
  46. endif
  47. ifdef WOW
  48. externD pPMDosCURDRV
  49. externD pPMDosPDB
  50. externD pPMDosExterr
  51. externD pPMDosExterrLocus
  52. externD pPMDosExterrActionClass
  53. externD pFileTable
  54. externW WinFlags
  55. externW fLMdepth
  56. externW WOWLastError
  57. externB WOWErrClass
  58. externB WOWErrAction
  59. externB WOWErrLocation
  60. endif
  61. DataEnd
  62. externFP WriteOutProfiles
  63. ifdef WOW
  64. externFP WOWFileRead
  65. externFP WOWFileWrite
  66. externFP WOWFileLSeek
  67. externFP WOWFileCreate
  68. externFP WOWFileOpen
  69. externFP WOWFileClose
  70. externFP WOWFileGetAttributes
  71. externFP WOWFileSetAttributes
  72. externFP WOWFileGetDateTime
  73. externFP WOWFileSetDateTime
  74. externFP WOWFileLock
  75. externFP WOWDelFile
  76. externFP WOWFindFirst
  77. externFP WOWFindNext
  78. externFP WOWSetDefaultDrive
  79. externFP WOWGetCurrentDirectory
  80. externFP WOWSetCurrentDirectory
  81. externFP WOWGetCurrentDate
  82. externFP WOWDeviceIOCTL
  83. endif
  84. SetDosErr macro ErrorCode,ErrorCodeLocus,ErrorCodeAction,ErrorCodeClass
  85. push es
  86. push di
  87. push ax
  88. mov ax, pPMDosExterr.sel
  89. mov es, ax
  90. pop ax
  91. mov di, pPMDosExterr.off
  92. mov word ptr es:[di], ErrorCode
  93. mov WOWLastError, ErrorCode
  94. ifnb <ErrorCodeLocus>
  95. mov di, pPMDosExterrLocus.off
  96. mov byte ptr es:[di], ErrorCodeLocus
  97. endif
  98. ifnb <ErrorCodeAction>
  99. mov di, pPMDosExterrActionClass.off
  100. mov byte ptr es:[di], ErrorCodeAction
  101. mov byte ptr es:[di+1], ErrorCodeClass
  102. endif
  103. pop di
  104. pop es
  105. endm
  106. CheckDosErr macro
  107. push es
  108. push di
  109. push ax
  110. mov ax, pPMDosExterr.sel
  111. mov es, ax
  112. pop ax
  113. mov di, pPMDosExterr.off
  114. cmp word ptr es:[di], 0
  115. pop di
  116. pop es
  117. endm
  118. GetDosErr macro regCode,regCodeLocus,regCodeAction,regCodeClass
  119. push es
  120. push di
  121. push ax
  122. mov ax, pPMDosExterr.sel
  123. mov es, ax
  124. pop ax
  125. mov di, pPMDosExterr.off
  126. mov regCode, word ptr es:[di]
  127. ; mov regCode, WOWLastError
  128. ifnb <regCodeLocus>
  129. mov di, pPMDosExterrLocus.off
  130. mov regCodeLocus, byte ptr es:[di]
  131. endif
  132. ifnb <regCodeAction>
  133. mov di, pPMDosExterrActionClass.off
  134. mov regCodeAction, byte ptr es:[di]
  135. mov regCodeClass, byte ptr es:[di+1]
  136. endif
  137. pop di
  138. pop es
  139. endm
  140. sBegin CODE
  141. assumes CS,CODE
  142. assumes ds, nothing
  143. assumes es, nothing
  144. ife ROM
  145. externD prevInt21Proc
  146. endif
  147. ifdef WOW
  148. externFP WOWLFNEntry
  149. externNP DPMIProc
  150. endif
  151. ;***********************************************************************;
  152. ; ;
  153. ; WINDOWS mediated system calls. ;
  154. ; ;
  155. ; Windows mediates certain system calls. Several matters complicate ;
  156. ; the mediation: ;
  157. ; ;
  158. ; a. MSDOS uses registers to pass arguments. Thus, registers AND ;
  159. ; ANY RETURN VALUES in registers must be preserved across tasks. ;
  160. ; ;
  161. ; b. MSDOS stores global state information that must be preserved ;
  162. ; on a task by task basis. ;
  163. ; ;
  164. ; c. To handle multiple exec calls, the notion of a "parent" task ;
  165. ; is introduced. ;
  166. ; ;
  167. ; ;
  168. ;***********************************************************************;
  169. entry macro fred
  170. if1
  171. dw 0
  172. else
  173. ifndef fred
  174. extrn fred:near
  175. endif
  176. dw CODEOffset fred
  177. endif
  178. endm
  179. sEnd CODE
  180. sBegin DATA
  181. DosTrap1 label word
  182. ;;; entry not_supported ; 00 abort call
  183. ;;; entry not_supported ; 01 read keyboard and echo
  184. ;;; entry not_supported ; 02 display character
  185. ;;; entry not_supported ; 03 aux input
  186. ;;; entry not_supported ; 04 aux output
  187. ;;; entry not_supported ; 05 printer output
  188. ;;; entry not_supported ; 06 direct console IO
  189. ;;; entry not_supported ; 07 direct console input
  190. ;;; entry not_supported ; 08 read keyboard
  191. ;;; entry not_supported ; 09 display string
  192. ;;; entry not_supported ; 0A buffered keyboard input
  193. ;;; entry not_supported ; 0B check keyboard status
  194. ;;; entry not_supported ; 0C flush keyboard buffer
  195. ;;; entry PassOnThrough ; 0D disk reset
  196. entry Select_Disk ; 0E
  197. entry not_supported ; 0F open file FCB
  198. entry not_supported ; 10 close file FCB
  199. entry FCBCall ; 11 search first FCB
  200. entry not_supported ; 12 search next FCB
  201. entry not_supported ; 13 delete file FCB
  202. entry not_supported ; 14 read FCB
  203. entry not_supported ; 15 write FCB
  204. entry not_supported ; 16 create file FCB
  205. entry not_supported ; 17 rename file FCB
  206. entry not_supported ; 18 ???
  207. entry PassOnThrough ; 19 current disk
  208. entry Set_DTA ; 1A
  209. entry not_supported ; 1B allocation table info
  210. entry not_supported ; 1C allocation table info
  211. entry not_supported ; 1D ???
  212. entry not_supported ; 1E ???
  213. entry not_supported ; 1F ???
  214. entry not_supported ; 20 ???
  215. entry not_supported ; 21 read FCB
  216. entry not_supported ; 22 write FCB
  217. entry not_supported ; 23 file size FCB
  218. entry not_supported ; 24 set record field FCB
  219. entry Set_Vector ; 25
  220. entry not_supported ; 26
  221. entry not_supported ; 27 random read FCB
  222. entry not_supported ; 28 random write FCB
  223. entry not_supported ; 29 parse filename FCB
  224. entry PassOnThrough ; 2A get date
  225. entry PassOnThrough ; 2B set date
  226. entry PassOnThrough ; 2C get time
  227. entry PassOnThrough ; 2D set time
  228. entry PassOnThrough ; 2E set verify
  229. entry PassOnThrough ; 2F get DTA
  230. entry PassOnThrough ; 30 get DOS version
  231. entry not_supported ; 31 TSR
  232. entry DLDriveCall1 ; 32
  233. entry not_supported ; 33 break state
  234. entry not_supported ; 34 ???
  235. entry Get_Vector ; 35
  236. entry DLDriveCall1 ; 36
  237. entry not_supported ; 37 ???
  238. entry not_supported ; 38 country info
  239. entry PathDSDXCall ; 39
  240. entry PathDSDXCall ; 3A
  241. entry Change_Dir ; 3B
  242. entry PathDSDXCall ; 3C
  243. entry PathDSDXCall ; 3D
  244. entry FileHandleCall ; 3E
  245. entry PassOnThrough ; 3F
  246. entry PassOnThrough ; 40
  247. entry PathDSDXCall ; 41
  248. entry FileHandleCall ; 42
  249. entry PathDSDXCall ; 43
  250. entry Xenix_Status ; 44
  251. entry FileHandleCall ; 45
  252. entry FileHandleCall ; 46
  253. entry DLDriveCall2 ; 47
  254. entry not_supported ; 48 allocate memory
  255. entry not_supported ; 49 free memory
  256. entry not_supported ; 4A reallocate memory
  257. entry ExecCall ; 4B
  258. entry ExitCall ; 4C
  259. entry not_supported ; 4D get return code
  260. entry PathDSDXCall ; 4E
  261. entry PassOnThrough ; 4F find next
  262. entry set_PDB ; 50
  263. entry get_PDB ; 51
  264. entry not_supported ; 52 ???
  265. entry not_supported ; 53 ???
  266. entry PassOnThrough ; 54 get verify
  267. entry not_supported ; 55 ???
  268. entry XenixRename ; 56
  269. entry FileHandleCall ; 57
  270. entry not_supported ; 58 ???
  271. entry PassOnThrough ; 59 extended error
  272. entry PathDSDXCall ; 5A create unique file
  273. entry PathDSDXCall ; 5B create new file
  274. entry FileHandleCall ; 5C lock/unlock file access
  275. entry not_supported ; 5D ???
  276. entry PassOnThrough ; 5E network stuff
  277. entry AssignCall ; 5F network stuff
  278. entry NameTrans ; 60
  279. entry not_supported ; 61 ???
  280. entry get_PDB ; 62
  281. entry PassOnThrough ; 63
  282. entry PassOnThrough ; 64
  283. entry PassOnThrough ; 65
  284. entry PassOnThrough ; 66
  285. entry SetMaxHandleCount ; 67
  286. entry PassOnThrough ; 68
  287. entry PassOnThrough ; 69
  288. entry PassOnThrough ; 6a
  289. entry PassOnThrough ; 6b
  290. entry PathDSSICall ; 6c Extended File Open
  291. entry PassOnThrough ; 6d
  292. entry PassOnThrough ; 6e
  293. entry PassOnThrough ; 6f
  294. entry PassOnThrough ; 70
  295. entry PassOnThrough ; 71 LFN API
  296. TableEnd = 71h
  297. ifdef W_Q21
  298. QuickDispatchTable label word
  299. QD_FIRST equ 0eh
  300. dw offset QuickSetDefaultDrive ;0e
  301. dw offset Not_WOW_Handled ;0f
  302. dw offset Not_WOW_Handled ;10
  303. dw offset Not_WOW_Handled ;11
  304. dw offset Not_WOW_Handled ;12
  305. dw offset Not_WOW_Handled ;13
  306. dw offset Not_WOW_Handled ;14
  307. dw offset Not_WOW_Handled ;15
  308. dw offset Not_WOW_Handled ;16
  309. dw offset Not_WOW_Handled ;17
  310. dw offset Not_WOW_Handled ;18
  311. dw offset QuickGetDefaultDrive ;19
  312. dw offset Not_WOW_Handled ;1a
  313. dw offset Not_WOW_Handled ;1b
  314. dw offset Not_WOW_Handled ;1c
  315. dw offset Not_WOW_Handled ;1d
  316. dw offset Not_WOW_Handled ;1e
  317. dw offset Not_WOW_Handled ;1f
  318. dw offset Not_WOW_Handled ;20
  319. dw offset Not_WOW_Handled ;21
  320. dw offset Not_WOW_Handled ;22
  321. dw offset Not_WOW_Handled ;23
  322. dw offset Not_WOW_Handled ;24
  323. dw offset Not_WOW_Handled ;25
  324. dw offset Not_WOW_Handled ;26
  325. dw offset Not_WOW_Handled ;27
  326. dw offset Not_WOW_Handled ;28
  327. dw offset Not_WOW_Handled ;29
  328. dw offset QuickGetDate ;2a
  329. dw offset Not_WOW_Handled ;2b
  330. dw offset Not_WOW_Handled ;2c
  331. dw offset Not_WOW_Handled ;2d
  332. dw offset Not_WOW_Handled ;2e
  333. dw offset Not_WOW_Handled ;2f
  334. dw offset Not_WOW_Handled ;30
  335. dw offset Not_WOW_Handled ;31
  336. dw offset Not_WOW_Handled ;32
  337. dw offset Not_WOW_Handled ;33
  338. dw offset Not_WOW_Handled ;34
  339. dw offset Not_WOW_Handled ;35
  340. dw offset Not_WOW_Handled ;36
  341. dw offset Not_WOW_Handled ;37
  342. dw offset Not_WOW_Handled ;38
  343. dw offset Not_WOW_Handled ;39
  344. dw offset Not_WOW_Handled ;3a
  345. dw offset QuickSetCurrentDirectory ;3b
  346. dw offset QuickCreate ;3c
  347. dw offset QuickOpen ;3d
  348. dw offset QuickClose ;3e
  349. dw offset QuickRead ;3f
  350. dw offset Quickwrite ;40
  351. dw offset QuickDelete ;41
  352. dw offset QuickLSeek ;42
  353. dw offset QuickGetSetAttributes ;43
  354. dw offset QuickDeviceIOCTL ;44
  355. dw offset Not_WOW_Handled ;45
  356. dw offset Not_WOW_Handled ;46
  357. dw offset QuickGetCurrentDirectory ;47
  358. dw offset Not_WOW_Handled ;48
  359. dw offset Not_WOW_Handled ;49
  360. dw offset Not_WOW_Handled ;4a
  361. dw offset Not_WOW_Handled ;4b
  362. dw offset Not_WOW_Handled ;4c
  363. dw offset Not_WOW_Handled ;4d
  364. dw offset QuickFindFirstFile ;4e
  365. dw offset QuickFindNextFile ;4f
  366. dw offset Not_WOW_Handled ;50
  367. dw offset Not_WOW_Handled ;51
  368. dw offset Not_WOW_Handled ;52
  369. dw offset Not_WOW_Handled ;53
  370. dw offset Not_WOW_Handled ;54
  371. dw offset Not_WOW_Handled ;55
  372. dw offset Not_WOW_Handled ;56
  373. dw offset QuickFileDateTime ;57
  374. dw offset Not_WOW_Handled ;58
  375. dw offset QuickExtendedError ;59
  376. dw offset Not_WOW_Handled ;5a
  377. dw offset Not_WOW_Handled ;5b
  378. dw offset QuickLock ;5c
  379. ifdef IGROUP_HAS_ENOUGH_ROOM
  380. dw offset Not_WOW_Handled ;5d
  381. dw offset Not_WOW_Handled ;5e
  382. dw offset Not_WOW_Handled ;5f
  383. dw offset Not_WOW_Handled ;60
  384. dw offset Not_WOW_Handled ;61
  385. dw offset Not_WOW_Handled ;62
  386. dw offset Not_WOW_Handled ;63
  387. dw offset Not_WOW_Handled ;64
  388. dw offset Not_WOW_Handled ;65
  389. dw offset Not_WOW_Handled ;66
  390. dw offset Not_WOW_Handled ;67
  391. dw offset Not_WOW_Handled ;68
  392. dw offset Not_WOW_Handled ;69
  393. dw offset Not_WOW_Handled ;6a
  394. dw offset Not_WOW_Handled ;6b
  395. dw offset Not_WOW_Handled ;6c
  396. dw offset Not_WOW_Handled ;6d
  397. dw offset Not_WOW_Handled ;6e
  398. dw offset Not_WOW_Handled ;6f
  399. dw offset Not_WOW_Handled ;70
  400. dw offset QuickLFNApiCall ;71
  401. QD_LAST equ 71h
  402. else
  403. QD_LAST equ 5ch
  404. QD_LFNAPI equ 71h
  405. endif
  406. QuickDispatchAddr dw ?
  407. endif
  408. sEnd DATA
  409. sBegin CODE
  410. ;-----------------------------------------------------------------------;
  411. ; ;
  412. ; Interrupt 21h handler. ;
  413. ; ;
  414. ;-----------------------------------------------------------------------;
  415. labelFP <PUBLIC,Int21Handler>
  416. ;-----------------------------------------------------------------------;
  417. ; Int21Entry ;
  418. ; ;
  419. ; The is the dispatcher for our INT 21h handler. ;
  420. ; ;
  421. ; Arguments: ;
  422. ; ;
  423. ; Returns: ;
  424. ; ;
  425. ; Error Returns: ;
  426. ; ;
  427. ; Registers Preserved: ;
  428. ; ;
  429. ; Registers Destroyed: ;
  430. ; ;
  431. ; Calls: ;
  432. ; ;
  433. ; History: ;
  434. ; ;
  435. ; Mon 07-Aug-1989 23:48:06 -by- David N. Weise [davidw] ;
  436. ; Made it use a jump table!! ;
  437. ; ;
  438. ; Thu Apr 16, 1987 07:44:19p -by- David N. Weise [davidw] ;
  439. ; Added this nifty comment block. ;
  440. ;-----------------------------------------------------------------------;
  441. assumes ds, nothing
  442. assumes es, nothing
  443. cProc Int21Entry,<PUBLIC,NEAR>
  444. cBegin nogen
  445. push ds
  446. SetKernelDS
  447. cmp fInt21, 0
  448. je not_me
  449. pop ds
  450. UnSetKernelDS
  451. inc bp
  452. push bp
  453. mov bp, sp
  454. push ds
  455. push bx ; Will be exchanged later
  456. SetKernelDS
  457. cmp ah,12h
  458. jbe dont_reset_InDOS
  459. mov Kernel_InDOS,0
  460. mov Kernel_InINT24,0
  461. dont_reset_InDOS:
  462. cmp Kernel_InDOS,0
  463. jz not_in_INT24
  464. mov kernel_InINT24,1
  465. not_in_INT24:
  466. ifndef WOW ; FOR WOW All the Profile Stuff is handled by Win 32
  467. ;** On every DOS call, the profile string buffers may become stale
  468. ;** in case the app does a DOS call on the INI file.
  469. ;** We set the stale profile file and on the next profile read
  470. ;** or write, we will check to see if the file is dirty.
  471. ;** 27-Nov-1991 [JonT]
  472. mov ds:[fProfileMaybeStale], 1
  473. ;** In a similar situation to the above, DOS calls done after
  474. ;** profile string calls but before task switches may depend on
  475. ;** the data being flushed to the INI file from the buffer.
  476. ;** So, here we do a fast check to see if the profile buffers
  477. ;** have unflushed information. If they do, we flush them.
  478. ;** Note that 2 is PROUNCLEAN taken from UP.C
  479. ;** 27-Nov-1991 [JonT]
  480. test WinIniInfo.ProFlags, 2 ;Win.INI dirty?
  481. jnz I21_Flush_It ;Yes, flush it
  482. test PrivateProInfo.ProFlags, 2 ;Private profile dirty?
  483. jz I21_Done_Flushing ;No. Neither.
  484. ;** When writing out profiles we trash pretty much all the registers
  485. ;** and since we can't do this for a DOS call, we save everything
  486. I21_Flush_It:
  487. cmp fWriteOutProfilesReenter, 0 ;Ignore if reentering
  488. jne I21_Done_Flushing ; because of profile strings
  489. pusha
  490. push es
  491. if PMODE32
  492. .386
  493. push fs
  494. push gs
  495. endif
  496. cCall WriteOutProfiles
  497. if PMODE32
  498. pop gs
  499. pop fs
  500. .286p
  501. endif
  502. pop es
  503. popa
  504. endif ; NOT WOW
  505. I21_Done_Flushing:
  506. mov bx, CODEOffset PassOnThrough
  507. cmp ah,TableEnd ; Table is for call 0Eh to 6ch
  508. ja let_it_go
  509. cmp ah, 0Eh
  510. jb let_it_go
  511. mov bh, 0
  512. mov bl, ah
  513. add bx, bx ; Word index in bx
  514. mov bx, word ptr DosTrap1[bx][-0Eh*2]
  515. let_it_go:
  516. xchg bx, [bp-4] ; 'pop bx' and push proc addr
  517. mov ds, [bp-2] ; Restore DS
  518. UnSetKernelDS
  519. if 1 ; PMODE32 - always want to avoid sti in WOW
  520. push ax
  521. pushf
  522. pop ax
  523. test ah, 2
  524. pop ax
  525. jnz short ints_are_enabled
  526. endif ; WOW
  527. FSTI
  528. ints_are_enabled:
  529. ret
  530. not_me:
  531. pop ds
  532. ;;; jmp prevInt21Proc
  533. call real_dos
  534. retf 2
  535. cEnd nogen
  536. ;-----------------------------------------------------------------------;
  537. ; not_supported
  538. ;
  539. ;
  540. ; Entry:
  541. ;
  542. ; Returns:
  543. ;
  544. ; Registers Destroyed:
  545. ;
  546. ; History:
  547. ; Sun 06-Aug-1989 13:26:19 -by- David N. Weise [davidw]
  548. ; Wrote it!
  549. ;-----------------------------------------------------------------------;
  550. assumes ds,nothing
  551. assumes es,nothing
  552. cProc not_supported,<PUBLIC,NEAR>
  553. cBegin nogen
  554. jmps PassOnThrough
  555. ;;; cmp ah,55h
  556. ;;; jnz @F
  557. ;;; jmp PassOnThrough
  558. ;;;@@: int 3
  559. cEnd nogen
  560. ;-----------------------------------------------------------------------;
  561. ; PassOnThrough ;
  562. ; ;
  563. ; This doesn't quite pass on through anymore. It calls down to DOS. ;
  564. ; In this fashion we know when we are in DOS. In addition this routine ;
  565. ; does the delayed binding of DOS variables after task switches. ;
  566. ; ;
  567. ; Arguments: ;
  568. ; ;
  569. ; Returns: ;
  570. ; ;
  571. ; Error Returns: ;
  572. ; ;
  573. ; Registers Preserved: ;
  574. ; ;
  575. ; Registers Destroyed: ;
  576. ; ;
  577. ; Calls: ;
  578. ; ;
  579. ; History: ;
  580. ; ;
  581. ; Sun 25-Mar-1990 15:31:49 -by- David N. Weise [davidw] ;
  582. ; added the check for 2Fh, GetDTA, so that the correct one is gotten! ;
  583. ; ;
  584. ; Tue Feb 03, 1987 10:32:25p -by- David N. Weise [davidw] ;
  585. ; Put in the delayed binding of DOS variables. ;
  586. ; ;
  587. ; Tue Feb 03, 1987 10:26:01p -by- David N. Weise [davidw] ;
  588. ; Rewrote it and added this nifty comment block. ;
  589. ;-----------------------------------------------------------------------;
  590. assumes ds, nothing
  591. assumes es, nothing
  592. f_iret:
  593. FIRET
  594. cProc PassOnThrough,<PUBLIC,NEAR>
  595. cBegin nogen
  596. SetKernelDS
  597. test Kernel_Flags,KF_restore_disk
  598. jnz maybe_restore_disk
  599. PUBLIC final_call_for_DOS
  600. final_call_for_DOS:
  601. pop ds
  602. UnSetKernelDS
  603. push [bp][6]
  604. and [bp][-2],NOT CPUF_TRAP
  605. popf ; Correct input flags back in flags
  606. pop bp
  607. dec bp
  608. call real_DOS
  609. push bp ; pass back the correct flags
  610. mov bp,sp
  611. pushf
  612. pop [bp][6]
  613. if 1 ; PMODE32 - always for WOW
  614. test [bp][6], 200h ; Interrupts on?
  615. pop bp
  616. jnz short no_sti
  617. else
  618. pop bp
  619. endif
  620. FSTI
  621. no_sti:
  622. jmp f_iret
  623. maybe_restore_disk:
  624. ; Note, caller's DS is on stack, current DS == kernel DS
  625. cmp ah,2Fh ; get DTA, don't hit disk but
  626. jz OnThrough ; DTA must be set correctly!
  627. cmp ah,29h ; for system calls 29h -> 30h ....
  628. jb OnThrough
  629. cmp ah,30h ; don't restore directory...
  630. jbe final_call_for_DOS ; ...they don't hit disk
  631. cmp ah,3Fh ; file handle read
  632. jz final_call_for_DOS
  633. cmp ah,40h ; file handle write
  634. jz final_call_for_DOS
  635. cmp ah,50h ; for system calls 50h -> 51h ....
  636. jz final_call_for_DOS
  637. cmp ah,51h ; don't restore directory...
  638. jz final_call_for_DOS ; ...they don't hit disk
  639. ; restore the DOS environment
  640. OnThrough:
  641. push ax
  642. push bx
  643. push dx
  644. push es
  645. SetKernelDS es
  646. cmp [CurTDB], 0
  647. je DeadTDB
  648. and Kernel_Flags,NOT KF_restore_disk
  649. mov ds,[CurTDB]
  650. cmp ds:[TDB_sig],TDB_SIGNATURE
  651. jz @F
  652. DeadTDB:
  653. jmp done_restoring_dos
  654. @@:
  655. ; restore DTA
  656. mov ax,ds:[TDB_DTA].sel
  657. mov dx,ds:[TDB_DTA].off
  658. cmp dx,curDTA.off
  659. jnz restore_DTA
  660. cmp ax,curDTA.sel
  661. jz dont_restore_DTA
  662. restore_DTA:
  663. mov curDTA.sel,ax
  664. mov curDTA.off,dx
  665. push ds
  666. mov ds,ax
  667. mov ah,1Ah
  668. call real_DOS
  669. pop ds
  670. dont_restore_DTA:
  671. ; restore drive and directory
  672. ;-----------------------------------------------------------------------;
  673. ; We now need to perform a little check. ;
  674. ; On DOS >= 3.20 it is possible that the phantom drive state ;
  675. ; has changed since we stored this tasks current drive and current ;
  676. ; directory in his task header. UNDER NO CIRCUMSTANCES do we want ;
  677. ; to SetDrive or CHDIR on a phantom drive if the first level of hooks ;
  678. ; are in (to allow this results in the "Please Insert Disk..." message) ;
  679. ; so we check out the SetDrive drive number. ;
  680. ; If it is phantom we will NOT restore drive or directory. ;
  681. ;-----------------------------------------------------------------------;
  682. xor dx,dx
  683. mov dl,ds:[TDB_Drive]
  684. and dl,01111111b
  685. mov bx,dx ; Index into PhantArray
  686. CheckKernelDS es
  687. cmp byte ptr PhantArray[bx],0
  688. jnz done_restoring_dos
  689. no_drive_check:
  690. mov ax,ds
  691. cmp ax,cur_drive_owner
  692. jz hasnt_been_changed
  693. inc InScheduler ; prevent Int 24h dialog boxes
  694. lar ax, cur_drive_owner ; Ensure we have valid TDB
  695. jnz restore_dos ; in cur_drive_owner
  696. test ah, DSC_PRESENT
  697. jz restore_dos
  698. lsl ax, cur_drive_owner
  699. cmp ax, TDBsize-1
  700. jb restore_dos
  701. push es
  702. mov es, cur_drive_owner
  703. UnsetKernelDS es
  704. cmp es:[TDB_sig], TDB_SIGNATURE
  705. jne restore_dos0 ; Dead TDB, can't compare
  706. mov al, es:[TDB_Drive]
  707. ; these messages allow to track current drive problems
  708. ; krDebugOut DEB_WARN, "Current Drive Owner: #ES Current TDB #DS"
  709. ; krDebugOut DEB_WARN, "Current Drive Owner: Drive #AX"
  710. ; krDebugOut DEB_WARN, "Current TDB: Drive #DX"
  711. and al,01111111b
  712. cmp al, dl
  713. jne restore_dos0 ; Drive the same?
  714. push cx ; Compare directories
  715. push si
  716. push di
  717. mov si, TDB_LFNDirectory
  718. mov di, si
  719. xor al, al ; Scan for end of string
  720. mov cx, size TDB_LFNDirectory
  721. cld
  722. ; Current drive problem trace
  723. ; krDebugOut DEB_WARN, "Current Drive Owner: @es:di / Current TDB: @ds:si"
  724. repne scasb
  725. mov cx, di ; Calculate length
  726. sub cx, si
  727. mov di, si
  728. rep cmpsb
  729. pop di
  730. pop si
  731. pop cx
  732. pop es
  733. ResetKernelDS es
  734. jnz restore_directory ; We know the drive is the same
  735. jmps have_new_owner
  736. restore_dos0:
  737. pop es
  738. restore_dos:
  739. mov ah,0Eh
  740. call real_DOS ; select the disk
  741. restore_directory:
  742. mov dx,TDB_LFNDirectory
  743. ; current directory problem trace
  744. ; krDebugOut DEB_WARN, "Restoring directory @ds:dx"
  745. mov ah,3Bh
  746. call real_DOS ; change directory
  747. have_new_owner:
  748. dec InScheduler ; allow int 24's
  749. mov cur_drive_owner,ds
  750. hasnt_been_changed:
  751. done_restoring_dos:
  752. ; current drive/dir problem trace
  753. ; krDebugOut DEB_WARN, "Done restoring dos"
  754. pop es
  755. UnSetKernelDS es
  756. pop dx
  757. pop bx
  758. pop ax
  759. jmp final_call_for_DOS
  760. cEnd nogen
  761. ;-----------------------------------------------------------------------;
  762. ; real_DOS ;
  763. ; ;
  764. ; Calls the real DOS. ;
  765. ; ;
  766. ; Arguments: ;
  767. ; ;
  768. ; Returns: ;
  769. ; ;
  770. ; Error Returns: ;
  771. ; ;
  772. ; Registers Preserved: ;
  773. ; ;
  774. ; Registers Destroyed: ;
  775. ; ;
  776. ; Calls: ;
  777. ; ;
  778. ; History: ;
  779. ; ;
  780. ; Mon 07-Aug-1989 23:45:48 -by- David N. Weise [davidw] ;
  781. ; Removed WinOldApp support. ;
  782. ; ;
  783. ; Mon Apr 20, 1987 07:59:00p -by- R. O. [ ] ;
  784. ; Set cur_dos_PDB when we call DOS to change it, for efficiency. ;
  785. ; ;
  786. ; Sun Jan 11, 1987 07:18:19p -by- David N. Weise [davidw] ;
  787. ; Put the per task maintenance of ^C here instead of in the switcher. ;
  788. ; ;
  789. ; Sun Jan 04, 1987 01:19:16p -by- David N. Weise [davidw] ;
  790. ; Wrote it. ;
  791. ;-----------------------------------------------------------------------;
  792. assumes ds, nothing
  793. assumes es, nothing
  794. cProc far_real_dos,<PUBLIC,FAR>
  795. cBegin nogen
  796. call real_dos
  797. ret
  798. cEnd nogen
  799. cProc real_dos,<PUBLIC,NEAR>
  800. cBegin nogen
  801. pushf
  802. push ds
  803. SetKernelDS
  804. mov Kernel_InDOS,1
  805. push bx
  806. if KDEBUG
  807. cmp ah, 50h ; SET PSP
  808. jne OK_PDB ; No, all's fine
  809. cmp bx, Win_PDB ; It is Win_PDB, isn't it?
  810. je OK_PDB
  811. int 3
  812. int 3
  813. OK_PDB:
  814. endif
  815. mov bx, Win_PDB
  816. cmp bx, cur_dos_PDB
  817. je PDB_ok
  818. push ax
  819. mov cur_dos_PDB,bx
  820. ifdef W_Q21
  821. call SetPDBForDOS
  822. else
  823. mov ah,50h
  824. pushf
  825. ifndef WOW
  826. ife PMODE32
  827. FCLI
  828. endif
  829. endif
  830. if ROM
  831. call prevInt21Proc
  832. else
  833. call cs:prevInt21Proc ; JUMP THROUGH CS VARIABLE
  834. endif
  835. endif ;WOW
  836. pop ax
  837. PDB_OK:
  838. pop bx
  839. ifdef TraceInt21 ; <<< Only Useful when debugging fileio routine >>>
  840. test fBooting,1
  841. jnz @f
  842. krDebugOut DEB_WARN, "DOS Call #AX bx #BX cx #CX dx #DX"
  843. cmp ah,3dh ; Open ?
  844. jnz @f
  845. pop ds ; USERs DS
  846. push ds
  847. UnSetKernelDS
  848. krDebugOut DEB_WARN,"Opening File @DS:DX"
  849. SetKernelDS
  850. @@:
  851. cmp ah,3ch ; Create ?
  852. jnz @f
  853. pop ds ; USERs DS
  854. push ds
  855. UnSetKernelDS
  856. krDebugOut DEB_WARN,"Creating File @DS:DX"
  857. SetKernelDS
  858. @@:
  859. endif
  860. ifdef W_Q21
  861. ; If we are the running in protected mode then there is no need to
  862. ; switch to v86 mode and then to call the DOSKrnl for most Int 21
  863. ; operations - since mode switches are slow and DOSX has to read
  864. ; into a buffer in low memory and copy it high. Since we just want
  865. ; to call the Win32 file system we can stay in protected mode.
  866. ; For some DOS calls which don't happen very frequently we don't
  867. ; bother intercepting them.
  868. cmp ah,59h ; GetExtendedError ?
  869. jz short @f
  870. ; SetDosErr 0h
  871. mov WOWLastError,0h
  872. @@:
  873. ;-----------------------------------------------------------------------------
  874. ; Dispatch code for WOW quick entry points
  875. ;-----------------------------------------------------------------------------
  876. cmp ah, QD_FIRST
  877. jb really_call_dos
  878. cmp ah, QD_LAST
  879. ja really_call_dos
  880. push bx
  881. xor bh, bh
  882. mov bl, ah
  883. sub bx, QD_FIRST
  884. shl bx, 1
  885. mov bx, QuickDispatchTable[bx]
  886. mov QuickDispatchAddr, bx
  887. pop bx
  888. jmp word ptr QuickDispatchAddr
  889. really_call_dos:
  890. ifndef IGROUP_HAS_ENOUGH_ROOM
  891. cmp ah, QD_LFNAPI
  892. je QuickLFNApiCall
  893. endif
  894. jmp Not_WOW_Handled
  895. ;-----------------------------------------------------------------------------
  896. ; WOW quick entry points
  897. ;-----------------------------------------------------------------------------
  898. QuickLFNApiCall:
  899. ; first, we emulate dos to reduce size of 32-bit required processing
  900. ; then we don't care for many other fun things like retrying anything
  901. ; through dos as we call into dem from here and thus result is
  902. ; likely to be the same
  903. ; this is a place-holder for user flags - see demlfn.c for details
  904. pushf
  905. push ES
  906. ; next goes user ds - we need to get it off the stack - it however is
  907. ; already there... we need to replicate it's value somehow
  908. push ax ; there will it be - bogus value for now
  909. ; could have been a sub sp, 2
  910. push bp
  911. push di
  912. push si
  913. push dx
  914. push cx
  915. push bx
  916. push ax
  917. mov bx, sp
  918. mov dx, ss:[bx+20] ; dx - user ds
  919. mov ss:[bx + 14], dx ; shove user ds into the right place
  920. ; this call takes ss:sp as a pointer to a dos-like user stack frame
  921. ;
  922. cCall WOWLFNEntry,<ss, bx>
  923. ; return is dx:ax, where ax is non-zero for errors and
  924. ; dx is 0xffff for hard error
  925. ; if hard error case is encountered, the procedure turns to
  926. ; "real dos" then, allowing for int24 to be fired properly
  927. ; To continue in real_dos we need to restore regs
  928. ; dem does not touch registers on failed calls thus
  929. ; we can pop them off the stack and continue
  930. ;
  931. SetDosErr ax
  932. ; mov WOWLastError, ax
  933. ; resulting flags are :
  934. ; - if no carry then no error
  935. ; - if carry then error
  936. ; - if zero then harderror
  937. pop ax ; restore ax
  938. pop bx ;
  939. pop cx
  940. pop dx
  941. pop si
  942. pop di
  943. ; here we need to preserve flags so they stay after the stack
  944. ; adjustment
  945. add sp, 6 ; the rest are not important to retrieve
  946. ; now get the mod flags
  947. popf
  948. .386
  949. jnc QuickDone
  950. ; carry - this is an error
  951. jz Not_WoW_Handled ; if zero - hard error there
  952. ; here zero is not set - the just return error
  953. .286p
  954. ; here is error condition to be returned to the app
  955. ; restore error code and return to the app
  956. mov ax, WOWLastError
  957. jmp QerrRet
  958. QuickDelete:
  959. push dx
  960. push bx
  961. push ax
  962. mov bx,sp
  963. mov bx,ss:[bx + 6] ; BX = USER DS
  964. cCall WOWDelFile,<BX,DX>
  965. ; DX = FFFF, AX = Error Code if failure
  966. ; AX = 0 if success
  967. inc dx
  968. jnz qdf_ok
  969. jmp DoDos
  970. qdf_ok:
  971. pop ax
  972. pop bx
  973. pop dx
  974. jmp QuickDone
  975. regptr cxdx,cx,dx
  976. regptr axdx,ax,dx
  977. QuickExtendedError:
  978. ; CheckDosErr
  979. cmp WOWLastError, 0
  980. jnz DoExtendedError
  981. jmp Not_WOW_Handled
  982. DoExtendedError:
  983. GetDosErr ax, ch, bl, bh
  984. ; mov ax,WOWLastError ;load values for extended error
  985. ; mov bh,WOWErrClass
  986. ; mov bl,WOWErrAction
  987. ; mov ch,WOWErrLocation ; location
  988. jmp QuickDone
  989. QuickGetDate:
  990. cCall WowGetCurrentDate
  991. push dx ;year
  992. mov dl, ah ;monthday
  993. mov ah, al ;
  994. mov cl, 4 ;shift count
  995. shr ah, cl
  996. mov dh, ah ;month
  997. and al, 0fh ;weekday
  998. mov ah, 2ah ;reload ah
  999. pop cx ;cx is now the year
  1000. jmp QuickDone
  1001. QuickGetDefaultDrive:
  1002. call GetDefaultDriveFromDOS
  1003. mov CurDOSDrive, al
  1004. jmp QuickDone
  1005. GetDefaultDriveFromDOS:
  1006. push di
  1007. push es
  1008. les di, pPMDosCURDRV
  1009. mov al, byte ptr es:[di] ;get drive number from DOS
  1010. ; GetDefaultDriveFromDos trace
  1011. ; pusha
  1012. ; xor ah, ah
  1013. ; krDebugOut DEB_WARN, "GetDefaultDriveFromDos: ret #ax"
  1014. ; popa
  1015. pop es
  1016. pop di
  1017. ret
  1018. QuickSetPSPAddress:
  1019. call SetPDBForDOS
  1020. jmp QuickDone
  1021. SetPDBForDOS:
  1022. push es
  1023. push di
  1024. push cx
  1025. push dx
  1026. push bx
  1027. DPMICALL 0006h ; Get physical address
  1028. mov bx,cx ; hiword of address
  1029. mov cx,4 ; shift count
  1030. shr dx,cl
  1031. mov cx,12 ; for high nibble
  1032. shl bx,cl
  1033. or dx,bx ; now real mode segment
  1034. les di, pPMDosPDB ; get pointer to PDB in DOS
  1035. mov word ptr es:[di],dx ; set new PDB
  1036. pop bx
  1037. pop dx
  1038. pop cx
  1039. pop di
  1040. pop es
  1041. ret
  1042. QuickSetDefaultDrive:
  1043. push dx
  1044. push ax
  1045. call GetDefaultDriveFromDOS
  1046. cmp dl, al ;doing a NOP?
  1047. jz short @f ;yes, skip call to WOW
  1048. cCall WowSetDefaultDrive,<DX>
  1049. mov CurDOSDrive, al ;returned from SetDefaultDrive
  1050. @@:
  1051. pop ax
  1052. mov al, 26 ;this is what DOS does
  1053. pop dx
  1054. jmp QuickDone
  1055. QuickGetCurrentDirectory:
  1056. push ax
  1057. push dx
  1058. push bx
  1059. mov bx,sp
  1060. mov bx,ss:[bx + 6] ; BX = USER DS
  1061. cCall WowGetCurrentDirectory,<DX,BX,SI>
  1062. pop bx
  1063. inc dx ;DX=FFFF on error
  1064. pop dx
  1065. jz short qgcd_err ;jif error
  1066. pop ax
  1067. mov al, 0 ;this is what DOS does
  1068. jmp QuickDone
  1069. QuickSetCurrentDirectory:
  1070. push ax
  1071. push dx
  1072. push bx
  1073. mov bx,sp
  1074. mov bx,ss:[bx + 6] ; BX = USER DS
  1075. cCall WowSetCurrentDirectory,<BX,DX>
  1076. pop bx
  1077. inc dx ;DX=FFFF on error
  1078. pop dx
  1079. jz short qgcd_err ;jif error
  1080. pop ax
  1081. mov al, 0 ;BUGBUG is this what DOS does?
  1082. jmp QuickDone
  1083. qgcd_err:
  1084. add sp, 2 ;leave error code in AX
  1085. SetDosErr ax, 9, 1ch, 1
  1086. ; mov WOWLastError,ax ;use this for filefind errors
  1087. ; mov WOWErrClass,1 ;this is what DOS seems to do
  1088. ; mov WOWErrAction,1ch
  1089. ; mov WOWErrLocation,9
  1090. jmp QErrRet
  1091. QuickDeviceIOCTL:
  1092. cmp al, 8 ;removeable media only
  1093. jz short @f
  1094. jmp Not_WOW_Handled
  1095. @@:
  1096. push dx
  1097. cCall WowDeviceIOCTL,<BX,AX>
  1098. inc dx
  1099. pop dx
  1100. jnz short @f
  1101. jmp QErrRet
  1102. @@:
  1103. jmp QuickDone
  1104. QuickFindFirstFile:
  1105. push dx
  1106. push bx
  1107. push si
  1108. push di
  1109. mov si, curDTA.sel
  1110. mov di, curDTA.off
  1111. mov bx,sp
  1112. mov bx,ss:[bx + 8] ; BX = USER DS
  1113. ifdef TraceInt21 ; <<< Only Useful when debugging fileio routine >>>
  1114. test fBooting,1
  1115. jnz @f
  1116. mov ds,bx ; USERs DS
  1117. UnSetKernelDS
  1118. krDebugOut DEB_WARN, "QuickFindFirstFile looking for @DS:DX"
  1119. SetKernelDS
  1120. @@:
  1121. endif
  1122. cCall WowFindFirst,<CX,BX,DX,SI,DI>
  1123. ifdef TraceInt21 ; <<< Only Useful when debugging fileio routine >>>
  1124. or ax, ax
  1125. jnz @f
  1126. mov bx, curDTA.off
  1127. mov si, curDTA.sel
  1128. mov ds, si
  1129. UnSetKernelDS
  1130. mov si, bx
  1131. mov bx, 18h
  1132. mov di, [si+bx]
  1133. mov bx, 16h
  1134. mov dx, [si+bx]
  1135. mov bx, 1Eh
  1136. add bx, si
  1137. krDebugOut DEB_WARN, "QuickFindFirstFile found @DS:BX, date #DI, time #DX"
  1138. mov bx, 1Ah
  1139. mov di, [si+bx]
  1140. mov bx, 1Ch
  1141. mov dx, [si+bx]
  1142. mov bx, 15h
  1143. mov bl, [si+bx]
  1144. xor bh, bh
  1145. krDebugOut DEB_WARN, " attribute #BX size #DX:#DI"
  1146. SetKernelDS
  1147. @@:
  1148. endif
  1149. pop di
  1150. pop si
  1151. pop bx
  1152. pop dx
  1153. or ax, ax
  1154. jnz qfErr
  1155. jmp QuickDone
  1156. QuickFindNextFile:
  1157. push si
  1158. push di
  1159. mov si, curDTA.sel
  1160. mov di, curDTA.off
  1161. cCall WowFindNext,<SI,DI>
  1162. pop di
  1163. pop si
  1164. or ax, ax
  1165. jnz qfErr
  1166. jmp QuickDone
  1167. qfErr:
  1168. SetDosErr ax,2,3,8
  1169. ; mov WOWLastError,ax ;use this for filefind errors
  1170. ; mov WOWErrClass,8
  1171. ; mov WOWErrAction,3 ; file or item not found, prompt user
  1172. ; mov WOWErrLocation,2 ; location is block device
  1173. krDebugOut DEB_WARN, "QFindErr: #AX"
  1174. jmp QErrRet
  1175. QuickLSeek:
  1176. push dx
  1177. push bx
  1178. push ax
  1179. xor ah,ah
  1180. cCall WowFileLSeek,<BX,CXDX,AX,cur_dos_PDB,0,pFileTable>
  1181. ; DX:AX = File Position if success
  1182. ; DX = FFFF, AX = Error Code if failure
  1183. inc dx
  1184. jnz LSeekFinish
  1185. jmp DoDos
  1186. LSeekFinish:
  1187. dec dx
  1188. add sp,6
  1189. jmp QuickDone
  1190. QuickCreate:
  1191. push dx
  1192. push bx
  1193. push ax
  1194. test cx, 8 ; ATTR_VOLUME?
  1195. jz short @f ; no, ok
  1196. jmp DoDos ; yes, not supported in wow32
  1197. @@:
  1198. mov bx,sp
  1199. mov bx,ss:[bx + 6] ; BX = USER DS
  1200. cCall WowFileCreate,<CX,BX,DX,cur_dos_PDB,0,pFileTable>
  1201. ; AX = FileHandle if success
  1202. ; AX = FFFF if path was a device
  1203. ; DX = FFFF, AX = Error Code if failure
  1204. cmp ax,0FFFFh
  1205. jnz short @f ;
  1206. jmp DoDos ; Device case, just go through DOS
  1207. @@:
  1208. inc dx ; Set the zero flag on error.
  1209. jz QOpenError ; Error occured
  1210. add sp,2 ; discard AX
  1211. pop bx
  1212. pop dx
  1213. ifdef TraceInt21
  1214. jmp QuickDone ; Success
  1215. else
  1216. jmp QuickDone ; Success
  1217. endif
  1218. QuickOpen:
  1219. push dx
  1220. push bx
  1221. push ax
  1222. mov bx,sp
  1223. mov bx,ss:[bx + 6] ; BX = USER DS
  1224. xor ah,ah ; clear AH leaving file-access in AX
  1225. cCall WowFileOpen,<BX,DX,AX,cur_dos_PDB,0,pFileTable>
  1226. ; AX = FileHandle if success
  1227. ; AX = FFFF if path was a device
  1228. ; DX = FFFF, AX = Error Code if failure
  1229. cmp ax,0FFFFh
  1230. ifdef TraceInt21
  1231. jnz @f
  1232. jmp DoDos
  1233. @@:
  1234. else
  1235. .386
  1236. jz DoDos ; Device case, just go through DOS
  1237. .286p
  1238. endif
  1239. inc dx ; Set the zero flag on error.
  1240. jz QOpenError ; Error occured
  1241. add sp,2 ; discard AX
  1242. pop bx
  1243. pop dx
  1244. jmps QuickDone ; Success
  1245. QOpenError:
  1246. cmp ax, 3 ; If the error is not file_not_found or path_not_found
  1247. ifdef TraceInt21
  1248. jbe @f
  1249. jmp DoDos
  1250. @@:
  1251. else
  1252. .386
  1253. ja DoDos ; then go through DOS again for the open.
  1254. .286p
  1255. endif
  1256. cmp ax, 2
  1257. jb DoDos
  1258. SetDosErr ax,2,3,8
  1259. ; mov WOWLastError,ax
  1260. ; mov WOWErrClass,8
  1261. ; mov WOWErrAction,3 ; file or item not found, prompt user
  1262. ; mov WOWErrLocation,2 ; location is block device
  1263. add sp,2 ; discard saved AX, since AX = Error Code
  1264. pop bx
  1265. pop dx
  1266. QErrRet:
  1267. ifdef TraceInt21
  1268. krDebugOut DEB_WARN, "Q21 fails AX #AX bx #BX cx #CX dx #DX (t)"
  1269. endif
  1270. pop ds
  1271. popf
  1272. stc ; Set Carry = ERROR
  1273. ret
  1274. QuickRead:
  1275. pop ax ; AX = USER DS
  1276. push ax
  1277. push dx ; save user pointer
  1278. cCall WowFileRead,<BX,AXDX,0,CX,cur_dos_PDB,0,pFileTable>
  1279. ; AX = Number Bytes Read
  1280. ; DX = FFFF, AX = Error Code
  1281. inc dx
  1282. pop dx ; restore user pointer
  1283. jz QRError
  1284. QuickDone:
  1285. ifdef TraceInt21
  1286. krDebugOut DEB_WARN, "Q21 succeeds AX #AX bx #BX cx #CX dx #DX (t)"
  1287. endif
  1288. pop ds
  1289. popf
  1290. clc ; Clear Carry - OK Read
  1291. ret
  1292. QuickClose:
  1293. push dx
  1294. push bx
  1295. push ax
  1296. cCall WowFileClose,<BX,cur_dos_PDB,0,pFileTable>
  1297. ; DX = FFFF, AX = Error Code if failure
  1298. ; AX = FFFF if path was a device
  1299. cmp ax,0FFFFh
  1300. jz DoDos ; Device opens go through DOS
  1301. inc dx ; Sets zero flag on error.
  1302. jz DoDos ; Let DOS Handle Close Errors
  1303. pop bx ; Throw old AX out
  1304. pop bx
  1305. pop dx
  1306. mov ah,3Eh ; bogus multiplan fix
  1307. jmps QuickDone ; Success
  1308. DoDos:
  1309. pop ax
  1310. pop bx
  1311. pop dx
  1312. jmp Not_WOW_Handled
  1313. QRError:
  1314. mov ah,3Fh ; On Error Retry Operation Via DOEem
  1315. jmp Not_WOW_Handled
  1316. QuickGetSetAttributes:
  1317. cmp al, 0
  1318. jz short qget_attr
  1319. cmp al, 1
  1320. jz short qset_attr
  1321. jmp Not_WOW_Handled
  1322. qget_attr:
  1323. push dx
  1324. push bx
  1325. push ax
  1326. mov bx,sp
  1327. mov bx,ss:[bx + 6] ; BX = USER DS
  1328. cCall WowFileGetAttributes,<BX,DX>
  1329. ; AX = Attributes if success
  1330. ; DX = FFFF, AX = Error Code if failure
  1331. inc dx
  1332. jz DoDos ; if failure retry through DOS
  1333. mov cx,ax ; move result into CX
  1334. pop ax
  1335. pop bx
  1336. pop dx
  1337. jmp QuickDone
  1338. qset_attr:
  1339. push dx
  1340. push bx
  1341. push ax
  1342. mov bx,sp
  1343. mov bx,ss:[bx + 6] ; BX = USER DS
  1344. cCall WowFileSetAttributes,<CX,BX,DX>
  1345. ; DX = FFFF, AX = Error Code if failure
  1346. inc dx
  1347. jz DoDos ; if failure retry through DOS
  1348. pop ax
  1349. pop bx
  1350. pop dx
  1351. jmp QuickDone
  1352. QuickFileDateTime:
  1353. cmp al, 0
  1354. jz short qget_datetime
  1355. cmp al, 1
  1356. jz short qset_datetime
  1357. jmp Not_WOW_Handled
  1358. qget_datetime:
  1359. push dx
  1360. push bx
  1361. push ax
  1362. cCall WowFileGetDateTime,<BX,cur_dos_PDB,0,pFileTable>
  1363. ; AX = Time, DX = Date if success
  1364. ; AX = FFFF if failure
  1365. cmp ax,0FFFFh
  1366. jz DoDos
  1367. mov cx,ax
  1368. pop ax
  1369. pop bx
  1370. add sp,2 ; throw away saved DX
  1371. jmp QuickDone
  1372. qset_datetime:
  1373. push dx
  1374. push bx
  1375. push ax
  1376. cCall WowFileSetDateTime,<BX,CX,DX,cur_dos_PDB,0,pFileTable>
  1377. ; AX = 0 if success
  1378. ; AX = FFFF if failure
  1379. cmp ax,0FFFFh
  1380. jnz short @f
  1381. jmp DoDos
  1382. @@:
  1383. pop ax
  1384. pop bx
  1385. pop dx
  1386. jmp QuickDone
  1387. QuickLock:
  1388. push dx
  1389. push bx
  1390. push ax
  1391. cCall WowFileLock,<AX,BX,CX,DX,SI,DI,cur_dos_PDB,0,pFileTable>
  1392. ; DX = FFFF, AX = Error Code if failure
  1393. ; AX = 0 if success
  1394. inc dx
  1395. jnz FinishLock
  1396. cmp ax, 21h ;is this lock violation?
  1397. jz short @f ;yes, give it back to app
  1398. jmp DoDos
  1399. @@:
  1400. add sp,2 ; discard saved AX, since AX = Error Code
  1401. pop bx
  1402. pop dx
  1403. SetDosErr ax,2,2,10
  1404. ; mov WOWLastError,ax
  1405. ; mov WOWErrClass,10 ;ext. err info for lock violation
  1406. ; mov WOWErrAction,2
  1407. ; mov WOWErrLocation,2
  1408. jmp QErrRet
  1409. FinishLock:
  1410. add sp,2 ; throw out old AX
  1411. pop bx
  1412. pop dx
  1413. jmp QuickDone
  1414. QuickWrite:
  1415. pop ax ; AX = USER DS
  1416. push ax
  1417. push dx
  1418. cCall WowFileWrite,<BX,AXDX,0,CX,cur_dos_PDB,0,pFileTable>
  1419. ; AX = Number Bytes Read
  1420. ; DX = FFFF, AX = Error Code
  1421. inc dx
  1422. pop dx ; restore user pointer
  1423. jz RetryWrite
  1424. jmp QuickDone
  1425. RetryWrite:
  1426. mov ah,40h ; On Error Retry Operation Via DOEem
  1427. ;-----------------------------------------------------------------------------
  1428. ; END OF WOW quick entry points
  1429. ;-----------------------------------------------------------------------------
  1430. Not_WOW_Handled:
  1431. endif ; W_Q21
  1432. ;
  1433. ; Intercept Select Disk and Get Current Disk
  1434. ;
  1435. cmp ah, 0Eh
  1436. je rd_Select
  1437. cmp ah, 19h
  1438. je rd_Get
  1439. rd_no_intercept:
  1440. ;;; test Kernel_flags,kf_restore_CtrlC
  1441. ;;; jz no_need_to_set_CtrlC
  1442. ;;; and Kernel_flags,not kf_restore_CtrlC
  1443. ;;;
  1444. ;;; push ax
  1445. ;;; push bx
  1446. ;;; push es
  1447. ;;; mov es,curTDB
  1448. ;;; cmp es:[TDB_sig],TDB_SIGNATURE
  1449. ;;; jne PDB_okay
  1450. ;;;
  1451. ; restore PDB
  1452. ;;;
  1453. ;;; mov bx,Win_PDB
  1454. ;;; cmp bx,cur_dos_PDB
  1455. ;;; jz PDB_okay
  1456. ;;;if KDEBUG
  1457. ;;; cmp bx,es:[TDB_PDB]
  1458. ;;; jz @F
  1459. ;;; int 1
  1460. ;;;@@:
  1461. ;;;endif
  1462. ;;; mov cur_dos_PDB,bx
  1463. ;;; mov ah,50h
  1464. ;;; pushf
  1465. ;;;ife PMODE32
  1466. ;;; cli
  1467. ;;;endif
  1468. ;;; call cs:prevInt21Proc ; JUMP THROUGH CS VARIABLE
  1469. ;;;PDB_okay:
  1470. ;;;
  1471. ;;; pop es
  1472. ;;; pop bx
  1473. ;;; pop ax
  1474. ;;;no_need_to_set_CtrlC:
  1475. pop ds
  1476. UnSetKernelDS
  1477. ifndef WOW
  1478. ife PMODE32
  1479. FCLI
  1480. endif
  1481. endif
  1482. if ROM
  1483. cCall <far ptr PrevROMInt21Proc>
  1484. else
  1485. call cs:prevInt21Proc ; JUMP THROUGH CS VARIABLE
  1486. ifdef TraceInt21
  1487. pushf
  1488. jc rd_Trace_CarrySet
  1489. krDebugOut DEB_WARN, "DOS succeeds AX #AX bx #BX cx #CX dx #DX"
  1490. jmp @f
  1491. rd_Trace_CarrySet:
  1492. krDebugOut DEB_WARN, "DOS fails AX #AX bx #BX cx #CX dx #DX"
  1493. @@:
  1494. popf
  1495. endif
  1496. endif
  1497. rd_after_DOS:
  1498. push ds
  1499. SetKernelDS
  1500. rd_after_DOS1:
  1501. push ax
  1502. mov al,kernel_inINT24
  1503. mov Kernel_InDOS,al ; dont change flags!
  1504. pushf
  1505. or al, al ; If in int 24h, don't
  1506. jnz @F ; reset extended error yet
  1507. cmp LastExtendedError[2],-1 ; Flag to indicate saved status
  1508. je @F
  1509. push dx
  1510. lea dx, LastExtendedError
  1511. mov ax, 5D0Ah
  1512. pushf
  1513. if ROM
  1514. call prevInt21Proc
  1515. else
  1516. call cs:prevInt21Proc
  1517. endif
  1518. mov LastExtendedError[2], -1 ; Forget the status
  1519. pop dx
  1520. @@:
  1521. popf
  1522. pop ax
  1523. pop ds
  1524. UnSetKernelDS
  1525. ret
  1526. rd_Select:
  1527. ReSetKernelDS
  1528. cmp dl, CurDOSDrive ; Setting to current drive?
  1529. jne rd_invalidate ; no, invalidate saved value
  1530. mov al, DOSDrives ; yes, emulate call
  1531. rd_intercepted:
  1532. pop ds ; Return from the DOS call
  1533. UnSetKernelDS
  1534. popf
  1535. jmps rd_after_DOS
  1536. rd_invalidate:
  1537. ReSetKernelDS
  1538. mov CurDOSDrive, 0FFh ; Invalidate saved drive
  1539. jmps rd_no_intercept
  1540. rd_Get:
  1541. ReSetKernelDS
  1542. cmp CurDOSDrive, 0FFh ; Saved drive invalid?
  1543. jne rd_have_drive ; no, return it
  1544. pop ds ; yes, call DOS to get it
  1545. UnSetKernelDS
  1546. ifndef WOW
  1547. ife PMODE32
  1548. FCLI
  1549. endif
  1550. endif
  1551. if ROM
  1552. cCall <far ptr PrevROMInt21Proc>
  1553. else
  1554. call cs:prevInt21Proc
  1555. endif
  1556. push ds
  1557. SetKernelDS
  1558. mov CurDOSDrive, al ; And save it
  1559. jmps rd_after_DOS1
  1560. rd_have_drive:
  1561. ReSetKernelDS
  1562. mov al, CurDOSDrive ; We have the drive, emulate call
  1563. jmps rd_intercepted ; and return
  1564. cEnd nogen
  1565. if ROM ;----------------------------------------------------------------
  1566. ;-----------------------------------------------------------------------;
  1567. ; PrevROMInt21Proc ;
  1568. ; ;
  1569. ; Calls the routine pointed to by the PrevInt21Proc DWORD. Used by ;
  1570. ; ROM Windows kernel to when PrevInt21Proc is not a CS variable, and ;
  1571. ; kernel's DS is not addressable. ;
  1572. ; ;
  1573. ; Arguments: ;
  1574. ; ;
  1575. ; Returns: ;
  1576. ; ;
  1577. ;-----------------------------------------------------------------------;
  1578. cProc PrevROMInt21Proc,<PUBLIC,FAR>
  1579. cBegin nogen
  1580. push ds
  1581. SetKernelDS
  1582. push bp
  1583. mov bp,sp
  1584. push PrevInt21Proc.sel
  1585. push PrevInt21Proc.off
  1586. mov ds,[bp][2]
  1587. UnSetKernelDS
  1588. mov bp,[bp]
  1589. retf 4
  1590. cEnd nogen
  1591. endif ;ROM ---------------------------------------------------------
  1592. ;**
  1593. ;
  1594. ; NoHookDOSCall -- Issue an INT 21 circumventing all Windows Hooks
  1595. ;
  1596. ; This call is provided as a Kernel service to Core routines
  1597. ; which wish to issue DOS INT 21h calls WITHOUT the intervention
  1598. ; of the Windows INT 21h hooks.
  1599. ;
  1600. ; ENTRY:
  1601. ; All registers as for INT 21h
  1602. ;
  1603. ; EXIT:
  1604. ; All registers as for particular INT 21h call
  1605. ;
  1606. ; USES:
  1607. ; As per INT 21h call
  1608. ;
  1609. ;
  1610. cProc NoHookDOSCall,<PUBLIC,FAR>
  1611. cBegin
  1612. call real_DOS
  1613. cEnd
  1614. ;**
  1615. ;
  1616. ; DOS3CALL -- Issue an INT 21 for caller
  1617. ;
  1618. ; This call is provided as a Kernel service to applications that
  1619. ; wish to issue DOS INT 21h calls WITHOUT coding an INT 21h, which
  1620. ; is incompatible with protected mode.
  1621. ;
  1622. ; ENTRY:
  1623. ; All registers as for INT 21h
  1624. ;
  1625. ; EXIT:
  1626. ; All registers as for particular INT 21h call
  1627. ;
  1628. ; USES:
  1629. ; As per INT 21h call
  1630. ;
  1631. ;
  1632. cProc DOS3CALL,<PUBLIC,FAR>
  1633. cBegin nogen
  1634. DOSCALL
  1635. retf
  1636. cEnd nogen
  1637. sEnd CODE
  1638. end