HyperDbg Debugger
Loading...
Searching...
No Matches
Apic.c File Reference
#include "pch.h"

Functions

VOID XApicIcrWrite (UINT32 Low, UINT32 High)
 Trigger NMI on XAPIC.
 
VOID X2ApicIcrWrite (UINT32 Low, UINT32 High)
 Trigger NMI on X2APIC.
 
VOID ApicTriggerGenericNmi ()
 Trigger NMI on X2APIC or APIC based on Current system.
 
BOOLEAN ApicInitialize ()
 Initialize APIC.
 
VOID ApicUninitialize ()
 Uninitialize APIC.
 
VOID ApicSelfIpi (UINT32 Vector)
 Self IPI the current core.
 

Function Documentation

◆ ApicInitialize()

BOOLEAN ApicInitialize ( )

Initialize APIC.

Returns
BOOLEAN
66{
67 UINT64 ApicBaseMSR;
68 PHYSICAL_ADDRESS PaApicBase;
69
70 ApicBaseMSR = __readmsr(0x1B);
71 if (!(ApicBaseMSR & (1 << 11)))
72 return FALSE;
73
74 if (ApicBaseMSR & (1 << 10))
75 {
77 return FALSE;
78 }
79 else
80 {
81 PaApicBase.QuadPart = ApicBaseMSR & 0xFFFFFF000;
82 g_ApicBase = MmMapIoSpace(PaApicBase, 0x1000, MmNonCached);
83
84 if (!g_ApicBase)
85 return FALSE;
86
88 }
89 return TRUE;
90}
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
unsigned __int64 UINT64
Definition BasicTypes.h:21
COMPATIBILITY_CHECKS_STATUS g_CompatibilityCheck
Different attributes and compatibility checks of the current processor.
Definition GlobalVariables.h:26
VOID * g_ApicBase
APIC Base.
Definition GlobalVariables.h:81
BOOLEAN IsX2Apic
Definition CompatibilityChecks.h:25

◆ ApicSelfIpi()

VOID ApicSelfIpi ( UINT32 Vector)

Self IPI the current core.

Parameters
Vector
Returns
VOID
115{
116 //
117 // Check and apply self-IPI to x2APIC and xAPIC
118 //
120 {
122 }
123 else
124 {
126 }
127}
VOID XApicIcrWrite(UINT32 Low, UINT32 High)
Trigger NMI on XAPIC.
Definition Apic.c:22
VOID X2ApicIcrWrite(UINT32 Low, UINT32 High)
Trigger NMI on X2APIC.
Definition Apic.c:36
#define APIC_DM_FIXED
Definition Apic.h:79
#define APIC_DEST_SELF
Definition Apic.h:67
#define APIC_DEST_PHYSICAL
Definition Apic.h:78

◆ ApicTriggerGenericNmi()

VOID ApicTriggerGenericNmi ( )

Trigger NMI on X2APIC or APIC based on Current system.

Returns
VOID
48{
50 {
51 X2ApicIcrWrite((4 << 8) | (1 << 14) | (3 << 18), 0);
52 }
53 else
54 {
55 XApicIcrWrite((4 << 8) | (1 << 14) | (3 << 18), 0);
56 }
57}

◆ ApicUninitialize()

VOID ApicUninitialize ( )

Uninitialize APIC.

Returns
VOID
99{
100 //
101 // Unmap I/O Base
102 //
103 if (g_ApicBase)
104 MmUnmapIoSpace(g_ApicBase, 0x1000);
105}

◆ X2ApicIcrWrite()

VOID X2ApicIcrWrite ( UINT32 Low,
UINT32 High )

Trigger NMI on X2APIC.

Parameters
Low
High
Returns
VOID
37{
38 __writemsr(X2_MSR_BASE + TO_X2(ICROffset), ((UINT64)High << 32) | Low);
39}
#define ICROffset
Definition Apic.h:19
#define TO_X2(x)
Definition Apic.h:20
#define X2_MSR_BASE
Definition Apic.h:18

◆ XApicIcrWrite()

VOID XApicIcrWrite ( UINT32 Low,
UINT32 High )

Trigger NMI on XAPIC.

Parameters
Low
High
Returns
VOID
23{
24 *(UINT32 *)((uintptr_t)g_ApicBase + ICROffset + 0x10) = High;
25 *(UINT32 *)((uintptr_t)g_ApicBase + ICROffset) = Low;
26}
unsigned int UINT32
Definition BasicTypes.h:48