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.

1832 lines
59 KiB

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