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.

321 lines
9.7 KiB

  1. // RequestObject.h: interface for the CRequestObject class.
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. //////////////////////////////////////////////////////////////////////
  5. #if !defined(AFX_REQUESTOBJECT_H__F370C612_D96E_11D1_8B5D_00A0C9954921__INCLUDED_)
  6. #define AFX_REQUESTOBJECT_H__F370C612_D96E_11D1_8B5D_00A0C9954921__INCLUDED_
  7. #if _MSC_VER >= 1000
  8. #pragma once
  9. #endif // _MSC_VER >= 1000
  10. #define EVENT_THREADS 50
  11. #define THREAD_NO_PROGRESS -9
  12. class CGenericClass;
  13. //Used to house progress message information
  14. typedef struct ProgressStruct
  15. {
  16. long field1;
  17. long field2;
  18. long field3;
  19. long field4;
  20. } ProgressStruct;
  21. //Used to house progress message information
  22. typedef struct ProListNode
  23. {
  24. //Link
  25. ProListNode *pNext;
  26. //Data
  27. int iThread;
  28. IWbemObjectSink *pSink;
  29. WORD wTotal;
  30. __int64 lTotal;
  31. WORD wComplete;
  32. __int64 lComplete;
  33. __int64 lActionData;
  34. } ProListNode;
  35. //Used to house package codes
  36. class PackageListNode
  37. {
  38. public:
  39. PackageListNode() { pNext = NULL; wcscpy(wcCode, L""); }
  40. virtual ~PackageListNode() {}
  41. //Link
  42. PackageListNode *pNext;
  43. //Data
  44. WCHAR wcCode[39];
  45. };
  46. //UI Handler
  47. int WINAPI MyEventHandler(LPVOID pvContext, UINT iMessageType, LPCWSTR szMessage);
  48. class CRequestObject
  49. {
  50. friend BOOL WINAPI DllMain(HINSTANCE, ULONG, LPVOID );
  51. public:
  52. CRequestObject();
  53. virtual ~CRequestObject();
  54. void Initialize(IWbemServices *pNamespace);
  55. HRESULT CreateObject(BSTR bstrPath, IWbemObjectSink *pHandler, IWbemContext *pCtx);
  56. HRESULT CreateObjectEnum(BSTR bstrPath, IWbemObjectSink *pHandler, IWbemContext *pCtx);
  57. HRESULT PutObject(IWbemClassObject *pInst, IWbemObjectSink *pHandler, IWbemContext *pCtx);
  58. HRESULT ExecMethod(BSTR bstrPath, BSTR bstrMethod, IWbemClassObject *pInParams,
  59. IWbemObjectSink *pHandler, IWbemContext *pCtx);
  60. HRESULT DeleteObject(BSTR bstrPath, IWbemObjectSink *pHandler, IWbemContext *pCtx);
  61. #ifdef _EXEC_QUERY_SUPPORT
  62. HRESULT ExecQuery(BSTR bstrQuery, IWbemObjectSink *pHandler, IWbemContext *pCtx);
  63. bool ParseQuery(BSTR bstrQuery);
  64. #endif
  65. bool ParsePath(BSTR bstrPath);
  66. HRESULT InitializeList(bool bGetList);
  67. bool DestroyList();
  68. bool Cleanup();
  69. void FinalRelease();
  70. //Registry Hive stuff
  71. DWORD GetAccount(HANDLE TokenHandle, WCHAR *wcDomain, WCHAR *wcUser);
  72. DWORD GetSid(HANDLE TokenHandle, WCHAR *wcSID, DWORD dwSID = BUFF_SIZE );
  73. DWORD LoadHive();
  74. DWORD UnloadHive();
  75. DWORD AcquirePrivilege();
  76. void RestorePrivilege();
  77. TOKEN_PRIVILEGES* m_pOriginalPriv;
  78. HKEY m_hKey;
  79. DWORD m_dwSize;
  80. DWORD m_dwCheckKeyPresentStatus;
  81. WCHAR m_wcAccount[BUFF_SIZE];
  82. WCHAR m_wcKeyName[1024];
  83. WCHAR m_wcDomain[BUFF_SIZE];
  84. WCHAR m_wcUser[BUFF_SIZE];
  85. BSTR Package(int iPos);
  86. BSTR m_bstrClass;
  87. BSTR m_bstrPath;
  88. BSTR m_Property[MSI_KEY_LIST_SIZE];
  89. BSTR m_Value[MSI_KEY_LIST_SIZE];
  90. int m_iPropCount;
  91. int m_iValCount;
  92. int m_iThreadID;
  93. IWbemServices *m_pNamespace;
  94. IWbemObjectSink *m_pHandler;
  95. bool ParseProgress (WCHAR *wcMessage, ProgressStruct *ps);
  96. bool ActionDataProgress (HRESULT *hr, int iThread);
  97. bool ActionStartProgress (HRESULT *hr, int iThread);
  98. bool CreateProgress (ProgressStruct *ps, HRESULT *hr, int iThread);
  99. ProListNode * GetNode (int iThread);
  100. private:
  101. HRESULT CreateClass(CGenericClass **pClass, IWbemContext *pCtx);
  102. #ifdef _EXEC_QUERY_SUPPORT
  103. //Query Parsing Functions
  104. WCHAR * GetNextProperty(WCHAR **pwcString, WCHAR wcProp[]);
  105. WCHAR * GetNextValue(WCHAR **pwcString, WCHAR wcVal[]);
  106. bool ExpectedToken(WCHAR **pwcString, WCHAR *pwcExpected);
  107. WCHAR * GetNextToken(WCHAR **pwcString, WCHAR wcToken[]);
  108. WCHAR * GetStringValue(WCHAR **pwcString, WCHAR wcToken[]);
  109. bool EOL(WCHAR **pwcString);
  110. #endif // _EXEC_QUERY_SUPPORT
  111. bool IsInstance();
  112. ProListNode * InitializeProgress(IWbemObjectSink *pHandler);
  113. //Package list head
  114. PackageListNode *m_pPackageHead;
  115. //Thread List for progress messages
  116. ProListNode * m_pHead;
  117. ProListNode * RemoveNode (int iThread);
  118. int InsertNode (ProListNode *pNode);
  119. //Critical section for event handling and thread ID assignement
  120. static CRITICAL_SECTION m_cs;
  121. static CHeap_Exception m_he;
  122. protected:
  123. ULONG m_cRef; //Object reference count
  124. };
  125. //Properties
  126. //////////////////
  127. extern const char * pAccesses;
  128. extern const char * pAction;
  129. extern const char * pActionID;
  130. extern const char * pAntecedent;
  131. extern const char * pAppData;
  132. extern const char * pAppID;
  133. extern const char * pArgument;
  134. extern const char * pArguments;
  135. extern const char * pAttribute;
  136. extern const char * pAttributes;
  137. extern const char * pCabinet;
  138. extern const char * pCaption;
  139. extern const char * pCheck;
  140. extern const char * pCheckID;
  141. extern const char * pCLSID;
  142. extern const char * pCommand;
  143. extern const char * pCommandLine;
  144. extern const char * pComponent;
  145. extern const char * pComponentID;
  146. extern const char * pCondition;
  147. extern const char * pContentType;
  148. extern const char * pContext;
  149. extern const char * pCost;
  150. extern const char * pCreationClassName;
  151. extern const char * pDataSource;
  152. extern const char * pDefaultDir;
  153. extern const char * pDefInprocHandler;
  154. extern const char * pDependencies;
  155. extern const char * pDependent;
  156. extern const char * pDescription;
  157. extern const char * pDestination;
  158. extern const char * pDestFolder;
  159. extern const char * pDestName;
  160. extern const char * pDirectory;
  161. extern const char * pDirectoryName;
  162. extern const char * pDirectoryPath;
  163. extern const char * pDirProperty;
  164. extern const char * pDiskID;
  165. extern const char * pDiskPrompt;
  166. extern const char * pDisplay;
  167. extern const char * pDisplayName;
  168. extern const char * pDomain;
  169. extern const char * pDriver;
  170. extern const char * pDriverDescription;
  171. extern const char * pElement;
  172. extern const char * pEntryName;
  173. extern const char * pEntryValue;
  174. extern const char * pEnvironment;
  175. extern const char * pError;
  176. extern const char * pErrorControl;
  177. extern const char * pEvent;
  178. extern const char * pExpression;
  179. extern const char * pExpressionType;
  180. extern const char * pExtension;
  181. extern const char * pFeature;
  182. extern const char * pFeatures;
  183. extern const char * pField;
  184. extern const char * pFile;
  185. extern const char * pFileKey;
  186. extern const char * pFileName;
  187. extern const char * pFileSize;
  188. extern const char * pFileTypeMask;
  189. extern const char * pFontTitle;
  190. extern const char * pGroupComponent;
  191. extern const char * pHotKey;
  192. extern const char * pID;
  193. extern const char * pIdentificationCode;
  194. extern const char * pIdentifyingNumber;
  195. extern const char * pIniFile;
  196. extern const char * pInsertable;
  197. extern const char * pInstallDate;
  198. extern const char * pInstallDate2;
  199. extern const char * pInstallLocation;
  200. extern const char * pInstallMode;
  201. extern const char * pInstallState;
  202. extern const char * pKey;
  203. extern const char * pLanguage;
  204. extern const char * pLastSequence;
  205. extern const char * pLastUse;
  206. extern const char * pLevel;
  207. extern const char * pLibID;
  208. extern const char * pLoadOrderGroup;
  209. extern const char * pLocation;
  210. extern const char * pManufacturer;
  211. extern const char * pMaxDate;
  212. extern const char * pMaxSize;
  213. extern const char * pMaxVersion;
  214. extern const char * pMessage;
  215. extern const char * pMIME;
  216. extern const char * pMinDate;
  217. extern const char * pMinSize;
  218. extern const char * pMinVersion;
  219. extern const char * pName;
  220. extern const char * pNext;
  221. extern const char * pOperator;
  222. extern const char * pOptions;
  223. extern const char * pPackageCache;
  224. extern const char * pParent;
  225. extern const char * pPartComponent;
  226. extern const char * pPassword;
  227. extern const char * pPatch;
  228. extern const char * pPatchID;
  229. extern const char * pPatchSize;
  230. extern const char * pPath;
  231. extern const char * pPermission;
  232. extern const char * pPrior;
  233. extern const char * pProduct;
  234. extern const char * pProductCode;
  235. extern const char * pProductName;
  236. extern const char * pProductVersion;
  237. extern const char * pProgID;
  238. extern const char * pProperty;
  239. extern const char * pQual;
  240. extern const char * pRegistration;
  241. extern const char * pRegistry;
  242. extern const char * pRemoteName;
  243. extern const char * pReserveKey;
  244. extern const char * pReserveLocal;
  245. extern const char * pReserveSource;
  246. extern const char * pResource;
  247. extern const char * pRoot;
  248. extern const char * pSection;
  249. extern const char * pSequence;
  250. extern const char * pServiceType;
  251. extern const char * pSetting;
  252. extern const char * pSetupFile;
  253. extern const char * pShellNew;
  254. extern const char * pShellNewValue;
  255. extern const char * pSignature;
  256. extern const char * pShortcut;
  257. extern const char * pShowCmd;
  258. extern const char * pSoftware;
  259. extern const char * pSoftwareElementID;
  260. extern const char * pSoftwareElementState;
  261. extern const char * pSource;
  262. extern const char * pSourceFolder;
  263. extern const char * pSourceName;
  264. extern const char * pStartMode;
  265. extern const char * pStartName;
  266. extern const char * pStartType;
  267. extern const char * pStatus;
  268. extern const char * pSystem;
  269. extern const char * pSystemCreationClassName;
  270. extern const char * pSystemName;
  271. extern const char * pTable;
  272. extern const char * pTarget;
  273. extern const char * pTargetOperatingSystem;
  274. extern const char * pTranslator;
  275. extern const char * pType;
  276. extern const char * pUpgradeCode;
  277. extern const char * pUser;
  278. extern const char * pValue;
  279. extern const char * pVendor;
  280. extern const char * pVerb;
  281. extern const char * pVersion;
  282. extern const char * pVolumeLabel;
  283. extern const char * pWait;
  284. extern const char * pWkDir;
  285. #endif // !defined(AFX_REQUESTOBJECT_H__F370C612_D96E_11D1_8B5D_00A0C9954921__INCLUDED_)