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.

1057 lines
29 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. genobj.h
  5. Abstract:
  6. Definitions for the generic object implementation.
  7. AZ roles has so many objects that need creation, enumeration, etc
  8. that it seems prudent to have a single body of code for doing those operations.
  9. Author:
  10. Cliff Van Dyke (cliffv) 11-Apr-2001
  11. --*/
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. //
  17. // Structure definitions
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. //
  21. // A generic object list head.
  22. //
  23. // This structure represent the head of a linked list of objects. The linked
  24. // list of objects are considered to be "children" of this structure.
  25. //
  26. typedef struct _GENERIC_OBJECT_HEAD {
  27. //
  28. // Head of the linked list of objects
  29. //
  30. LIST_ENTRY Head;
  31. //
  32. // Count of entries on the list headed by Head
  33. //
  34. ULONG ObjectCount;
  35. //
  36. // Tree of the names of the objects
  37. //
  38. RTL_GENERIC_TABLE AvlTree;
  39. //
  40. // Back pointer to the GenericObject containing this structure
  41. //
  42. struct _GENERIC_OBJECT *ParentGenericObject;
  43. //
  44. // Each of the list heads that are rooted on a single object are linked
  45. // together. That list is headed by GENERIC_OBJECT->ChildGenericObjectHead.
  46. // This field is a pointer to the next entry in the list.
  47. //
  48. struct _GENERIC_OBJECT_HEAD *SiblingGenericObjectHead;
  49. //
  50. // The next sequence number to give out.
  51. //
  52. ULONG NextSequenceNumber;
  53. //
  54. // Object type of objects in this list
  55. //
  56. ULONG ObjectType;
  57. //
  58. // Flag to indicate that the parent needs to be loaded before this object can be
  59. // referenced
  60. //
  61. BOOLEAN LoadParentBeforeReferencing;
  62. //
  63. // The order of the defines below must match the tables at the top of genobj.cxx
  64. //
  65. // Define object types that are not visible to the providers
  66. //
  67. #define OBJECT_TYPE_SID (OBJECT_TYPE_COUNT)
  68. #define OBJECT_TYPE_CLIENT_CONTEXT (OBJECT_TYPE_COUNT+1)
  69. #define OBJECT_TYPE_ROOT (OBJECT_TYPE_COUNT+2)
  70. #define OBJECT_TYPE_MAXIMUM (OBJECT_TYPE_COUNT+3)
  71. } GENERIC_OBJECT_HEAD, *PGENERIC_OBJECT_HEAD;
  72. //
  73. // The name of a generic object
  74. //
  75. // This is a separate structure since the AVL tree manager insists on allocating its own
  76. // structure. Combine that with the facts that objects can be renamed and that a pointer
  77. // to the object is returned directly to the user as the handle to the object. These
  78. // facts imply that the structure containing the object name and the structure implementing
  79. // the "handle" cannot be the same structure. I chose to not implement a separate "handle"
  80. // structure. Such an implementation would have to "re-create and copy" the generic object
  81. // structure upon rename.
  82. //
  83. typedef struct _GENERIC_OBJECT_NAME {
  84. //
  85. // Name of the object
  86. //
  87. AZP_STRING ObjectName;
  88. //
  89. // Pointer to the GenericObject structure named by this name
  90. //
  91. struct _GENERIC_OBJECT *GenericObject;
  92. } GENERIC_OBJECT_NAME, *PGENERIC_OBJECT_NAME;
  93. //
  94. // The new name of a generic object
  95. //
  96. // This structure is only used during an AzPersistUpdateCache. Every attempt is made
  97. // to update the name of the object in the AVL tree. However, if there are name conflicts,
  98. // a GUID-ized name is used. That's certainly OK in a pinch. And we'll leave the name
  99. // that way if we can't fix it or in certain bounday low memory conditions. However, we
  100. // should fix it up if we can. This structure remembers the real name of the object and
  101. // allows AzpPersistReconcile to try to fix the name up.
  102. //
  103. typedef struct _NEW_OBJECT_NAME {
  104. //
  105. // Link to the next new name for the same authorization store object
  106. //
  107. LIST_ENTRY Next;
  108. //
  109. // Pointer to the GenericObject structure named by this name
  110. // The specified generic object has its reference count incremented.
  111. //
  112. struct _GENERIC_OBJECT *GenericObject;
  113. //
  114. // New name of the object
  115. //
  116. AZP_STRING ObjectName;
  117. } NEW_OBJECT_NAME, *PNEW_OBJECT_NAME;
  118. //
  119. // Object List
  120. //
  121. // Some objects have lists of references to other objects. These lists are
  122. // not parent/child relationships. Rather they represent memberships, etc.
  123. //
  124. // This structure represents the head of such a list.
  125. //
  126. // Both the pointed-from and pointed-to object have a generic object list. The
  127. // "forward" link represents the list that is managed via external API. The
  128. // "backward" link is provided to allow fixup of references when an object is deleted.
  129. // The "backward" link is also provided for cases where internal routines need to
  130. // traverse the link relationship in the opposite direction of the external API.
  131. // By convention, GENERIC_OBJECT_LIST instances in the forward direction are named
  132. // simply by the name of the object to point to. For instance, an object list that points
  133. // to AZ_OPERATION objects might be called "Operations". By convention, GENERIC_OBJECT_LIST
  134. // instances in the backward direction are prefixed by the name "back". For instance,
  135. // "backTasks".
  136. //
  137. // Note, there really isn't any reason why we couldn't expose "AddPropertyItem" and
  138. // "RemovePropertyItem" APIs for the "back" lists. See the IsBackLink and LinkPairId
  139. // definition.
  140. //
  141. typedef struct _GENERIC_OBJECT_LIST {
  142. //
  143. // Each of the object lists that are rooted on a single object are linked
  144. // together. That list is headed by GENERIC_OBJECT->GenericObjectLists.
  145. // This field is a pointer to the next entry in the list.
  146. //
  147. struct _GENERIC_OBJECT_LIST *NextGenericObjectList;
  148. //
  149. // Since an object list is a list of other objects, we want to be able to
  150. // generically find the other objects. The array below is an array of pointers
  151. // to the head of the lists that contain the other objects.
  152. //
  153. //
  154. // Unused elements in this array are set to NULL.
  155. //
  156. // These pointers are always pointers to a field in a "parent" structure.
  157. // Therefore, reference counts aren't needed. Instead, the "child" structure
  158. // containing the pointer to the parent will be deleted before the parent structure.
  159. //
  160. #define GEN_OBJECT_HEAD_COUNT 3
  161. PGENERIC_OBJECT_HEAD GenericObjectHeads[GEN_OBJECT_HEAD_COUNT];
  162. //
  163. // List identifier.
  164. //
  165. // The code maintains the link and the backlink. To do that, the code needs to
  166. // find one the "other" generic object list from this one. That algorithm uses
  167. // the IsBackLink and LinkPairId field.
  168. //
  169. // One object list has IsBackLink set TRUE and the other set FALSE. This handles
  170. // the case where an object contain both a forward an backward object list. For
  171. // instance, the AZ_GROUP object contains the AppMembers and backAppMembers fields.
  172. // This field differentiates between the two.
  173. //
  174. // There are cases where an object has multiple links between the same object types.
  175. // For instance, the AZ_GROUP object has both AppMembers and AppNonMembers links.
  176. // In those cases, the LinkPairId is set to a unique value to identify the pair.
  177. // In most cases, the value is simply zero.
  178. //
  179. BOOL IsBackLink;
  180. ULONG LinkPairId;
  181. #define AZP_LINKPAIR_MEMBERS 1
  182. #define AZP_LINKPAIR_NON_MEMBERS 2
  183. #define AZP_LINKPAIR_SID_MEMBERS 3
  184. #define AZP_LINKPAIR_SID_NON_MEMBERS 4
  185. #define AZP_LINKPAIR_POLICY_ADMINS 5
  186. #define AZP_LINKPAIR_POLICY_READERS 6
  187. #define AZP_LINKPAIR_DELEGATED_POLICY_USERS 7
  188. //
  189. // Dirty Bit to be set when this list is changed
  190. //
  191. ULONG DirtyBit;
  192. //
  193. // The array of pointers to the generic objects.
  194. //
  195. // Being in this list does not increment the ReferenceCount on the pointed-to
  196. // generic object.
  197. //
  198. AZP_PTR_ARRAY GenericObjects;
  199. //
  200. // An array of pointers to AZP_DELTA_ENTRY containing the GUIDs of the pointed to objects.
  201. //
  202. // This array contains GUIDs of links that have not yet been persisted.
  203. // It also contains GUIDs of links that have been updated from the persistence
  204. // provider but not yet merged into GenericObjects.
  205. AZP_PTR_ARRAY DeltaArray;
  206. } GENERIC_OBJECT_LIST, *PGENERIC_OBJECT_LIST;
  207. //
  208. // A generic object
  209. //
  210. typedef struct _GENERIC_OBJECT {
  211. //
  212. // Link to the next instance of an object of this type for the same parent object
  213. //
  214. LIST_ENTRY Next;
  215. //
  216. // Back pointer to the head of the list this object is in
  217. //
  218. PGENERIC_OBJECT_HEAD ParentGenericObjectHead;
  219. GENERIC_OBJECT_HEAD AzpSids;
  220. //
  221. // Pointer to the list heads for children of this object
  222. // This is a static list of the various GENERIC_OBJECT_HEAD structures
  223. // that exist in the object type specific portion of this object.
  224. // The list allows the generic object code to have insight into the
  225. // children of this object.
  226. //
  227. PGENERIC_OBJECT_HEAD ChildGenericObjectHead;
  228. //
  229. // Pointer to the list heads of pointers to other objects
  230. // This is a static list of the various GENERIC_OBJECT_LIST structures
  231. // that exist in the object type specific portion of this object.
  232. // The list allows the generic object code to have insight into the
  233. // other types of objects pointed to by this object.
  234. //
  235. struct _GENERIC_OBJECT_LIST *GenericObjectLists;
  236. //
  237. // Pointer to the generic object at the root of all generic objects
  238. // (Pointer to an AzAuthorizationStore object)
  239. //
  240. struct _AZP_AZSTORE *AzStoreObject;
  241. //
  242. // Pointer to provider specific data for this object
  243. //
  244. PVOID ProviderData;
  245. //
  246. // A list of SIDs as policy users
  247. // Used by AzAuthorizationStore, AzApplication and AzScope objects
  248. //
  249. GENERIC_OBJECT_LIST PolicyAdmins;
  250. GENERIC_OBJECT_LIST PolicyReaders;
  251. //
  252. // Boolean specifying whether or not the object ACL-able
  253. //
  254. // Used by AzAuthorizationStore, AzApplication and AzScope objects
  255. LONG IsAclSupported;
  256. //
  257. // Boolean specifying if delegation is supported. It is set during the
  258. // persist open calls at the provider levels. For example, an XML provider
  259. // would set this to FALSE, while an LDAP provider would set it to TRUE
  260. //
  261. // Used by AzAuthorizationStore and AzApplication objects
  262. //
  263. LONG IsDelegationSupported;
  264. //
  265. // A list of SIDs as delegated users
  266. // Used by AzAuthorizationStore and AzApplication
  267. //
  268. GENERIC_OBJECT_LIST DelegatedPolicyUsers;
  269. //
  270. // Name of the object
  271. //
  272. PGENERIC_OBJECT_NAME ObjectName;
  273. //
  274. // Opaque private information added by an application
  275. //
  276. AZP_STRING ApplicationData;
  277. //
  278. // Description of the object
  279. //
  280. AZP_STRING Description;
  281. //
  282. // Boolean indicating if the caller can write the object
  283. //
  284. LONG IsWritable;
  285. //
  286. // Boolen indicating if the caller can create children for this object
  287. //
  288. LONG CanCreateChildren;
  289. //
  290. // GUID of the object
  291. // The Guid of the object is assigned by the persistence provider.
  292. // The GUID is needed to make the object rename safe.
  293. //
  294. GUID PersistenceGuid;
  295. //
  296. // Number of references to this instance of the object
  297. // These are references from within our code.
  298. //
  299. LONG ReferenceCount;
  300. //
  301. // Number of references to this instance of the object
  302. // These are references represented by handles passed back to our caller.
  303. //
  304. LONG HandleReferenceCount;
  305. //
  306. // Sequence number of this object.
  307. // The list specified in Next is maintained in SequenceNumber order.
  308. // New entries are added to the tail end.
  309. // Enumerations are returned in SequenceNumber order.
  310. // SequenceNumber is returned to the caller as the EnumerationContext.
  311. //
  312. // This mechanism allows insertions and deletions to be handled seemlessly.
  313. //
  314. ULONG SequenceNumber;
  315. //
  316. // Specific object type represented by this generic object
  317. //
  318. ULONG ObjectType;
  319. //
  320. // Flags describing attributes of the generic object
  321. //
  322. ULONG Flags;
  323. #define GENOBJ_FLAGS_DELETED 0x01 // Object has been deleted
  324. #define GENOBJ_FLAGS_PERSIST_OK 0x02 // Persist provider has finished with this object
  325. #define GENOBJ_FLAGS_REFRESH_ME 0x04 // Object needs to be refreshed from cache
  326. //
  327. // Flags to indicate which attributes are dirty
  328. // High order bits are generic to all objects
  329. // Low order bits are specific to individual objects
  330. //
  331. // Bits in "DirtyBits" indicates that the object needs to be submitted
  332. // See the AZ_DIRTY_* defines.
  333. //
  334. ULONG DirtyBits;
  335. //
  336. // Flags to indicate that Persistence provider has changed the attribute
  337. // Access to this field is serialized by the PersistCritSect
  338. //
  339. // See the AZ_DIRTY_* defines.
  340. //
  341. ULONG PersistDirtyBits;
  342. //
  343. // Boolean specifying whether or not audits should be generated. Only
  344. // Authorizartion Store and application objects have this property. When this
  345. // is set to TRUE all possible audits for this AzAuthStore/application are generated.
  346. //
  347. LONG IsGeneratingAudits;
  348. //
  349. // Apply SACL property. Only AzAuthorizationStore, application and Scope objects
  350. // have this property.
  351. //
  352. LONG ApplySacl;
  353. //
  354. // whether apply SACL property is supported or not.
  355. // For AD stores, AzAuthorizationStore, application and Scope objects support it.
  356. // For XML stores, only AzAuthorizationStore supports it.
  357. //
  358. LONG IsSACLSupported;
  359. //
  360. // Boolean to indicate if the children are loaded into cache
  361. //
  362. BOOLEAN AreChildrenLoaded;
  363. //
  364. // Boolean to indicate that the object has been closed
  365. //
  366. BOOLEAN ObjectClosed;
  367. } GENERIC_OBJECT, *PGENERIC_OBJECT;
  368. //
  369. // Property ID to dirty bit mapping table
  370. //
  371. // This structure gives a mapping between property ID and the corresponding dirty bit.
  372. // It also provides a default value for the property.
  373. //
  374. typedef struct _AZP_DEFAULT_VALUE {
  375. ULONG PropertyId;
  376. ULONG DirtyBit;
  377. PVOID DefaultValue;
  378. } AZP_DEFAULT_VALUE, *PAZP_DEFAULT_VALUE;
  379. /////////////////////////////////////////////////////////////////////////////
  380. //
  381. // Macro definitions
  382. //
  383. /////////////////////////////////////////////////////////////////////////////
  384. //
  385. // Macro to determine if a GENERIC_OBJECT_LIST is a list of sids
  386. //
  387. #define AzpIsSidList( _gol ) \
  388. ((_gol)->GenericObjectHeads[0] != NULL && \
  389. (_gol)->GenericObjectHeads[0]->ObjectType == OBJECT_TYPE_SID )
  390. //
  391. // Macro to determine the address of a parent object from a child object
  392. //
  393. #define ParentOfChild( _go ) \
  394. ((_go)->ParentGenericObjectHead->ParentGenericObject)
  395. //
  396. // Macro to determine if an object type is a container type object or not
  397. //
  398. #define IsContainerObject( _objT ) \
  399. ( (_objT) == OBJECT_TYPE_AZAUTHSTORE || \
  400. (_objT) == OBJECT_TYPE_APPLICATION || \
  401. (_objT) == OBJECT_TYPE_SCOPE )
  402. //
  403. // Macro to determine is an object type is a delegator type object or not
  404. //
  405. #define IsDelegatorObject( _objT ) \
  406. ( (_objT) == OBJECT_TYPE_AZAUTHSTORE || \
  407. (_objT) == OBJECT_TYPE_APPLICATION )
  408. //
  409. // Macros to determine if the provider actually supports ACLs or delegation
  410. //
  411. #define CHECK_ACL_SUPPORT(_o) \
  412. (IsContainerObject( (_o)->ObjectType ) ? \
  413. ((_o)->IsAclSupported ? NO_ERROR : ERROR_NOT_SUPPORTED) : \
  414. ERROR_INVALID_PARAMETER )
  415. #define CHECK_DELEGATION_SUPPORT(_o) \
  416. (IsDelegatorObject( (_o)->ObjectType ) ? \
  417. ((_o)->IsDelegationSupported ? NO_ERROR : ERROR_NOT_SUPPORTED) : \
  418. ERROR_INVALID_PARAMETER )
  419. //
  420. // Macro to set a property in the cache.
  421. //
  422. // This macro acts as a wrapper around the code to set the property.
  423. // The macro detects the mode of the caller and properly handles the following:
  424. //
  425. // * Ensures object supports this "dirty" bit
  426. // * Sets the appropriate "dirty" bit depending on mode
  427. // * Avoids setting the property on AzUpdateCache if the property is dirty
  428. //
  429. // The correct calling sequence of the macros is:
  430. //
  431. // case AZ_PROP_XXX:
  432. // BEGIN_SETPROP( &WinStatus, Object, AZ_DIRTY_XXX ) {
  433. // WinStatus = f( Object->Property );
  434. // /* Optionally */ if ( WinStatus != NO_ERROR ) goto Cleanup
  435. // } END_SETPROP;
  436. // break;
  437. //
  438. extern DWORD AzGlObjectAllDirtyBits[];
  439. #define BEGIN_SETPROP( __WinStatusPtr, __ObjectPtr, __Flags, __DirtyBit ) \
  440. { \
  441. DWORD *_WinStatusPtr = (__WinStatusPtr); \
  442. PGENERIC_OBJECT _GenericObject = ((PGENERIC_OBJECT)(__ObjectPtr)); \
  443. ULONG _DirtyBit = (__DirtyBit); \
  444. ULONG _Flags = (__Flags); \
  445. BOOLEAN _DoSetProperty = FALSE; \
  446. \
  447. if ( (AzGlObjectAllDirtyBits[_GenericObject->ObjectType] & _DirtyBit) == 0 ) { \
  448. AzPrint(( AZD_INVPARM, "SetProperty: Object doesn't support dirty bit 0x%lx\n", _DirtyBit )); \
  449. *_WinStatusPtr = ERROR_INVALID_PARAMETER; \
  450. \
  451. } else if ( IsNormalFlags(_Flags) ) { \
  452. \
  453. _DoSetProperty = TRUE; \
  454. AzPrint(( AZD_PERSIST_MORE, "IsNormalFlags(_Flags) = TRUE\n" )); \
  455. if ( (_Flags & AZP_FLAGS_SETTING_TO_DEFAULT) == 0 && !AzpAzStoreVersionAllowWrite(_GenericObject->AzStoreObject) ) \
  456. { \
  457. *_WinStatusPtr = ERROR_REVISION_MISMATCH; \
  458. } \
  459. else { \
  460. _DoSetProperty = TRUE; \
  461. } \
  462. \
  463. } else { \
  464. \
  465. if ( (_GenericObject->DirtyBits & _DirtyBit) == 0 ) { \
  466. AzPrint(( AZD_PERSIST_MORE, "(_GenericObject->DirtyBits & _DirtyBit) = 0\n" )); \
  467. _DoSetProperty = TRUE; \
  468. } else if (IsRefreshFlags(_Flags)) { \
  469. AzPrint(( AZD_PERSIST_MORE, "IsRefreshFlags(_Flags) = TRUE\n" )); \
  470. _DoSetProperty = TRUE; \
  471. } else { \
  472. *_WinStatusPtr = NO_ERROR; \
  473. } \
  474. \
  475. } \
  476. \
  477. if ( _DoSetProperty ) { \
  478. #define END_SETPROP( __PropHasChanged ) \
  479. if ( *_WinStatusPtr == NO_ERROR && \
  480. (_Flags & AZP_FLAGS_SETTING_TO_DEFAULT) == 0 ) { \
  481. if ( IsNormalFlags( _Flags ) ) { \
  482. if ( (__PropHasChanged) ) { \
  483. _GenericObject->DirtyBits |= _DirtyBit; \
  484. } \
  485. } else { \
  486. ASSERT( AzpIsCritsectLocked( &_GenericObject->AzStoreObject->PersistCritSect ) ); \
  487. ASSERT( (_GenericObject->Flags & GENOBJ_FLAGS_PERSIST_OK) == 0 ); \
  488. _GenericObject->PersistDirtyBits |= _DirtyBit; \
  489. } \
  490. \
  491. } \
  492. } \
  493. }
  494. //
  495. // Macro to do validity checking after setting a property in the cache.
  496. //
  497. // This macro acts as a wrapper around the code to do the validity checking.
  498. // Some validity checking is only appropriate only when the caller is the UI
  499. // or application. This validity checking may not be valid when setting default
  500. // values or when populating the cache from the store.
  501. //
  502. // The correct calling sequence of the macros is:
  503. //
  504. // case AZ_PROP_XXX:
  505. // BEGIN_SETPROP( &WinStatus, Object, AZ_DIRTY_XXX ) {
  506. //
  507. // BEGIN_VALIDITY_CHECKING( Flags ) {
  508. // checks to see if property is valid
  509. // } END_VALIDITY_CHECKING;
  510. //
  511. // WinStatus = f( Object->Property );
  512. //
  513. // /* Optionally */ if ( WinStatus != NO_ERROR ) goto Cleanup
  514. // } END_SETPROP;
  515. // break;
  516. //
  517. #define DO_VALIDITY_CHECKING( _Flags ) \
  518. ( IsNormalFlags(_Flags) && (_Flags & (AZP_FLAGS_SETTING_TO_DEFAULT)) == 0 )
  519. #define BEGIN_VALIDITY_CHECKING( _Flags ) \
  520. { \
  521. \
  522. if ( DO_VALIDITY_CHECKING( _Flags ) ) {
  523. #define END_VALIDITY_CHECKING \
  524. } \
  525. }
  526. //
  527. // Macro to handle validity check on string length.
  528. //
  529. // The correct calling sequence of the macros is:
  530. //
  531. // case AZ_PROP_XXX:
  532. // BEGIN_SETPROP( &WinStatus, Object, AZ_DIRTY_XXX ) {
  533. //
  534. // //
  535. // // Capture the input string
  536. // //
  537. //
  538. // WinStatus = AzpCaptureString( &CapturedString,
  539. // (LPWSTR) PropertyValue,
  540. // CHECK_STRING_LENGTH( Flags, AZ_MAX_XXX),
  541. // TRUE ); // NULL is OK
  542. //
  543. // if ( WinStatus != NO_ERROR ) {
  544. // goto Cleanup;
  545. // }
  546. //
  547. // WinStatus = f( Object->Property );
  548. //
  549. // /* Optionally */ if ( WinStatus != NO_ERROR ) goto Cleanup
  550. // } END_SETPROP;
  551. // break;
  552. //
  553. #define CHECK_STRING_LENGTH( _Flags, _MaxLen ) \
  554. (DO_VALIDITY_CHECKING( _Flags ) ? (_MaxLen) : 0xFFFFFFFF)
  555. /////////////////////////////////////////////////////////////////////////////
  556. //
  557. // Procedure definitions
  558. //
  559. /////////////////////////////////////////////////////////////////////////////
  560. VOID
  561. ObInitGenericHead(
  562. IN PGENERIC_OBJECT_HEAD GenericObjectHead,
  563. IN ULONG ObjectType,
  564. IN PGENERIC_OBJECT ParentGenericObject,
  565. IN PGENERIC_OBJECT_HEAD SiblingGenericObjectHead OPTIONAL
  566. );
  567. VOID
  568. ObFreeGenericObject(
  569. IN PGENERIC_OBJECT GenericObject
  570. );
  571. VOID
  572. ObIncrHandleRefCount(
  573. IN PGENERIC_OBJECT GenericObject
  574. );
  575. DWORD
  576. ObDecrHandleRefCount(
  577. IN PGENERIC_OBJECT GenericObject
  578. );
  579. DWORD
  580. ObGetHandleType(
  581. IN PGENERIC_OBJECT Handle,
  582. IN BOOL AllowDeletedObjects,
  583. OUT PULONG ObjectType
  584. );
  585. DWORD
  586. ObReferenceObjectByName(
  587. IN PGENERIC_OBJECT_HEAD GenericObjectHead,
  588. IN PAZP_STRING ObjectName,
  589. IN ULONG Flags,
  590. OUT PGENERIC_OBJECT *RetGenericObject
  591. );
  592. DWORD
  593. ObReferenceObjectByHandle(
  594. IN PGENERIC_OBJECT Handle,
  595. IN BOOL AllowDeletedObjects,
  596. IN BOOLEAN RefreshCache,
  597. IN ULONG ObjectType
  598. );
  599. VOID
  600. ObDereferenceObject(
  601. IN PGENERIC_OBJECT GenericObject
  602. );
  603. typedef DWORD
  604. (OBJECT_INIT_ROUTINE)(
  605. IN PGENERIC_OBJECT ParentGenericObject,
  606. IN PGENERIC_OBJECT ChildGenericObject
  607. );
  608. typedef DWORD
  609. (OBJECT_NAME_CONFLICT_ROUTINE)(
  610. IN PGENERIC_OBJECT ParentGenericObject,
  611. IN PAZP_STRING ChildObjectNameString
  612. );
  613. typedef VOID
  614. (OBJECT_FREE_ROUTINE)(
  615. IN PGENERIC_OBJECT GenericObject
  616. );
  617. typedef DWORD
  618. (OBJECT_GET_PROPERTY_ROUTINE)(
  619. IN PGENERIC_OBJECT GenericObject,
  620. IN ULONG Flags,
  621. IN ULONG PropertyId,
  622. OUT PVOID *PropertyValue
  623. );
  624. typedef DWORD
  625. (OBJECT_SET_PROPERTY_ROUTINE)(
  626. IN PGENERIC_OBJECT GenericObject,
  627. IN ULONG Flags,
  628. IN ULONG PropertyId,
  629. IN PVOID PropertyValue
  630. );
  631. typedef DWORD
  632. (OBJECT_ADD_PROPERTY_ITEM_ROUTINE)(
  633. IN PGENERIC_OBJECT GenericObject,
  634. IN PGENERIC_OBJECT_LIST GenericObjectList,
  635. IN PGENERIC_OBJECT LinkedToObject
  636. );
  637. DWORD
  638. ObCreateObject(
  639. IN PGENERIC_OBJECT ParentGenericObject,
  640. IN PGENERIC_OBJECT_HEAD GenericChildHead,
  641. IN ULONG ChildObjectType,
  642. IN PAZP_STRING ChildObjectNameString,
  643. IN GUID *ChildObjectGuid OPTIONAL,
  644. IN ULONG Flags,
  645. OUT PGENERIC_OBJECT *RetChildGenericObject
  646. );
  647. //
  648. // Flags to various internal functions
  649. // The low order 2 bytes of this DWORD are shared with the AZPE_FLAGS defines in azper.h
  650. //
  651. #define AZP_FLAGS_SETTING_TO_DEFAULT 0x00010000 // Property is being set to default value
  652. #define AZP_FLAGS_BY_GUID 0x00020000 // Name based routine should use GUID instead
  653. #define AZP_FLAGS_ALLOW_DELETED_OBJECTS 0x00040000 // Allow deleted objects to be found
  654. #define AZP_FLAGS_REFRESH_CACHE 0x00080000 // Ensure cache is up to date
  655. #define AZP_FLAGS_RECONCILE 0x00100000 // The caller is AzpPersistReconcile
  656. //
  657. // Macro to return TRUE if this is a normal caller
  658. // (e.g., the app and not an internal caller)
  659. //
  660. #define IsNormalFlags( _Flags ) (((_Flags) & (AZPE_FLAGS_PERSIST_MASK|AZP_FLAGS_RECONCILE)) == 0 )
  661. #define IsRefreshFlags( _Flags ) (((_Flags) & (AZPE_FLAGS_PERSIST_REFRESH)) != 0 )
  662. DWORD
  663. ObGetProperty(
  664. IN PGENERIC_OBJECT GenericObject,
  665. IN ULONG Flags,
  666. IN ULONG PropertyId,
  667. OUT PVOID *PropertyValue
  668. );
  669. DWORD
  670. ObSetProperty(
  671. IN PGENERIC_OBJECT GenericObject,
  672. IN ULONG Flags,
  673. IN ULONG PropertyId,
  674. IN PVOID PropertyValue
  675. );
  676. DWORD
  677. ObSetPropertyToDefault(
  678. IN PGENERIC_OBJECT GenericObject,
  679. IN ULONG DirtyBits
  680. );
  681. DWORD
  682. ObCommonCreateObject(
  683. IN PGENERIC_OBJECT ParentGenericObject,
  684. IN ULONG ParentObjectType,
  685. IN PGENERIC_OBJECT_HEAD GenericChildHead,
  686. IN ULONG ChildObjectType,
  687. IN LPCWSTR ChildObjectName,
  688. IN DWORD Reserved,
  689. OUT PGENERIC_OBJECT *RetChildGenericObject
  690. );
  691. DWORD
  692. ObCommonOpenObject(
  693. IN PGENERIC_OBJECT ParentGenericObject,
  694. IN ULONG ParentObjectType,
  695. IN PGENERIC_OBJECT_HEAD GenericChildHead,
  696. IN ULONG ChildObjectType,
  697. IN LPCWSTR ChildObjectName,
  698. IN DWORD Reserved,
  699. OUT PGENERIC_OBJECT *RetChildGenericObject
  700. );
  701. DWORD
  702. ObEnumObjects(
  703. IN PGENERIC_OBJECT_HEAD GenericChildHead,
  704. IN BOOL EnumerateDeletedObjects,
  705. IN BOOL RefreshCache,
  706. IN OUT PULONG EnumerationContext,
  707. OUT PGENERIC_OBJECT *RetChildGenericObject
  708. );
  709. DWORD
  710. ObCommonEnumObjects(
  711. IN PGENERIC_OBJECT ParentGenericObject,
  712. IN ULONG ParentObjectType,
  713. IN PGENERIC_OBJECT_HEAD GenericChildHead,
  714. IN OUT PULONG EnumerationContext,
  715. IN DWORD Reserved,
  716. OUT PGENERIC_OBJECT *RetChildGenericObject
  717. );
  718. DWORD
  719. ObCommonGetProperty(
  720. IN PGENERIC_OBJECT GenericObject,
  721. IN ULONG Flags,
  722. IN ULONG PropertyId,
  723. IN DWORD Reserved,
  724. OUT PVOID *PropertyValue
  725. );
  726. DWORD
  727. ObCommonSetProperty(
  728. IN PGENERIC_OBJECT GenericObject,
  729. IN ULONG PropertyId,
  730. IN DWORD Reserved,
  731. IN PVOID PropertyValue
  732. );
  733. VOID
  734. ObMarkObjectDeleted(
  735. IN PGENERIC_OBJECT GenericObject
  736. );
  737. DWORD
  738. ObCommonDeleteObject(
  739. IN PGENERIC_OBJECT ParentGenericObject,
  740. IN ULONG ParentObjectType,
  741. IN PGENERIC_OBJECT_HEAD GenericChildHead,
  742. IN ULONG ChildObjectType,
  743. IN LPCWSTR ChildObjectName,
  744. IN DWORD Reserved
  745. );
  746. VOID
  747. ObInitObjectList(
  748. IN OUT PGENERIC_OBJECT_LIST GenericObjectList,
  749. IN PGENERIC_OBJECT_LIST NextGenericObjectList OPTIONAL,
  750. IN BOOL IsBackLink,
  751. IN ULONG LinkPairId,
  752. IN ULONG DirtyBit,
  753. IN PGENERIC_OBJECT_HEAD GenericObjectHead0 OPTIONAL,
  754. IN PGENERIC_OBJECT_HEAD GenericObjectHead1 OPTIONAL,
  755. IN PGENERIC_OBJECT_HEAD GenericObjectHead2 OPTIONAL
  756. );
  757. DWORD
  758. ObAddPropertyItem(
  759. IN PGENERIC_OBJECT GenericObject,
  760. IN PGENERIC_OBJECT_LIST GenericObjectList,
  761. IN ULONG Flags,
  762. IN PAZP_STRING ObjectName
  763. );
  764. DWORD
  765. ObLookupPropertyItem(
  766. IN PGENERIC_OBJECT_LIST GenericObjectList,
  767. IN PAZP_STRING ObjectName,
  768. OUT PULONG InsertionPoint OPTIONAL
  769. );
  770. DWORD
  771. ObRemovePropertyItem(
  772. IN PGENERIC_OBJECT GenericObject,
  773. IN PGENERIC_OBJECT_LIST GenericObjectList,
  774. IN PAZP_STRING ObjectName
  775. );
  776. PAZ_STRING_ARRAY
  777. ObGetPropertyItems(
  778. IN PGENERIC_OBJECT_LIST GenericObjectList
  779. );
  780. PAZ_GUID_ARRAY
  781. ObGetPropertyItemGuids(
  782. IN PGENERIC_OBJECT_LIST GenericObjectList
  783. );
  784. VOID
  785. ObRemoveObjectListLink(
  786. IN PGENERIC_OBJECT GenericObject,
  787. IN PGENERIC_OBJECT_LIST GenericObjectList,
  788. IN ULONG Index
  789. );
  790. VOID
  791. ObRemoveObjectListLinks(
  792. IN PGENERIC_OBJECT GenericObject
  793. );
  794. VOID
  795. ObFreeObjectList(
  796. IN PGENERIC_OBJECT GenericObject,
  797. IN OUT PGENERIC_OBJECT_LIST GenericObjectList
  798. );
  799. DWORD
  800. ObCheckNameConflict(
  801. IN PGENERIC_OBJECT_HEAD GenericObjectHead,
  802. IN PAZP_STRING ObjectNameString,
  803. IN ULONG ConflictListOffset,
  804. IN ULONG GrandchildListOffset,
  805. IN ULONG GrandChildConflictListOffset
  806. );
  807. DWORD
  808. ObMapPropIdToObjectList(
  809. IN PGENERIC_OBJECT GenericObject,
  810. IN ULONG PropertyId,
  811. OUT PGENERIC_OBJECT_LIST *GenericObjectList,
  812. OUT PULONG ObjectType
  813. );
  814. BOOLEAN
  815. ObLookupDelta(
  816. IN ULONG DeltaFlags,
  817. IN GUID *Guid,
  818. IN PAZP_PTR_ARRAY AzpPtrArray,
  819. OUT PULONG InsertionPoint OPTIONAL
  820. );
  821. DWORD
  822. ObAddDeltaToArray(
  823. IN ULONG DeltaFlags,
  824. IN GUID *Guid,
  825. IN PAZP_PTR_ARRAY AzpPtrArray,
  826. IN BOOLEAN DiscardDeletes
  827. );
  828. VOID
  829. ObFreeDeltaArray(
  830. IN PAZP_PTR_ARRAY DeltaArray,
  831. IN BOOLEAN FreeAllEntries
  832. );
  833. BOOLEAN
  834. ObAllocateNewName(
  835. IN PGENERIC_OBJECT GenericObject,
  836. IN PAZP_STRING ObjectName
  837. );
  838. VOID
  839. ObFreeNewName(
  840. IN PNEW_OBJECT_NAME NewObjectName
  841. );
  842. DWORD
  843. ObUnloadChildGenericHeads(
  844. IN PGENERIC_OBJECT pParentObject
  845. );
  846. #ifdef __cplusplus
  847. }
  848. #endif