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.

377 lines
8.0 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 2000
  6. //
  7. // File: A D T G E N . H
  8. //
  9. // Contents: definitions of types/functions required for
  10. // generating generic audits.
  11. //
  12. // !!!WARNING!!!
  13. // This file is included by lsarpc.idl, therefore, if you
  14. // change it, make sure to clean build the entire DS depot.
  15. //
  16. //
  17. // History:
  18. // 07-January-2000 kumarp created
  19. //
  20. //------------------------------------------------------------------------
  21. #ifndef _ADTGEN_H
  22. #define _ADTGEN_H
  23. //
  24. // type of audit
  25. //
  26. // AUDIT_TYPE_LEGACY
  27. // In this case the audit event schema is stored in a .mc file.
  28. //
  29. // AUDIT_TYPE_WMI
  30. // The schema is stored in WMI. (currently not supported)
  31. //
  32. #define AUDIT_TYPE_LEGACY 1
  33. #define AUDIT_TYPE_WMI 2
  34. //
  35. // Type of parameters passed in the AUDIT_PARAMS.Parameters array
  36. //
  37. // Use the AdtInitParams function to initialize and prepare
  38. // an array of audit parameters.
  39. //
  40. typedef enum _AUDIT_PARAM_TYPE
  41. {
  42. //
  43. // do we need this?
  44. //
  45. APT_None = 1,
  46. //
  47. // NULL terminated string
  48. //
  49. APT_String,
  50. //
  51. // unsigned long
  52. //
  53. APT_Ulong,
  54. //
  55. // a pointer. use for specifying handles/pointers
  56. // (32 bit on 32 bit systems and 64 bit on 64 bit systems)
  57. // Note that the memory to which the pointer points to
  58. // is not marshalled when using this type. Use this when you
  59. // are interested in the absolute value of the pointer.
  60. // A good example of this is when specifying HANDLE values.
  61. //
  62. APT_Pointer,
  63. //
  64. // SID
  65. //
  66. APT_Sid,
  67. //
  68. // Logon ID (LUID)
  69. //
  70. APT_LogonId,
  71. //
  72. // Object Type List
  73. //
  74. APT_ObjectTypeList,
  75. } AUDIT_PARAM_TYPE;
  76. //
  77. // There are two types of flags that can be used with a parameter.
  78. //
  79. // - formatting flag
  80. // This defines the appearance of a parameter when
  81. // written to the eventlog. Such flags may become obsolete
  82. // when we move to WMI auditing.
  83. //
  84. // - control flag
  85. // This causes a specified action to be taken that affects
  86. // a parameter value.
  87. //
  88. // For example:
  89. // If you use the AP_PrimaryLogonId/AP_ClientLogonId flag,
  90. // the system will capture the logon-id from the process/thread token.
  91. //
  92. #define AP_ParamTypeBits 8
  93. #define AP_ParamTypeMask 0x000000ffL
  94. //
  95. // the flags values below have overlapping values. this is ok since
  96. // the scope of each flag is limited to the type to which it applies.
  97. //
  98. //
  99. // APT_Ulong : format flag : causes a number to appear in hex
  100. //
  101. #define AP_FormatHex (0x0001L << AP_ParamTypeBits)
  102. //
  103. // APT_Ulong : format flag : causes a number to be treated as access-mask.
  104. // The meaning of each bit depends on the associated
  105. // object type.
  106. //
  107. #define AP_AccessMask (0x0002L << AP_ParamTypeBits)
  108. //
  109. // APT_String : format flag : causes a string to be treated as a file-path
  110. //
  111. #define AP_Filespec (0x0001L << AP_ParamTypeBits)
  112. //
  113. // APT_LogonId : control flag : logon-id is captured from the process token
  114. //
  115. #define AP_PrimaryLogonId (0x0001L << AP_ParamTypeBits)
  116. //
  117. // APT_LogonId : control flag : logon-id is captured from the thread token
  118. //
  119. #define AP_ClientLogonId (0x0002L << AP_ParamTypeBits)
  120. //
  121. // internal helper macros
  122. //
  123. #define ApExtractType(TypeFlags) ((AUDIT_PARAM_TYPE)(TypeFlags & AP_ParamTypeMask))
  124. #define ApExtractFlags(TypeFlags) ((TypeFlags & ~AP_ParamTypeMask))
  125. //
  126. // Element of an object-type-list
  127. //
  128. // The AUDIT_OBJECT_TYPES structure identifies an object type element
  129. // in a hierarchy of object types. The AccessCheckByType functions use
  130. // an array of such structures to define a hierarchy of an object and
  131. // its subobjects, such as property sets and properties.
  132. //
  133. typedef struct _AUDIT_OBJECT_TYPE
  134. {
  135. GUID ObjectType; // guid of the (sub)object
  136. USHORT Flags; // currently not defined
  137. USHORT Level; // level within the hierarchy.
  138. // 0 is the root level
  139. ACCESS_MASK AccessMask; // access-mask for this (sub)object
  140. } AUDIT_OBJECT_TYPE, *PAUDIT_OBJECT_TYPE;
  141. typedef struct _AUDIT_OBJECT_TYPES
  142. {
  143. USHORT Count; // number of object-types in pObjectTypes
  144. USHORT Flags; // currently not defined
  145. #ifdef MIDL_PASS
  146. [size_is(Count)]
  147. #endif
  148. AUDIT_OBJECT_TYPE* pObjectTypes; // array of object-types
  149. } AUDIT_OBJECT_TYPES, *PAUDIT_OBJECT_TYPES;
  150. //
  151. // Structure that defines a single audit parameter.
  152. //
  153. // LsaGenAuditEvent accepts an array of such elements to
  154. // represent the parameters of the audit to be generated.
  155. //
  156. // It is best to initialize this structure using AdtInitParams function.
  157. // This will ensure compatibility with any future changes to this
  158. // structure.
  159. //
  160. typedef struct _AUDIT_PARAM
  161. {
  162. AUDIT_PARAM_TYPE Type; // type
  163. ULONG Length; // currently unused
  164. DWORD Flags; // currently unused
  165. #ifdef MIDL_PASS
  166. [switch_type(AUDIT_PARAM_TYPE),switch_is(Type)]
  167. #endif
  168. union
  169. {
  170. #ifdef MIDL_PASS
  171. [default]
  172. #endif
  173. ULONG_PTR Data0;
  174. #ifdef MIDL_PASS
  175. [case(APT_String)]
  176. [string]
  177. #endif
  178. PWSTR String;
  179. #ifdef MIDL_PASS
  180. [case(APT_Ulong,
  181. APT_Pointer)]
  182. #endif
  183. ULONG_PTR u;
  184. #ifdef MIDL_PASS
  185. [case(APT_Sid)]
  186. #endif
  187. SID* psid;
  188. #ifdef MIDL_PASS
  189. [case(APT_LogonId)]
  190. #endif
  191. ULONG LogonId_LowPart;
  192. #ifdef MIDL_PASS
  193. [case(APT_ObjectTypeList)]
  194. #endif
  195. AUDIT_OBJECT_TYPES* pObjectTypes;
  196. };
  197. #ifdef MIDL_PASS
  198. [switch_type(AUDIT_PARAM_TYPE),switch_is(Type)]
  199. #endif
  200. union
  201. {
  202. #ifdef MIDL_PASS
  203. [default]
  204. #endif
  205. ULONG_PTR Data1;
  206. #ifdef MIDL_PASS
  207. [case(APT_LogonId)]
  208. #endif
  209. LONG LogonId_HighPart;
  210. };
  211. } AUDIT_PARAM, *PAUDIT_PARAM;
  212. //
  213. // Audit control flags. To be used with AUDIT_PARAMS.Flags
  214. //
  215. #define APF_AuditFailure 0x00000000 // generate a failure audit
  216. #define APF_AuditSuccess 0x00000001 // generate a success audit when set,
  217. // a failure audit otherwise.
  218. //
  219. // set of valid audit control flags
  220. //
  221. #define APF_ValidFlags (APF_AuditSuccess)
  222. //
  223. // Audit parameters passed to LsaGenAuditEvent
  224. //
  225. typedef struct _AUDIT_PARAMS
  226. {
  227. ULONG Length; // size in bytes
  228. DWORD Flags; // currently unused
  229. USHORT Count; // number of parameters
  230. #ifdef MIDL_PASS
  231. [size_is(Count)]
  232. #endif
  233. AUDIT_PARAM* Parameters; // array of parameters
  234. } AUDIT_PARAMS, *PAUDIT_PARAMS;
  235. //
  236. // Defines the elements of a legacy audit event.
  237. //
  238. typedef struct _AUTHZ_AUDIT_EVENT_TYPE_LEGACY
  239. {
  240. //
  241. // Audit category ID
  242. //
  243. USHORT CategoryId;
  244. //
  245. // Audit event ID
  246. //
  247. USHORT AuditId;
  248. //
  249. // Parameter count
  250. //
  251. USHORT ParameterCount;
  252. } AUTHZ_AUDIT_EVENT_TYPE_LEGACY, *PAUTHZ_AUDIT_EVENT_TYPE_LEGACY;
  253. typedef
  254. #ifdef MIDL_PASS
  255. [switch_type(BYTE)]
  256. #endif
  257. union _AUTHZ_AUDIT_EVENT_TYPE_UNION
  258. {
  259. #ifdef MIDL_PASS
  260. [case(AUDIT_TYPE_LEGACY)]
  261. #endif
  262. AUTHZ_AUDIT_EVENT_TYPE_LEGACY Legacy;
  263. } AUTHZ_AUDIT_EVENT_TYPE_UNION, *PAUTHZ_AUDIT_EVENT_TYPE_UNION;
  264. //
  265. // description of an audit event
  266. //
  267. typedef
  268. struct _AUTHZ_AUDIT_EVENT_TYPE_OLD
  269. {
  270. // version number
  271. ULONG Version;
  272. DWORD dwFlags;
  273. LONG RefCount;
  274. ULONG_PTR hAudit;
  275. LUID LinkId;
  276. #ifdef MIDL_PASS
  277. [switch_is(Version)]
  278. #endif
  279. AUTHZ_AUDIT_EVENT_TYPE_UNION u;
  280. } AUTHZ_AUDIT_EVENT_TYPE_OLD;
  281. typedef
  282. #ifdef MIDL_PASS
  283. [handle]
  284. #endif
  285. AUTHZ_AUDIT_EVENT_TYPE_OLD* PAUTHZ_AUDIT_EVENT_TYPE_OLD;
  286. typedef
  287. #ifdef MIDL_PASS
  288. [context_handle]
  289. #endif
  290. PVOID AUDIT_HANDLE, *PAUDIT_HANDLE;
  291. BOOL
  292. AuthzpRegisterAuditEvent(
  293. IN PAUTHZ_AUDIT_EVENT_TYPE_OLD pAuditEventType,
  294. OUT PAUDIT_HANDLE phAuditContext
  295. );
  296. BOOL
  297. AuthzpUnregisterAuditEvent(
  298. IN OUT AUDIT_HANDLE* phAuditContext
  299. );
  300. #endif //_ADTGEN_H