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.

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