Bitdefender Hypervisor Memory Introspection
winidt.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Bitdefender
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #include "winidt.h"
6 #include "alerts.h"
7 #include "hook.h"
8 
9 
10 static INTSTATUS
13  _In_ EXCEPTION_KM_ORIGINATOR *Originator,
14  _In_ INTRO_ACTION Action,
16  )
27 {
28  INTSTATUS status;
30 
31  pEvent = &gAlert.Integrity;
32  memzero(pEvent, sizeof(*pEvent));
33 
34  pEvent->BaseAddress= Victim->Integrity.StartVirtualAddress;
35  pEvent->VirtualAddress = Victim->Integrity.StartVirtualAddress + Victim->Integrity.Offset;
37  pEvent->Victim.IdtEntry = (BYTE)(Victim->Integrity.Offset / pEvent->Size);
38  pEvent->Victim.Type = introObjectTypeIdt;
39 
40 
41  // No valid CPU context and no valid current process can be obtained for this, as it is
42  // an integrity alert.
43  pEvent->Header.CpuContext.Valid = FALSE;
44  pEvent->Header.CurrentProcess.Valid = FALSE;
45 
47  pEvent->Header.Flags |= ALERT_FLAG_ASYNC;
48 
49  pEvent->Header.Action = Action;
50  pEvent->Header.Reason = Reason;
51  pEvent->Header.MitreID = idRootkit;
52 
53  memcpy(pEvent->Victim.Name, VICTIM_IDT, sizeof(VICTIM_IDT));
54 
55  IntAlertFillWriteInfo(Victim, &pEvent->WriteInfo);
56 
57  IntAlertFillWinKmModule(Originator->Original.Driver, &pEvent->Originator.Module);
58 
60 
61  status = IntNotifyIntroEvent(introEventIntegrityViolation, pEvent, sizeof(*pEvent));
62  if (!INT_SUCCESS(status))
63  {
64  WARNING("[WARNING] IntNotifyIntroEvent failed: 0x%08x\n", status);
65  }
66 
67  return INT_STATUS_SUCCESS;
68 }
69 
70 static INTSTATUS
72  _Inout_ INTEGRITY_REGION *IntegrityRegion
73  )
91 {
93  BOOLEAN recalculate = FALSE;
94 
96 
97  // Search for modifications
98  for (DWORD offset = 0; offset < IntegrityRegion->Length;)
99  {
100  EXCEPTION_VICTIM_ZONE victim = { 0 };
101  EXCEPTION_KM_ORIGINATOR originator = { 0 };
104 
105  status = IntExceptGetVictimIntegrity(IntegrityRegion, &offset, &victim);
106  if (INT_STATUS_NOT_FOUND == status)
107  {
108  // We are done with the modifications, so exit
109  status = INT_STATUS_SUCCESS;
110  break;
111  }
112  else if (!INT_SUCCESS(status))
113  {
114  ERROR("[ERROR] Failed getting integrity zone: 0x%08x\n", status);
115  break;
116  }
117 
118  status = IntExceptGetOriginatorFromModification(&victim, &originator);
119  if (!INT_SUCCESS(status))
120  {
121  ERROR("[ERROR] Failed getting originator: 0x%08x\n", status);
122  break;
123  }
124 
125  IntExcept(&victim, &originator, exceptionTypeKm, &action, &reason, introEventIntegrityViolation);
126 
127  if (IntPolicyCoreTakeAction(INTRO_OPT_PROT_KM_IDT, &action, &reason))
128  {
129  IntWinIdtSendIntegrityAlert(&victim, &originator, action, reason);
130  }
131 
133  {
134  reason = introReasonAllowed;
135  }
136 
137  if (action == introGuestAllowed)
138  {
139  recalculate = TRUE;
140  }
141  else if (action == introGuestNotAllowed)
142  {
143  IntPauseVcpus();
144 
145  status = IntKernVirtMemWrite(IntegrityRegion->Gva + victim.Integrity.Offset,
146  victim.WriteInfo.AccessSize,
147  (BYTE *)IntegrityRegion->OriginalContent + victim.Integrity.Offset);
148  IntResumeVcpus();
149 
150  if (!INT_SUCCESS(status))
151  {
152  ERROR("[ERROR] IntKernVirtMemWrite failed for gva 0x%016llx: 0x%08x\n",
153  IntegrityRegion->Gva + victim.Integrity.Offset, status);
154  goto cleanup_and_exit;
155  }
156  }
157  }
158 
159  if (recalculate)
160  {
161  IntIntegrityRecalculate(IntegrityRegion);
162  }
163 
164 cleanup_and_exit:
166 
167  return status;
168 }
169 
170 
172 static INTSTATUS
174  _In_opt_ void *Context,
175  _In_ void *Hook,
176  _In_ QWORD Address,
177  _Out_ INTRO_ACTION *Action
178  )
197 {
198  INTSTATUS status;
199  EXCEPTION_VICTIM_ZONE victim;
200  EXCEPTION_KM_ORIGINATOR originator;
201  INTRO_ACTION_REASON reason;
202  QWORD idtBase;
203  QWORD idtLimit;
204 
205  UNREFERENCED_PARAMETER(Context);
207  UNREFERENCED_PARAMETER(Address);
208 
209  if (NULL == Action)
210  {
212  }
213 
214  status = IntGuestGetIdtFromGla(gVcpu->Gla, &idtBase, &idtLimit);
215  if (!INT_SUCCESS(status))
216  {
217  ERROR("[ERROR] IntGuestGetIdtFromGla failed: 0x%08x, the write on 0x%016llx "
218  "(gpa 0x%016llx) from cpu %d seems to be outside any idt!\n",
219  status, gVcpu->Gla, gVcpu->Gpa, gVcpu->Index);
220 
221  *Action = introGuestAllowed;
222 
224  }
225 
226  *Action = introGuestNotAllowed;
227  reason = introReasonUnknown;
228 
230 
231  memzero(&victim, sizeof(victim));
232  memzero(&originator, sizeof(originator));
233 
234  status = IntExceptKernelGetOriginator(&originator, 0);
235  if (!INT_SUCCESS(status))
236  {
237  ERROR("[ERROR] Failed getting originator: 0x%08x\n", status);
238  reason = introReasonInternalError;
239  }
240 
241  status = IntExceptGetVictimEpt(&idtBase,
242  gVcpu->Gpa,
243  gVcpu->Gla,
245  ZONE_WRITE,
246  &victim);
247  if (!INT_SUCCESS(status))
248  {
249  ERROR("[ERROR] Failed getting zone details: 0x%08x\n", status);
250  reason = introReasonInternalError;
251  }
252 
253  IntExcept(&victim, &originator, exceptionTypeKm, Action, &reason, introEventEptViolation);
254 
256 
257  if (IntPolicyCoreTakeAction(INTRO_OPT_PROT_KM_IDT, Action, &reason))
258  {
259  PEVENT_EPT_VIOLATION pEptViol = &gAlert.Ept;
260  memzero(pEptViol, sizeof(*pEptViol));
261 
262  pEptViol->Header.Action = *Action;
263  pEptViol->Header.Reason = reason;
264  pEptViol->Header.MitreID = idRootkit;
265 
267 
269 
270  if (originator.Original.Driver)
271  {
272  IntAlertFillWinKmModule(originator.Original.Driver, &pEptViol->Originator.Module);
273  }
274  if (originator.Return.Driver)
275  {
277  }
278 
279  IntAlertEptFillFromVictimZone(&victim, pEptViol);
280 
282 
283  IntAlertFillCodeBlocks(originator.Original.Rip, gVcpu->Regs.Cr3, FALSE, &pEptViol->CodeBlocks);
284  IntAlertFillExecContext(0, &pEptViol->ExecContext);
285 
286  IntAlertFillVersionInfo(&pEptViol->Header);
287 
288  status = IntNotifyIntroEvent(introEventEptViolation, pEptViol, sizeof(*pEptViol));
289  if (!INT_SUCCESS(status))
290  {
291  WARNING("[WARNING] IntNotifyIntroEvent failed: 0x%08x\n", status);
292  }
293  }
294 
296 
297  return INT_STATUS_SUCCESS;
298 }
299 
300 
301 static INTSTATUS
303  _In_ DWORD CpuNumber
304  )
316 {
317  INTSTATUS status = INT_STATUS_SUCCESS;
318  DWORD size;
319 
320  if (gGuest.VcpuArray[CpuNumber].IdtHookObject != NULL)
321  {
323  }
324 
325  TRACE("[HOOK] Adding IDT protection (EPT) on CPU %d at 0x%016llx (limit 0x%x)...\n",
326  CpuNumber, gGuest.VcpuArray[CpuNumber].IdtBase, gGuest.VcpuArray[CpuNumber].IdtLimit);
327 
329  if (!INT_SUCCESS(status))
330  {
331  ERROR("[ERROR] IntHookObjectCreate failed: 0x%08x\n", status);
332  return status;
333  }
334 
336  gGuest.VcpuArray[CpuNumber].IdtLimit + 1);
337 
339  0,
340  gGuest.VcpuArray[CpuNumber].IdtBase,
341  size,
344  NULL,
345  0,
346  NULL);
347  if (!INT_SUCCESS(status))
348  {
349  ERROR("[ERROR] Failed hooking IDT at 0x%016llx for CPU %d: 0x%08x\n",
350  gGuest.VcpuArray[CpuNumber].IdtBase, CpuNumber, status);
351  return status;
352  }
353 
354  return INT_STATUS_SUCCESS;
355 }
356 
357 
358 static INTSTATUS
360  _In_ DWORD CpuNumber
361  )
373 {
374  INTSTATUS status = INT_STATUS_SUCCESS;
375  DWORD size;
376 
377  if (gGuest.VcpuArray[CpuNumber].IdtIntegrityObject != NULL)
378  {
380  }
381 
382  TRACE("[HOOK] Adding IDT protection (Integrity) on CPU %d at 0x%016llx (limit 0x%x)...\n",
383  CpuNumber, gGuest.VcpuArray[CpuNumber].IdtBase, gGuest.VcpuArray[CpuNumber].IdtLimit);
384 
386  gGuest.VcpuArray[CpuNumber].IdtLimit + 1);
387 
388  status = IntIntegrityAddRegion(gGuest.VcpuArray[CpuNumber].IdtBase,
389  size,
391  NULL,
393  TRUE,
394  &gGuest.VcpuArray[CpuNumber].IdtIntegrityObject);
395  if (!INT_SUCCESS(status))
396  {
397  ERROR("[ERROR] Failed to add IDT to integrity checks: 0x%08x\n", status);
398  return status;
399  }
400 
401  return INT_STATUS_SUCCESS;
402 }
403 
404 
405 static INTSTATUS
407  _In_ DWORD CpuNumber
408  )
419 {
420  INTSTATUS status;
421 
422  if (gGuest.VcpuArray[CpuNumber].IdtHookObject == NULL)
423  {
425  }
426 
427  TRACE("[HOOK] Removing IDT protection (EPT) on CPU %d at 0x%016llx...\n", CpuNumber,
428  gGuest.VcpuArray[CpuNumber].IdtBase);
429 
431  if (!INT_SUCCESS(status))
432  {
433  ERROR("[ERROR] Failed removing idt hook object: 0x%08x\n", status);
434  return status;
435  }
436 
437  return INT_STATUS_SUCCESS;
438 }
439 
440 
441 static INTSTATUS
443  _In_ DWORD CpuNumber
444  )
455 {
456  INTSTATUS status = INT_STATUS_SUCCESS;
457 
458  if (gGuest.VcpuArray[CpuNumber].IdtIntegrityObject == NULL)
459  {
461  }
462 
463  TRACE("[HOOK] Removing IDT protection (Integrity) on CPU %d at 0x%016llx...\n",
464  CpuNumber, gGuest.VcpuArray[CpuNumber].IdtBase);
465 
467  if (!INT_SUCCESS(status))
468  {
469  ERROR("[ERROR] IntIntegrityRemoveRegion failed: 0x%08x\n", status);
470  return status;
471  }
472 
473  gGuest.VcpuArray[CpuNumber].IdtIntegrityObject = NULL;
474 
475  return INT_STATUS_SUCCESS;
476 }
477 
478 
479 INTSTATUS
481  _In_ DWORD CpuNumber
482  )
501 {
502  if (CpuNumber >= gGuest.CpuCount)
503  {
505  }
506 
508  {
510  }
511 
512  // Windows version >= 16299
513  if (gGuest.OSVersion >= 16299 && gGuest.Guest64)
514  {
515  return IntWinIdtProtectOnCpuEpt(CpuNumber);
516  }
517  else
518  {
519  return IntWinIdtProtectOnCpuIntegrity(CpuNumber);
520  }
521 }
522 
523 
524 INTSTATUS
526  _In_ DWORD CpuNumber
527  )
537 {
538  if (CpuNumber >= gGuest.CpuCount)
539  {
541  }
542 
544  {
546  }
547 
548  if (gGuest.OSVersion >= 16299 && gGuest.Guest64)
549  {
550  return IntWinIdtUnprotectOnCpuEpt(CpuNumber);
551  }
552  else
553  {
554  return IntWinIdtUnprotectOnCpuIntergity(CpuNumber);
555  }
556 }
557 
558 
559 INTSTATUS
561  void
562  )
568 {
569  DWORD i;
570  INTSTATUS status;
571  INTSTATUS failStatus;
572 
573  // In case there are no CPU's (which is never!)
574  failStatus = INT_STATUS_NOT_NEEDED_HINT;
575 
576  for (i = 0; i < gGuest.CpuCount; i++)
577  {
578  status = IntWinIdtProtectOnCpu(i);
579  if (!INT_SUCCESS(status))
580  {
581  failStatus = status;
582  continue;
583  }
584  }
585 
586  return failStatus;
587 }
588 
589 
590 INTSTATUS
592  void
593  )
599 {
600  DWORD i;
601  INTSTATUS status;
602  INTSTATUS failStatus;
603 
604  // In case there are no CPU's (which is never!)
605  failStatus = INT_STATUS_NOT_NEEDED_HINT;
606 
607  for (i = 0; i < gGuest.CpuCount; i++)
608  {
609  status = IntWinIdtUnprotectOnCpu(i);
610  if (!INT_SUCCESS(status))
611  {
612  failStatus = status;
613  continue;
614  }
615  }
616 
617  return failStatus;
618 }
Measures kernel mode exceptions checks.
Definition: stats.h:51
#define _In_opt_
Definition: intro_sal.h:16
struct _EXCEPTION_KM_ORIGINATOR::@63 Original
#define DESCRIPTOR_SIZE_32
Definition: processor.h:101
enum _INTRO_ACTION_REASON INTRO_ACTION_REASON
The reason for which an INTRO_ACTION was taken.
INTRO_CODEBLOCKS CodeBlocks
Code blocks extracted for the alert.
Definition: intro_types.h:1145
#define _Out_
Definition: intro_sal.h:22
_Bool BOOLEAN
Definition: intro_types.h:58
BOOLEAN Valid
Set to True if the information in the structure is valid, False otherwise.
Definition: intro_types.h:818
QWORD IntAlertCoreGetFlags(QWORD ProtectionFlag, INTRO_ACTION_REASON Reason)
Returns the flags for an alert.
Definition: alerts.c:366
An internal error occurred (no memory, pages not present, etc.).
Definition: intro_types.h:195
BOOLEAN IntPolicyCoreForceBetaIfNeeded(QWORD Flag, INTRO_ACTION *Action)
Checks if a forced action should be taken even if the log-only mode is active.
Definition: introcore.c:2803
uint8_t BYTE
Definition: intro_types.h:47
INTSTATUS IntKernVirtMemWrite(QWORD KernelGva, DWORD Length, void *Buffer)
Writes data to a guest kernel virtual memory range.
Definition: introcore.c:699
INTSTATUS IntHookObjectDestroy(HOOK_OBJECT_DESCRIPTOR **Object, DWORD Flags)
Destroy an entire hook object. All regions belonging to this object will be removed.
Definition: hook_object.c:357
IG_ARCH_REGS Regs
The current state of the guest registers.
Definition: guests.h:95
DWORD Index
The VCPU number.
Definition: guests.h:172
#define _In_
Definition: intro_sal.h:21
MITRE_ID MitreID
The Mitre ID that corresponds to this attack.
Definition: intro_types.h:1088
static INTSTATUS IntWinIdtProtectOnCpuIntegrity(DWORD CpuNumber)
Protects the IDT on a guest CPU against writes using the integrity mechanism.
Definition: winidt.c:359
#define INT_STATUS_SUCCESS
Definition: introstatus.h:54
BOOLEAN IntPolicyCoreTakeAction(QWORD Flag, INTRO_ACTION *Action, INTRO_ACTION_REASON *Reason)
Returns the action that should be taken for a core introspection option.
Definition: introcore.c:2693
void * IdtIntegrityObject
The integrity region used to protect the IDT.
Definition: guests.h:159
#define STATS_EXIT(id)
Definition: stats.h:148
struct _EVENT_EPT_VIOLATION::@276 Originator
Event structure for integrity violations on monitored structures.
Definition: intro_types.h:1450
INTSTATUS IntIntegrityAddRegion(QWORD VirtualAddress, DWORD Length, INTRO_OBJECT_TYPE Type, void *Context, PFUNC_IntegrityViolationCallback Callback, BOOLEAN CopyContent, void **Descriptor)
Creates an INTEGRITY_REGION object and adds it to the gIntegrityRegions list.
Definition: integrity.c:91
WORD IdtLimit
The current IDT limit.
Definition: guests.h:111
INTSTATUS IntWinIdtUnprotectAll(void)
Removes the IDT protection for all the guest CPUs.
Definition: winidt.c:591
struct _EXCEPTION_VICTIM_ZONE::@57::@59 WriteInfo
#define INT_SUCCESS(Status)
Definition: introstatus.h:42
QWORD Flags
A combination of ALERT_FLAG_* values describing the alert.
Definition: intro_types.h:1087
INTSTATUS IntResumeVcpus(void)
Resumes the VCPUs previously paused with IntPauseVcpus.
Definition: introcore.c:2355
INTRO_OBJECT_TYPE Type
Definition: intro_types.h:1462
The action was not allowed because there was no reason to allow it.
Definition: intro_types.h:183
void * IdtHookObject
The EPT hook object used to protect the IDT.
Definition: guests.h:155
#define INT_STATUS_NOT_NEEDED_HINT
Definition: introstatus.h:317
#define ERROR(fmt,...)
Definition: glue.h:62
#define ALERT_FLAG_ASYNC
If set, the alert was generated in an async manner.
Definition: intro_types.h:637
KERNEL_DRIVER * Driver
The driver that&#39;s modifying the memory.
Definition: exceptions.h:903
int INTSTATUS
The status data type.
Definition: introstatus.h:24
DWORD OSVersion
Os version.
Definition: guests.h:277
#define INT_STATUS_NOT_FOUND
Definition: introstatus.h:284
INTSTATUS IntWinIdtUnprotectOnCpu(DWORD CpuNumber)
Removes the IDT write protection for a CPU.
Definition: winidt.c:525
DWORD Offset
The offset of the modification.
Definition: exceptions.h:766
Rootkit.
Definition: intro_types.h:1033
Describes a kernel-mode originator.
Definition: exceptions.h:897
PVCPU_STATE VcpuArray
Array of the VCPUs assigned to this guest. The index in this array matches the VCPU number...
Definition: guests.h:368
static INTSTATUS IntWinIdtSendIntegrityAlert(EXCEPTION_VICTIM_ZONE *Victim, EXCEPTION_KM_ORIGINATOR *Originator, INTRO_ACTION Action, INTRO_ACTION_REASON Reason)
Sends an introEventIntegrityViolation alert for an IDT entry.
Definition: winidt.c:11
#define VICTIM_IDT
Printable name used for introObjectTypeIdt.
Definition: intro_types.h:681
INTSTATUS IntPauseVcpus(void)
Pauses all the guest VCPUs.
Definition: introcore.c:2320
BYTE IdtEntry
The modified IDT entry. Valid only if Type is introObjectTypeIdt.
Definition: intro_types.h:1472
#define INTRO_OPT_PROT_KM_IDT
Definition: intro_types.h:396
void IntAlertFillCpuContext(BOOLEAN CopyInstruction, INTRO_CPUCTX *CpuContext)
Fills the current CPU context for an alert.
Definition: alerts.c:492
#define MIN(a, b)
Definition: introdefs.h:146
EVENT_EPT_VIOLATION Ept
Definition: alerts.h:16
INTSTATUS IntWinIdtProtectAll(void)
Activates the IDT protection for all the guest CPUs.
Definition: winidt.c:560
void IntAlertFillVersionInfo(INTRO_VIOLATION_HEADER *Header)
Fills version information for an alert.
Definition: alerts.c:327
INTRO_VIOLATION_HEADER Header
The alert header.
Definition: intro_types.h:1106
INTRO_ACTION_REASON Reason
The reason for which Action was taken.
Definition: intro_types.h:1084
INTSTATUS IntAlertFillCodeBlocks(QWORD Rip, QWORD Cr3, BOOLEAN Execute, INTRO_CODEBLOCKS *CodeBlocks)
Fills the code blocks pattern for an alert.
Definition: alerts.c:71
GENERIC_ALERT gAlert
Global alert buffer.
Definition: alerts.c:27
#define _Inout_
Definition: intro_sal.h:20
INTSTATUS IntIntegrityRecalculate(INTEGRITY_REGION *IntegrityRegion)
Recalculates the hash and reads the original content again for a given region.
Definition: integrity.c:242
void IntAlertFillWriteInfo(const EXCEPTION_VICTIM_ZONE *Victim, INTRO_WRITE_INFO *WriteInfo)
Fills the write information for an alert.
Definition: alerts.c:521
DWORD Size
The size of the modified memory area.
Definition: intro_types.h:1483
void IntAlertEptFillFromVictimZone(const EXCEPTION_VICTIM_ZONE *Victim, EVENT_EPT_VIOLATION *EptViolation)
Fills the victim information inside an EPT alert.
Definition: alerts.c:868
#define STATS_ENTER(id)
Definition: stats.h:141
INTRO_CPUCTX CpuContext
The context of the CPU that triggered the alert.
Definition: intro_types.h:1085
INTSTATUS IntNotifyIntroEvent(INTRO_EVENT_TYPE EventClass, void *Param, size_t EventSize)
Notifies the integrator about an introspection alert.
Definition: glue.c:1042
#define memzero(a, s)
Definition: introcrt.h:35
BOOLEAN Guest64
True if this is a 64-bit guest, False if it is a 32-bit guest.
Definition: guests.h:286
INTSTATUS IntExceptGetVictimEpt(void *Context, QWORD Gpa, QWORD Gva, INTRO_OBJECT_TYPE Type, DWORD ZoneFlags, EXCEPTION_VICTIM_ZONE *Victim)
Fills an EXCEPTION_VICTIM_ZONE with relevant information from an EPT violation.
Definition: exceptions.c:742
unsigned long long QWORD
Definition: intro_types.h:53
QWORD IdtBase
Original IDT base.
Definition: guests.h:110
static INTSTATUS IntWinIdtUnprotectOnCpuIntergity(DWORD CpuNumber)
Removes the integrity protection for a IDT.
Definition: winidt.c:442
INTRO_MODULE Module
The module that modified the translation.
Definition: intro_types.h:1456
struct _EVENT_INTEGRITY_VIOLATION::@295 Victim
QWORD VirtualAddress
The guest virtual address which was modified.
Definition: intro_types.h:1481
#define TRUE
Definition: intro_types.h:30
#define INT_STATUS_INVALID_PARAMETER_4
Definition: introstatus.h:71
INTRO_VIOLATION_HEADER Header
The alert header.
Definition: intro_types.h:1452
#define IS_KERNEL_POINTER_WIN(is64, p)
Checks if a guest virtual address resides inside the Windows kernel address space.
Definition: wddefs.h:76
QWORD Gpa
The accessed guest physical address. Valid only for EPT exits.
Definition: guests.h:101
INTSTATUS IntExceptGetVictimIntegrity(INTEGRITY_REGION *IntegrityRegion, DWORD *Offset, EXCEPTION_VICTIM_ZONE *Victim)
This function is used to get the information about the modified zone from the integrity region...
#define TRACE(fmt,...)
Definition: glue.h:58
INTSTATUS IntWinIdtProtectOnCpu(DWORD CpuNumber)
Protects the IDT against writes on a CPU.
Definition: winidt.c:480
Kernel-mode exception.
Definition: exceptions.h:62
INTRO_EXEC_CONTEXT ExecContext
Information about the instruction that triggered the alert.
Definition: intro_types.h:1191
#define DESCRIPTOR_SIZE_64
Definition: processor.h:102
#define INT_STATUS_ALREADY_INITIALIZED_HINT
Definition: introstatus.h:323
#define WARNING(fmt,...)
Definition: glue.h:60
INTSTATUS IntGuestGetIdtFromGla(QWORD Address, QWORD *IdtBase, QWORD *IdtLimit)
Checks if an address is inside one of the guest&#39;s IDTs.
Definition: guests.h:522
Sent when an EPT violation triggers an alert. See EVENT_EPT_VIOLATION.
Definition: intro_types.h:84
#define IDT_DESC_SIZE64
The size of a 64-bit interrupt descriptor.
Definition: wddefs.h:32
static INTSTATUS IntWinIdtWriteHandler(void *Context, void *Hook, QWORD Address, INTRO_ACTION *Action)
Handles IDT modifications detected by the EPT mechanism. This is the EPT callback set by IntWinIdtPro...
Definition: winidt.c:173
DWORD CpuCount
The number of logical CPUs.
Definition: guests.h:275
Describes the modified zone.
Definition: exceptions.h:847
#define UNREFERENCED_PARAMETER(P)
Definition: introdefs.h:29
WCHAR Name[ALERT_PATH_MAX_LEN]
NULL-terminated string with a human readable description of the modified object.
Definition: intro_types.h:1464
static INTSTATUS IntWinIdtUnprotectOnCpuEpt(DWORD CpuNumber)
Removes the EPT write protection for a IDT.
Definition: winidt.c:406
uint32_t DWORD
Definition: intro_types.h:49
BOOLEAN Valid
Set to True if the information in the structure is valid, False otherwise.
Definition: intro_types.h:879
enum _INTRO_ACTION INTRO_ACTION
Event actions.
QWORD Rip
The RIP from where the call to the exported function came.
Definition: exceptions.h:904
INTSTATUS IntIntegrityRemoveRegion(void *Descriptor)
Removes an integrity region from the gIntegrityRegions list.
Definition: integrity.c:313
INTRO_WRITE_INFO WriteInfo
The original and the new value.
Definition: intro_types.h:1477
INTSTATUS(* PFUNC_EptViolationCallback)(void *Context, void *Hook, QWORD Address, INTRO_ACTION *Action)
EPT callback handler.
Definition: hook_gpa.h:30
GUEST_STATE gGuest
The current guest state.
Definition: guests.c:48
void IntAlertFillWinProcessByCr3(QWORD ProcessCr3, INTRO_PROCESS *EventProcess)
Saves information about a Windows process inside an alert. The process is searched by its kernel CR3...
Definition: alerts.c:756
#define _Function_class_(expr)
Definition: intro_sal.h:40
EVENT_INTEGRITY_VIOLATION Integrity
Definition: alerts.h:23
INTRO_ACTION Action
The action that was taken as the result of this alert.
Definition: intro_types.h:1083
QWORD BaseAddress
The guest virtual address at which the monitored integrity region starts.
Definition: intro_types.h:1479
struct _EVENT_INTEGRITY_VIOLATION::@294 Originator
INTSTATUS IntHookObjectHookRegion(void *Object, QWORD Cr3, QWORD Gla, SIZE_T Length, BYTE Type, void *Callback, void *Context, DWORD Flags, HOOK_REGION_DESCRIPTOR **Region)
Hook a contiguous region of virtual memory inside the provided virtual address space.
Definition: hook_object.c:132
INTSTATUS IntExceptGetOriginatorFromModification(EXCEPTION_VICTIM_ZONE *Victim, EXCEPTION_KM_ORIGINATOR *Originator)
This function is used for integrity violations to get the information about the kernel-mode originato...
#define INT_STATUS_NOT_INITIALIZED_HINT
Definition: introstatus.h:320
INTRO_PROCESS CurrentProcess
The current process.
Definition: intro_types.h:1086
VCPU_STATE * gVcpu
The state of the current VCPU.
Definition: guests.c:57
Sent for integrity violation alerts. See EVENT_INTEGRITY_VIOLATION.
Definition: intro_types.h:92
INTRO_MODULE Module
The module that did the malicious access.
Definition: intro_types.h:1110
static INTSTATUS IntWinIdtProtectOnCpuEpt(DWORD CpuNumber)
Protects the IDT on a guest CPU against writes using an EPT hook.
Definition: winidt.c:302
EXCEPTION_VICTIM_INTEGRITY Integrity
Valid if the modified zone is Integrity.
Definition: exceptions.h:862
Event structure for EPT violations.
Definition: intro_types.h:1104
static INTSTATUS IntWinIdtHandleModification(INTEGRITY_REGION *IntegrityRegion)
Handles IDT modifications detected by the integrity mechanism. This is the integrity callback set by ...
Definition: winidt.c:71
void IntAlertFillWinKmModule(const KERNEL_DRIVER *Driver, INTRO_MODULE *EventModule)
Saves kernel module information inside an alert.
Definition: alerts.c:617
struct _EXCEPTION_KM_ORIGINATOR::@62 Return
#define IDT_DESC_SIZE32
The size of a 32-bit interrupt descriptor.
Definition: wddefs.h:31
Write-access hook.
Definition: glueiface.h:299
INTSTATUS IntExceptKernelGetOriginator(EXCEPTION_KM_ORIGINATOR *Originator, DWORD Options)
This function is used to get the information about the kernel-mode originator.
INTSTATUS IntAlertFillExecContext(QWORD Cr3, INTRO_EXEC_CONTEXT *ExecContext)
Fills the current execution context.
Definition: alerts.c:31
#define ZONE_WRITE
Used for write violation.
Definition: exceptions.h:698
#define INT_STATUS_INVALID_PARAMETER_2
Definition: introstatus.h:65
QWORD Gla
The accessed guest virtual address. Valid only for EPT exits.
Definition: guests.h:102
INTSTATUS IntHookObjectCreate(DWORD ObjectType, QWORD Cr3, void **Object)
Create a new hook object.
Definition: hook_object.c:81
void IntExcept(EXCEPTION_VICTIM_ZONE *Victim, void *Originator, EXCEPTION_TYPE Type, INTRO_ACTION *Action, INTRO_ACTION_REASON *Reason, INTRO_EVENT_TYPE EventClass)
This function is the entry point for the exception mechanism.
Definition: exceptions.c:3317
INTRO_MODULE ReturnModule
The module to which the current code returns to.
Definition: intro_types.h:1111
#define FALSE
Definition: intro_types.h:34