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.

603 lines
24 KiB

  1. //***************************************************************************
  2. //
  3. // (c) 1999-2001 by Microsoft Corp. All Rights Reserved.
  4. //
  5. // repdrvr.h
  6. //
  7. // cvadai 19-Mar-99 Created as prototype for Quasar.
  8. //
  9. //***************************************************************************
  10. #ifndef _REPDRVR_H_
  11. #define _REPDRVR_H_
  12. #pragma warning( disable : 4251 ) // needs to have dll-interface to be used by clients of class
  13. //#define InterlockedIncrement(l) (++(*(l)))
  14. //#define InterlockedDecrement(l) (--(*(l)))
  15. EXTERN_C const IID IID_IWbemQuery;
  16. EXTERN_C const IID IID_IWmiDbHandle;
  17. EXTERN_C const IID IID_IWmiDbController;
  18. EXTERN_C const IID IID_IWmiDbSession;
  19. EXTERN_C const IID IID_IWmiDbBatchSession;
  20. EXTERN_C const IID IID_IWmiDbIterator;
  21. EXTERN_C const IID IID_ISequentialStream2;
  22. #define WMIDB_OBJECT_STATE_NORMAL 0
  23. #define WMIDB_OBJECT_STATE_IN_USE 1
  24. #define WMIDB_OBJECT_STATE_DELETED 2
  25. #define WMIDB_OBJECT_STATE_PROTECTED 3
  26. #define WMIDB_OBJECT_STATE_EXCLUSIVE 4
  27. #define WMIDB_OBJECT_STATE_PERSISTENT 5
  28. #define WMIDB_OBJECT_STATE_AUTODELETE 6
  29. #define WMIDB_SECURITY_FLAG_CLASS 1
  30. #define WMIDB_SECURITY_FLAG_INSTANCE 2
  31. #include <wmiutils.h>
  32. #include <winbase.h>
  33. #include <sqlcache.h>
  34. #include <repcache.h>
  35. #include <wbemint.h>
  36. #include <coresvc.h>
  37. extern CRITICAL_SECTION g_csRepdrvr;
  38. class _WMILockit
  39. {
  40. public:
  41. _WMILockit(CRITICAL_SECTION *pCS);
  42. ~_WMILockit();
  43. private:
  44. CRITICAL_SECTION *m_cs;
  45. };
  46. class CWmiDbIterator;
  47. struct MappedProperties
  48. {
  49. LPWSTR wPropName;
  50. LPWSTR wTableName;
  51. BOOL bReadOnly;
  52. LPWSTR wScopeClass;
  53. BOOL bIsKey;
  54. BOOL bStoreAsBlob;
  55. BOOL bStoreAsNumber;
  56. BOOL bStoreAsMOFText;
  57. LPWSTR * arrColumnNames;
  58. LPWSTR * arrForeignKeys;
  59. DWORD dwNumColumns;
  60. DWORD dwNumForeignKeys;
  61. // Special treatment for embedded objects
  62. BOOL bDecompose;
  63. LPWSTR wClassTable;
  64. LPWSTR wClassNameCol;
  65. LPWSTR wClassDataCol;
  66. LPWSTR wClassForeignKey;
  67. };
  68. LPWSTR GetKeyString (LPWSTR lpString);
  69. void ConvertDataToString(WCHAR * lpKey, BYTE* pData, DWORD dwType, BOOL bQuotes = FALSE);
  70. LPWSTR StripUnresolvedName (LPWSTR lpPath);
  71. BOOL IsDerivedFrom(IWbemClassObject *pObj, LPWSTR lpClassName, BOOL bDirectOnly=FALSE);
  72. HRESULT ConvertBlobToObject (IWbemClassObject *pNewObj, BYTE *pBuffer, DWORD dwLen, _IWmiObject **ppNewObj);
  73. //***************************************************************************
  74. // CWmiDbHandle
  75. //***************************************************************************
  76. class CWmiDbHandle : public IWmiDbHandle
  77. {
  78. friend class CWmiDbSession;
  79. friend class CWmiDbIterator;
  80. friend class CLockCache;
  81. friend class CObjectCache;
  82. friend class CWmiCustomDbIterator;
  83. friend class CWmiESEIterator;
  84. public:
  85. HRESULT STDMETHODCALLTYPE QueryInterface(
  86. /* [in] */ REFIID riid,
  87. /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
  88. ULONG STDMETHODCALLTYPE AddRef( );
  89. ULONG STDMETHODCALLTYPE Release( );
  90. HRESULT STDMETHODCALLTYPE GetHandleType(
  91. /* [out] */ DWORD __RPC_FAR *pdwType) ;
  92. CWmiDbHandle();
  93. ~CWmiDbHandle();
  94. HRESULT QueryInterface_Internal(CSQLConnection *pConn, void __RPC_FAR *__RPC_FAR *ppvObject, LPWSTR lpKey = NULL);
  95. private:
  96. DWORD m_dwHandleType;
  97. DWORD m_dwVersion;
  98. SQL_ID m_dObjectId;
  99. SQL_ID m_dClassId;
  100. SQL_ID m_dScopeId;
  101. ULONG m_uRefCount;
  102. BOOL m_bSecDesc;
  103. BOOL m_bDefault;
  104. IWmiDbSession *m_pSession;
  105. IWbemClassObject *m_pData;
  106. };
  107. class CESSHolder
  108. {
  109. public:
  110. CESSHolder(long lType, LPWSTR lpNs, LPWSTR lpClass, _IWmiObject *pOld, _IWmiObject *pNew);
  111. ~CESSHolder() {};
  112. HRESULT Deliver(_IWmiCoreServices *pCS, LPCWSTR lpRootNs);
  113. private:
  114. _bstr_t m_sNamespace;
  115. _bstr_t m_sClass;
  116. _IWmiObject *pOldObject;
  117. _IWmiObject *pNewObject;
  118. long m_lType;
  119. };
  120. class CESSManager
  121. {
  122. friend class CWmiDbController;
  123. public:
  124. typedef std::map <DWORD, CESSHolder *> ESSObjs;
  125. CESSManager();
  126. ~CESSManager ();
  127. void SetConnCache (CSQLConnCache *pConn) {m_Conns = pConn;};
  128. void SetSchemaCache (CSchemaCache *pCache) {m_Schema = pCache;};
  129. void SetObjectCache (CObjectCache *pObjects) {m_Objects = pObjects;};
  130. void InitializeESS();
  131. HRESULT AddInsertRecord(CSQLConnection *pConn, LPWSTR lpGUID, LPWSTR lpNamespace, LPWSTR lpClass, DWORD dwGenus,
  132. IWbemClassObject *pOldObj, IWbemClassObject *pNewObj);
  133. HRESULT AddDeleteRecord(CSQLConnection *pConn, LPWSTR lpGUID, LPWSTR lpNamespace, LPWSTR lpClass, DWORD dwGenus,
  134. IWbemClassObject *pObj);
  135. HRESULT CommitAll (LPCWSTR lpGUID, LPCWSTR lpRootNs);
  136. HRESULT DeleteAll (LPCWSTR lpGUID);
  137. private:
  138. _IWmiCoreServices *m_EventSubSys;
  139. CSQLConnCache *m_Conns;
  140. CObjectCache *m_Objects;
  141. CSchemaCache *m_Schema;
  142. ESSObjs m_ESSObjs;
  143. };
  144. //***************************************************************************
  145. // CWmiDbController
  146. //***************************************************************************
  147. class CWmiDbController : public IWmiDbController
  148. {
  149. friend class CWmiDbSession;
  150. friend class CWmiDbIterator;
  151. friend class CWmiCustomDbIterator;
  152. friend class CWmiESEIterator;
  153. friend class CWmiDbHandle;
  154. typedef std::map<SQL_ID, bool> SQL_IDMap;
  155. public:
  156. HRESULT STDMETHODCALLTYPE QueryInterface(
  157. /* [in] */ REFIID riid,
  158. /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
  159. ULONG STDMETHODCALLTYPE AddRef( );
  160. ULONG STDMETHODCALLTYPE Release( );
  161. virtual HRESULT STDMETHODCALLTYPE Logon(
  162. /* [in] */ WMIDB_LOGON_TEMPLATE __RPC_FAR *pLogonParms,
  163. /* [in] */ DWORD dwFlags,
  164. /* [in] */ DWORD dwRequestedHandleType,
  165. /* [out] */ IWmiDbSession __RPC_FAR *__RPC_FAR *ppSession,
  166. /* [out] */ IWmiDbHandle __RPC_FAR *__RPC_FAR *ppRootNamespace) ;
  167. virtual HRESULT STDMETHODCALLTYPE GetLogonTemplate(
  168. /* [in] */ LCID lLocale,
  169. /* [in] */ DWORD dwFlags,
  170. /* [out] */ WMIDB_LOGON_TEMPLATE __RPC_FAR *__RPC_FAR *ppTemplate) ;
  171. virtual HRESULT STDMETHODCALLTYPE FreeLogonTemplate(
  172. /* [out][in] */ WMIDB_LOGON_TEMPLATE __RPC_FAR *__RPC_FAR *pTemplate) ;
  173. virtual HRESULT STDMETHODCALLTYPE Shutdown(
  174. /* [in] */ DWORD dwFlags);
  175. virtual HRESULT STDMETHODCALLTYPE SetCallTimeout(
  176. /* [in] */ DWORD dwMaxTimeout);
  177. virtual HRESULT STDMETHODCALLTYPE SetCacheValue(
  178. /* [in] */ DWORD dwMaxBytes);
  179. virtual HRESULT STDMETHODCALLTYPE FlushCache(
  180. /* [in] */ DWORD dwFlags);
  181. virtual HRESULT STDMETHODCALLTYPE GetStatistics(
  182. /* [in] */ DWORD dwParameter,
  183. /* [out] */ DWORD __RPC_FAR *pdwValue) ;
  184. CWmiDbController();
  185. ~CWmiDbController();
  186. private:
  187. typedef std::vector<CWmiDbSession *> Sessions;
  188. HRESULT GetUnusedSession(WMIDB_LOGON_TEMPLATE *pLogon,
  189. DWORD dwFlags,
  190. DWORD dwHandleType,
  191. IWmiDbSession **ppSession);
  192. HRESULT SetConnProps(WMIDB_LOGON_TEMPLATE *pLogon);
  193. HRESULT ReleaseSession(IWmiDbSession *pSession);
  194. void IncrementHitCount(bool bCacheUsed=false);
  195. void AddHandle();
  196. void SubtractHandle();
  197. HINSTANCE GetResourceDll (LCID lLocale);
  198. BOOL HasSecurityDescriptor(SQL_ID ObjId);
  199. void AddSecurityDescriptor(SQL_ID ObjId);
  200. void RemoveSecurityDescriptor(SQL_ID ObjId);
  201. DWORD m_dwTimeOut;
  202. DWORD m_dwCurrentStatus;
  203. ULONG m_uRefCount;
  204. DWORD m_dwTotalHits;
  205. DWORD m_dwCacheHits;
  206. DWORD m_dwTotalHandles;
  207. CRITICAL_SECTION m_cs;
  208. DBPROP *m_InitProperties;
  209. DBPROPSET *m_rgInitPropSet;
  210. IMalloc *m_pIMalloc;
  211. CObjectCache ObjectCache;
  212. CSchemaCache SchemaCache; // separate so it doesn't get flushed.
  213. CLockCache LockCache; // separate so it doesn't get flushed.
  214. CSQLConnCache ConnCache; // Cache of SQL connections.
  215. CESSManager ESSMgr;
  216. SQL_IDMap SecuredIDs; // List of objects with security descriptors.
  217. Sessions m_Sessions;
  218. BOOL m_bCacheInit;
  219. BOOL m_bIsAdmin;
  220. BOOL m_bESSEnabled;
  221. };
  222. class CWbemClassObjectProps
  223. {
  224. public:
  225. LPWSTR lpClassName;
  226. LPWSTR lpNamespace;
  227. LPWSTR lpRelPath;
  228. LPWSTR lpSuperClass;
  229. LPWSTR lpDynasty;
  230. LPWSTR lpKeyString;
  231. DWORD dwGenus;
  232. CWbemClassObjectProps(CWmiDbSession *pSession, CSQLConnection *pConn,
  233. IWbemClassObject *pObj, CSchemaCache *pCache, SQL_ID dScopeID);
  234. ~CWbemClassObjectProps();
  235. };
  236. struct SessionLock
  237. {
  238. SQL_ID dObjectId;
  239. DWORD dwHandleType;
  240. };
  241. //***************************************************************************
  242. // CWmiDbSession
  243. //***************************************************************************
  244. class CWmiDbSession : public IWmiDbSession, IWmiDbBatchSession, IWbemTransaction, IWmiDbBackupRestore
  245. {
  246. friend class CWmiDbController;
  247. friend class CWmiDbIterator;
  248. friend class CWmiCustomDbIterator;
  249. friend class CWmiESEIterator;
  250. friend class CWmiDbHandle;
  251. typedef std::vector <SQL_ID> SQLIDs;
  252. typedef std::map <DWORD, DWORD> Properties;
  253. typedef std::vector <SessionLock *> SessionLocks;
  254. typedef std::map <DWORD, SQLIDs> SessionDynasties;
  255. typedef std::map <DWORD, DWORD> RefCount;
  256. public:
  257. HRESULT STDMETHODCALLTYPE QueryInterface(
  258. /* [in] */ REFIID riid,
  259. /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
  260. ULONG STDMETHODCALLTYPE AddRef( );
  261. ULONG STDMETHODCALLTYPE Release( );
  262. virtual HRESULT STDMETHODCALLTYPE GetObject(
  263. /* [in] */ IWmiDbHandle __RPC_FAR *pScope,
  264. /* [in] */ IWbemPath __RPC_FAR *pPath,
  265. /* [in] */ DWORD dwFlags,
  266. /* [in] */ DWORD dwRequestedHandleType,
  267. /* [out] */ IWmiDbHandle __RPC_FAR *__RPC_FAR *ppResult);
  268. virtual HRESULT STDMETHODCALLTYPE GetObjectDirect(
  269. /* [in] */ IWmiDbHandle __RPC_FAR *pScope,
  270. /* [in] */ IWbemPath __RPC_FAR *pPath,
  271. /* [in] */ DWORD dwFlags,
  272. /* [in] */ REFIID riid,
  273. /* [iid_is][out] */ LPVOID __RPC_FAR *pObj);
  274. virtual HRESULT STDMETHODCALLTYPE PutObject(
  275. /* [in] */ IWmiDbHandle __RPC_FAR *pScope,
  276. /* [in] */ REFIID riid,
  277. /* [iid_is][in] */ LPVOID pObjToPut,
  278. /* [in] */ DWORD dwFlags,
  279. /* [in] */ DWORD dwRequestedHandleType,
  280. /* [out] */ IWmiDbHandle __RPC_FAR *__RPC_FAR *ppResult);
  281. virtual HRESULT STDMETHODCALLTYPE DeleteObject(
  282. /* [in] */ IWmiDbHandle __RPC_FAR *pScope,
  283. /* [in] */ DWORD dwFlags,
  284. /* [in] */ REFIID riid,
  285. /* [iid_is][in] */ LPVOID pObj);
  286. virtual HRESULT STDMETHODCALLTYPE ExecQuery(
  287. /* [in] */ IWmiDbHandle __RPC_FAR *pScope,
  288. /* [in] */ IWbemQuery __RPC_FAR *pQuery,
  289. /* [in] */ DWORD dwFlags,
  290. /* [in] */ DWORD dwHandleType,
  291. /* [out] */ DWORD *dwMessageFlags,
  292. /* [out] */ IWmiDbIterator __RPC_FAR *__RPC_FAR *pQueryResult) ;
  293. virtual HRESULT STDMETHODCALLTYPE RenameObject(
  294. /* [in] */ IWbemPath __RPC_FAR *pOldPath,
  295. /* [in] */ IWbemPath __RPC_FAR *pNewPath,
  296. /* [in] */ DWORD dwFlags,
  297. /* [in] */ DWORD dwRequestedHandleType,
  298. /* [out] */ IWmiDbHandle __RPC_FAR *__RPC_FAR *ppResult);
  299. virtual HRESULT STDMETHODCALLTYPE Enumerate(
  300. /* [in] */ IWmiDbHandle __RPC_FAR *pScope,
  301. /* [in] */ DWORD dwFlags,
  302. /* [in] */ DWORD dwRequestedHandleType,
  303. /* [out] */ IWmiDbIterator __RPC_FAR *__RPC_FAR *ppQueryResult);
  304. virtual HRESULT STDMETHODCALLTYPE AddObject(
  305. /* [in] */ IWmiDbHandle __RPC_FAR *pScope,
  306. /* [in] */ IWbemPath __RPC_FAR *pPath,
  307. /* [in] */ DWORD dwFlags,
  308. /* [in] */ DWORD dwRequestedHandleType,
  309. /* [out] */ IWmiDbHandle __RPC_FAR *__RPC_FAR *ppResult);
  310. virtual HRESULT STDMETHODCALLTYPE RemoveObject(
  311. /* [in] */ IWmiDbHandle __RPC_FAR *pScope,
  312. /* [in] */ IWbemPath __RPC_FAR *pPath,
  313. /* [in] */ DWORD dwFlags);
  314. virtual HRESULT STDMETHODCALLTYPE SetDecoration(
  315. /* [in] */ LPWSTR lpMachineName,
  316. /* [in] */ LPWSTR lpNamespacePath);
  317. virtual HRESULT STDMETHODCALLTYPE SupportsQueries(
  318. /* [in] */ DWORD *dwQuerySupportLevel
  319. ) {return WBEM_S_NO_ERROR;};
  320. // batch session methods
  321. virtual HRESULT STDMETHODCALLTYPE PutObjects(
  322. /* [in] */ IWmiDbHandle __RPC_FAR *pScope,
  323. /* [in] */ DWORD dwFlags,
  324. /* [in] */ DWORD dwHandleType,
  325. /* [out][in] */ WMIOBJECT_BATCH __RPC_FAR *pBatch);
  326. virtual HRESULT STDMETHODCALLTYPE GetObjects(
  327. /* [in] */ IWmiDbHandle __RPC_FAR *pScope,
  328. /* [in] */ DWORD dwFlags,
  329. /* [in] */ DWORD dwHandleType,
  330. /* [in, out] */ WMIOBJECT_BATCH __RPC_FAR *pBatch);
  331. virtual HRESULT STDMETHODCALLTYPE DeleteObjects(
  332. /* [in] */ IWmiDbHandle __RPC_FAR *pScope,
  333. /* [in] */ DWORD dwFlags,
  334. /* [out][in] */ WMIOBJECT_BATCH __RPC_FAR *pBatch);
  335. // IWbemTransaction methods.
  336. virtual HRESULT STDMETHODCALLTYPE Begin(
  337. /* [in] */ ULONG uTimeout,
  338. /* [in] */ ULONG uFlags,
  339. /* [in] */ GUID __RPC_FAR *pTransGUID);
  340. virtual HRESULT STDMETHODCALLTYPE Rollback(
  341. /* [in] */ ULONG uFlags);
  342. virtual HRESULT STDMETHODCALLTYPE Commit(
  343. /* [in] */ ULONG uFlags);
  344. virtual HRESULT STDMETHODCALLTYPE QueryState(
  345. /* [in] */ ULONG uFlags,
  346. /* [out] */ ULONG __RPC_FAR *puState);
  347. virtual HRESULT STDMETHODCALLTYPE Backup(
  348. /* [in] */ LPCWSTR lpBackupPath,
  349. /* [in] */ DWORD dwFlags);
  350. virtual HRESULT STDMETHODCALLTYPE Restore(
  351. /* [in] */ LPCWSTR lpRestorePath,
  352. /* [in] */ LPCWSTR lpDestination,
  353. /* [in] */ DWORD dwFlags);
  354. HRESULT LoadSchemaCache ();
  355. HRESULT LoadClassInfo (CSQLConnection *pConn, LPCWSTR lpDynasty = NULL, SQL_ID dScopeId = 0, BOOL bDeep = TRUE);
  356. HRESULT LoadClassInfo (CSQLConnection *pConn, SQL_ID dClassId, BOOL bDeep = TRUE);
  357. HRESULT GetObjectData (CSQLConnection *pConn, SQL_ID dObjectId, SQL_ID dClassId, SQL_ID dScopeId,
  358. DWORD dwHandleType, DWORD &dwVersion, IWbemClassObject **pObj, BOOL bNoDefaults = FALSE,
  359. LPWSTR lpKey = NULL, BOOL bGetSD = FALSE);
  360. HRESULT GetObjectData2 (CSQLConnection *pConn, SQL_ID dObjectId, SQL_ID dClassId, SQL_ID dScopeId,
  361. IWbemClassObject *pObj, BOOL bNoDefaults = FALSE, LPWSTR *lpKey = NULL);
  362. HRESULT GetClassObject (CSQLConnection *pConn, SQL_ID dClassId, IWbemClassObject **ppObj);
  363. HRESULT STDMETHODCALLTYPE GetObject_Internal(
  364. /* [in] */ LPWSTR lpPath,
  365. /* [in] */ DWORD dwFlags,
  366. /* [in] */ DWORD dwRequestedHandleType,
  367. /* [in] */ SQL_ID *dScopeId,
  368. /* [out] */ IWmiDbHandle __RPC_FAR *__RPC_FAR *ppResult,
  369. CSQLConnection *pConn = NULL);
  370. HRESULT STDMETHODCALLTYPE PutObject(
  371. CSQLConnection *pConn,
  372. /* [in] */ IWmiDbHandle *pScope,
  373. SQL_ID dScopeID,
  374. LPWSTR lpScopePath,
  375. /* [in] */ IUnknown __RPC_FAR *pObjToPut,
  376. /* [in] */ DWORD dwFlags,
  377. /* [in] */ DWORD dwRequestedHandleType,
  378. _bstr_t &sPath,
  379. /* [out] */ IWmiDbHandle __RPC_FAR *__RPC_FAR *ppResult,
  380. BOOL bStoreAsClass = FALSE);
  381. HRESULT CleanCache(SQL_ID dObjId, DWORD dwLockType = 0, void *pObj = NULL);
  382. HRESULT ShutDown ();
  383. HRESULT Delete(IWmiDbHandle *pHandle, CSQLConnection *pConn= NULL);
  384. HRESULT Delete(SQL_ID dID, CSQLConnection *pConn= NULL);
  385. HRESULT VerifyObjectSecurity (CSQLConnection *pConn, SQL_ID ObjectId, SQL_ID ClassId, SQL_ID ScopeId, SQL_ID ScopeClassId, DWORD AccessType);
  386. HRESULT AccessCheck( PNTSECURITY_DESCRIPTOR pSD, DWORD dwAccessType, BOOL &bHasDACL );
  387. CWmiDbController * GetController() { return (CWmiDbController *)m_pController;}
  388. CSchemaCache * GetSchemaCache() { return (m_pController ? &((CWmiDbController *)m_pController)->SchemaCache : NULL);}
  389. CObjectCache * GetObjectCache() { return (m_pController ? &((CWmiDbController *)m_pController)->ObjectCache : NULL);}
  390. CSQLConnCache * GetSQLCache() { return (m_pController ? &((CWmiDbController *)m_pController)->ConnCache : NULL);}
  391. CRITICAL_SECTION * GetCS() {return (m_pController ? &((CWmiDbController *)m_pController)->m_cs : NULL);}
  392. void FixMethodParamIds(IWbemClassObject *pTemp);
  393. CWmiDbSession(IWmiDbController *pController);
  394. ~CWmiDbSession();
  395. private:
  396. HRESULT CustomGetObject(IWmiDbHandle *pScope, IWbemPath *pPath, LPWSTR lpObjectKey,
  397. DWORD dwFlags, DWORD dwRequestedHandleType, IWmiDbHandle **ppResult);
  398. HRESULT CustomGetMapping(CSQLConnection *pConn, IWmiDbHandle *pScope, LPWSTR lpClassName, IWbemClassObject **ppMapping);
  399. HRESULT CustomCreateMapping(CSQLConnection *pConn, LPWSTR lpClassName, IWbemClassObject *pClassObj, IWmiDbHandle *pScope);
  400. HRESULT CustomPutInstance(CSQLConnection *pConn, IWmiDbHandle *pScope, SQL_ID dClassId,
  401. DWORD dwFlags, IWbemClassObject **ppObjToPut, LPWSTR lpClassName = NULL);
  402. HRESULT CustomFormatSQL(IWmiDbHandle *pScope, IWbemQuery *pQuery, _bstr_t &sSQL, SQL_ID *dClassId,
  403. MappedProperties **ppMapping, DWORD *dwNumProps, BOOL *bCount=FALSE);
  404. HRESULT CustomDelete(CSQLConnection *pConn, IWmiDbHandle *pScope, IWmiDbHandle *pHandle, LPWSTR lpClassName = NULL);
  405. HRESULT SetEmbeddedProp (IWmiDbHandle *pScope, LPWSTR lpPropName, IWbemClassObject *pObj, VARIANT &vValue, CIMTYPE ct);
  406. HRESULT GetEmbeddedClass (IWmiDbHandle *pScope, IWbemClassObject *pObj, LPWSTR lpEmbedProp, IWbemClassObject **ppClass);
  407. HRESULT CustomSetProperties (IWmiDbHandle *pScope, IRowset *pRowset, IMalloc *pMalloc,
  408. IWbemClassObject *pClassObj, MappedProperties *pProps,
  409. DWORD dwNumProps, IWbemClassObject *pObj);
  410. // Security helper functions.
  411. HRESULT VerifyObjectSecurity (CSQLConnection *pConn, IWmiDbHandle *pHandle, DWORD AccessType);
  412. HRESULT VerifyObjectSecurity(CSQLConnection *pConn, SQL_ID dScopeID, SQL_ID dScopeClassId, LPWSTR lpObjectPath,CWbemClassObjectProps *pProps,DWORD dwHandleType,
  413. DWORD dwReqAccess, SQL_ID &dObjectId, SQL_ID &dClassId);
  414. HRESULT VerifyClassSecurity (CSQLConnection *pConn, SQL_ID ClassId, DWORD AccessType);
  415. HRESULT GetEffectiveObjectSecurity(CSQLConnection *pConn, SQL_ID ObjectId, SQL_ID ClassId, SQL_ID ScopeId, SQL_ID ScopeClassId, PNTSECURITY_DESCRIPTOR *ppSD, DWORD &dwSDLength);
  416. HRESULT GetInheritedObjectSecurity(CSQLConnection *pConn, SQL_ID ObjectId, SQL_ID ClassId, SQL_ID ScopeId, SQL_ID ScopeClassId, PNTSECURITY_DESCRIPTOR *ppSD, DWORD &dwSDLength);
  417. HRESULT GetInheritedClassSecurity(CSQLConnection *pConn, SQL_ID ClassId, SQL_ID ScopeId, SQL_ID ScopeClassId, PNTSECURITY_DESCRIPTOR *ppSD, DWORD &dwSDLength);
  418. HRESULT GetInheritedInstanceSecurity(CSQLConnection *pConn, SQL_ID ObjectId, SQL_ID ClassId, SQL_ID ScopeId, SQL_ID ScopeClassId, PNTSECURITY_DESCRIPTOR *ppSD, DWORD &dwSDLength);
  419. HRESULT GetInheritedContainerSecurity(CSQLConnection *pConn, SQL_ID ClassId, SQL_ID ScopeId, SQL_ID ScopeClassId, PNTSECURITY_DESCRIPTOR *ppSD, DWORD &dwSDLength);
  420. HRESULT GetObjectSecurity (CSQLConnection *pConn, SQL_ID dObjectId, PNTSECURITY_DESCRIPTOR *pSD, DWORD dwSDLength, DWORD dwFlags, BOOL &bHasDacl);
  421. HRESULT PutClass( CSQLConnection *pConn,SQL_ID dScopeID,LPCWSTR lpScopePath,CWbemClassObjectProps *pProps, IWbemClassObject *pObj,DWORD dwFlags,
  422. SQL_ID &dObjectId,_bstr_t &sObjectPath, bool &bChg, BOOL bIgnoreDefaults = FALSE);
  423. HRESULT PutInstance( CSQLConnection *pConn,IWmiDbHandle *pScope, SQL_ID dScopeID,LPCWSTR lpScopePath,CWbemClassObjectProps *pProps,
  424. IWbemClassObject *pObj,DWORD dwFlags,SQL_ID &dObjectId,SQL_ID &dClassId, _bstr_t &sObjectPath, bool &bChg);
  425. // These three functions will only generate sp_InsertClassData procs
  426. HRESULT InsertPropertyDef(CSQLConnection *pConn,
  427. IWbemClassObject *pObj, SQL_ID dScopeId, SQL_ID dObjectId,
  428. LPWSTR lpPropName, VARIANT vDefault,
  429. CIMTYPE cimtype, long lPropFlags,DWORD dRefId,
  430. Properties &props);
  431. HRESULT InsertQualifier(CSQLConnection *pConn,IWmiDbHandle *pScope, SQL_ID dObjectId,
  432. LPWSTR lpQualifierName, VARIANT vValue,
  433. long lQfrFlags,DWORD dwFlags, DWORD PropID,
  434. Properties &props);
  435. HRESULT InsertQualifiers (CSQLConnection *pConn,IWmiDbHandle *pScope, SQL_ID dObjectId, DWORD PropID, DWORD Flags, IWbemQualifierSet *pQS,
  436. Properties &props);
  437. HRESULT InsertArray(CSQLConnection *pConn,IWmiDbHandle *pScope, SQL_ID dObjectId, SQL_ID dClassId,
  438. DWORD dwPropertyID, VARIANT &vDefault, long lFlavor=0, DWORD dwRefID = 0,
  439. LPCWSTR lpObjectKey = NULL, LPCWSTR lpObjectPath = NULL, SQL_ID dScope = 0,
  440. CIMTYPE ct = 0);
  441. HRESULT InsertPropertyValues (CSQLConnection *pConn, IWmiDbHandle *pScope,
  442. LPWSTR lpPath,SQL_ID &dObjectId,SQL_ID dClassId,SQL_ID dScopeId,
  443. DWORD dwFlags,CWbemClassObjectProps *pProps, IWbemClassObject *pObj);
  444. HRESULT FormatBatchInsQfrs (CSQLConnection *pConn,IWmiDbHandle *pScope,
  445. SQL_ID dObjectId, SQL_ID dClassId,
  446. DWORD dPropID, IWbemQualifierSet *pQS,
  447. int &iPos, InsertQualifierValues **ppVals,
  448. Properties &props, int &iNumProps);
  449. HRESULT FormatBatchInsQfrValues(CSQLConnection *pConn,IWmiDbHandle *pScope,
  450. SQL_ID dObjectId, DWORD dwQfrID,
  451. VARIANT &vTemp, long lFlavor, InsertQualifierValues *pVals, Properties &props,
  452. int &iPos, DWORD PropID);
  453. HRESULT SetKeyhole (CSQLConnection *pConn, IWbemClassObject *pObj, DWORD dwKeyholePropID,
  454. LPWSTR sKeyholeProp, LPCWSTR lpScopePath, _bstr_t &sPath);
  455. HRESULT SetUnkeyedPath(CSQLConnection *pConn, IWbemClassObject *pObj, SQL_ID dClassId, _bstr_t &sObjPath);
  456. HRESULT InsertQualifierValues (CSQLConnection *pConn, SQL_ID dObjectId,IWbemClassObject *pObj,Properties &props);
  457. HRESULT NormalizeObjectPathGet (IWmiDbHandle __RPC_FAR *pScope, IWbemPath __RPC_FAR *pPath,
  458. LPWSTR * lpNewPath, BOOL *bDefault = NULL, SQL_ID *dClassId = NULL, SQL_ID *dScopeId = NULL
  459. , CSQLConnection *pConn = NULL);
  460. HRESULT NormalizeObjectPath(IWmiDbHandle __RPC_FAR *pScope, LPCWSTR lpPath, LPWSTR * lpNewPath, BOOL bNamespace=FALSE,
  461. CWbemClassObjectProps **ppProps=NULL, BOOL *bDefault = NULL, CSQLConnection *pConn = NULL, BOOL bNoTrunc = FALSE);
  462. HRESULT NormalizeObjectPath(IWbemClassObject __RPC_FAR *pScope, IWmiDbHandle *pScope2, LPCWSTR lpPath, LPWSTR * lpNewPath, BOOL bNamespace=FALSE,
  463. CWbemClassObjectProps **ppProps=NULL, BOOL *bDefault = NULL, BOOL bNoTrunc = FALSE);
  464. HRESULT VerifyObjectLock (SQL_ID ObjectId, DWORD dwLockType, DWORD dwVersion);
  465. BOOL IsDistributed() { return m_bIsDistributed;};
  466. HRESULT IssueDeletionEvents (CSQLConnection *pConn, SQL_ID dObjectId,
  467. SQL_ID dClassId, SQL_ID dScopeId, IWbemClassObject *pObj);
  468. HRESULT AddTransLock(SQL_ID dObjectId, DWORD dwHandleType);
  469. HRESULT CleanTransLocks();
  470. BOOL LockExists (SQL_ID dObjId);
  471. HRESULT UpdateHierarchy(CSQLConnection *pConn, SQL_ID dClassId, DWORD dwFlags, LPCWSTR lpScopePath,
  472. CWbemClassObjectProps *pProps, _IWmiObject *pObj);
  473. HRESULT UnlockDynasties(BOOL bDelete = FALSE);
  474. HRESULT DeleteRows(IWmiDbHandle *pScope, IWmiDbIterator *pIterator, REFIID iid);
  475. DWORD AddRef_Lock();
  476. DWORD Release_Lock();
  477. ULONG m_uRefCount;
  478. IWmiDbController *m_pController;
  479. IMalloc *m_pIMalloc;
  480. _bstr_t m_sNamespacePath;
  481. _bstr_t m_sMachineName;
  482. BOOL m_bInUse;
  483. DWORD m_dwLocale;
  484. BOOL m_bIsDistributed;
  485. _bstr_t m_sGUID; // GUID of the transaction.
  486. SessionLocks m_TransLocks;
  487. SessionDynasties m_Dynasties;
  488. RefCount m_ThreadRefCount;
  489. };
  490. #endif