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.

403 lines
8.6 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. //
  76. // Luid (not translated to LogonId)
  77. //
  78. APT_Luid,
  79. //
  80. // Guid
  81. //
  82. APT_Guid,
  83. //
  84. // Time (FILETIME)
  85. //
  86. APT_Time,
  87. //
  88. // ULONGLONG
  89. //
  90. APT_Int64
  91. } AUDIT_PARAM_TYPE;
  92. //
  93. // There are two types of flags that can be used with a parameter.
  94. //
  95. // - formatting flag
  96. // This defines the appearance of a parameter when
  97. // written to the eventlog. Such flags may become obsolete
  98. // when we move to WMI auditing.
  99. //
  100. // - control flag
  101. // This causes a specified action to be taken that affects
  102. // a parameter value.
  103. //
  104. // For example:
  105. // If you use the AP_PrimaryLogonId/AP_ClientLogonId flag,
  106. // the system will capture the logon-id from the process/thread token.
  107. //
  108. #define AP_ParamTypeBits 8
  109. #define AP_ParamTypeMask 0x000000ffL
  110. //
  111. // the flags values below have overlapping values. this is ok since
  112. // the scope of each flag is limited to the type to which it applies.
  113. //
  114. //
  115. // APT_Ulong : format flag : causes a number to appear in hex
  116. //
  117. #define AP_FormatHex (0x0001L << AP_ParamTypeBits)
  118. //
  119. // APT_Ulong : format flag : causes a number to be treated as access-mask.
  120. // The meaning of each bit depends on the associated
  121. // object type.
  122. //
  123. #define AP_AccessMask (0x0002L << AP_ParamTypeBits)
  124. //
  125. // APT_String : format flag : causes a string to be treated as a file-path
  126. //
  127. #define AP_Filespec (0x0001L << AP_ParamTypeBits)
  128. //
  129. // APT_LogonId : control flag : logon-id is captured from the process token
  130. //
  131. #define AP_PrimaryLogonId (0x0001L << AP_ParamTypeBits)
  132. //
  133. // APT_LogonId : control flag : logon-id is captured from the thread token
  134. //
  135. #define AP_ClientLogonId (0x0002L << AP_ParamTypeBits)
  136. //
  137. // internal helper macros
  138. //
  139. #define ApExtractType(TypeFlags) ((AUDIT_PARAM_TYPE)(TypeFlags & AP_ParamTypeMask))
  140. #define ApExtractFlags(TypeFlags) ((TypeFlags & ~AP_ParamTypeMask))
  141. //
  142. // Element of an object-type-list
  143. //
  144. // The AUDIT_OBJECT_TYPES structure identifies an object type element
  145. // in a hierarchy of object types. The AccessCheckByType functions use
  146. // an array of such structures to define a hierarchy of an object and
  147. // its subobjects, such as property sets and properties.
  148. //
  149. typedef struct _AUDIT_OBJECT_TYPE
  150. {
  151. GUID ObjectType; // guid of the (sub)object
  152. USHORT Flags; // currently not defined
  153. USHORT Level; // level within the hierarchy.
  154. // 0 is the root level
  155. ACCESS_MASK AccessMask; // access-mask for this (sub)object
  156. } AUDIT_OBJECT_TYPE, *PAUDIT_OBJECT_TYPE;
  157. typedef struct _AUDIT_OBJECT_TYPES
  158. {
  159. USHORT Count; // number of object-types in pObjectTypes
  160. USHORT Flags; // currently not defined
  161. #ifdef MIDL_PASS
  162. [size_is(Count)]
  163. #endif
  164. AUDIT_OBJECT_TYPE* pObjectTypes; // array of object-types
  165. } AUDIT_OBJECT_TYPES, *PAUDIT_OBJECT_TYPES;
  166. //
  167. // Structure that defines a single audit parameter.
  168. //
  169. // LsaGenAuditEvent accepts an array of such elements to
  170. // represent the parameters of the audit to be generated.
  171. //
  172. // It is best to initialize this structure using AdtInitParams function.
  173. // This will ensure compatibility with any future changes to this
  174. // structure.
  175. //
  176. typedef struct _AUDIT_PARAM
  177. {
  178. AUDIT_PARAM_TYPE Type; // type
  179. ULONG Length; // currently unused
  180. DWORD Flags; // currently unused
  181. #ifdef MIDL_PASS
  182. [switch_type(AUDIT_PARAM_TYPE),switch_is(Type)]
  183. #endif
  184. union
  185. {
  186. #ifdef MIDL_PASS
  187. [default]
  188. #endif
  189. ULONG_PTR Data0;
  190. #ifdef MIDL_PASS
  191. [case(APT_String)]
  192. [string]
  193. #endif
  194. PWSTR String;
  195. #ifdef MIDL_PASS
  196. [case(APT_Ulong,
  197. APT_Pointer)]
  198. #endif
  199. ULONG_PTR u;
  200. #ifdef MIDL_PASS
  201. [case(APT_Sid)]
  202. #endif
  203. SID* psid;
  204. #ifdef MIDL_PASS
  205. [case(APT_Guid)]
  206. #endif
  207. GUID* pguid;
  208. #ifdef MIDL_PASS
  209. [case(APT_LogonId)]
  210. #endif
  211. ULONG LogonId_LowPart;
  212. #ifdef MIDL_PASS
  213. [case(APT_ObjectTypeList)]
  214. #endif
  215. AUDIT_OBJECT_TYPES* pObjectTypes;
  216. };
  217. #ifdef MIDL_PASS
  218. [switch_type(AUDIT_PARAM_TYPE),switch_is(Type)]
  219. #endif
  220. union
  221. {
  222. #ifdef MIDL_PASS
  223. [default]
  224. #endif
  225. ULONG_PTR Data1;
  226. #ifdef MIDL_PASS
  227. [case(APT_LogonId)]
  228. #endif
  229. LONG LogonId_HighPart;
  230. };
  231. } AUDIT_PARAM, *PAUDIT_PARAM;
  232. //
  233. // Audit control flags. To be used with AUDIT_PARAMS.Flags
  234. //
  235. #define APF_AuditFailure 0x00000000 // generate a failure audit
  236. #define APF_AuditSuccess 0x00000001 // generate a success audit when set,
  237. // a failure audit otherwise.
  238. //
  239. // set of valid audit control flags
  240. //
  241. #define APF_ValidFlags (APF_AuditSuccess)
  242. //
  243. // Audit parameters passed to LsaGenAuditEvent
  244. //
  245. typedef struct _AUDIT_PARAMS
  246. {
  247. ULONG Length; // size in bytes
  248. DWORD Flags; // currently unused
  249. USHORT Count; // number of parameters
  250. #ifdef MIDL_PASS
  251. [size_is(Count)]
  252. #endif
  253. AUDIT_PARAM* Parameters; // array of parameters
  254. } AUDIT_PARAMS, *PAUDIT_PARAMS;
  255. //
  256. // Defines the elements of a legacy audit event.
  257. //
  258. typedef struct _AUTHZ_AUDIT_EVENT_TYPE_LEGACY
  259. {
  260. //
  261. // Audit category ID
  262. //
  263. USHORT CategoryId;
  264. //
  265. // Audit event ID
  266. //
  267. USHORT AuditId;
  268. //
  269. // Parameter count
  270. //
  271. USHORT ParameterCount;
  272. } AUTHZ_AUDIT_EVENT_TYPE_LEGACY, *PAUTHZ_AUDIT_EVENT_TYPE_LEGACY;
  273. typedef
  274. #ifdef MIDL_PASS
  275. [switch_type(BYTE)]
  276. #endif
  277. union _AUTHZ_AUDIT_EVENT_TYPE_UNION
  278. {
  279. #ifdef MIDL_PASS
  280. [case(AUDIT_TYPE_LEGACY)]
  281. #endif
  282. AUTHZ_AUDIT_EVENT_TYPE_LEGACY Legacy;
  283. } AUTHZ_AUDIT_EVENT_TYPE_UNION, *PAUTHZ_AUDIT_EVENT_TYPE_UNION;
  284. //
  285. // description of an audit event
  286. //
  287. typedef
  288. struct _AUTHZ_AUDIT_EVENT_TYPE_OLD
  289. {
  290. // version number
  291. ULONG Version;
  292. DWORD dwFlags;
  293. LONG RefCount;
  294. ULONG_PTR hAudit;
  295. LUID LinkId;
  296. #ifdef MIDL_PASS
  297. [switch_is(Version)]
  298. #endif
  299. AUTHZ_AUDIT_EVENT_TYPE_UNION u;
  300. } AUTHZ_AUDIT_EVENT_TYPE_OLD;
  301. typedef
  302. #ifdef MIDL_PASS
  303. [handle]
  304. #endif
  305. AUTHZ_AUDIT_EVENT_TYPE_OLD* PAUTHZ_AUDIT_EVENT_TYPE_OLD;
  306. typedef
  307. #ifdef MIDL_PASS
  308. [context_handle]
  309. #endif
  310. PVOID AUDIT_HANDLE, *PAUDIT_HANDLE;
  311. //
  312. // Begin support for extensible auditing.
  313. //
  314. #define AUTHZ_ALLOW_MULTIPLE_SOURCE_INSTANCES 0x1
  315. #define AUTHZ_AUDIT_INSTANCE_INFORMATION 0x2
  316. #endif //_ADTGEN_H