Bitdefender Hypervisor Memory Introspection
update_exceptions.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Bitdefender
3  * SPDX-License-Identifier: Apache-2.0
4  */
9 
10 #ifndef _UPDATE_EXCEPTIONS_H_
11 #define _UPDATE_EXCEPTIONS_H_
12 
13 #include "exceptions.h"
14 
15 //
16 // These will be shared between Linux & Windows
17 //
18 
19 #pragma pack(push)
20 #pragma pack(1)
21 
22 
26 typedef struct _UPDATE_FILE_HEADER
27 {
29 
30  struct
31  {
34  } Version;
35 
39 
41 
44 
47 
48 
52 typedef struct _UPDATE_HEADER
53 {
57 
58 
62 typedef struct _UPDATE_KM_EXCEPTION
63 {
64  struct
65  {
68  } Originator;
69 
71 
73 
77 
78  _Field_size_(SigCount)
79  DWORD SigIds[];
81 
82 
86 typedef struct _UPDATE_UM_EXCEPTION
87 {
89 
90  struct
91  {
94  } Victim;
95 
97 
101 
102  _Field_size_(SigCount)
103  DWORD SigIds[];
105 
106 
111 {
114 
120 
122  CHAR OriginatorNameGlob[EXCEPTION_UM_GLOB_LENGTH];
123 
124  struct
125  {
130  } Victim;
131 
132  _Field_size_(SigCount)
133  DWORD SigIds[];
135 
136 
140 typedef struct _UPDATE_KUM_EXCEPTION
141 {
142 
144 
145  struct
146  {
149  } Victim;
150 
152 
156 
157  _Field_size_(SigCount)
158  DWORD SigIds[];
160 
161 
165 typedef struct _UPDATE_CB_HASH
166 {
168 
169  _Field_size_(Count)
170  DWORD Hashes[];
172 
173 
177 typedef struct _UPDATE_VALUE_HASH
178 {
181  BYTE _Reserved[4];
184 
185 
189 typedef struct _UPDATE_EXPORT_HASH
190 {
192  BYTE _Reserved[2];
195 
196 
200 typedef struct _UPDATE_CB_SIGNATURE
201 {
204 
207 
208  char HashesList[];
210 
211 
216 {
219 
221 
223  BYTE _Align[3];
224 
225  char HashesList[];
227 
228 
233 {
236 
239  BYTE _Align[2];
240 
241  char HashesList[];
243 
244 
248 typedef struct _UPDATE_IDT_SIGNATURE
249 {
252 
254  BYTE _Reserved[3];
256 
257 
262 {
265 
268 
269  WORD Pattern[];
271 
272 
277 {
280 
281  union
282  {
284  struct
285  {
290  BYTE _Reserved[2];
291  };
294  } Minimum;
295 
296  union
297  {
299  struct
300  {
301  BYTE Version;
302  BYTE Patch;
303  WORD Sublevel;
304  WORD Backport;
305  BYTE _Reserved[2];
306  };
308  QWORD Value;
309  } Maximum;
310 
312 
313 
318 {
321 
322  union
323  {
325  struct
326  {
331  };
332 
334  } Minimum;
335 
336  union
337  {
339  struct
340  {
341  WORD Major;
342  WORD Minor;
343  WORD Revision;
344  WORD Build;
345  };
346 
347  QWORD Raw;
348  } Maximum;
349 
351 
352 
357 {
360 
362 
363  DWORD _Reserved[3];
364 
366 
367 #pragma pack(pop)
368 
369 
370 #define UPDATE_MAGIC_WORD 'ANXE'
371 
372 #define UPDATE_TYPE_KM_EXCEPTION 1
373 #define UPDATE_TYPE_UM_EXCEPTION 2
374 #define UPDATE_TYPE_UM_EXCEPTION_GLOB_MATCH 6
375 #define UPDATE_TYPE_APC_UM_EXCEPTION 9
376 
377 #define UPDATE_TYPE_CB_SIGNATURE 3
378 #define UPDATE_TYPE_EXPORT_SIGNATURE 4
379 #define UPDATE_TYPE_VALUE_SIGNATURE 5
380 #define UPDATE_TYPE_RESERVED 7
381 #define UPDATE_TYPE_VALUE_CODE_SIGNATURE 8
382 #define UPDATE_TYPE_IDT_SIGNATURE 10
383 #define UPDATE_TYPE_VERSION_OS_SIGNATURE 11
384 #define UPDATE_TYPE_VERSION_INTRO_SIGNATURE 12
385 #define UPDATE_TYPE_PROCESS_CREATION_SIGNATURE 13
386 #define UPDATE_TYPE_KUM_EXCEPTION 14
387 
388 #define UPDATE_EXCEPTIONS_MIN_VER_MAJOR 2
389 #define UPDATE_EXCEPTIONS_MIN_VER_MINOR 2
390 
391 
392 INTSTATUS
394  _Out_ WORD *MajorVersion,
395  _Out_ WORD *MinorVersion,
397  );
398 
399 INTSTATUS
401  _In_ void *Buffer,
402  _In_ DWORD Length,
403  _In_ DWORD Flags
404  );
405 
406 INTSTATUS
408  _In_ const void *Event,
409  _In_ INTRO_EVENT_TYPE Type,
410  _In_ BOOLEAN Exception,
411  _In_ QWORD Context
412  );
413 
414 INTSTATUS
416  void
417  );
418 
419 INTSTATUS
421  _In_opt_ QWORD Context
422  );
423 
424 #endif // _UPDATE_EXCEPTIONS_H_
#define _In_opt_
Definition: intro_sal.h:16
BYTE _Reserved
Alignment purposes.
The header of an exception or a signature.
DWORD Flags
The flags of the exception; any flags from _EXCEPTION_FLG.
_Bool BOOLEAN
Definition: intro_types.h:58
#define _Out_
Definition: intro_sal.h:22
DWORD Id
An unique id (_EXCEPTION_SIGNATURE_ID)
BYTE Type
The type of the exception; any type from _UM_EXCEPTION_OBJECT.
DWORD Flags
Contains any flags from _SIGNATURE_FLG.
uint8_t BYTE
Definition: intro_types.h:47
struct _UPDATE_PROCESS_CREATION_SIGNATURE UPDATE_PROCESS_CREATION_SIGNATURE
Describe a process-creation signature in binary format.
#define _In_
Definition: intro_sal.h:21
struct _UPDATE_CB_SIGNATURE * PUPDATE_CB_SIGNATURE
uint16_t WORD
Definition: intro_types.h:48
Describe a code-blocks hash in binary format.
struct _UPDATE_EXPORT_SIGNATURE UPDATE_EXPORT_SIGNATURE
Describe an export signature in binary format.
Describe a kernel-mode exception in binary format.
DWORD Flags
Contains any flags from _SIGNATURE_FLG.
WORD SigCount
The number of the signatures.
struct _UPDATE_FILE_HEADER * PUPDATE_FILE_HEADER
Describe a export hash in binary format.
WORD SigCount
The number of the signatures.
Describe a version OS signature in binary format.
INTSTATUS IntUpdateLoadExceptions(void *Buffer, DWORD Length, DWORD Flags)
Handles the exceptions coming from the integrator.
DWORD OriginatorNameHash
The name-hash of the originator.
Describe a process-creation signature in binary format.
INT16 Offset
The displacement from the beginning of the modified zone.
DWORD Flags
Contains any flags from _SIGNATURE_FLG.
struct _UPDATE_IDT_SIGNATURE * PUPDATE_IDT_SIGNATURE
struct _UPDATE_VALUE_HASH UPDATE_VALUE_HASH
Describe a value hash in binary format.
BYTE ListsCount
The number of the list of hashes.
struct _UPDATE_VALUE_SIGNATURE * PUPDATE_VALUE_SIGNATURE
int INTSTATUS
The status data type.
Definition: introstatus.h:24
WORD Minor
The minor version of the exceptions binary file.
DWORD OriginatorNameHash
The name-hash of the originator.
DWORD CreateMask
Contains the DPI mask.
BYTE _Reserved
Alignment purposes.
Describe a value hash in binary format.
Describe an IDT signature in binary format.
DWORD Flags
Contains any flags from _SIGNATURE_FLG.
DWORD NameHash
The name-hash of the originator.
struct _UPDATE_HEADER * PUPDATE_HEADER
Describe a value-code signature in binary format.
DWORD Id
An unique id (_EXCEPTION_SIGNATURE_ID)
WORD Size
The size of the exception/signature.
DWORD BuildNumber
The build number of the exceptions binary file.
struct _UPDATE_VALUE_CODE_SIGNATURE * PUPDATE_VALUE_CODE_SIGNATURE
#define EXCEPTION_UM_GLOB_LENGTH
Definition: exceptions.h:36
#define _Field_size_(expr)
Definition: intro_sal.h:41
DWORD SignaturesCount
The number of the signatures.
struct _UPDATE_FILE_HEADER UPDATE_FILE_HEADER
The header of the exceptions binary file.
struct _UPDATE_FILE_HEADER::@138 Version
struct _UPDATE_VERSION_INTRO_SIGNATURE * PUPDATE_VERSION_INTRO_SIGNATURE
DWORD Hash
The hash of the modified zone.
unsigned long long QWORD
Definition: intro_types.h:53
DWORD Id
An unique id (_EXCEPTION_SIGNATURE_ID)
DWORD Id
An unique id (_EXCEPTION_SIGNATURE_ID)
BYTE ListsCount
The number of the list of hashes.
The header of the exceptions binary file.
DWORD VictimNameHash
The name-hash of the victim.
struct _UPDATE_PROCESS_CREATION_SIGNATURE * PUPDATE_PROCESS_CREATION_SIGNATURE
BYTE Type
The type of the exception/signature.
WORD Length
The length of the opcode pattern.
Describe a value signature in binary format.
Describe a kernel-user mode exception in binary format.
DWORD ProcessHash
The name-hash of the process in which the modification takes place.
DWORD Id
An unique id (_EXCEPTION_SIGNATURE_ID)
struct _UPDATE_EXPORT_HASH * PUPDATE_EXPORT_HASH
DWORD Magic
The magic value; must be UPDATE_MAGIC_WORD.
struct _UPDATE_HEADER UPDATE_HEADER
The header of an exception or a signature.
DWORD UserExceptionsCount
The number of the user-mode exceptions.
uint32_t DWORD
Definition: intro_types.h:49
int16_t INT16
Definition: intro_types.h:43
WORD SigCount
The number of the signatures.
BYTE Type
The type of the exception; any type from KUM_EXCEPTION_OBJECT.
BYTE Count
The number of hashes from the list.
struct _UPDATE_VALUE_SIGNATURE UPDATE_VALUE_SIGNATURE
Describe a value signature in binary format.
DWORD Flags
The flags of the exception; any flags from EXCEPTION_FLG.
DWORD Id
An unique id (_EXCEPTION_SIGNATURE_ID)
struct _UPDATE_VERSION_OS_SIGNATURE UPDATE_VERSION_OS_SIGNATURE
Describe a version OS signature in binary format.
DWORD Flags
Contains any flags from _SIGNATURE_FLG.
DWORD Flags
Contains any flags from _SIGNATURE_FLG.
struct _UPDATE_IDT_SIGNATURE UPDATE_IDT_SIGNATURE
Describe an IDT signature in binary format.
DWORD UserExceptionsGlobCount
The number of the user-mode exceptions that contains glob items.
struct _UPDATE_VERSION_INTRO_SIGNATURE UPDATE_VERSION_INTRO_SIGNATURE
Describe a version introspection signature in binary format.
Describe a version introspection signature in binary format.
DWORD Id
An unique id (_EXCEPTION_SIGNATURE_ID)
Describe an export signature in binary format.
DWORD KernelExceptionsCount
The number of the kernel-mode exceptions.
WORD Offset
The displacement from the beginning of the modified zone.
DWORD ProcessHash
The name-hash of the process in which the modification takes place.
Describe a code-blocks signature in binary format.
DWORD NameHash
The name-hash of the victim.
DWORD Flags
Contains any flags from _SIGNATURE_FLG.
struct _UPDATE_VALUE_HASH * PUPDATE_VALUE_HASH
INTSTATUS IntUpdateFlushAlertExceptions(void)
This function removes all exceptions that were added from alerts.
BYTE Type
The type of the exception; any type from _UM_EXCEPTION_OBJECT.
BYTE Score
The number of (minimum) hashes from a list that need to match.
Describe a user-mode-glob exception in binary format.
WORD SigCount
The number of the signatures.
WORD Major
The major version of the exceptions binary file.
enum _INTRO_EVENT_TYPE INTRO_EVENT_TYPE
Event classes.
BYTE ListsCount
The number of the list of hashes.
INTSTATUS IntUpdateGetVersion(WORD *MajorVersion, WORD *MinorVersion, DWORD *BuildNumber)
Get the version of the loaded exceptions binary file.
DWORD LibraryName
The name-hash of the modified library.
BYTE Entry
The number of the IDT entry.
DWORD Hash
The hash of the modified function name.
struct _UPDATE_EXPORT_HASH UPDATE_EXPORT_HASH
Describe a export hash in binary format.
BYTE Score
The number of (minimum) hashes from a list that need to match.
DWORD Flags
The flags of the exception; any flags from _EXCEPTION_FLG.
struct _UPDATE_EXPORT_SIGNATURE * PUPDATE_EXPORT_SIGNATURE
char CHAR
Definition: intro_types.h:56
DWORD NameHash
The name-hash of the victim.
BYTE _Reserved
Alignment purposes.
WORD Size
The size of of the modified zone.
DWORD Id
An unique id (_EXCEPTION_SIGNATURE_ID)
INTSTATUS IntUpdateAddExceptionFromAlert(const void *Event, INTRO_EVENT_TYPE Type, BOOLEAN Exception, QWORD Context)
Handles all types of supported exceptions that can be added from alerts.
DWORD Flags
Contains any flags from _SIGNATURE_FLG.
DWORD KernelUserExceptionsCount
The number of the kernel-user mode exceptions.
Describe a user-mode exception in binary format.
struct _UPDATE_VALUE_CODE_SIGNATURE UPDATE_VALUE_CODE_SIGNATURE
Describe a value-code signature in binary format.
INTSTATUS IntUpdateRemoveException(QWORD Context)
This function removes an exception for a given context.
WORD Delta
The number of bytes that are modified.
BYTE Type
The type of the exception; any type from _KM_EXCEPTION_OBJECT.
DWORD Flags
The flags of the exception; any flags from _EXCEPTION_FLG.
struct _UPDATE_CB_SIGNATURE UPDATE_CB_SIGNATURE
Describe a code-blocks signature in binary format.
struct _UPDATE_VERSION_OS_SIGNATURE * PUPDATE_VERSION_OS_SIGNATURE