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.

285 lines
9.5 KiB

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;
  3. ;; Copyright (c) 1998 Microsoft Corporation
  4. ;;
  5. ;; Module Name:
  6. ;;
  7. ;; whcon.tpl
  8. ;;
  9. ;; Abstract:
  10. ;;
  11. ;; This template defines the thunks for the console api set.
  12. ;;
  13. ;; Author:
  14. ;;
  15. ;; 6-Oct-98 mzoran
  16. ;;
  17. ;; Revision History:
  18. ;;
  19. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  20. [Types]
  21. TemplateName=SHAREDINFO
  22. NoType=psi
  23. NoType=aheList
  24. NoType=pDispInfo
  25. NoType=ulSharedDelta
  26. IndLevel=0
  27. Direction=OUT
  28. Locals=
  29. @StructLocal
  30. End=
  31. PreCall=
  32. End=
  33. PostCall=
  34. @StructOUT
  35. @ArgHostName.psi = (_int32)@ArgName.psi; @NL
  36. @ArgHostName.aheList = (_int32)@ArgName.aheList; @NL
  37. @ArgHostName.pDispInfo = (_int32)@ArgName.pDispInfo; @NL
  38. *(UNALIGNED LARGE_INTEGER *)&(@ArgHostName.ulSharedDelta) = *(UNALIGNED LARGE_INTEGER *)&(@ArgName.ulSharedDelta); @NL
  39. End=
  40. TemplateName=CONSOLE_INFO
  41. NoType=InitEvents
  42. IndLevel=0
  43. Direction=IN OUT
  44. Locals=
  45. DWORD eventIndex;
  46. @StructLocal
  47. End=
  48. PreCall=
  49. @StructIN
  50. // @NL
  51. // Thunk InitEvents (pre call) @NL
  52. // @NL
  53. @NL
  54. for (eventIndex = 0 ; eventIndex < NUMBER_OF_INITIALIZATION_EVENTS ; eventIndex++) { @NL
  55. @ArgName.InitEvents [eventIndex] = LongToPtr (@ArgHostName.InitEvents [eventIndex]); @NL
  56. } @NL
  57. End=
  58. PostCall=
  59. @StructOUT
  60. { @NL
  61. // @NL
  62. // Thunk InitEvents (post call) @NL
  63. // @NL
  64. @NL
  65. for (eventIndex = 0 ; eventIndex < NUMBER_OF_INITIALIZATION_EVENTS ; eventIndex++) { @NL
  66. @ArgHostName.InitEvents [eventIndex] = PtrToLong (@ArgName.InitEvents [eventIndex]); @NL
  67. } @NL
  68. } @NL
  69. End=
  70. TemplateName=PCONSOLE_INFO
  71. NoType=InitEvents
  72. IndLevel=0
  73. Direction=IN OUT
  74. Locals=
  75. DWORD eventIndex;
  76. @TypeStructPtrINLocal
  77. End=
  78. PreCall=
  79. @TypeStructPtrINPreCall
  80. // @NL
  81. // Thunk InitEvents (pre call) @NL
  82. // @NL
  83. @NL
  84. for (eventIndex = 0 ; eventIndex < NUMBER_OF_INITIALIZATION_EVENTS ; eventIndex++) { @NL
  85. @ArgName->InitEvents [eventIndex] = LongToPtr (((NT32CONSOLE_INFO *)(UlongToPtr (@ArgHostName)))->InitEvents [eventIndex]); @NL
  86. } @NL
  87. End=
  88. PostCall=
  89. @TypeStructPtrOUTPostCall
  90. // @NL
  91. // Thunk InitEvents (post call) @NL
  92. // @NL
  93. @NL
  94. for (eventIndex = 0 ; eventIndex < NUMBER_OF_INITIALIZATION_EVENTS ; eventIndex++) { @NL
  95. ((NT32CONSOLE_INFO *)UlongToPtr (@ArgHostName))->InitEvents [eventIndex] = PtrToLong ((@ArgName)->InitEvents [eventIndex]); @NL
  96. } @NL
  97. End=
  98. [Macros]
  99. MacroName=CallNameFromApiName
  100. NumArgs=1
  101. Begin=
  102. @ApiName
  103. End=
  104. [EFunc]
  105. TemplateName=UserConnectToServer
  106. NoType=ConnectionInformation
  107. Header=
  108. VOID @NL
  109. NtWow64UserConnectHook( @NL
  110. PVOID ConnectionInformation, @NL
  111. PULONG ConnectionInformationLength); @NL
  112. @NL
  113. End=
  114. Locals=
  115. USERCONNECT userconnect; @NL
  116. ULONG ulConnect; @NL
  117. End=
  118. PreCall=
  119. WOWASSERT(*ConnectionInformationLength == sizeof(NT32USERCONNECT)); @NL
  120. @NL
  121. ulConnect = sizeof(USERCONNECT); @NL
  122. userconnect.ulVersion = ((NT32USERCONNECT*)ConnectionInformationHost)->ulVersion; @NL
  123. @NL
  124. ConnectionInformation = &userconnect; @NL
  125. ConnectionInformationLength = &ulConnect; @NL
  126. End=
  127. PostCall=
  128. Wow64CopyOverSharedMemory(); @NL
  129. if (SUCCEEDED(RetVal)) { @NL @Indent(
  130. WOWASSERT(*ConnectionInformationLength == sizeof(USERCONNECT)); @NL
  131. @ForceType(PostCall, ((USERCONNECT*)ConnectionInformation), ConnectionInformationHost, USERCONNECT*,OUT);
  132. NtWow64UserConnectHook(ConnectionInformation, ConnectionInformationLength); @NL
  133. )} @NL
  134. End=
  135. TemplateName=DeviceEventWorker
  136. PreCall=
  137. // This was a hack put in for the user mode PNP manager. @NL
  138. // Since the PNP manager is going to be a 64bit process and nobody else @NL
  139. // calls this, we have no need for a complex thunk here. @NL
  140. End=
  141. Begin=
  142. @GenUnsupportedNtApiThunk
  143. End=
  144. TemplateName=CreateConsoleScreenBuffer
  145. Locals=
  146. @Types(Locals,lpScreenBufferData,PCONSOLE_GRAPHICS_BUFFER_INFO)
  147. End=
  148. PreCall=
  149. @Types(PreCall,lpScreenBufferData,PCONSOLE_GRAPHICS_BUFFER_INFO)
  150. End=
  151. PostCall=
  152. @Types(PostCall,lpScreenBufferData,PCONSOLE_GRAPHICS_BUFFER_INFO)
  153. End=
  154. [Code]
  155. TemplateName=whcon
  156. CGenBegin=
  157. @NoFormat(
  158. /*
  159. * genthunk generated code: Do Not Modify
  160. * Thunks for console functions.
  161. *
  162. */
  163. #define _WOW64DLLAPI_
  164. #include "nt32.h"
  165. #include "cgenhdr.h"
  166. #include <stdio.h>
  167. #include <stdlib.h>
  168. #include <windef.h>
  169. #include <nt.h>
  170. #include <ntrtl.h>
  171. #include <nturtl.h>
  172. #include <ntosp.h>
  173. #include "wow64thk.h"
  174. #include "wow64t.h"
  175. ASSERTNAME;
  176. #pragma warning(disable : 4311) //Disable pointer truncation warning
  177. #if defined(WOW64DOPROFILE)
  178. #define APIPROFILE(apinum) (ptecon[(apinum)].HitCount++)
  179. #else
  180. #define APIPROFILE(apinum)
  181. #endif
  182. )
  183. @NL
  184. #if defined(WOW64DOPROFILE) @NL
  185. WOW64SERVICE_PROFILE_TABLE_ELEMENT ptecon[] = { @Indent( @NL
  186. @ApiList({L"@ApiName", 0, NULL, TRUE}, @NL)
  187. {NULL, 0, NULL, FALSE} @NL
  188. )};@NL
  189. @NL
  190. @NL
  191. WOW64SERVICE_PROFILE_TABLE ptcon = {L"WHCON", L"CSRSS Thunks", ptecon,
  192. (sizeof(ptecon)/sizeof(WOW64SERVICE_PROFILE_TABLE_ELEMENT))-1}; @NL
  193. #endif @NL
  194. @NoFormat(
  195. LONG lConnectedToCsr = (LONG)FALSE;
  196. HANDLE
  197. Wow64GetConsoleHandle(
  198. VOID
  199. )
  200. {
  201. PPEB32 peb32;
  202. PRTL_USER_PROCESS_PARAMETERS32 params;
  203. peb32 = (PPEB32)NtCurrentTeb32()->ProcessEnvironmentBlock;
  204. params = (PRTL_USER_PROCESS_PARAMETERS32)peb32->ProcessParameters;
  205. return (HANDLE)params->ConsoleHandle;
  206. }
  207. VOID
  208. Wow64SetConsoleHandle(
  209. HANDLE hHandle
  210. )
  211. {
  212. PPEB32 peb32;
  213. PRTL_USER_PROCESS_PARAMETERS32 params;
  214. peb32 = (PPEB32)NtCurrentTeb32()->ProcessEnvironmentBlock;
  215. params = (PRTL_USER_PROCESS_PARAMETERS32)peb32->ProcessParameters;
  216. params->ConsoleHandle = HandleToUlong(hHandle);
  217. }
  218. VOID
  219. Wow64SetLastError(
  220. DWORD dwError
  221. )
  222. {
  223. NtCurrentTeb32()->LastErrorValue = NtCurrentTeb()->LastErrorValue = (LONG)dwError;
  224. }
  225. VOID
  226. Wow64CopyOverSharedMemory(
  227. VOID
  228. )
  229. {
  230. LONG lOldValue;
  231. // BUG, BUG really need to used interlockedexchange here.
  232. lOldValue = lConnectedToCsr;
  233. lConnectedToCsr = (LONG)TRUE;
  234. if (!lOldValue) {
  235. // Copy setting from 64Bit PEB to the 32Bit PEB @NL
  236. PPEB32 peb32 = (PPEB32)(NtCurrentTeb32()->ProcessEnvironmentBlock); @NL
  237. peb32->ReadOnlySharedMemoryBase = PtrToUlong(NtCurrentPeb()->ReadOnlySharedMemoryBase); @NL
  238. peb32->ReadOnlySharedMemoryHeap = PtrToUlong(NtCurrentPeb()->ReadOnlySharedMemoryHeap); @NL
  239. peb32->ReadOnlyStaticServerData = PtrToUlong(NtCurrentPeb()->ReadOnlyStaticServerData); @NL
  240. }
  241. }
  242. )
  243. @Template(Thunks)
  244. @NL
  245. // Each of the CSR NT APIs has different return values for error cases. @NL
  246. // Since no standard exists, a case list is needed.
  247. @NL
  248. // Not used. @NL
  249. #define WOW64_DEFAULT_ERROR_ACTION ApiErrorNTSTATUS @NL
  250. @NL
  251. // This parameter is unused. @NL
  252. #define WOW64_DEFAULT_ERROR_PARAM 0 @NL
  253. @NL
  254. // A case list is needed for these APIs. @NL
  255. extern WOW64_SERVICE_ERROR_CASE sdwhconErrorCase[]; @NL
  256. #define WOW64_API_ERROR_CASES sdwhconErrorCase @NL @NL
  257. @GenDispatchTable(sdwhcon)
  258. @NL
  259. CGenEnd=