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  // No valid CPU context and no valid current process can be obtained for this, as it is
41  // an integrity alert.
42  pEvent->Header.CpuContext.Valid = FALSE;
43  pEvent->Header.CurrentProcess.Valid = FALSE;
44 
46  pEvent->Header.Flags |= ALERT_FLAG_ASYNC;
47 
48  pEvent->Header.Action = Action;
49  pEvent->Header.Reason = Reason;
50  pEvent->Header.MitreID = idRootkit;
51 
52  memcpy(pEvent->Victim.Name, VICTIM_IDT, sizeof(VICTIM_IDT));
53 
54  IntAlertFillWriteInfo(Victim, &pEvent->WriteInfo);
55 
56  IntAlertFillWinKmModule(Originator->Original.Driver, &pEvent->Originator.Module);
57 
59 
60  status = IntNotifyIntroEvent(introEventIntegrityViolation, pEvent, sizeof(*pEvent));
61  if (!INT_SUCCESS(status))
62  {
63  WARNING("[WARNING] IntNotifyIntroEvent failed: 0x%08x\n", status);
64  }
65 
66  return INT_STATUS_SUCCESS;
67 }
68 
69 static INTSTATUS
71  _Inout_ INTEGRITY_REGION *IntegrityRegion
72  )
90 {
92  BOOLEAN recalculate = FALSE;
93 
95 
96  // Search for modifications
97  for (DWORD offset = 0; offset < IntegrityRegion->Length;)
98  {
99  EXCEPTION_VICTIM_ZONE victim = { 0 };
100  EXCEPTION_KM_ORIGINATOR originator = { 0 };
103 
104  status = IntExceptGetVictimIntegrity(IntegrityRegion, &offset, &victim);
105  if (INT_STATUS_NOT_FOUND == status)
106  {
107  // We are done with the modifications, so exit
108  status = INT_STATUS_SUCCESS;
109  break;
110  }
111  else if (!INT_SUCCESS(status))
112  {
113  ERROR("[ERROR] Failed getting integrity zone: 0x%08x\n", status);
114  break;
115  }
116 
117  status = IntExceptGetOriginatorFromModification(&victim, &originator);
118  if (!INT_SUCCESS(status))
119  {
120  ERROR("[ERROR] Failed getting originator: 0x%08x\n", status);
121  break;
122  }
123 
124  IntExcept(&victim, &originator, exceptionTypeKm, &action, &reason, introEventIntegrityViolation);
125 
126  if (IntPolicyCoreTakeAction(INTRO_OPT_PROT_KM_IDT, &action, &reason))
127  {
128  IntWinIdtSendIntegrityAlert(&victim, &originator, action, reason);
129  }
130 
132  {
133  reason = introReasonAllowed;
134  }
135 
136  if (action == introGuestAllowed)
137  {
138  recalculate = TRUE;
139  }
140  else if (action == introGuestNotAllowed)
141  {
142  IntPauseVcpus();
143 
144  status = IntKernVirtMemWrite(IntegrityRegion->Gva + victim.Integrity.Offset,
145  victim.WriteInfo.AccessSize,
146  (BYTE *)IntegrityRegion->OriginalContent + victim.Integrity.Offset);
147  IntResumeVcpus();
148 
149  if (!INT_SUCCESS(status))
150  {
151  ERROR("[ERROR] IntKernVirtMemWrite failed for gva 0x%016llx: 0x%08x\n",
152  IntegrityRegion->Gva + victim.Integrity.Offset, status);
153  goto cleanup_and_exit;
154  }
155  }
156  }
157 
158  if (recalculate)
159  {
160  IntIntegrityRecalculate(IntegrityRegion);
161  }
162 
163 cleanup_and_exit:
165 
166  return status;
167 }
168 
169 
171 static INTSTATUS
173  _In_opt_ void *Context,
174  _In_ void *Hook,
175  _In_ QWORD Address,
176  _Out_ INTRO_ACTION *Action
177  )
196 {
197  INTSTATUS status;
198  EXCEPTION_VICTIM_ZONE victim;
199  EXCEPTION_KM_ORIGINATOR originator;
200  INTRO_ACTION_REASON reason;
201  QWORD idtBase;
202  QWORD idtLimit;
203 
204  UNREFERENCED_PARAMETER(Context);
206  UNREFERENCED_PARAMETER(Address);
207 
208  if (NULL == Action)
209  {
211  }
212 
213  status = IntGuestGetIdtFromGla(gVcpu->Gla, &idtBase, &idtLimit);
214  if (!INT_SUCCESS(status))
215  {
216  ERROR("[ERROR] IntGuestGetIdtFromGla failed: 0x%08x, the write on 0x%016llx "
217  "(gpa 0x%016llx) from cpu %d seems to be outside any idt!\n",
218  status, gVcpu->Gla, gVcpu->Gpa, gVcpu->Index);
219 
220  *Action = introGuestAllowed;
221 
223  }
224 
225  *Action = introGuestNotAllowed;
226  reason = introReasonUnknown;
227 
229 
230  memzero(&victim, sizeof(victim));
231  memzero(&originator, sizeof(originator));
232 
233  status = IntExceptKernelGetOriginator(&originator, 0);
234  if (!INT_SUCCESS(status))
235  {
236  ERROR("[ERROR] Failed getting originator: 0x%08x\n", status);
237  reason = introReasonInternalError;
238  }
239 
240  status = IntExceptGetVictimEpt(&idtBase,
241  gVcpu->Gpa,
242  gVcpu->Gla,
244  ZONE_WRITE,
245  &victim);
246  if (!INT_SUCCESS(status))
247  {
248  ERROR("[ERROR] Failed getting zone details: 0x%08x\n", status);
249  reason = introReasonInternalError;
250  }
251 
252  IntExcept(&victim, &originator, exceptionTypeKm, Action, &reason, introEventEptViolation);
253 
255 
256  if (IntPolicyCoreTakeAction(INTRO_OPT_PROT_KM_IDT, Action, &reason))
257  {
258  PEVENT_EPT_VIOLATION pEptViol = &gAlert.Ept;
259  memzero(pEptViol, sizeof(*pEptViol));
260 
261  pEptViol->Header.Action = *Action;
262  pEptViol->Header.Reason = reason;
263  pEptViol->Header.MitreID = idRootkit;
264 
266 
268 
269  if (originator.Original.Driver)
270  {
271  IntAlertFillWinKmModule(originator.Original.Driver, &pEptViol->Originator.Module);
272  }
273  if (originator.Return.Driver)
274  {
276  }
277 
278  IntAlertEptFillFromVictimZone(&victim, pEptViol);
279 
281 
282  IntAlertFillCodeBlocks(originator.Original.Rip, gVcpu->Regs.Cr3, FALSE, &pEptViol->CodeBlocks);
283  IntAlertFillExecContext(0, &pEptViol->ExecContext);
284 
285  IntAlertFillVersionInfo(&pEptViol->Header);
286 
287  status = IntNotifyIntroEvent(introEventEptViolation, pEptViol, sizeof(*pEptViol));
288  if (!INT_SUCCESS(status))
289  {
290  WARNING("[WARNING] IntNotifyIntroEvent failed: 0x%08x\n", status);
291  }
292  }
293 
295 
296  return INT_STATUS_SUCCESS;
297 }
298 
299 
300 static INTSTATUS
302  _In_ DWORD CpuNumber
303  )
315 {
316  INTSTATUS status = INT_STATUS_SUCCESS;
317  DWORD size;
318 
319  if (gGuest.VcpuArray[CpuNumber].IdtHookObject != NULL)
320  {
322  }
323 
324  TRACE("[HOOK] Adding IDT protection (EPT) on CPU %d at 0x%016llx (limit 0x%x)...\n",
325  CpuNumber, gGuest.VcpuArray[CpuNumber].IdtBase, gGuest.VcpuArray[CpuNumber].IdtLimit);
326 
328  if (!INT_SUCCESS(status))
329  {
330  ERROR("[ERROR] IntHookObjectCreate failed: 0x%08x\n", status);
331  return status;
332  }
333 
335  gGuest.VcpuArray[CpuNumber].IdtLimit + 1);
336 
338  0,
339  gGuest.VcpuArray[CpuNumber].IdtBase,
340  size,
343  NULL,
344  0,
345  NULL);
346  if (!INT_SUCCESS(status))
347  {
348  ERROR("[ERROR] Failed hooking IDT at 0x%016llx for CPU %d: 0x%08x\n",
349  gGuest.VcpuArray[CpuNumber].IdtBase, CpuNumber, status);
350  return status;
351  }
352 
353  return INT_STATUS_SUCCESS;
354 }
355 
356 
357 static INTSTATUS
359  _In_ DWORD CpuNumber
360  )
372 {
373  INTSTATUS status = INT_STATUS_SUCCESS;
374  DWORD size;
375 
376  if (gGuest.VcpuArray[CpuNumber].IdtIntegrityObject != NULL)
377  {
379  }
380 
381  TRACE("[HOOK] Adding IDT protection (Integrity) on CPU %d at 0x%016llx (limit 0x%x)...\n",
382  CpuNumber, gGuest.VcpuArray[CpuNumber].IdtBase, gGuest.VcpuArray[CpuNumber].IdtLimit);
383 
385  gGuest.VcpuArray[CpuNumber].IdtLimit + 1);
386 
387  status = IntIntegrityAddRegion(gGuest.VcpuArray[CpuNumber].IdtBase,
388  size,
390  NULL,
392  TRUE,
393  &gGuest.VcpuArray[CpuNumber].IdtIntegrityObject);
394  if (!INT_SUCCESS(status))
395  {
396  ERROR("[ERROR] Failed to add IDT to integrity checks: 0x%08x\n", status);
397  return status;
398  }
399 
400  return INT_STATUS_SUCCESS;
401 }
402 
403 
404 static INTSTATUS
406  _In_ DWORD CpuNumber
407  )
418 {
419  INTSTATUS status;
420 
421  if (gGuest.VcpuArray[CpuNumber].IdtHookObject == NULL)
422  {
424  }
425 
426  TRACE("[HOOK] Removing IDT protection (EPT) on CPU %d at 0x%016llx...\n", CpuNumber,
427  gGuest.VcpuArray[CpuNumber].IdtBase);
428 
430  if (!INT_SUCCESS(status))
431  {
432  ERROR("[ERROR] Failed removing idt hook object: 0x%08x\n", status);
433  return status;
434  }
435 
436  return INT_STATUS_SUCCESS;
437 }
438 
439 
440 static INTSTATUS
442  _In_ DWORD CpuNumber
443  )
454 {
455  INTSTATUS status = INT_STATUS_SUCCESS;
456 
457  if (gGuest.VcpuArray[CpuNumber].IdtIntegrityObject == NULL)
458  {
460  }
461 
462  TRACE("[HOOK] Removing IDT protection (Integrity) on CPU %d at 0x%016llx...\n",
463  CpuNumber, gGuest.VcpuArray[CpuNumber].IdtBase);
464 
466  if (!INT_SUCCESS(status))
467  {
468  ERROR("[ERROR] IntIntegrityRemoveRegion failed: 0x%08x\n", status);
469  return status;
470  }
471 
472  gGuest.VcpuArray[CpuNumber].IdtIntegrityObject = NULL;
473 
474  return INT_STATUS_SUCCESS;
475 }
476 
477 
478 INTSTATUS
480  _In_ DWORD CpuNumber
481  )
500 {
501  if (CpuNumber >= gGuest.CpuCount)
502  {
504  }
505 
507  {
509  }
510 
511  // Windows version >= 16299
512  if (gGuest.OSVersion >= 16299 && gGuest.Guest64)
513  {
514  return IntWinIdtProtectOnCpuEpt(CpuNumber);
515  }
516  else
517  {
518  return IntWinIdtProtectOnCpuIntegrity(CpuNumber);
519  }
520 }
521 
522 
523 INTSTATUS
525  _In_ DWORD CpuNumber
526  )
536 {
537  if (CpuNumber >= gGuest.CpuCount)
538  {
540  }
541 
543  {
545  }
546 
547  if (gGuest.OSVersion >= 16299 && gGuest.Guest64)
548  {
549  return IntWinIdtUnprotectOnCpuEpt(CpuNumber);
550  }
551  else
552  {
553  return IntWinIdtUnprotectOnCpuIntergity(CpuNumber);
554  }
555 }
556 
557 
558 INTSTATUS
560  void
561  )
567 {
568  DWORD i;
569  INTSTATUS status;
570  INTSTATUS failStatus;
571 
572  // In case there are no CPU's (which is never!)
573  failStatus = INT_STATUS_NOT_NEEDED_HINT;
574 
575  for (i = 0; i < gGuest.CpuCount; i++)
576  {
577  status = IntWinIdtProtectOnCpu(i);
578  if (!INT_SUCCESS(status))
579  {
580  failStatus = status;
581  continue;
582  }
583  }
584 
585  return failStatus;
586 }
587 
588 
589 INTSTATUS
591  void
592  )
598 {
599  DWORD i;
600  INTSTATUS status;
601  INTSTATUS failStatus;
602 
603  // In case there are no CPU's (which is never!)
604  failStatus = INT_STATUS_NOT_NEEDED_HINT;
605 
606  for (i = 0; i < gGuest.CpuCount; i++)
607  {
608  status = IntWinIdtUnprotectOnCpu(i);
609  if (!INT_SUCCESS(status))
610  {
611  failStatus = status;
612  continue;
613  }
614  }
615 
616  return failStatus;
617 }
Measures kernel mode exceptions checks.
Definition: stats.h:51
#define _In_opt_
Definition: intro_sal.h:16
#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:1263
#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:904
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:1199
static INTSTATUS IntWinIdtProtectOnCpuIntegrity(DWORD CpuNumber)
Protects the IDT on a guest CPU against writes using the integrity mechanism.
Definition: winidt.c:358
#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:160
Event structure for integrity violations on monitored structures.
Definition: intro_types.h:1572
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:590
#define INT_SUCCESS(Status)
Definition: introstatus.h:42
QWORD Flags
A combination of ALERT_FLAG_* values describing the alert.
Definition: intro_types.h:1198
INTSTATUS IntResumeVcpus(void)
Resumes the VCPUs previously paused with IntPauseVcpus.
Definition: introcore.c:2355
INTRO_OBJECT_TYPE Type
Definition: intro_types.h:1589
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
struct _EVENT_INTEGRITY_VIOLATION::@304 Victim
#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:675
KERNEL_DRIVER * Driver
The driver that&#39;s modifying the memory.
Definition: exceptions.h:949
struct _EVENT_EPT_VIOLATION::@283 Originator
int INTSTATUS
The status data type.
Definition: introstatus.h:24
DWORD OSVersion
Os version.
Definition: guests.h:281
#define INT_STATUS_NOT_FOUND
Definition: introstatus.h:284
INTSTATUS IntWinIdtUnprotectOnCpu(DWORD CpuNumber)
Removes the IDT write protection for a CPU.
Definition: winidt.c:524
DWORD Offset
The offset of the modification.
Definition: exceptions.h:803
Rootkit.
Definition: intro_types.h:1144
Describes a kernel-mode originator.
Definition: exceptions.h:943
PVCPU_STATE VcpuArray
Array of the VCPUs assigned to this guest. The index in this array matches the VCPU number...
Definition: guests.h:372
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:749
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:1599
#define INTRO_OPT_PROT_KM_IDT
Definition: intro_types.h:412
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
struct _EXCEPTION_KM_ORIGINATOR::@63 Return
EVENT_EPT_VIOLATION Ept
Definition: alerts.h:16
INTSTATUS IntWinIdtProtectAll(void)
Activates the IDT protection for all the guest CPUs.
Definition: winidt.c:559
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:1217
INTRO_ACTION_REASON Reason
The reason for which Action was taken.
Definition: intro_types.h:1195
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:1618
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:153
INTRO_CPUCTX CpuContext
The context of the CPU that triggered the alert.
Definition: intro_types.h:1196
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:290
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:441
INTRO_MODULE Module
The module that modified the monitored region.
Definition: intro_types.h:1578
QWORD VirtualAddress
The guest virtual address which was modified.
Definition: intro_types.h:1616
#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:1574
#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:479
Kernel-mode exception.
Definition: exceptions.h:61
INTRO_EXEC_CONTEXT ExecContext
Information about the instruction that triggered the alert.
Definition: intro_types.h:1309
#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:526
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:172
DWORD CpuCount
The number of logical CPUs.
Definition: guests.h:279
Describes the modified zone.
Definition: exceptions.h:893
#define UNREFERENCED_PARAMETER(P)
Definition: introdefs.h:29
struct _EXCEPTION_VICTIM_ZONE::@58::@60 WriteInfo
WCHAR Name[ALERT_PATH_MAX_LEN]
NULL-terminated string with a human readable description of the modified object.
Definition: intro_types.h:1591
static INTSTATUS IntWinIdtUnprotectOnCpuEpt(DWORD CpuNumber)
Removes the EPT write protection for a IDT.
Definition: winidt.c:405
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:965
enum _INTRO_ACTION INTRO_ACTION
Event actions.
QWORD Rip
The RIP from where the call to the exported function came.
Definition: exceptions.h:950
INTSTATUS IntIntegrityRemoveRegion(void *Descriptor)
Removes an integrity region from the gIntegrityRegions list.
Definition: integrity.c:313
INTRO_WRITE_INFO WriteInfo
Definition: intro_types.h:1607
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:50
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
struct _EXCEPTION_KM_ORIGINATOR::@64 Original
struct _EVENT_INTEGRITY_VIOLATION::@302 Originator
INTRO_ACTION Action
The action that was taken as the result of this alert.
Definition: intro_types.h:1194
QWORD BaseAddress
The guest virtual address at which the monitored integrity region starts.
Definition: intro_types.h:1614
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:1197
VCPU_STATE * gVcpu
The state of the current VCPU.
Definition: guests.c:59
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:1221
static INTSTATUS IntWinIdtProtectOnCpuEpt(DWORD CpuNumber)
Protects the IDT on a guest CPU against writes using an EPT hook.
Definition: winidt.c:301
EXCEPTION_VICTIM_INTEGRITY Integrity
Valid if the modified zone is Integrity.
Definition: exceptions.h:908
Event structure for EPT violations.
Definition: intro_types.h:1215
static INTSTATUS IntWinIdtHandleModification(INTEGRITY_REGION *IntegrityRegion)
Handles IDT modifications detected by the integrity mechanism. This is the integrity callback set by ...
Definition: winidt.c:70
void IntAlertFillWinKmModule(const KERNEL_DRIVER *Driver, INTRO_MODULE *EventModule)
Saves kernel module information inside an alert.
Definition: alerts.c:617
#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:734
#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:3357
INTRO_MODULE ReturnModule
The module to which the current code returns to.
Definition: intro_types.h:1222
#define FALSE
Definition: intro_types.h:34