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.

584 lines
15 KiB

  1. TITLE KTHUNKS.ASM
  2. PAGE ,132
  3. ;
  4. ; WOW v1.0
  5. ;
  6. ; Copyright (c) 1991, Microsoft Corporation
  7. ;
  8. ; KTHUNKS.ASM
  9. ; Thunks in 16-bit space to route Windows API calls to WOW32
  10. ;
  11. ; History:
  12. ; 02-Apr-1991 Matt Felton (mattfe)
  13. ; Created.
  14. ;
  15. ifndef WINDEBUG
  16. KDEBUG = 0
  17. WDEBUG = 0
  18. else
  19. KDEBUG = 1
  20. WDEBUG = 1
  21. endif
  22. .286p
  23. .xlist
  24. include cmacros.inc
  25. include wow.inc
  26. include wowkrn.inc
  27. .list
  28. externFP WOW16Call
  29. sBegin CODE
  30. assumes CS,CODE
  31. ; Internal WOW Thunks
  32. DKernelThunk WowInitTask ; Task Creation
  33. DKernelThunk WowKillTask,0 ; Task Destruction
  34. DKernelThunk WOWFreeResource
  35. DKernelThunk WowFileRead
  36. DKernelThunk WowFileWrite
  37. DKernelThunk WowFileLSeek
  38. DKernelThunk WowKernelTrace
  39. DKernelThunk WOWOutputDebugString
  40. DKernelThunk WowCursorIconOp
  41. DKernelThunk WowFailedExec,0
  42. DKernelThunk WowCloseComPort
  43. DKernelThunk WowFileOpen
  44. DKernelThunk WowFileClose
  45. DKernelThunk WowIsKnownDLL
  46. DKernelThunk WowDdeFreeHandle
  47. DKernelThunk WowFileGetAttributes
  48. DKernelThunk WowFileGetDateTime
  49. DKernelThunk WowFileLock
  50. DKernelThunk WowFindFirst
  51. DKernelThunk WowFindNext
  52. DKernelThunk WowSetDefaultDrive
  53. DKernelThunk WowGetCurrentDirectory
  54. DKernelThunk WowSetCurrentDirectory
  55. DKernelThunk WowWaitForMsgAndEvent
  56. DKernelThunk WowMsgBox
  57. DKernelThunk WowGetCurrentDate,0
  58. DKernelThunk WowDeviceIOCTL
  59. DKernelThunk WowFileSetAttributes
  60. DKernelThunk WowFileSetDateTime
  61. DKernelThunk WowFileCreate
  62. DKernelThunk WowDosWowInit
  63. DKernelThunk WowCheckUserGdi
  64. DKernelThunk WowPartyByNumber
  65. DKernelThunk GetShortPathName
  66. DKernelThunk FindAndReleaseDib
  67. DKernelThunk WowReserveHtask
  68. DKernelThunk WOWLFNEntry, %(size WOWLFNFRAMEPTR16)
  69. DKernelThunk WowShutdownTimer
  70. DKernelThunk WowTrimWorkingSet, 0
  71. DKernelThunk SetAppCompatFlags
  72. ifdef FE_SB ;Add GetSystemDefaultLangID()
  73. DKernelThunk GetSystemDefaultLangID,0
  74. endif
  75. DKernelThunk TermsrvGetWindowsDir,%(size TERMSRVGETWINDIR16)
  76. ;-----------------------------------------------------------------------;
  77. ; WOWGetNexVdmCommand
  78. ;
  79. ; Returns the Next App Name for the Requested 32 Bit Exec
  80. ;
  81. ; Arguments:
  82. ; FARP lpReturnedString = LPSTR points to the buffer that receives the character strin
  83. ; int nSize = Size of the lpReturnedString buffer
  84. ;
  85. ; Returns:
  86. ; DX:AX = TRUE Success, sting is present
  87. ; DX:AX = NULL, buffer size was not large enough
  88. ;
  89. ; Error Returns:
  90. ;
  91. ; Registers Preserved:
  92. ; Registers Destroyed:
  93. ;
  94. ; Calls:
  95. ;
  96. ; History:
  97. ; Sun Jan 19, 1992 11:00:06a -by- Matthew Felton [MattFe]
  98. ; New API for Multi Tasking Exec by 32 bit app of 16 bit app
  99. ;-----------------------------------------------------------------------;
  100. DKernelThunk WowGetNextVdmCommand
  101. ;-----------------------------------------------------------------------;
  102. ; WowRegisterShellWindowHandle
  103. ;
  104. ; Tells WOW the Windows Handle To Post Messages to For Execing 16 bit
  105. ; apps. (see WOWEXEC and WK32NotifyThread)
  106. ;
  107. ; Arguments:
  108. ; hwndShell = Shell Window Handle
  109. ;
  110. ; Returns:
  111. ; nothing
  112. ;
  113. ; Error Returns:
  114. ;
  115. ; Registers Preserved:
  116. ; Registers Destroyed:
  117. ;
  118. ; Calls:
  119. ;
  120. ; History:
  121. ; thu mar 19, 1992 11:11:06a -by- Matthew Felton [MattFe]
  122. ; New API for Multi Tasking Exec by 32 bit app of 16 bit app
  123. ;-----------------------------------------------------------------------;
  124. DKernelThunk WowRegisterShellWindowHandle
  125. ;-----------------------------------------------------------------------;
  126. ; WOWLoadModule32
  127. ;
  128. ; Loads a module or creates a new instance of an existing module.
  129. ;
  130. ; Arguments:
  131. ; FARP p = name of module or handle of existing module
  132. ; FARP lpPBlock = Parameter Block to pass to CreateTask
  133. ; HWND hwndWinOldAp = hwnd to send WM_USER to when app exits.
  134. ;
  135. ; Returns:
  136. ; AX = 32 if Successful
  137. ;
  138. ; Error Returns:
  139. ; AX = Error from Win32 LoadModule
  140. ;
  141. ; Registers Preserved:
  142. ; Registers Destroyed:
  143. ;
  144. ; Calls:
  145. ;
  146. ; History:
  147. ; Mon 16-Mar-1991 14:19:04 -by- Matthew Felton [mattfe}
  148. ;-----------------------------------------------------------------------;
  149. DKernelThunk WOWLoadModule
  150. ;-----------------------------------------------------------------------;
  151. ; WOWSetIdleHook
  152. ;
  153. ; Calls WK32SetIdleHook For 16 Bit App
  154. ;
  155. ; Arguments:
  156. ; none
  157. ;
  158. ; Returns:
  159. ; AX = 32 if Successful
  160. ;
  161. ; Error Returns:
  162. ; AX = Error from Win32
  163. ;
  164. ; Registers Preserved:
  165. ; Registers Destroyed:
  166. ;
  167. ; Calls:
  168. ;
  169. ; History:
  170. ; Mon 01-Dec-1992 16:30:00 -by- Russ Blake [russbl}
  171. ;-----------------------------------------------------------------------;
  172. DKernelThunk WOWSetIdleHook,0
  173. ;-----------------------------------------------------------------------;
  174. ; WOWQueryPerformanceCounter
  175. ;
  176. ; Calls NTQueryPerformanceCounter For 16 Bit App
  177. ;
  178. ; Arguments:
  179. ; FARP p = name of module or handle of existing module
  180. ; FARP lpPBlock = Parameter Block to pass to CreateTask
  181. ;
  182. ; Returns:
  183. ; AX = 32 if Successful
  184. ;
  185. ; Error Returns:
  186. ; AX = Error from Win32
  187. ;
  188. ; Registers Preserved:
  189. ; Registers Destroyed:
  190. ;
  191. ; Calls:
  192. ;
  193. ; History:
  194. ; Mon 16-Mar-1991 14:19:04 -by- Matthew Felton [mattfe}
  195. ;-----------------------------------------------------------------------;
  196. DKernelThunk WOWQueryPerformanceCounter
  197. ;-----------------------------------------------------------------------;
  198. ; WOWGetFastAddress
  199. ;
  200. ; Calls into WOW32 to determine the address of WOWBopEntry on the 32-bit side.
  201. ;
  202. ; Arguments:
  203. ; none
  204. ;
  205. ; Returns:
  206. ; AX = LOWORD of address
  207. ; DX = HIWORD of address
  208. ;
  209. ; Error Returns:
  210. ; AX = 0
  211. ;
  212. ; Registers Preserved:
  213. ; Registers Destroyed:
  214. ;
  215. ; Calls:
  216. ;
  217. ; History:
  218. ; Mon 16-Mar-1991 14:19:04 -by- Matthew Felton [mattfe}
  219. ;-----------------------------------------------------------------------;
  220. DKernelThunk WOWGetFastAddress, 0
  221. DKernelThunk WOWGetFastCbRetAddress, 0
  222. DKernelThunk WOWGetTableOffsets
  223. ;-----------------------------------------------------------------------;
  224. ; WOWKillRemoteTask
  225. ;
  226. ; Tells the 32-bit thread to die and save its context so that later remote
  227. ; threads can be created to use this context.
  228. ;
  229. ; Arguments:
  230. ; none
  231. ;
  232. ; Returns:
  233. ; Nothing
  234. ;
  235. ; Error Returns:
  236. ; AX = 0
  237. ;
  238. ; Registers Preserved:
  239. ; Registers Destroyed:
  240. ;
  241. ; Calls:
  242. ;
  243. ; History:
  244. ; Mon 16-Mar-1991 14:19:04 -by- Matthew Felton [mattfe}
  245. ;-----------------------------------------------------------------------;
  246. DKernelThunk WOWKillRemoteTask
  247. ;-----------------------------------------------------------------------;
  248. ; WOWNotifyWOW32
  249. ;
  250. ; Tells the 32-bit world some cool stuff about the 16-bit world.
  251. ;
  252. ; Arguments:
  253. ; none
  254. ;
  255. ; Returns:
  256. ; Nothing
  257. ;
  258. ; Error Returns:
  259. ; AX = 0
  260. ;
  261. ; Registers Preserved:
  262. ; Registers Destroyed:
  263. ;
  264. ; Calls:
  265. ;
  266. ; History:
  267. ; Mon 16-Mar-1991 14:19:04 -by- Matthew Felton [mattfe}
  268. ;-----------------------------------------------------------------------;
  269. DKernelThunk WOWNotifyWOW32
  270. DKernelThunk KSYSERRORBOX
  271. DKernelThunk WOWDelFile
  272. DKernelThunk VirtualAlloc
  273. DKernelThunk VirtualFree
  274. DKernelThunk GlobalMemoryStatus
  275. DKernelThunk GetDriveType
  276. DKernelThunk LoadLibraryEx32W
  277. DKernelThunk FreeLibrary32W
  278. DKernelThunk GetProcAddress32W
  279. DKernelThunk GetVDMPointer32W
  280. DKernelThunk ICallProc32W,0
  281. ; 3.1 and earlier kernel APIs which are thunked (not many!)
  282. DKernelThunk Yield,0
  283. DKernelThunk OldYield,0
  284. KernelThunk GetProfileString
  285. KernelThunk GetProfileInt
  286. KernelThunk GetPrivateProfileInt
  287. KernelThunk GetPrivateProfileString
  288. KernelThunk WritePrivateProfileString
  289. KernelThunk WriteProfileString
  290. ; These Thunks Shouldn't be Called - They are Thunked to Trap Them.
  291. DKernelThunk PostEvent
  292. DKernelThunk WaitEvent
  293. DKernelThunk SetPriority
  294. DKernelThunk DirectedYield
  295. DKernelThunk LockCurrentTask
  296. DKernelThunk WriteOutProfiles,0
  297. ;
  298. ; ExitKernel is small wrapper which takes exit status in AX and pushes it
  299. ; for the convenience of ExitKernelThunk, a regular WOW stack-based thunk.
  300. ; The FUN_ aliasing below allows us to generate the thunk with the name
  301. ; ExitKernelThunk while using the arguments and thunk table entry already
  302. ; set up for ExitKernel.
  303. ;
  304. FUN_ExitKernelThunk equ FUN_ExitKernel
  305. DKernelThunk ExitKernelThunk, %(size EXITKERNEL16)
  306. ; FatalExitC is called by FatalExit and takes the same one word parameter
  307. ; indicating fatalexit code.
  308. FUN_FatalExitC equ FUN_FatalExit
  309. DKernelThunk FatalExitC, %(size FATALEXIT16)
  310. ; Thunk for WowGetModuleFileName reuses the GetModuleFileName slot.
  311. FUN_WowGetModuleFileName equ FUN_GetModuleFileName
  312. DKernelThunk WowGetModuleFileName, %(size GetModuleFileName16)
  313. ; Thunk for WowGetModuleHandle reuses the GetModuleHandle slot.
  314. FUN_WowGetModuleHandle equ FUN_GetModuleHandle
  315. DKernelThunk WowGetModuleHandle
  316. ;-----------------------------------------------------------------------;
  317. ; CallProc32W
  318. ;
  319. ; Generic Thunk Routine
  320. ; Transitions to 32 bits and calls specified routine
  321. ;
  322. ; Arguments:
  323. ; Variable number of Parameters for function they want to call
  324. ; up to 32.
  325. ;
  326. ; DWORD fAddressConvert - Bit Field, for 16:16 address Convertion
  327. ; eg (bit 1 means convert parameter 1 from 16:16
  328. ; to flat address before calling routine)
  329. ; DWORD cParams - Number of DWORD parameters (so we can clean the stack
  330. ; and so 32 bit land know how many params to copy to
  331. ; 32 bit stack before call.
  332. ; DWORD lpProcAddress - 32 bit native address to call (use LoadLibraryEx32W
  333. ; and GetProcAddress32W to figure this out).
  334. ;
  335. ; Returns:
  336. ; What ever the API returned on 32 bit side in AX:DX
  337. ;
  338. ; Error Returns:
  339. ; AX = 0, more than 32 parameters.
  340. ;
  341. ; Registers Preserved:
  342. ; Registers Destroyed:
  343. ;
  344. ; History:
  345. ; Mon 12-Mar-1993 14:19:04 -by- Matthew Felton [mattfe}
  346. ;-----------------------------------------------------------------------;
  347. assumes ds,nothing
  348. assumes es,nothing
  349. cProc CallProc32W,<PUBLIC,FAR>
  350. ; PARMD cParams
  351. cBegin nogen
  352. push bp
  353. mov bp,sp
  354. ; Disable CDECL source bit
  355. and word ptr [bp+8],NOT CPEX32_SOURCE_CDECL
  356. cCall ICallProc32W
  357. ; Clean Up Callers Stack to remove Parameters Passed
  358. mov bx, WORD PTR [bp+6] ; get the # of DWORDS this API took
  359. shl bx, 2 ; convert it to offset into aRets table
  360. add bx, codeoffset aRets
  361. pop bp
  362. jmp bx ; dispatch to the right RETF n
  363. CRETENTRIES equ 021h
  364. ; generate the retf n codetable
  365. bytes = 0
  366. REPT CRETENTRIES
  367. IFE bytes
  368. aRets:
  369. ENDIF
  370. retf bytes + 4*3 ; 4*3 - Always
  371. nop
  372. bytes = bytes + 4
  373. ENDM
  374. cEnd
  375. public _CallProcEx32W
  376. _CallProcEx32W PROC FAR
  377. push bp
  378. mov bp,sp
  379. ; Enable CDECL source bit
  380. or word ptr [bp+8],CPEX32_SOURCE_CDECL
  381. cCall ICallProc32W
  382. pop bp
  383. ret
  384. _CallProcEx32W ENDP
  385. ; get the address of the array containing the selector bases
  386. DKernelThunk WOWGetFlatAddressArray, 0
  387. assumes CS,NOTHING
  388. sEnd CODE
  389. ;
  390. ; All the thunks above are in Kernel's primary code segment (IGROUP/TEXT),
  391. ; the ones below are in the second code segment, NRESTEXT.
  392. ;
  393. _NRESTEXT SEGMENT WORD PUBLIC 'CODE'
  394. assumes CS,_NRESTEXT
  395. assumes DS,NOTHING
  396. assumes ES,NOTHING
  397. ;
  398. ; New-for-NT5 thunks for Win95 compatibility. Many of these are unimplemented.
  399. ;
  400. DKernelThunk GetVersionEx
  401. DKernelThunk GetPrivateProfileSectionNames
  402. DKernelThunk CreateDirectory
  403. DKernelThunk RemoveDirectory
  404. DKernelThunk DeleteFile
  405. DKernelThunk SetLastError
  406. DKernelThunk GetLastError,0
  407. DKernelThunk Local32Init
  408. DKernelThunk Local32Alloc
  409. DKernelThunk Local32ReAlloc
  410. DKernelThunk Local32Free
  411. DKernelThunk Local32Translate
  412. DKernelThunk Local32Size
  413. DKernelThunk Local32ValidHandle
  414. KernelThunk RegEnumKey32
  415. KernelThunk RegOpenKey32
  416. KernelThunk RegCreateKey32
  417. KernelThunk RegDeleteKey32
  418. DKernelThunk RegCloseKey32
  419. KernelThunk RegSetValue32
  420. KernelThunk RegDeleteValue32
  421. KernelThunk RegEnumValue32
  422. KernelThunk RegQueryValue32
  423. KernelThunk RegQueryValueEx32
  424. KernelThunk RegSetValueEx32
  425. KernelThunk RegLoadKey32
  426. KernelThunk RegUnloadKey32
  427. KernelThunk RegSaveKey32
  428. DKernelThunk RegFlushKey32
  429. DKernelThunk ComputeObjectOwner
  430. DKernelThunk Local32GetSel
  431. DKernelThunk InvalidateNLSCache,0
  432. DKernelThunk GetProductName
  433. DKernelThunk IsSafeMode,0
  434. DKernelThunk OpenFileEx
  435. DKernelThunk FastAndDirtyGlobalFix
  436. DKernelThunk WritePrivateProfileStruct
  437. DKernelThunk GetPrivateProfileStruct
  438. DKernelThunk GetCurrentDirectory
  439. DKernelThunk SetCurrentDirectory
  440. DKernelThunk FindFirstFile
  441. DKernelThunk FindNextFile
  442. DKernelThunk FindClose
  443. DKernelThunk WritePrivateProfileSection
  444. DKernelThunk WriteProfileSection
  445. DKernelThunk GetPrivateProfileSection
  446. DKernelThunk GetProfileSection
  447. DKernelThunk GetFileAttributes
  448. DKernelThunk SetFileAttributes
  449. DKernelThunk GetDiskFreeSpace
  450. DKernelThunk IsPEFormat
  451. DKernelThunk FileTimeToLocalFileTime
  452. DKernelThunk UniToAnsi
  453. DKernelThunk CreateThread
  454. DKernelThunk LeaveEnterWin16Lock,0
  455. DKernelThunk GetWin16Lock,0
  456. DKernelThunk LoadLibrary32
  457. DKernelThunk GetProcAddress32
  458. DKernelThunk CreateWin32Event
  459. DKernelThunk SetWin32Event
  460. DKernelThunk ResetWin32Event
  461. DKernelThunk WaitForSingleObject
  462. DKernelThunk WaitForMultipleObjects
  463. DKernelThunk GetCurrentThreadID,0
  464. DKernelThunk GetThreadQueue
  465. DKernelThunk SetThreadQueue
  466. DKernelThunk NukeProcess
  467. DKernelThunk ExitProcess
  468. DKernelThunk GetCurrentProcessID,0
  469. DKernelThunk MapHINSTLS,0
  470. DKernelThunk MapHINSTSL,0
  471. DKernelThunk CloseWin32Handle
  472. DKernelThunk LoadSystemLibrary32
  473. DKernelThunk FreeLibrary32
  474. DKernelThunk GetModuleFilename32
  475. DKernelThunk GetModuleHandle32
  476. DKernelThunk RegisterServiceProcess
  477. DKernelThunk InitCB
  478. DKernelThunk GetStdCBLS
  479. DKernelThunk GetStdCBSL
  480. DKernelThunk GetExistingStdCBLS
  481. DKernelThunk GetExistingStdCBSL
  482. DKernelThunk GetFlexCBSL
  483. DKernelThunk GetStdCBLSEx
  484. DKernelThunk GetStdCBSLEx
  485. DKernelThunk Callback2
  486. DKernelThunk Callback4
  487. DKernelThunk Callback6
  488. DKernelThunk Callback8
  489. DKernelThunk Callback10
  490. DKernelThunk Callback12
  491. DKernelThunk Callback14
  492. DKernelThunk Callback16
  493. DKernelThunk Callback18
  494. DKernelThunk Callback20
  495. DKernelThunk Callback22
  496. DKernelThunk Callback24
  497. DKernelThunk Callback26
  498. DKernelThunk Callback28
  499. DKernelThunk Callback30
  500. DKernelThunk Callback32
  501. DKernelThunk Callback34
  502. DKernelThunk Callback36
  503. DKernelThunk Callback38
  504. DKernelThunk Callback40
  505. DKernelThunk Callback42
  506. DKernelThunk Callback44
  507. DKernelThunk Callback46
  508. DKernelThunk Callback48
  509. DKernelThunk Callback50
  510. DKernelThunk Callback52
  511. DKernelThunk Callback54
  512. DKernelThunk Callback56
  513. DKernelThunk Callback58
  514. DKernelThunk Callback60
  515. DKernelThunk Callback62
  516. DKernelThunk Callback64
  517. DKernelThunk WowPassEnvironment
  518. DKernelThunk WowSyncTask
  519. _NRESTEXT ENDS
  520. end