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.

445 lines
9.2 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. basesrv.h
  5. Abstract:
  6. This is the main include file for the Windows 32-bit Base API Server
  7. DLL.
  8. Author:
  9. Steve Wood (stevewo) 10-Oct-1990
  10. Revision History:
  11. --*/
  12. //
  13. // Include Common Definitions.
  14. //
  15. #include "nt.h"
  16. #include "ntrtl.h"
  17. #include "nturtl.h"
  18. #include "ntos.h"
  19. #include <base.h>
  20. //
  21. // Include server definitions for CSR
  22. //
  23. #include "ntcsrsrv.h"
  24. //
  25. // Include message definitions for communicating between client and server
  26. // portions of the Base portion of the Windows subsystem
  27. //
  28. #include "basemsg.h"
  29. #include "sxsapi.h"
  30. //
  31. //
  32. // WX86 needs to be enabled on the server side, since it
  33. // may be enabled in a 32bit dll such as kernel32.dll
  34. // that reads from the csrss shared memory.
  35. #if defined(_AXP64_) && !defined(WX86)
  36. #define WX86 1
  37. #endif
  38. //
  39. // Routines and data defined in srvinit.c
  40. //
  41. UNICODE_STRING BaseSrvWindowsDirectory;
  42. UNICODE_STRING BaseSrvWindowsSystemDirectory;
  43. #if defined(WX86)
  44. UNICODE_STRING BaseSrvWindowsSys32x86Directory;
  45. #endif
  46. PBASE_STATIC_SERVER_DATA BaseSrvpStaticServerData;
  47. NTSTATUS
  48. ServerDllInitialization(
  49. PCSR_SERVER_DLL LoadedServerDll
  50. );
  51. NTSTATUS
  52. BaseClientConnectRoutine(
  53. IN PCSR_PROCESS Process,
  54. IN OUT PVOID ConnectionInfo,
  55. IN OUT PULONG ConnectionInfoLength
  56. );
  57. VOID
  58. BaseClientDisconnectRoutine(
  59. IN PCSR_PROCESS Process
  60. );
  61. ULONG
  62. BaseSrvDefineDosDevice(
  63. IN OUT PCSR_API_MSG m,
  64. IN OUT PCSR_REPLY_STATUS ReplyStatus
  65. );
  66. //
  67. // Routines defined in srvbeep.c
  68. //
  69. NTSTATUS
  70. BaseSrvInitializeBeep( VOID );
  71. ULONG
  72. BaseSrvBeep(
  73. IN OUT PCSR_API_MSG m,
  74. IN OUT PCSR_REPLY_STATUS ReplyStatus
  75. );
  76. //
  77. // Routines defined in srvtask.c
  78. //
  79. typedef BOOL (*PFNNOTIFYPROCESSCREATE)(DWORD,DWORD,DWORD,DWORD);
  80. extern PFNNOTIFYPROCESSCREATE UserNotifyProcessCreate;
  81. WORD BaseSrvGetTempFileUnique;
  82. ULONG
  83. BaseSrvCreateProcess(
  84. IN OUT PCSR_API_MSG m,
  85. IN OUT PCSR_REPLY_STATUS ReplyStatus
  86. );
  87. ULONG
  88. BaseSrvDebugProcess(
  89. IN OUT PCSR_API_MSG m,
  90. IN OUT PCSR_REPLY_STATUS ReplyStatus
  91. );
  92. ULONG
  93. BaseSrvDebugProcessStop(
  94. IN OUT PCSR_API_MSG m,
  95. IN OUT PCSR_REPLY_STATUS ReplyStatus
  96. );
  97. ULONG
  98. BaseSrvExitProcess(
  99. IN OUT PCSR_API_MSG m,
  100. IN OUT PCSR_REPLY_STATUS ReplyStatus
  101. );
  102. ULONG
  103. BaseSrvCreateThread(
  104. IN OUT PCSR_API_MSG m,
  105. IN OUT PCSR_REPLY_STATUS ReplyStatus
  106. );
  107. ULONG
  108. BaseSrvGetTempFile(
  109. IN OUT PCSR_API_MSG m,
  110. IN OUT PCSR_REPLY_STATUS ReplyStatus
  111. );
  112. ULONG
  113. BaseSrvSetProcessShutdownParam(
  114. IN OUT PCSR_API_MSG m,
  115. IN OUT PCSR_REPLY_STATUS ReplyStatus
  116. );
  117. ULONG
  118. BaseSrvGetProcessShutdownParam(
  119. IN OUT PCSR_API_MSG m,
  120. IN OUT PCSR_REPLY_STATUS ReplyStatus
  121. );
  122. ULONG
  123. BaseSrvRegisterThread(
  124. IN OUT PCSR_API_MSG m,
  125. IN OUT PCSR_REPLY_STATUS ReplyStatus
  126. );
  127. //
  128. // Routines defined in srvnls.c
  129. //
  130. NTSTATUS
  131. BaseSrvNLSInit(
  132. PBASE_STATIC_SERVER_DATA pStaticServerData
  133. );
  134. NTSTATUS
  135. BaseSrvNlsConnect(
  136. PCSR_PROCESS Process,
  137. PVOID pConnectionInfo,
  138. PULONG pConnectionInfoLength
  139. );
  140. NTSTATUS
  141. BaseSrvNlsGetUserInfo(
  142. IN OUT PCSR_API_MSG m,
  143. IN OUT PCSR_REPLY_STATUS ReplyStatus
  144. );
  145. ULONG
  146. BaseSrvNlsSetUserInfo(
  147. IN OUT PCSR_API_MSG m,
  148. IN OUT PCSR_REPLY_STATUS ReplyStatus
  149. );
  150. ULONG
  151. BaseSrvNlsSetMultipleUserInfo(
  152. IN OUT PCSR_API_MSG m,
  153. IN OUT PCSR_REPLY_STATUS ReplyStatus
  154. );
  155. ULONG
  156. BaseSrvNlsCreateSection(
  157. IN OUT PCSR_API_MSG m,
  158. IN OUT PCSR_REPLY_STATUS ReplyStatus
  159. );
  160. ULONG
  161. BaseSrvNlsUpdateCacheCount(
  162. IN OUT PCSR_API_MSG m,
  163. IN OUT PCSR_REPLY_STATUS ReplyStatus);
  164. //
  165. // Routines defined in srvini.c
  166. //
  167. NTSTATUS
  168. BaseSrvInitializeIniFileMappings(
  169. PBASE_STATIC_SERVER_DATA StaticServerData
  170. );
  171. ULONG
  172. BaseSrvRefreshIniFileMapping(
  173. IN OUT PCSR_API_MSG m,
  174. IN OUT PCSR_REPLY_STATUS ReplyStatus
  175. );
  176. //
  177. // Terminal Server specific defines
  178. //
  179. #define GLOBAL_SYM_LINK L"Global"
  180. #define LOCAL_SYM_LINK L"Local"
  181. #define SESSION_SYM_LINK L"Session"
  182. ULONG
  183. BaseSrvSetTermsrvAppInstallMode(
  184. IN OUT PCSR_API_MSG m,
  185. IN OUT PCSR_REPLY_STATUS ReplyStatus
  186. );
  187. ULONG
  188. BaseSrvSetTermsrvClientTimeZone(
  189. IN PCSR_API_MSG m,
  190. IN OUT PCSR_REPLY_STATUS ReplyStatus
  191. );
  192. //
  193. // Routines defined in srvaccess.c
  194. //
  195. ULONG
  196. BaseSrvSoundSentryNotification(
  197. IN OUT PCSR_API_MSG m,
  198. IN OUT PCSR_REPLY_STATUS ReplyStatus
  199. );
  200. //
  201. // Routines defined in srvcmpat.c
  202. //
  203. NTSTATUS
  204. BaseSrvCheckApplicationCompatibility(
  205. IN OUT PCSR_API_MSG m,
  206. IN OUT PCSR_REPLY_STATUS ReplyStatus
  207. );
  208. NTSTATUS
  209. BaseSrvDelayLoadApphelp(
  210. VOID
  211. );
  212. typedef BOOL
  213. (STDAPICALLTYPE *PFNCheckRunApp)(
  214. IN HANDLE FIleHandle,
  215. IN LPCWSTR lpApplicationName,
  216. IN PVOID pEnvironment,
  217. IN USHORT ExeType,
  218. IN OUT PDWORD pdwCacheCookie,
  219. OUT PVOID* ppAppCompatData,
  220. OUT PDWORD pcbAppCompatData,
  221. OUT PVOID* ppSxsData,
  222. OUT PDWORD pcbSxsData,
  223. OUT PDWORD pdwFusionFlags
  224. );
  225. extern PFNCheckRunApp pfnCheckRunApp;
  226. //
  227. // Routines defined in srvsxs.c
  228. //
  229. union _BASE_SRV_SXS_STREAM_UNION_WITH_VTABLE;
  230. typedef union _BASE_SRV_SXS_STREAM_UNION_WITH_VTABLE* PBASE_SRV_SXS_STREAM_UNION_WITH_VTABLE;
  231. NTSTATUS
  232. BaseSrvSxsInit(
  233. VOID
  234. );
  235. ULONG
  236. BaseSrvSxsCreateActivationContext(
  237. IN OUT PCSR_API_MSG m,
  238. IN OUT PCSR_REPLY_STATUS ReplyStatus
  239. );
  240. NTSTATUS
  241. BaseSrvSxsGetActivationContextGenerationFunction(
  242. OUT PSXS_GENERATE_ACTIVATION_CONTEXT_FUNCTION* Function,
  243. OUT PDWORD_PTR Cookie
  244. );
  245. NTSTATUS
  246. BaseSrvSxsReleaseActivationContextGenerationFunction(
  247. IN DWORD_PTR Cookie
  248. );
  249. NTSTATUS
  250. BaseSrvSxsCreateProcess(
  251. HANDLE CsrClientProcess,
  252. HANDLE NewProcess,
  253. IN OUT PCSR_API_MSG CsrMessage,
  254. PPEB NewProcessPeb
  255. );
  256. struct _BASE_SRV_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT;
  257. typedef struct _BASE_SRV_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT {
  258. HANDLE Section;
  259. const UNICODE_STRING ProcessorArchitectureString;
  260. const ULONG ProcessorArchitecture;
  261. } BASE_SRV_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT, *PBASE_SRV_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT;
  262. NTSTATUS
  263. BaseSrvSxsInvalidateSystemDefaultActivationContextCache(
  264. VOID
  265. );
  266. NTSTATUS
  267. BaseSrvSxsGetCachedSystemDefaultActivationContext(
  268. IN USHORT ProcessorArchitecture,
  269. OUT PBASE_SRV_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT *SystemDefaultActivationContext
  270. );
  271. NTSTATUS
  272. BaseSrvSxsCreateMemoryStream(
  273. HANDLE CsrClientProcess,
  274. IN PCBASE_MSG_SXS_STREAM MsgStream,
  275. OUT PBASE_SRV_SXS_STREAM_UNION_WITH_VTABLE StreamUnion,
  276. const IID* IIDStream,
  277. OUT PVOID* OutIStream
  278. );
  279. NTSTATUS
  280. BaseSrvSxsDoSystemDefaultActivationContext(
  281. USHORT ProcessorArchitecture,
  282. HANDLE NewProcess,
  283. PPEB NewPeb
  284. );
  285. // validates pointers
  286. ULONG
  287. BaseSrvSxsCreateActivationContextFromMessage(
  288. IN OUT PCSR_API_MSG m,
  289. IN OUT PCSR_REPLY_STATUS ReplyStatus
  290. );
  291. // assumes pointers are valid
  292. NTSTATUS
  293. BaseSrvSxsCreateActivationContextFromStruct(
  294. HANDLE CsrClientProcess,
  295. HANDLE SxsClientProcess,
  296. IN OUT PBASE_SXS_CREATE_ACTIVATION_CONTEXT_MSG Struct,
  297. OUT HANDLE* OutSection OPTIONAL
  298. );
  299. NTSTATUS
  300. BaseSrvSxsMapViewOfSection(
  301. OUT PVOID* Address,
  302. IN HANDLE Process,
  303. IN HANDLE Section,
  304. IN ULONGLONG Offset,
  305. IN SIZE_T Size,
  306. IN ULONG Protect,
  307. IN ULONG AllocationType
  308. );
  309. NTSTATUS
  310. BaseSrvSxsValidateMessageStrings(
  311. IN CONST CSR_API_MSG* Message,
  312. IN ULONG NumberOfStrings,
  313. IN CONST PCUNICODE_STRING* Strings
  314. );
  315. #define MEDIUM_PATH (64)
  316. PVOID BaseSrvSharedHeap;
  317. ULONG BaseSrvSharedTag;
  318. #define MAKE_SHARED_TAG( t ) (RTL_HEAP_MAKE_TAG( BaseSrvSharedTag, t ))
  319. #define INIT_TAG 0
  320. #define INI_TAG 1
  321. PVOID BaseSrvHeap;
  322. ULONG BaseSrvTag;
  323. #define MAKE_TAG( t ) (RTL_HEAP_MAKE_TAG( BaseSrvTag, t ))
  324. #define TMP_TAG 0
  325. #define VDM_TAG 1
  326. #define SXS_TAG 2
  327. #include <vdmapi.h>
  328. #include "srvvdm.h"
  329. #include "basevdm.h"
  330. #include <stdio.h>
  331. #include "winnlsp.h"
  332. extern HANDLE BaseSrvKernel32DllHandle;
  333. extern PGET_NLS_SECTION_NAME pGetNlsSectionName;
  334. extern PGET_DEFAULT_SORTKEY_SIZE pGetDefaultSortkeySize;
  335. extern PGET_LINGUIST_LANG_SIZE pGetLinguistLangSize;
  336. extern PVALIDATE_LOCALE pValidateLocale;
  337. extern PVALIDATE_LCTYPE pValidateLCType;
  338. extern POPEN_DATA_FILE pOpenDataFile;
  339. extern PNLS_CONVERT_INTEGER_TO_STRING pNlsConvertIntegerToString;
  340. typedef LANGID (WINAPI* PGET_USER_DEFAULT_LANG_ID)(VOID);
  341. extern PGET_USER_DEFAULT_LANG_ID pGetUserDefaultLangID;
  342. extern PGET_CP_FILE_NAME_FROM_REGISTRY pGetCPFileNameFromRegistry;
  343. extern PCREATE_NLS_SECURITY_DESCRIPTOR pCreateNlsSecurityDescriptor;
  344. NTSTATUS
  345. BaseSrvDelayLoadKernel32(
  346. VOID
  347. );
  348. extern UNICODE_STRING BaseSrvSxsDllPath;
  349. #define BASESRV_UNLOAD_SXS_DLL DBG