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.

413 lines
8.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 srvsxs.c
  202. //
  203. union _BASE_SRV_SXS_STREAM_UNION_WITH_VTABLE;
  204. typedef union _BASE_SRV_SXS_STREAM_UNION_WITH_VTABLE* PBASE_SRV_SXS_STREAM_UNION_WITH_VTABLE;
  205. NTSTATUS
  206. BaseSrvSxsInit(
  207. IN PBASE_STATIC_SERVER_DATA pStaticServerData
  208. );
  209. ULONG
  210. BaseSrvSxsCreateActivationContext(
  211. IN OUT PCSR_API_MSG m,
  212. IN OUT PCSR_REPLY_STATUS ReplyStatus
  213. );
  214. NTSTATUS
  215. BaseSrvSxsGetActivationContextGenerationFunction(
  216. OUT PSXS_GENERATE_ACTIVATION_CONTEXT_FUNCTION* Function,
  217. OUT PDWORD_PTR Cookie
  218. );
  219. NTSTATUS
  220. BaseSrvSxsReleaseActivationContextGenerationFunction(
  221. IN DWORD_PTR Cookie
  222. );
  223. NTSTATUS
  224. BaseSrvSxsCreateProcess(
  225. HANDLE CsrClientProcess,
  226. HANDLE NewProcess,
  227. IN OUT PCSR_API_MSG CsrMessage,
  228. PPEB NewProcessPeb
  229. );
  230. struct _BASE_SRV_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT;
  231. typedef struct _BASE_SRV_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT {
  232. HANDLE Section;
  233. const UNICODE_STRING ProcessorArchitectureString;
  234. const ULONG ProcessorArchitecture;
  235. } BASE_SRV_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT, *PBASE_SRV_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT;
  236. NTSTATUS
  237. BaseSrvSxsInvalidateSystemDefaultActivationContextCache(
  238. VOID
  239. );
  240. NTSTATUS
  241. BaseSrvSxsGetCachedSystemDefaultActivationContext(
  242. IN USHORT ProcessorArchitecture,
  243. OUT PBASE_SRV_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT *SystemDefaultActivationContext
  244. );
  245. NTSTATUS
  246. BaseSrvSxsCreateMemoryStream(
  247. HANDLE CsrClientProcess,
  248. IN PCBASE_MSG_SXS_STREAM MsgStream,
  249. OUT PBASE_SRV_SXS_STREAM_UNION_WITH_VTABLE StreamUnion,
  250. const IID* IIDStream,
  251. OUT PVOID* OutIStream
  252. );
  253. NTSTATUS
  254. BaseSrvSxsDoSystemDefaultActivationContext(
  255. USHORT ProcessorArchitecture,
  256. HANDLE NewProcess,
  257. PPEB NewPeb
  258. );
  259. // validates pointers
  260. ULONG
  261. BaseSrvSxsCreateActivationContextFromMessage(
  262. IN OUT PCSR_API_MSG m,
  263. IN OUT PCSR_REPLY_STATUS ReplyStatus
  264. );
  265. // assumes pointers are valid
  266. NTSTATUS
  267. BaseSrvSxsCreateActivationContextFromStruct(
  268. HANDLE CsrClientProcess,
  269. HANDLE SxsClientProcess,
  270. IN OUT PBASE_SXS_CREATE_ACTIVATION_CONTEXT_MSG Struct,
  271. OUT HANDLE* OutSection OPTIONAL
  272. );
  273. NTSTATUS
  274. BaseSrvSxsMapViewOfSection(
  275. OUT PVOID* Address,
  276. IN HANDLE Process,
  277. IN HANDLE Section,
  278. IN ULONGLONG Offset,
  279. IN SIZE_T Size,
  280. IN ULONG Protect,
  281. IN ULONG AllocationType
  282. );
  283. NTSTATUS
  284. BaseSrvSxsValidateMessageStrings(
  285. IN CONST CSR_API_MSG* Message,
  286. IN ULONG NumberOfStrings,
  287. IN CONST PCUNICODE_STRING* Strings
  288. );
  289. #define MEDIUM_PATH (64)
  290. PVOID BaseSrvSharedHeap;
  291. ULONG BaseSrvSharedTag;
  292. #define MAKE_SHARED_TAG( t ) (RTL_HEAP_MAKE_TAG( BaseSrvSharedTag, t ))
  293. #define INIT_TAG 0
  294. #define INI_TAG 1
  295. PVOID BaseSrvHeap;
  296. ULONG BaseSrvTag;
  297. #define MAKE_TAG( t ) (RTL_HEAP_MAKE_TAG( BaseSrvTag, t ))
  298. #define TMP_TAG 0
  299. #define VDM_TAG 1
  300. #define SXS_TAG 2
  301. #include <vdmapi.h>
  302. #include "srvvdm.h"
  303. #include "basevdm.h"
  304. #include <stdio.h>
  305. #include "winnlsp.h"
  306. extern HANDLE BaseSrvKernel32DllHandle;
  307. extern PGET_NLS_SECTION_NAME pGetNlsSectionName;
  308. extern PGET_DEFAULT_SORTKEY_SIZE pGetDefaultSortkeySize;
  309. extern PGET_LINGUIST_LANG_SIZE pGetLinguistLangSize;
  310. extern PVALIDATE_LOCALE pValidateLocale;
  311. extern PVALIDATE_LCTYPE pValidateLCType;
  312. extern POPEN_DATA_FILE pOpenDataFile;
  313. extern PNLS_CONVERT_INTEGER_TO_STRING pNlsConvertIntegerToString;
  314. typedef LANGID (WINAPI* PGET_USER_DEFAULT_LANG_ID)(VOID);
  315. extern PGET_USER_DEFAULT_LANG_ID pGetUserDefaultLangID;
  316. extern PGET_CP_FILE_NAME_FROM_REGISTRY pGetCPFileNameFromRegistry;
  317. extern PCREATE_NLS_SECURITY_DESCRIPTOR pCreateNlsSecurityDescriptor;
  318. NTSTATUS
  319. BaseSrvDelayLoadKernel32(
  320. VOID
  321. );
  322. extern UNICODE_STRING BaseSrvSxsDllPath;
  323. #define BASESRV_UNLOAD_SXS_DLL DBG