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.

343 lines
7.6 KiB

  1. #ifndef _OM_H
  2. #define _OM_H
  3. /*++
  4. Copyright (c) 1996 Microsoft Corporation
  5. Module Name:
  6. om.h
  7. Abstract:
  8. Public data structures and procedure prototypes for the
  9. Object Manager (Om) subcomponent of the NT Cluster Service
  10. Author:
  11. Rod Gamache (rodga) 13-Mar-1996
  12. Revision History:
  13. --*/
  14. //
  15. // Common object header
  16. //
  17. #define OM_TRACE_REF 0
  18. //
  19. // Delete object callback method
  20. //
  21. typedef VOID (*OM_DELETE_OBJECT_METHOD)(
  22. IN PVOID Object
  23. );
  24. typedef OM_DELETE_OBJECT_METHOD *POM_DELETE_OBJECT_METHOD;
  25. //
  26. // Object Types
  27. //
  28. typedef enum _ObjectType {
  29. ObjectTypeResource = 1,
  30. ObjectTypeResType,
  31. ObjectTypeGroup,
  32. ObjectTypeNode,
  33. ObjectTypeCluster,
  34. ObjectTypeNetwork,
  35. ObjectTypeNetInterface,
  36. ObjectTypeMax
  37. } OBJECT_TYPE;
  38. //
  39. // Object Type structure
  40. //
  41. typedef struct _OM_OBJECT_TYPE_INITIALIZE {
  42. DWORD ObjectSize;
  43. DWORD Signature;
  44. LPCWSTR Name;
  45. OM_DELETE_OBJECT_METHOD DeleteObjectMethod;
  46. } OM_OBJECT_TYPE_INITIALIZE, *POM_OBJECT_TYPE_INITIALIZE;
  47. typedef struct _OM_OBJECT_TYPE {
  48. LIST_ENTRY ListHead;
  49. LIST_ENTRY CallbackListHead;
  50. DWORD Signature;
  51. DWORD Type;
  52. LPWSTR Name;
  53. DWORD ObjectSize;
  54. DWORD EnumKey; // If we ever run out, go to DWORDLONG
  55. CRITICAL_SECTION CriticalSection;
  56. OM_DELETE_OBJECT_METHOD DeleteObjectMethod;
  57. } OM_OBJECT_TYPE, *POM_OBJECT_TYPE;
  58. //
  59. // Object flags
  60. //
  61. #define OM_FLAG_OBJECT_INSERTED 0x00000001
  62. //the callback registered for object notifications
  63. typedef void (WINAPI *OM_OBJECT_NOTIFYCB)(
  64. IN PVOID pContext,
  65. IN PVOID pObject,
  66. IN DWORD dwNotification
  67. );
  68. // the notification record stored for an object
  69. typedef struct _OM_NOTIFY_RECORD{
  70. LIST_ENTRY ListEntry;
  71. OM_OBJECT_NOTIFYCB pfnObjNotifyCb;
  72. DWORD dwNotifyMask;
  73. PVOID pContext;
  74. }OM_NOTIFY_RECORD,*POM_NOTIFY_RECORD;
  75. //
  76. // Object header structure
  77. //
  78. typedef struct _OM_HEADER {
  79. #if OM_TRACE_REF
  80. LIST_ENTRY DeadListEntry;
  81. #endif
  82. LIST_ENTRY ListEntry;
  83. DWORD Signature;
  84. DWORD RefCount;
  85. DWORD Flags;
  86. LPWSTR Id;
  87. LPWSTR Name;
  88. POM_OBJECT_TYPE ObjectType;
  89. DWORD EnumKey;
  90. LIST_ENTRY CbListHead;
  91. DWORDLONG Body; // For alignment
  92. } OM_HEADER, *POM_HEADER;
  93. #define OmpObjectToHeader(pObject) CONTAINING_RECORD((pObject), OM_HEADER, Body)
  94. #define OmpReferenceHeader(pOmHeader) InterlockedIncrement(&(pOmHeader)->RefCount)
  95. #if OM_TRACE_REF
  96. extern DWORDLONG *OmpMatchRef;
  97. #define OmReferenceObject(pObject) \
  98. { \
  99. CsDbgPrint(LOG_NOISE, \
  100. "[OM] Reference object %1!lx! (new refcnt %2!d!) from file %3!s! line %4!u!.\n", \
  101. pObject, \
  102. ((OmpObjectToHeader(pObject))->RefCount) + 1, \
  103. __FILE__, \
  104. __LINE__ ); \
  105. OmpReferenceHeader(OmpObjectToHeader(pObject));\
  106. }
  107. #define OmDereferenceObject(pObject) \
  108. { \
  109. CsDbgPrint(LOG_NOISE, \
  110. "[OM] DeReference object %1!lx! (new refcnt %2!d!) from file %3!s! line %4!u!.\n", \
  111. pObject, \
  112. ((OmpObjectToHeader(pObject))->RefCount) - 1, \
  113. __FILE__, \
  114. __LINE__ ); \
  115. OmpDereferenceObject(pObject); \
  116. }
  117. //SS: Dont use this in an initialization assignment! This includes a comma, expression
  118. #define OmReferenceObjectByName(ObjectType, Name) \
  119. ((CsDbgPrint(LOG_NOISE, \
  120. "[OM] Reference object name %1!ws! from file %2!s! line %3!u!.\n", \
  121. Name, \
  122. __FILE__, \
  123. __LINE__ )), \
  124. (OmpReferenceObjectByName(ObjectType, Name))) \
  125. //SS: Dont use this in an initialization assignment! This includes a comma, expression
  126. #define OmReferenceObjectById(ObjectType, Id) \
  127. ((CsDbgPrint(LOG_NOISE, \
  128. "[OM] Reference object Id %1!ws! from file %2!s! line %3!u!.\n", \
  129. Id, \
  130. __FILE__, \
  131. __LINE__ )), \
  132. (OmpReferenceObjectById(ObjectType, Id))) \
  133. #else
  134. #define OmReferenceObject(pObject) OmpReferenceHeader(OmpObjectToHeader(pObject))
  135. #define OmDereferenceObject(pObject) OmpDereferenceObject(pObject)
  136. //SS: Dont use these in an initialization assignment! This includes a comma, expression
  137. // when the OM_TRACE_REF flag is on
  138. #define OmReferenceObjectById(ObjectType, Id) OmpReferenceObjectById(ObjectType, Id)
  139. #define OmReferenceObjectByName(ObjectType, Name) OmpReferenceObjectByName(ObjectType, Name)
  140. #endif
  141. #define OmObjectSignature(pObject) (OmpObjectToHeader(pObject))->Signature
  142. //
  143. // Read-only access to object name, Id, and type
  144. //
  145. #define OmObjectId(pObject) ((LPCWSTR)(OmpObjectToHeader(pObject)->Id))
  146. #define OmObjectName(pObject) ((LPCWSTR)(OmpObjectToHeader(pObject)->Name))
  147. #define OmObjectType(pObject) (OmpObjectToHeader(pObject)->ObjectType->Type)
  148. #define OmObjectInserted(pObject) ((BOOL)(OmpObjectToHeader(pObject)->Flags & OM_FLAG_OBJECT_INSERTED))
  149. //
  150. // Enumeration callback routine definitions
  151. //
  152. typedef BOOL (*OM_ENUM_OBJECT_ROUTINE)(
  153. IN PVOID Context1,
  154. IN PVOID Context2,
  155. IN PVOID Object,
  156. IN LPCWSTR Name
  157. );
  158. //
  159. // Global Functions
  160. //
  161. //
  162. // Startup and shutdown
  163. //
  164. DWORD
  165. WINAPI
  166. OmInitialize(
  167. VOID
  168. );
  169. VOID
  170. OmShutdown(
  171. VOID
  172. );
  173. //
  174. // Object types
  175. //
  176. DWORD
  177. WINAPI
  178. OmCreateType(
  179. IN OBJECT_TYPE ObjectType,
  180. IN POM_OBJECT_TYPE_INITIALIZE ObjectTypeInitialize
  181. );
  182. //
  183. // Objects management
  184. //
  185. PVOID
  186. WINAPI
  187. OmCreateObject(
  188. IN OBJECT_TYPE ObjectType,
  189. IN LPCWSTR ObjectId,
  190. IN LPCWSTR ObjectName OPTIONAL,
  191. OUT PBOOL Created OPTIONAL
  192. );
  193. DWORD
  194. WINAPI
  195. OmInsertObject(
  196. IN PVOID Object
  197. );
  198. DWORD
  199. WINAPI
  200. OmRemoveObject(
  201. IN PVOID Object
  202. );
  203. PVOID
  204. WINAPI
  205. OmpReferenceObjectById(
  206. IN OBJECT_TYPE ObjectType,
  207. IN LPCWSTR Id
  208. );
  209. PVOID
  210. WINAPI
  211. OmpReferenceObjectByName(
  212. IN OBJECT_TYPE ObjectType,
  213. IN LPCWSTR Name
  214. );
  215. DWORD
  216. WINAPI
  217. OmCountObjects(
  218. IN OBJECT_TYPE ObjectType,
  219. OUT LPDWORD NumberOfObjects
  220. );
  221. DWORD
  222. WINAPI
  223. OmEnumObjects(
  224. IN OBJECT_TYPE ObjectType,
  225. IN OM_ENUM_OBJECT_ROUTINE EnumerationRoutine,
  226. IN PVOID Context1,
  227. IN PVOID Context2
  228. );
  229. VOID
  230. OmpDereferenceObject(
  231. IN PVOID Object
  232. );
  233. DWORD
  234. WINAPI
  235. OmSetObjectName(
  236. IN PVOID Object,
  237. IN LPCWSTR ObjectName
  238. );
  239. DWORD
  240. WINAPI
  241. OmRegisterNotify(
  242. IN PVOID pObject,
  243. IN PVOID pContext,
  244. IN DWORD dwNotifyMask,
  245. IN OM_OBJECT_NOTIFYCB pfnObjNotifyCb
  246. );
  247. DWORD
  248. WINAPI
  249. OmDeregisterNotify(
  250. IN PVOID pObject,
  251. IN OM_OBJECT_NOTIFYCB lpfnObjNotifyCb
  252. );
  253. DWORD
  254. WINAPI
  255. OmRegisterTypeNotify(
  256. IN OBJECT_TYPE ObjectType,
  257. IN PVOID Context,
  258. IN DWORD NotifyMask,
  259. IN OM_OBJECT_NOTIFYCB lpfnObjNotifyCb
  260. );
  261. DWORD
  262. WINAPI
  263. OmNotifyCb(
  264. IN PVOID pObject,
  265. IN DWORD dwNotification
  266. );
  267. #endif //ifndef _OM_H