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.

1305 lines
39 KiB

  1. page ,132
  2. title CONTEXT - task event procedures.
  3. .xlist
  4. include gpfix.inc
  5. include kernel.inc
  6. include tdb.inc
  7. include pdb.inc
  8. ifdef WOW
  9. include vint.inc
  10. include wowcmpat.inc
  11. endif
  12. .list
  13. externFP CloseCachedFiles
  14. externFP Int21Handler
  15. externFP Far_real_dos
  16. externFP GlobalAlloc
  17. externFP GlobalFree
  18. externFP GlobalLock
  19. externFP GlobalUnlock
  20. externFP GetAppCompatFlags
  21. ifdef FE_SB
  22. externFP FarMyIsDBCSLeadByte
  23. endif
  24. ifdef WOW
  25. externFP IGetModuleFileName
  26. endif
  27. DataBegin
  28. externB Kernel_Flags
  29. externW cpLowHeap
  30. externW selLowHeap
  31. externW selHighHeap
  32. externW selWoaPdb
  33. externB InScheduler
  34. externB DOS_version
  35. externB DOS_revision
  36. externB lpszFileName
  37. ;externW pGlobalHeap
  38. externW winVer
  39. externW topPDB
  40. externW cur_dos_PDB
  41. externW Win_PDB
  42. externW curTDB
  43. externW WinFlags
  44. externW FileEntrySize
  45. externW shell_file_TDB
  46. externD shell_file_proc
  47. externD ptrace_DLL_entry
  48. externD ptrace_app_entry
  49. externD lpfnToolHelpProc
  50. externD dressed_for_success
  51. externB fTaskSwitchCalled
  52. externW LockTDB
  53. DataEnd
  54. sBegin CODE
  55. assumes ds,NOTHING
  56. assumes cs,CODE
  57. externD pYieldProc
  58. ifndef WOW
  59. externNP Reschedule
  60. externNP DeleteTask
  61. externNP InsertTask
  62. endif ; WOW
  63. ifdef WOW
  64. externFP MyGetAppWOWCompatFlagsEx
  65. endif
  66. ifndef WOW
  67. ;-----------------------------------------------------------------------;
  68. ; WaitEvent ;
  69. ; ;
  70. ; If an event is waiting on taskID, suspend the current task until ;
  71. ; an event is ready. Returns if an event was ready and no reschedule ;
  72. ; occured. Otherwise returns true to indicate a reschedule has occured.;
  73. ; ;
  74. ; Arguments: ;
  75. ; ;
  76. ; Returns: ;
  77. ; ;
  78. ; Error Returns: ;
  79. ; ;
  80. ; Registers Preserved: ;
  81. ; ;
  82. ; Registers Destroyed: ;
  83. ; ;
  84. ; Calls: ;
  85. ; ;
  86. ; History: ;
  87. ; ;
  88. ; Sat Mar 28, 1987 05:13:50p -by- David N. Weise [davidw] ;
  89. ; Wrote it. ;
  90. ;-----------------------------------------------------------------------;
  91. assumes ds, nothing
  92. assumes es, nothing
  93. cProc WaitEvent,<PUBLIC,FAR>,<bx,ds>
  94. parmW taskID
  95. cBegin
  96. push ds
  97. SetKernelDS
  98. cmp LockTDB, 0 ;Do we have a locked task
  99. jne @F ;Yes, we want to be able to reboot
  100. mov fTaskSwitchCalled, 1 ;Tell Reboot VxD that we're scheduling
  101. @@:
  102. pop ds
  103. mov ax,taskID
  104. call GetTaskHandle0
  105. mov ds,ax
  106. xor ax,ax
  107. wait_test:
  108. pushf
  109. FCLI
  110. dec ds:[TDB_nEvents]
  111. jge wait_exit
  112. mov ds:[TDB_nEvents],0
  113. ; go uncritical
  114. pop bx
  115. test bh,02 ; the interrupt flag
  116. jz leave_int_off
  117. FSTI
  118. leave_int_off:
  119. smov es, 0
  120. .386
  121. smov fs, 0
  122. smov gs, 0
  123. .286
  124. push cs
  125. call Reschedule
  126. mov al,-1
  127. jmp wait_test
  128. wait_exit:
  129. pop bx
  130. test bh,02 ; the interrupt flag
  131. jz leave_ints_off
  132. FSTI
  133. leave_ints_off:
  134. cEnd
  135. ;-----------------------------------------------------------------------;
  136. ; DirectedYield ;
  137. ; ;
  138. ; This does a yield and attempts to yield to the specific yo-yo. ;
  139. ; In reschedule is checked the event count of the target task, if ;
  140. ; non-zero then that task is started. Else the task queue is searched ;
  141. ; as normal. ;
  142. ; ;
  143. ; Arguments: ;
  144. ; parmW yield_to ;
  145. ; ;
  146. ; Returns: ;
  147. ; nothing ;
  148. ; ;
  149. ; Error Returns: ;
  150. ; ;
  151. ; Registers Preserved: ;
  152. ; All ;
  153. ; ;
  154. ; Registers Destroyed: ;
  155. ; ;
  156. ; Calls: ;
  157. ; ;
  158. ; History: ;
  159. ; ;
  160. ; Sat Mar 28, 1987 06:14:17p -by- David N. Weise [davidw] ;
  161. ; Fixed it for aaronr. ;
  162. ; ;
  163. ; Fri Feb 06, 1987 00:00:11a -by- David N. Weise [davidw] ;
  164. ; Wrote it for aaronr. ;
  165. ;-----------------------------------------------------------------------;
  166. assumes ds, nothing
  167. assumes es, nothing
  168. cProc DirectedYield,<PUBLIC,FAR>
  169. ; parmW yield_to
  170. cBegin nogen
  171. push bp
  172. mov bp,sp
  173. push ax
  174. push ds
  175. ; get rid of the argument on the stack
  176. mov ax,[bp][2] ; move IP up
  177. xchg [bp][4],ax
  178. xchg [bp][6],ax ; move CS up
  179. SetKernelDS
  180. mov ds,curTDB
  181. assumes ds,nothing
  182. mov ds:[TDB_Yield_to],ax
  183. ;
  184. ; Since this function is used by SendMessage() to switch directly
  185. ; to and from the destination app, we don't want to call USER to recieve
  186. ; any messages, since that causes unnecessary and inefficient recursion.
  187. ;
  188. ifdef DISABLE
  189. cmp ds:[TDB_QUEUE],0
  190. pop ds
  191. pop ax
  192. pop bp
  193. jz dy_OldYield
  194. add sp,2 ; waste the space
  195. jmp cs:pYieldProc ; Jump through CS VARIABLE
  196. else
  197. pop ds
  198. pop ax
  199. pop bp
  200. endif
  201. dy_OldYield:
  202. add sp,2 ; waste the space
  203. jmps OldYield ; If no task queue, do OLD Yield.
  204. cEnd nogen
  205. ;-----------------------------------------------------------------------;
  206. ; Yield ;
  207. ; ;
  208. ; Does what it says. ;
  209. ; ;
  210. ; Arguments: ;
  211. ; ;
  212. ; Returns: ;
  213. ; ;
  214. ; Error Returns: ;
  215. ; ;
  216. ; Registers Preserved: ;
  217. ; ;
  218. ; Registers Destroyed: ;
  219. ; ;
  220. ; Calls: ;
  221. ; ;
  222. ; History: ;
  223. ; ;
  224. ; Sat May 09, 1987 12:21:13p -by- David N. Weise [davidw] ;
  225. ; Added this nifty comment block. ;
  226. ; ;
  227. ; Wed Apr 15, 1987 12:13:00p -by- Raymond E. Ozzie [-iris-] ;
  228. ; Changed Yield to work for tasks that don't ever do an INITAPP, and ;
  229. ; thus don't have a task queue. These are presumably tasks that do ;
  230. ; some sort of background computational activity that don't have a ;
  231. ; window associated with them. ;
  232. ; ;
  233. ;-----------------------------------------------------------------------;
  234. assumes ds, nothing
  235. assumes es, nothing
  236. cProc Yield,<PUBLIC,FAR>
  237. cBegin nogen
  238. push ds
  239. SetKernelDS
  240. mov ds,curTDB
  241. assumes ds, nothing
  242. mov ds:[TDB_Yield_to],0
  243. cmp ds:[TDB_QUEUE],0
  244. pop ds
  245. jz OldYield ; If no task queue, do OLD Yield.
  246. jmp cs:pYieldProc ; Pass to USER Jump through CS VARIABLE
  247. cEnd nogen
  248. assumes ds, nothing
  249. assumes es, nothing
  250. cProc OldYield,<PUBLIC,FAR>,<ds>
  251. cBegin
  252. SetKernelDS
  253. xor ax,ax
  254. cmp InScheduler,al ; can't yield if inside scheduler
  255. jnz yld3 ; just return false
  256. cmp CurTDB,0 ; did it kill itself?
  257. jz @F
  258. mov ds,CurTDB
  259. assumes ds, nothing
  260. inc ds:[TDB_nEvents]
  261. @@: smov es, ax
  262. .386
  263. smov fs, ax
  264. smov gs, ax
  265. .286
  266. push cs
  267. call Reschedule
  268. dec ds:[TDB_nEvents]
  269. mov ax,-1 ; TRUE
  270. yld3:
  271. cEnd
  272. endif ; !WOW
  273. assumes ds, nothing
  274. assumes es, nothing
  275. GetTaskHandle2:
  276. mov bx,sp
  277. mov ax,ss:[bx+8]
  278. mov bx,ss:[bx+6]
  279. jmps GetTaskHandle0
  280. GetTaskHandle1:
  281. mov bx,sp
  282. mov ax,ss:[bx+6]
  283. GetTaskHandle0:
  284. or ax,ax
  285. jnz gt1
  286. SetKernelDS es
  287. mov ax,curTDB
  288. gt1: mov es,ax
  289. assumes es, nothing
  290. ; cmp es:[TDB_sig],TDB_SIGNATURE
  291. ; jne gt2
  292. ret
  293. ;gt2: kerror ERR_TASKID,<GetTaskHandle: Invalid task handle>
  294. ; ret
  295. ifndef WOW
  296. ;;
  297. ;; PostEvent( taskID ) - increment the event counter for a task. Return
  298. ;; false if invalid task handle passed. Otherwise return true, after
  299. ;; setting the scheduler flag that says a new task might be ready to
  300. ;; run.
  301. ;;
  302. assumes ds, nothing
  303. assumes es, nothing
  304. cProc PostEvent,<PUBLIC,FAR>
  305. ; parmW taskID
  306. cBegin nogen
  307. call GetTaskHandle1
  308. inc es:[TDB_nEvents] ; indicate one more event
  309. ret 2
  310. cEnd nogen
  311. endif ; !WOW
  312. ;-------------------------------------------------------
  313. ;
  314. ; Get the Task pull model event queue handle
  315. ;
  316. assumes ds, nothing
  317. assumes es, nothing
  318. cProc GetTaskQueue,<PUBLIC,FAR>
  319. ; parmW taskID
  320. cBegin nogen
  321. call GetTaskHandle1
  322. mov ax,es:[TDB_queue]
  323. ret 2
  324. cEnd nogen
  325. ;-------------------------------------------------------
  326. ;
  327. ; Get the Task pull model event queue handle into DS
  328. ;
  329. assumes ds, nothing
  330. assumes es, nothing
  331. cProc GetTaskQueueDS,<PUBLIC,FAR>
  332. cBegin nogen
  333. SetKernelDS
  334. mov ds,curTDB
  335. assumes ds, nothing
  336. mov ds,ds:[TDB_queue]
  337. ret
  338. cEnd nogen
  339. ;-------------------------------------------------------
  340. ;
  341. ; Get the Task pull model event queue handle into ES
  342. ;
  343. assumes ds, nothing
  344. assumes es, nothing
  345. cProc GetTaskQueueES,<PUBLIC,FAR>
  346. cBegin nogen
  347. SetKernelDS es
  348. mov es,curTDB
  349. assumes es,nothing
  350. mov es,es:[TDB_queue]
  351. ret
  352. cEnd nogen
  353. assumes ds, nothing
  354. assumes es, nothing
  355. cProc SetTaskSignalProc,<PUBLIC,FAR>
  356. ; parmW taskID
  357. ; parmD signalProc
  358. cBegin nogen
  359. mov bx,sp
  360. mov ax,ss:[bx+8]
  361. call GetTaskHandle0
  362. mov ax,ss:[bx+4]
  363. mov dx,ss:[bx+6]
  364. xchg ax,es:[TDB_USignalProc].off
  365. xchg dx,es:[TDB_USignalProc].sel
  366. ret 6
  367. cEnd nogen
  368. ;--------------------------------------------------------
  369. ;
  370. ; Set (and Get) the Task pull model event queue handle
  371. ;
  372. assumes ds, nothing
  373. assumes es, nothing
  374. cProc SetTaskQueue,<PUBLIC,FAR>
  375. ; parmW taskID
  376. ; parmW hQueue
  377. cBegin nogen
  378. call GetTaskHandle2
  379. mov ax,bx
  380. xchg ax,es:[TDB_queue]
  381. ret 4
  382. cEnd nogen
  383. ifndef WOW
  384. ;--------------------------------------------------------
  385. ;
  386. ; Set (and Get) Task Priority
  387. ;
  388. assumes ds, nothing
  389. assumes es, nothing
  390. cProc SetPriority,<PUBLIC,FAR>
  391. ; parmW taskID
  392. ; parmW newPri
  393. cBegin nogen
  394. call GetTaskHandle2
  395. add bl,es:[TDB_priority]
  396. cmp bl,-32
  397. jge stp1
  398. mov bl,-32
  399. stp1: cmp bl,15
  400. jle stp2
  401. mov bl,15
  402. stp2: push bx
  403. mov bh,1 ; put at back of priority queue
  404. cmp es:[TDB_priority],bl ; SetPriority( 0 )?
  405. jne stp3 ; No, continue
  406. mov ax,es ; Yes, is this the current task?
  407. push ds
  408. SetKernelDS
  409. cmp ax,curTDB
  410. pop ds
  411. assumes ds, nothing
  412. je stp4 ; Yes, exit without doing anything
  413. mov bh,0 ; No, put at front of priority queue
  414. stp3:
  415. add bl,bh
  416. mov es:[TDB_priority],bl
  417. push bx
  418. push es
  419. cCall DeleteTask,<es>
  420. cCall InsertTask,<ax>
  421. pop es
  422. pop ax
  423. sub es:[TDB_priority],ah
  424. stp4:
  425. pop ax
  426. cbw
  427. ret 4
  428. cEnd nogen
  429. endif ; WOW - the above code is not required in WOW
  430. ;;
  431. ;; Aaron Reynolds 7/20/87 - Added so folks like USER can ask if this is Winoldap
  432. ;;
  433. ;; IsWinoldapTask( taskID ) - Is this a Winoldap Task?
  434. ;; false if not a Winoldap task, else true
  435. ;; This works by returning the low bit in the Global Heap pointer of the task's
  436. ;; PDB. Nobody in KERNEL sets this bit (it is always initialized to 0). It is
  437. ;; up to WINOLDAP to mark its tasks by setting the low bit itself.
  438. ;;
  439. assumes ds, nothing
  440. assumes es, nothing
  441. cProc IsWinoldapTask,<PUBLIC,FAR>
  442. ; parmW taskID
  443. cBegin nogen
  444. ifdef WOW
  445. xor ax, ax ; always return false
  446. else
  447. call GetTaskHandle1
  448. mov es,es:[TDB_PDB] ; Get PDB pointer from task handle
  449. mov ax,word ptr es:[PDB_GlobalHeap] ; Get low word of Global heap ptr
  450. and ax,0000000000000001B ; Mask to low bit
  451. endif
  452. ret 2
  453. cEnd nogen
  454. ;----------------------------------------------------------------------------;
  455. ; IsTask
  456. ;
  457. ; OLE 1.0 DLLs check whether the task they are talking to is a genuine one
  458. ; or not. This they do by calling IsTask(). So, I look for -1 as the hTask,
  459. ; which was returned from GetWindowTask() as BOGUSGDT for the 32 bit tasks
  460. ; and for the 16 bit tasks a correct value was returned.
  461. ;
  462. ; So, if we find hTask on this function as -1, we should return TRUE to
  463. ; keep OLE DLLs happy.
  464. ;
  465. ; ChandanC Feb 9th 1993.
  466. ;
  467. ;----------------------------------------------------------------------------;
  468. ; Validate a task handle
  469. ; davidds
  470. cProc IsTask,<PUBLIC, FAR>
  471. ; parmW taskID
  472. cBegin nogen
  473. mov bx,sp
  474. mov ax,ss:[bx+4]
  475. or ax,ax
  476. jz IT_err
  477. ifdef WOW
  478. test al, 0100b ; Check for task aliases (see WOLE2.C) or BOGUSGDT
  479. jnz task_check
  480. task_ok:
  481. mov ax, 1
  482. jmp SHORT IT_exit
  483. task_check:
  484. endif
  485. .286p
  486. lsl bx,ax
  487. jnz IT_err
  488. cmp bx,size TDB
  489. jl IT_err
  490. mov es,ax
  491. cmp es:[TDB_sig],TDB_SIGNATURE
  492. jne IT_err
  493. jmp short IT_exit
  494. IT_err:
  495. xor ax,ax
  496. IT_exit:
  497. ret 2
  498. cEnd nogen
  499. ;-----------------------------------------------------------------------;
  500. ; CVW_Hack
  501. ;
  502. ; This is a little hack for the next rev of CVW. This is a cheap
  503. ; way to break into an app just before it really starts up. We
  504. ; call off to the ptrace DLL and then jump off to the real entry
  505. ; point.
  506. ;
  507. ; Entry:
  508. ; none
  509. ;
  510. ; Returns:
  511. ; none
  512. ;
  513. ; Registers Preserved:
  514. ; all
  515. ;
  516. ; Registers Destroyed:
  517. ;
  518. ; History:
  519. ;
  520. ; Mon 27-Feb-1989 20:22:06 -by- David N. Weise [davidw]
  521. ; Wrote it.
  522. ;-----------------------------------------------------------------------;
  523. assumes ds,nothing
  524. assumes es,nothing
  525. cProc CVW_Hack,<PUBLIC,FAR>
  526. cBegin nogen
  527. sub sp, 4
  528. ;** See if we should call the TOOLHELP hook first
  529. push ds
  530. SetKernelDS
  531. test Kernel_Flags[2],KF2_TOOLHELP ;TOOLHELP.DLL?
  532. jz st_NoToolHelp ;Nope
  533. push ax ;Save regs we use
  534. push cx
  535. push bx
  536. push Win_PDB ; Preserve Win_TDB across ToolHelp call
  537. cmp curTDB,0
  538. jz @F
  539. push es
  540. mov es,curTDB
  541. push es:[TDB_PDB]
  542. pop ds:Win_PDB
  543. pop es
  544. @@:
  545. mov ax,SDM_LOADTASK
  546. mov bx,WORD PTR ptrace_app_entry[0] ;Task start address in CX:DX
  547. mov cx,WORD PTR ptrace_app_entry[2]
  548. call lpfnToolHelpProc ;Do it
  549. pop Win_PDB
  550. pop bx
  551. pop cx
  552. pop ax
  553. ;** Since we got here, we know that at least one of the two
  554. ;** (WINDEBUG, TOOLHELP) or both are here. Since we know
  555. ;** TOOLHELP is here, we still need to check for WINDEBUG.
  556. ;** If it's here, act as if TOOLHELP were not
  557. cmp WORD PTR ptrace_DLL_entry[2],0 ;WINDEBUG present?
  558. jnz st_NoToolHelp ;Yes, give it a turn
  559. ;** Since we have no one else to call, simply start the task
  560. ;** Stack: AX[-2] BP[0] DS[2] RETFIP[4] RETFCS[6]
  561. push bp
  562. mov bp,sp
  563. push ax
  564. mov ax,WORD PTR ptrace_app_entry[0] ;Get the IP value
  565. mov [bp + 4],ax ;Put in place of RETFIP
  566. mov ax,WORD PTR ptrace_app_entry[2] ;Get the CS value
  567. mov [bp + 6],ax ;Put in place of RETFCS
  568. pop ax ;Clean up and start up the task
  569. pop bp
  570. pop ds
  571. retf
  572. st_NoToolHelp:
  573. pop ds
  574. add sp, 4
  575. ;** Now call CVW's hook (WINDEBUG.DLL)
  576. push ax
  577. push bx
  578. push cx
  579. push ds
  580. mov bx,ds
  581. SetKernelDS
  582. push ptrace_app_entry.sel ; push real app entry point
  583. push ptrace_app_entry.off
  584. push cs ; push return to return
  585. push codeOffset cvwh_clever
  586. push ptrace_DLL_entry.sel ; push call into ptrace
  587. push ptrace_DLL_entry.off
  588. push ptrace_app_entry.sel
  589. push ptrace_app_entry.off
  590. mov ds,bx
  591. UnsetKernelDS
  592. mov ax,59h
  593. pop bx
  594. pop cx
  595. retf ; 'call' ptrace
  596. cvwh_clever:
  597. mov bx,sp
  598. mov ax,ss:[bx].10
  599. mov cx,ss:[bx].06
  600. mov bx,ss:[bx].08
  601. retf 8 ; return to real entry point
  602. cEnd nogen
  603. ;-----------------------------------------------------------------------;
  604. ; FileCDR_notify
  605. ;
  606. ;
  607. ; Entry:
  608. ;
  609. ; Returns:
  610. ;
  611. ; Registers Destroyed:
  612. ;
  613. ; History:
  614. ; Thu 08-Jun-1989 17:04:49 -by- David N. Weise [davidw]
  615. ; Wrote it!
  616. ;-----------------------------------------------------------------------;
  617. assumes ds,nothing
  618. assumes es,nothing
  619. cProc FileCDR_notify,<PUBLIC,FAR>,<ax,bx,cx,dx,si,di,ds,es>
  620. localW hHunkOMemory
  621. localD lpDestFile
  622. cBegin
  623. mov hHunkOMemory, 0 ; Handle/flag for RENAME
  624. mov SEG_lpDestFile, es
  625. mov OFF_lpDestFile, di
  626. mov si,dx ; DS:SI points to [source] file
  627. SetKernelDS es
  628. cmp word ptr shell_file_proc[2],0
  629. jnz @F
  630. fcdr_no_exitj:
  631. jmp fcdr_no_exit
  632. @@:
  633. mov di,dataOffset lpszFileName ; Where we will copy filename
  634. cmp ah, 56h ; RENAME?
  635. jne fcdr_no_alloc
  636. mov ax, 256 ; Get enough for two filenames
  637. xor bx, bx
  638. mov cx, (GA_SHAREABLE SHL 8)+GA_MOVEABLE+GA_NOCOMPACT+GA_NODISCARD
  639. cCall GlobalAlloc,<cx, bx, ax>
  640. or ax, ax
  641. jz fcdr_no_exitj
  642. mov hHunkOMemory, ax
  643. cCall GlobalLock,<ax>
  644. mov es, dx
  645. UnSetKernelDS es
  646. mov di, ax
  647. mov ah, 56h
  648. fcdr_no_alloc:
  649. cld
  650. push ax ; push arguments to call
  651. push es
  652. push di
  653. cmp byte ptr ds:[si][1],':'
  654. jnz nodrive
  655. ifdef FE_SB
  656. mov al, byte ptr ds:[si][0]
  657. call FarMyIsDBCSLeadByte
  658. jnc nodrive
  659. endif
  660. lodsb
  661. inc si
  662. or al,20h ; convert to lower case
  663. sub al,'a' ; convert to number
  664. jmps gotdrive
  665. nodrive:
  666. mov ah,19h
  667. DOSCALL
  668. gotdrive:
  669. mov dl,al
  670. inc dl
  671. add al,'A' ; convert to ascii
  672. mov ah,':'
  673. stosw
  674. mov bx,'/' shl 8 + '\'
  675. mov al,ds:[si]
  676. cmp al,bh
  677. jz getpath
  678. cmp al,bl
  679. jz getpath
  680. mov al,bl
  681. stosb
  682. mov cx,ds
  683. xchg si,di
  684. smov ds,es
  685. mov ah,47h
  686. DOSCALL
  687. mov ds,cx
  688. xchg si,di
  689. xor al,al
  690. ifdef FE_SB
  691. ; seek pointer to final byte of path.
  692. xor ah,ah ; flag to indicate last char is dbc
  693. bsl_1:
  694. mov al,es:[di]
  695. test al,al ; end of string?
  696. jz bsl_2 ; jump if so
  697. inc di
  698. xor ah,ah
  699. call FarMyIsDBCSLeadByte ; DBC?
  700. jc bsl_1 ; jump if not
  701. inc ah ; indicate 'DBC'
  702. jmp bsl_1
  703. bsl_2:
  704. test ah,ah ; last char is DBC?
  705. jnz getpath ; yes - don't test '\/'
  706. else
  707. mov cx,-1
  708. repnz scasb
  709. dec di
  710. endif
  711. mov al,es:[di-1]
  712. cmp al,bh
  713. je getpath
  714. cmp al,bl
  715. je getpath
  716. mov al,bl
  717. stosb
  718. getpath:
  719. @@: lodsb
  720. or al,al
  721. stosb
  722. jnz @B
  723. cmp hHunkOMemory, 0
  724. jz no_second_file
  725. lds si, lpDestFile ; Tack destination file name
  726. copy_second: ; after source file name
  727. lodsb
  728. stosb
  729. or al, al
  730. jnz copy_second
  731. no_second_file:
  732. SetKernelDS es
  733. if KDEBUG
  734. call shell_file_proc
  735. else ; KDEBUG
  736. ;
  737. ; The call to shell_file_proc can blow up if the variable has not
  738. ; been updated properly, and we generate an invalid call fault.
  739. ;
  740. beg_fault_trap bad_shell_file_proc
  741. call shell_file_proc
  742. jmps good_shell_file_proc
  743. bad_shell_file_proc:
  744. fault_fix_stack
  745. ;
  746. ; If shell_file_proc has a bad non-zero value, then zero it out
  747. ; so USER doesn't get confused.
  748. ;
  749. xor si,si
  750. mov word ptr [shell_file_proc],si
  751. mov word ptr [shell_file_proc+2],si
  752. end_fault_trap
  753. good_shell_file_proc:
  754. endif ; KDEBUG
  755. mov si, hHunkOMemory ; Free up memory if necessary
  756. or si, si
  757. jz fcdr_no_exit
  758. cCall GlobalUnlock,<si>
  759. cCall GlobalFree,<si>
  760. fcdr_no_exit:
  761. cEnd
  762. ;-----------------------------------------------------------------------;
  763. ; InitTask1
  764. ;
  765. ;
  766. ; Entry:
  767. ;
  768. ; Returns:
  769. ;
  770. ; Registers Destroyed:
  771. ;
  772. ; History:
  773. ; Sun 04-Feb-1990 23:47:37 -by- David N. Weise [davidw]
  774. ; Wrote it!
  775. ;-----------------------------------------------------------------------;
  776. assumes ds,nothing
  777. assumes es,nothing
  778. cProc InitTask1,<PUBLIC,FAR>
  779. ; parmD callback
  780. cBegin nogen
  781. mov bx,sp
  782. push ds
  783. SetKernelDS
  784. mov ax,ss:[bx].4
  785. mov dressed_for_success.off,ax
  786. mov ax,ss:[bx].6
  787. mov dressed_for_success.sel,ax
  788. pop ds
  789. ret 4
  790. cEnd nogen
  791. ifdef WOW
  792. ;-----------------------------------------------------------------------;
  793. ; IsTaskLocked ;
  794. ; ;
  795. ; Another hack procedure to determine if the current task is locked. ;
  796. ; A non-NULL value is returned if the task is locked and NULL is ;
  797. ; returned is the task is not locked. ;
  798. ; ;
  799. ; This will always return null, because we will always have more than ;
  800. ; one WOW app. (wowexec is always running ;
  801. ; ;
  802. ; This api is used by QuickC ;
  803. ; - Nanduri ;
  804. ;-----------------------------------------------------------------------;
  805. assumes ds, nothing
  806. assumes es, nothing
  807. cProc IsTaskLocked,<PUBLIC,FAR>
  808. cBegin nogen
  809. xor ax,ax
  810. ret
  811. cEnd nogen
  812. endif ; WOW
  813. assumes ds, nothing
  814. assumes es, nothing
  815. cProc GetVersion,<PUBLIC,FAR>
  816. cBegin nogen
  817. push ds
  818. SetKernelDS
  819. cCall GetAppCompatFlags,<0>
  820. test dx, HIW_GACF_WINVER31
  821. jz gv0
  822. mov ax, 0a03h ; Win ver 3.10 if app hack set
  823. jmps gv1
  824. gv0:
  825. mov ax, 5f03h ; Win ver 3.95
  826. ; mov ax,winVer
  827. ; xchg ah,al
  828. gv1:
  829. mov dh,DOS_version
  830. mov dl,DOS_revision
  831. pop ds
  832. UnSetKernelDS
  833. ret
  834. cEnd nogen
  835. sEnd CODE
  836. sBegin MISCCODE
  837. assumes cs, misccode
  838. assumes ds, nothing
  839. assumes es, nothing
  840. ExternNP MISCMapDStoDATA
  841. ;-----------------------------------------------------------------------;
  842. ;
  843. ; SetErrorMode - set the current task's error mode
  844. ;
  845. ; Entry:
  846. ; parmW errMode 0001h = fail critical errors to app
  847. ; 0002h = don't put up pmode fault message
  848. ; 8000h = don't promt for file in OpenFile
  849. ;
  850. ; Returns:
  851. ; AX = old flags
  852. ;
  853. ; History:
  854. ; Sun 11-Feb-1990 19:01:12 -by- David N. Weise [davidw]
  855. ; Added this nifty comment block.
  856. ;-----------------------------------------------------------------------;
  857. assumes ds, nothing
  858. assumes es, nothing
  859. cProc ISetErrorMode,<PUBLIC,FAR>
  860. parmW errMode
  861. cBegin
  862. cCall MISCMapDStoDATA
  863. ResetKernelDS
  864. mov ax,errMode
  865. mov ds,CurTDB
  866. UnSetKernelDS
  867. xchg ds:[TDB_ErrMode],ax
  868. cEnd
  869. ;-----------------------------------------------------------------------;
  870. ; GetWinFlags
  871. ;
  872. ; Gets the WinFlags for those wimps that can't import
  873. ; __WinFlags properly!
  874. ;
  875. ; Entry:
  876. ; none
  877. ;
  878. ; Returns:
  879. ; AX = WinFlags
  880. ;
  881. ; History:
  882. ; Wed 05-Jul-1989 20:19:46 -by- David N. Weise [davidw]
  883. ; Wrote it!
  884. ;-----------------------------------------------------------------------;
  885. assumes ds,nothing
  886. assumes es,nothing
  887. cProc GetWinFlags,<PUBLIC,FAR>
  888. cBegin nogen
  889. push ds
  890. cCall MISCMapDStoDATA
  891. ResetKernelDS
  892. ; Comment out this app hack since toolbook is no longer hacked...
  893. ; above is from Win95 source, why is toolbook no longer hacked? -DaveHart
  894. xor ax, ax
  895. push ax ; NULL => current task
  896. cCall GetAppCompatFlags
  897. test ax, GACF_HACKWINFLAGS
  898. mov ax,WinFlags
  899. jz @f
  900. ifdef WOW
  901. ; fixes toolbook for WOW -BobDay
  902. ; and ah, not ( WF1_WINNT or WF1_PAGING )
  903. and ah, not WF1_WINNT ; fixes some apps that think they can't run on NT
  904. else
  905. and ah, not WF1_PAGING ; fixes toolbook
  906. endif
  907. @@:
  908. xor dx,dx
  909. pop ds
  910. ret
  911. cEnd nogen
  912. ;--------------------------------------------------------
  913. ;
  914. ; GetExeVersion - return the current task's expected Windows version
  915. ;
  916. assumes ds, nothing
  917. assumes es, nothing
  918. cProc GetExeVersion,<PUBLIC,FAR>
  919. cBegin nogen
  920. push ds
  921. call MISCMapDStoDATA
  922. ReSetKernelDS
  923. mov ds, CurTDB
  924. UnSetKernelDS
  925. mov ax, ds:[TDB_ExpWinVer]
  926. pop ds
  927. ret
  928. cEnd nogen
  929. ifndef WOW
  930. ;-----------------------------------------------------------------------;
  931. ; WinOldApCall ;
  932. ; ;
  933. ; This gives WinOldAp the information it needs to run in Expanded ;
  934. ; Memory. ;
  935. ; ;
  936. ; Arguments: ;
  937. ; none ;
  938. ; ;
  939. ; Returns: ;
  940. ; (Real Mode) ;
  941. ; BX = XMS Handle of segment cache block ;
  942. ; CX = Size (in K bytes) of segment cache block ;
  943. ; DS:SI = pointer to original Int 21h handler ;
  944. ; DI = DOS System File Table Entry size ;
  945. ; ;
  946. ; (Protected Mode) ;
  947. ; AX = Selector to low (lower 640k) heap block ;
  948. ; BX = paragraph count of low heap block ;
  949. ; CX = Selector to high (above 1024k & HMA) heap block ;
  950. ; DX = Selector to fixed low PDB block for WOA use ;
  951. ; DS:SI = pointer to original Int 21h handler ;
  952. ; DI = DOS System File Table Entry size ;
  953. ; ;
  954. ; Error Returns: ;
  955. ; ;
  956. ; Registers Preserved: ;
  957. ; ;
  958. ; Registers Destroyed: ;
  959. ; ;
  960. ; Calls: ;
  961. ; nothing ;
  962. ; ;
  963. ; History: ;
  964. ; ;
  965. ; Wed Mar 25, 1987 03:03:57p -by- David N. Weise [davidw] ;
  966. ; Wrote it. ;
  967. ;-----------------------------------------------------------------------;
  968. assumes ds, nothing
  969. assumes es, nothing
  970. cProc WinOldApCall,<PUBLIC,FAR>
  971. ; parmW func
  972. cBegin nogen
  973. push ds
  974. call MISCMapDStoDATA
  975. ReSetKernelDS
  976. mov bx,sp ; check function code
  977. cmp word ptr ss:[bx+6],0 ; 0 - get WOA info call
  978. jz get_info ; !0 - close cached files call
  979. push Win_PDB ; Save current PDB
  980. cCall CloseCachedFiles,<topPDB> ; close the cached files--really
  981. pop Win_PDB ; 'Set' it back
  982. ;;; mov bx, Win_PDB
  983. ;;; mov ah, 50h ; Reset the PDB
  984. ;;; call far_real_DOS
  985. ;;; mov cur_dos_PDB, bx ; Keep variables in sync
  986. jmps woa_exit ; closes them when passed topPDB
  987. get_info:
  988. mov ax,selLowHeap
  989. mov bx,cpLowHeap
  990. mov cx,selHighHeap
  991. mov dx,selWoaPdb
  992. mov di,FileEntrySize ;DOS version specific SFT entry size
  993. woa_exit:
  994. pop ds
  995. ret 2
  996. cEnd nogen
  997. endif
  998. ;-----------------------------------------------------------------------;
  999. ; RegisterPtrace
  1000. ;
  1001. ; The ptrace engine DLL gets calls on behalf of the KERNEL.
  1002. ;
  1003. ; Entry:
  1004. ;
  1005. ; Returns:
  1006. ;
  1007. ; Registers Destroyed:
  1008. ;
  1009. ; History:
  1010. ; Fri 02-Feb-1990 23:41:54 -by- David N. Weise [davidw]
  1011. ; We'll get this right one of these days.
  1012. ;
  1013. ; Mon 27-Feb-1989 20:22:06 -by- David N. Weise [davidw]
  1014. ; Wrote it!
  1015. ;-----------------------------------------------------------------------;
  1016. assumes ds,nothing
  1017. assumes es,nothing
  1018. cProc RegisterPtrace,<PUBLIC,FAR>
  1019. ; parmD ptrace_proc
  1020. cBegin nogen
  1021. push ds
  1022. call MISCMapDStoDATA
  1023. ReSetKernelDS
  1024. mov bx,sp
  1025. or Kernel_flags[2],KF2_PTRACE
  1026. mov ax,ss:[bx][6]
  1027. mov ptrace_DLL_entry.off,ax
  1028. or ax,ss:[bx][8] ; is there one?
  1029. mov ax,ss:[bx][8]
  1030. mov ptrace_DLL_entry.sel,ax
  1031. jnz rp_done
  1032. ;** If TOOLHELP's still installed, we don't really want to clear the
  1033. ;** flag. If it's unhooked, clear the flag
  1034. test Kernel_flags[2], KF2_TOOLHELP
  1035. jnz rp_done
  1036. and Kernel_flags[2],NOT KF2_PTRACE
  1037. rp_done:
  1038. pop ds
  1039. ret 4
  1040. cEnd nogen
  1041. ;-----------------------------------------------------------------------;
  1042. ; ToolHelpHook
  1043. ;
  1044. ; Allows TOOLHELP.DLL to get PTrace notifications BEFORE the
  1045. ; normal PTrace hook used by WINDEBUG.DLL. The WINDEBUG.DLL
  1046. ; hook is now obsolete and is maintained only for backward
  1047. ; compatibility.
  1048. ;
  1049. ; TOOLHELP calls this function with a valid lpfn or with NULL
  1050. ; when it is ready to unhook.
  1051. ;
  1052. ; July 25, 1991 [jont]
  1053. ;-----------------------------------------------------------------------;
  1054. cProc ToolHelpHook,<PUBLIC,FAR>, <ds,si,di>
  1055. parmD lpfn
  1056. cBegin
  1057. SetKernelDSMisc
  1058. ;** Set/clear the ToolHelp hook installed flag + we also set the
  1059. ;* PTrace flag because the ToolHelp hook is just a new
  1060. ;* PTrace hook. We can only clear it, though, if BOTH PTrace
  1061. ;** hooks are now clear.
  1062. or Kernel_Flags[2],KF2_TOOLHELP OR KF2_PTRACE ;Set the flags
  1063. mov ax,WORD PTR lpfn[0] ;Get the offset
  1064. mov dx,WORD PTR lpfn[2] ; and the selector
  1065. mov bx,ax ;Get a copy to trash
  1066. or bx,dx ;NULL?
  1067. jnz THH_Installed ;No
  1068. and Kernel_Flags[2],NOT KF2_TOOLHELP ;Clear the flag
  1069. cmp WORD PTR ptrace_dll_entry[2],0 ;WINDEBUG.DLL lurking?
  1070. jnz THH_Installed ;Yes, don't clear PTrace flag
  1071. and Kernel_Flags[2],NOT KF2_PTRACE ;Clear the flag
  1072. THH_Installed:
  1073. ;** Install the hook and return the old one
  1074. xchg ax,WORD PTR lpfnToolHelpProc[0]
  1075. xchg dx,WORD PTR lpfnToolHelpProc[2]
  1076. cEnd
  1077. ;-----------------------------------------------------------------------;
  1078. ; FileCDR
  1079. ;
  1080. ; Allows the shell to set a procedure that gets called when
  1081. ; a file or directory is created, moved, or destroyed.
  1082. ;
  1083. ; Entry:
  1084. ; parmD lpNotifyProc call back function
  1085. ;
  1086. ; Returns:
  1087. ; AX != 0 success
  1088. ;
  1089. ; History:
  1090. ; Mon 05-Jun-1989 22:59:33 -by- David N. Weise [davidw]
  1091. ; Wrote it!
  1092. ;-----------------------------------------------------------------------;
  1093. assumes ds,nothing
  1094. assumes es,nothing
  1095. cProc FileCDR,<PUBLIC,FAR>
  1096. ; parmD lpNotifyProc
  1097. cBegin nogen
  1098. mov bx,sp
  1099. push ds
  1100. call MISCMapDStoDATA
  1101. ReSetKernelDS
  1102. mov ax,ss:[bx][6]
  1103. cmp ax,-1 ; is sel == -1, return current
  1104. jne @F ; proc
  1105. mov ax,shell_file_proc.off
  1106. mov dx,shell_file_proc.sel
  1107. jmps fcdr_exit
  1108. @@:
  1109. xchg shell_file_proc.sel,ax
  1110. or ax,ax
  1111. jz @F
  1112. mov cx,curTDB
  1113. cmp cx,shell_file_TDB
  1114. jnz fcdr_error
  1115. @@: mov ax,ss:[bx][4]
  1116. mov shell_file_proc.off,ax
  1117. mov ax,curTDB
  1118. mov shell_file_TDB,ax
  1119. mov ax,1
  1120. jmps fcdr_exit
  1121. fcdr_error:
  1122. xchg shell_file_proc.sel,ax ; replace what was there
  1123. xor ax,ax
  1124. fcdr_exit:
  1125. pop ds
  1126. UnSetKernelDS
  1127. retf 4
  1128. cEnd nogen
  1129. sEnd MISCCODE
  1130. end