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.

509 lines
10 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996.
  5. //
  6. // clsid.hxx
  7. //
  8. //--------------------------------------------------------------------------
  9. #ifndef __CLSID_HXX__
  10. #define __CLSID_HXX__
  11. // For LookupClsidData, CClsidData::Load Option parameter.
  12. // Note that LOAD_APPID skips the check in CClsidData::Load() to screen
  13. // against COM+ library aps. In the legacy case, VB sometimes loads a library
  14. // app with CoRegisterClassObject() for debugging, so, we have to let that
  15. // work.
  16. #define LOAD_NORMAL 0
  17. #define LOAD_APPID 1
  18. // _ServerTypes values
  19. #define SERVERTYPE_NONE 0
  20. #define SERVERTYPE_EXE32 1
  21. #define SERVERTYPE_SERVICE 2
  22. #define SERVERTYPE_SURROGATE 3
  23. #define SERVERTYPE_EXE16 4
  24. #define SERVERTYPE_INPROC32 5
  25. // NOTE: Both of following are dllhost.exe but complus
  26. // is more specific
  27. #define SERVERTYPE_COMPLUS 6
  28. #define SERVERTYPE_DLLHOST 7
  29. // A COM+ app configured to be an NT service
  30. #define SERVERTYPE_COMPLUS_SVC 8
  31. class CClsidData;
  32. class CAppidData;
  33. HRESULT
  34. LookupClsidData(
  35. IN GUID & Clsid,
  36. IN IComClassInfo* pComClassInfo,
  37. IN CToken * pToken,
  38. IN DWORD Option,
  39. IN OUT CClsidData **ppClsidData
  40. );
  41. HRESULT
  42. LookupAppidData(
  43. IN GUID & AppidGuid,
  44. IN CToken * pToken,
  45. IN DWORD Option,
  46. OUT CAppidData ** ppAppidData
  47. );
  48. class CAppidData
  49. {
  50. public:
  51. CAppidData(
  52. IN WCHAR * pwszAppid,
  53. IN CToken * pToken
  54. );
  55. ~CAppidData();
  56. HRESULT
  57. Load(
  58. IN DWORD Option
  59. );
  60. HRESULT
  61. Load(
  62. IN IComProcessInfo *pICPI
  63. );
  64. void
  65. Purge();
  66. inline WCHAR *
  67. AppidString()
  68. {
  69. return _wszAppid;
  70. }
  71. inline GUID *
  72. AppidGuid()
  73. {
  74. return &_GuidAppid;
  75. }
  76. inline BOOL
  77. ActivateAtStorage()
  78. {
  79. return _bActivateAtStorage;
  80. }
  81. inline BOOL
  82. ComPlusProcess()
  83. {
  84. // NOTE!!!!:: This is true for normal dllhost.exe regardless of
  85. // whether they are really complus or not. We won't
  86. // distinguish this in here in AppidData but in
  87. // ClsidData
  88. return _bComPlusProcess;
  89. }
  90. inline WCHAR *
  91. RemoteServerNames()
  92. {
  93. return _pwszRemoteServerNames;
  94. }
  95. inline WCHAR *
  96. RunAsUser()
  97. {
  98. return _pwszRunAsUser;
  99. }
  100. inline BOOL
  101. IsInteractiveUser()
  102. {
  103. RunAsType type;
  104. if (FAILED(_pICPI->GetRunAsType(&type)))
  105. return FALSE;
  106. return (type == RunAsInteractiveUser);
  107. }
  108. inline WCHAR *
  109. RunAsDomain()
  110. {
  111. return _pwszRunAsDomain;
  112. }
  113. inline WCHAR *
  114. Service()
  115. {
  116. return _pwszService;
  117. }
  118. inline WCHAR *
  119. ServiceArgs()
  120. {
  121. return _pwszServiceParameters;
  122. }
  123. inline SECURITY_DESCRIPTOR *
  124. LaunchPermission()
  125. {
  126. return _pLaunchPermission;
  127. }
  128. inline BOOL
  129. GetSaferLevel(DWORD *pdwSaferLevel)
  130. {
  131. if (_fSaferLevelValid)
  132. *pdwSaferLevel = _dwSaferLevel;
  133. return _fSaferLevelValid;
  134. }
  135. BOOL
  136. CertifyServer(
  137. IN CProcess * pProcess
  138. );
  139. HANDLE
  140. ServerRegisterEvent();
  141. HANDLE
  142. ServerInitializedEvent();
  143. private:
  144. CToken * _pToken;
  145. WCHAR * _pwszService;
  146. WCHAR * _pwszServiceParameters;
  147. WCHAR * _pwszRunAsUser;
  148. WCHAR * _pwszRunAsDomain;
  149. SECURITY_DESCRIPTOR * _pLaunchPermission;
  150. DWORD _dwSaferLevel;
  151. BOOL _fSaferLevelValid;
  152. BOOL _bActivateAtStorage;
  153. WCHAR * _pwszRemoteServerNames;
  154. BOOL _bComPlusProcess;
  155. WCHAR _wszAppid[GUIDSTR_MAX];
  156. GUID _GuidAppid;
  157. IComProcessInfo* _pICPI;
  158. };
  159. class CClsidData
  160. {
  161. friend class CServerTableEntry;
  162. public:
  163. CClsidData( IN GUID & Clsid, IN CToken * pToken, IN IComClassInfo* );
  164. ~CClsidData();
  165. HRESULT
  166. Load(
  167. IN DWORD Option
  168. );
  169. void
  170. Purge();
  171. inline CToken *
  172. Token()
  173. {
  174. #ifndef _CHICAGO_
  175. return _pToken;
  176. #else
  177. return NULL;
  178. #endif
  179. }
  180. inline GUID *
  181. ClsidGuid()
  182. {
  183. return &_Clsid;
  184. }
  185. inline WCHAR *
  186. AppidString()
  187. {
  188. return _pAppid ? _pAppid->AppidString() : NULL;
  189. }
  190. inline GUID *
  191. AppidGuid()
  192. {
  193. return _pAppid ? _pAppid->AppidGuid() : NULL;
  194. }
  195. inline DWORD
  196. ServerType()
  197. {
  198. return _ServerType;
  199. }
  200. inline BOOL
  201. IsInprocClass()
  202. {
  203. return _bIsInprocClass;
  204. }
  205. inline DWORD
  206. DllThreadModel()
  207. {
  208. return _DllThreadModel;
  209. }
  210. inline WCHAR *
  211. Server()
  212. {
  213. if ((_ServerType == SERVERTYPE_SERVICE) ||
  214. (_ServerType == SERVERTYPE_COMPLUS_SVC))
  215. return _pAppid->Service();
  216. else
  217. return _pwszServer;
  218. }
  219. inline BOOL
  220. ActivateAtStorage()
  221. {
  222. return _pAppid ? _pAppid->ActivateAtStorage() : FALSE;
  223. }
  224. inline BOOL
  225. ComPlusProcess()
  226. {
  227. return (_ServerType == SERVERTYPE_COMPLUS);
  228. }
  229. inline BOOL
  230. DllHostOrComPlusProcess()
  231. {
  232. return (ComPlusProcess() ||
  233. (_ServerType == SERVERTYPE_COMPLUS_SVC) ||
  234. (_ServerType == SERVERTYPE_DLLHOST));
  235. }
  236. inline WCHAR *
  237. DllSurrogate()
  238. {
  239. return _pwszDllSurrogate;
  240. }
  241. inline WCHAR *
  242. RemoteServerNames()
  243. {
  244. return _pAppid ? _pAppid->RemoteServerNames() : 0;
  245. }
  246. inline WCHAR *
  247. RunAsUser()
  248. {
  249. #ifndef _CHICAGO_
  250. return _pAppid ? _pAppid->RunAsUser() : NULL;
  251. #else
  252. return NULL;
  253. #endif
  254. }
  255. inline BOOL
  256. IsInteractiveUser()
  257. {
  258. #ifndef _CHICAGO_
  259. return _pAppid ? _pAppid->IsInteractiveUser() : FALSE;
  260. #else
  261. return FALSE;
  262. #endif
  263. }
  264. inline BOOL
  265. HasRunAs()
  266. {
  267. #ifndef _CHICAGO_
  268. return ((RunAsUser() != 0) || IsInteractiveUser());
  269. #else
  270. return FALSE;
  271. #endif
  272. }
  273. #ifndef _CHICAGO_
  274. inline WCHAR *
  275. RunAsDomain()
  276. {
  277. return _pAppid ? _pAppid->RunAsDomain() : 0;
  278. }
  279. inline WCHAR *
  280. ServiceArgs()
  281. {
  282. return _pAppid ? _pAppid->ServiceArgs() : 0;
  283. }
  284. inline SECURITY_DESCRIPTOR *
  285. LaunchPermission()
  286. {
  287. return _pAppid ? _pAppid->LaunchPermission() : 0;
  288. }
  289. inline SAFER_LEVEL_HANDLE
  290. SaferLevel()
  291. {
  292. return _hSaferLevel;
  293. }
  294. inline BOOL
  295. CertifyServer( IN CProcess * pProcess )
  296. {
  297. return _pAppid ? _pAppid->CertifyServer( pProcess ) : TRUE;
  298. }
  299. #endif
  300. HANDLE
  301. ServerLaunchMutex();
  302. HANDLE
  303. ServerRegisterEvent();
  304. HANDLE
  305. ServerInitializedEvent();
  306. inline DWORD
  307. GetAcceptableContext()
  308. {
  309. return _dwAcceptableCtx;
  310. }
  311. private:
  312. HRESULT
  313. LaunchActivatorServer(
  314. IN CToken * pClientToken,
  315. IN WCHAR * pEnvBlock,
  316. IN DWORD EnvBlockLength,
  317. IN BOOL fRemoteActivation,
  318. IN BOOL fClientImpersonating,
  319. IN WCHAR* pwszWinstaDesktop,
  320. IN DWORD clsctx,
  321. OUT HANDLE * phProcess,
  322. OUT DWORD * pdwProcessId
  323. );
  324. HRESULT
  325. LaunchRunAsServer(
  326. IN CToken * pClientToken,
  327. IN BOOL fRemoteActivation,
  328. IN ActivationPropertiesIn *pActIn,
  329. IN DWORD clsctx,
  330. OUT HANDLE * phProcess,
  331. OUT DWORD * pdwProcessId,
  332. OUT void ** ppvRunAsHandle
  333. );
  334. HRESULT
  335. LaunchService(
  336. IN CToken * pClientToken,
  337. IN DWORD clsctx,
  338. OUT SC_HANDLE * phService
  339. );
  340. BOOL
  341. LaunchAllowed(
  342. IN CToken * pClientToken,
  343. IN DWORD clsctx
  344. );
  345. #if(_WIN32_WINNT >= 0x0500)
  346. HRESULT
  347. LaunchRestrictedServer(
  348. IN CToken * pClientToken,
  349. IN WCHAR * pEnvBlock,
  350. IN DWORD EnvBlockLength,
  351. IN DWORD clsctx,
  352. OUT HANDLE * phProcess,
  353. OUT DWORD * pdwProcessId
  354. );
  355. HRESULT
  356. CreateHKEYRestrictedSite(
  357. IN CToken * pToken);
  358. #endif //(_WIN32_WINNT >= 0x0500)
  359. HRESULT
  360. GetLaunchCommandLine(
  361. OUT WCHAR ** ppwszCommandLine
  362. );
  363. HRESULT
  364. AddAppPathsToEnv(
  365. IN WCHAR * pEnvBlock,
  366. IN DWORD EnvBlockLength,
  367. OUT WCHAR ** ppFinalEnvBlock
  368. );
  369. HRESULT
  370. CalculateSaferLevel();
  371. BOOL
  372. AutoSaferEnabled();
  373. HRESULT
  374. DefaultSaferLevel(
  375. DWORD *pdwSafer
  376. );
  377. HRESULT
  378. GetAAASaferToken(
  379. CToken *pClientTone,
  380. HANDLE *pTokenOut
  381. );
  382. GUID _Clsid;
  383. CAppidData * _pAppid;
  384. CToken * _pToken;
  385. BOOL _bIsInprocClass;
  386. UCHAR _ServerType;
  387. UCHAR _DllThreadModel;
  388. WCHAR * _pwszServer;
  389. WCHAR * _pwszDarwinId;
  390. WCHAR * _pwszDllSurrogate;
  391. SAFER_LEVEL_HANDLE _hSaferLevel;
  392. IComClassInfo* _pIComCI;
  393. IClassClassicInfo* _pIClassCI;
  394. IComProcessInfo* _pICPI;
  395. DWORD _dwAcceptableCtx;
  396. WCHAR _wszClsid[GUIDSTR_MAX];
  397. };
  398. typedef UINT (WINAPI * PFNMSIPROVIDECOMPONENTFROMDESCRIPTORW)(
  399. LPCWSTR szDescriptor, // product,feature,component info
  400. LPWSTR lpPathBuf, // returned path, NULL if not desired
  401. DWORD *pcchPathBuf, // in/out buffer character count
  402. DWORD *pcchArgsOffset); // returned offset of args in descriptor
  403. typedef UINT (WINAPI * PFNMSIGETPRODUCTINFOW)(
  404. LPCWSTR szProduct, // product code, string GUID, or descriptor
  405. LPCWSTR szAttribute, // attribute name, case-sensitive
  406. LPWSTR lpValueBuf, // returned value, NULL if not desired
  407. DWORD *pcchValueBuf); // in/out buffer character count
  408. #ifdef DIRECTORY_SERVICE
  409. typedef INSTALLUILEVEL (WINAPI * PFNMSISETINTERNALUI)(
  410. INSTALLUILEVEL dwUILevel, // UI level
  411. HWND *phWnd); // handle of owner window
  412. extern PFNMSIPROVIDECOMPONENTFROMDESCRIPTORW gpfnMsiProvideComponentFromDescriptor;
  413. extern PFNMSISETINTERNALUI gpfnMsiSetInternalUI;
  414. extern HINSTANCE ghMsi;
  415. #endif
  416. #endif // __CLSID_HXX__