KiBoundFault
VOID __fastcall KiBoundFault(INT64 SecurityDomain, UINT64 a2, UINT64 a3, _UNICODE_STRING *a4, CHAR a5){
unsigned __int64 v5;
unsigned __int64 v6;
unsigned __int64 v7;
_M128A v8;
_M128A v9;
_M128A v10;
_M128A v11;
_M128A v12;
_M128A v13;
_KTRAP_FRAME *__shifted(_KTRAP_FRAME,0x80) TrapFrame;
_ETHREAD *CurrentThread;
unsigned __int8 BpbKernelSpecCtrl;
unsigned __int8 BpbState;
ULONG64 v18;
_QWORD *Object;
bool v20;
NTSTATUS v21;
INT64 v22;
void *v23;
_ETHREAD *v24;
_ETHREAD *v25;
INT64 R9;
INT64 R8;
unsigned __int8 BpbUserSpecCtrl;
unsigned __int8 v29;
CHAR v32;
void *retaddr;
__int16 v34;
int v35;
void *v36;
__int16 v37;
TrapFrame = KeGetTrapFrame();
ADJ(TrapFrame)->ExceptionActive = 1;
ADJ(TrapFrame)->_Rax = v5;
ADJ(TrapFrame)->_Rcx = SecurityDomain;
ADJ(TrapFrame)->_Rdx = a2;
ADJ(TrapFrame)->_R8 = a3;
ADJ(TrapFrame)->_R9 = (unsigned __int64)a4;
ADJ(TrapFrame)->_R10 = v6;
ADJ(TrapFrame)->_R11 = v7;
if( (ADJ(TrapFrame)->SegCs & 1) != 0 )
{
if( (KiKvaShadow & 1) == 0 )
__swapgs();
_mm_lfence();
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
SecurityDomain = CurrentThread->Tcb.Process->SecurityDomain;
__writegsqword(0x270u, SecurityDomain);
__writegsbyte(0x851u, KeGetPcr()->Prcb.BpbRetpolineExitSpecCtrl);
LOBYTE(SecurityDomain) = KeGetPcr()->Prcb.BpbState;
__writegsbyte(0x852u, SecurityDomain);
BpbKernelSpecCtrl = KeGetPcr()->Prcb.BpbKernelSpecCtrl;
if( KeGetPcr()->Prcb.BpbCurrentSpecCtrl != BpbKernelSpecCtrl )
{
__writegsbyte(0x27Au, BpbKernelSpecCtrl);
SecurityDomain = 72i64;
__writemsr(0x48u, BpbKernelSpecCtrl);
}
BpbState = KeGetPcr()->Prcb.BpbState;
if( (BpbState & 8) != 0 )
{
SecurityDomain = 73i64;
__writemsr(0x49u, 1ui64);
BpbState = KeGetPcr()->Prcb.BpbState;
}
if( (BpbState & 2) != 0 )
__flush_rsb();
_mm_lfence();
__writegsbyte(0x853u, 0);
if( (char)CurrentThread->Tcb.gap0[3] < 0 )
{
SecurityDomain = 3221225730i64;
v18 = __readmsr(0xC0000102);
if( v18 >= MmUserProbeAddress )
v18 = MmUserProbeAddress;
if( CurrentThread->Tcb.Teb != (void *)v18 )
{
Object = CurrentThread->Tcb.WaitBlock[3].Object;
CurrentThread->Tcb._bf_0 |= 0x100u;
--CurrentThread->Tcb.SpecialApcDisable;
Object[16] = v18;
}
}
v20 = (CurrentThread->Tcb.gap0[3] & 3) == 0;
LOWORD(ADJ(TrapFrame)->Dr7) = 0;
if( !v20 )
KiSaveDebugRegisterState();
}
else
{
_mm_lfence();
if( (KeGetPcr()->Prcb.BpbState & 1) != 0 )
{
SecurityDomain = 72i64;
__writemsr(0x48u, KeGetPcr()->Prcb.BpbCurrentSpecCtrl);
}
else
{
_mm_lfence();
}
}
ADJ(TrapFrame)->_MxCsr = _mm_getcsr();
_mm_setcsr(KeGetPcr()->Prcb._MxCsr);
ADJ(TrapFrame)->_Xmm0 = v8;
ADJ(TrapFrame)->_Xmm1 = v9;
ADJ(TrapFrame)->_Xmm2 = v10;
ADJ(TrapFrame)->_Xmm3 = v11;
ADJ(TrapFrame)->_Xmm4 = v12;
ADJ(TrapFrame)->_Xmm5 = v13;
if( (_BYTE)KeSmapEnabled && (ADJ(TrapFrame)->SegCs & 1) != 0 )
__stac();
if( (ADJ(TrapFrame)->EFlags & 0x200) != 0 )
_enable();
if( (ADJ(TrapFrame)->SegCs & 1) != 0 )
{
if( _bittest((const signed __int32 *)&KeGetCurrentThread()->116, 8u) )
KiUmsTrapEntry(SecurityDomain);
v21 = KiHandleBound();
if( v21 )
{
if( v21 == 1 )
goto LABEL_34;
if( v21 != 2 )
KiBugCheckDispatch(0x7Fu, (void *)5, v23, a4);
KiFastFailDispatch(3221226505i64, 1i64, (void *)ADJ(TrapFrame)->_Rip, 0x1Cui64, v32);
}
}
KiExceptionDispatch(3221225612i64, 0i64, (VOID *)ADJ(TrapFrame)->_Rip, (UINT64)a4, v32);
LABEL_34:
_disable();
if( (ADJ(TrapFrame)->SegCs & 1) == 0 )
{
_mm_setcsr(ADJ(TrapFrame)->_MxCsr);
__iretq(retaddr, v34, v35, v36, v37);
}
if( (_BYTE)KeSmapEnabled )
__stac();
while( (KeGetCurrentThread()->ApcState.UserApcPendingAll & 3) != 0 )
{
__writecr8(1ui64);
_enable();
KiInitiateUserApc((_KTRAP_FRAME *)1);
_disable();
__writecr8(0i64);
}
if( (*((_BYTE *)&KeGetPcr()->Prcb.2 + 14) & 2) != 0 )
KiUpdateStibpPairing(0i64);
v24 = (_ETHREAD *)KeGetCurrentThread();
if( (*(_DWORD *)v24->Tcb.gap0 & 0x8000000) != 0 )
KiRestoreSetContextState((INT64)v24, v22, (INT64)v23, (INT64)a4, v32);
v25 = (_ETHREAD *)KeGetCurrentThread();
if( (*(_DWORD *)v25->Tcb.gap0 & 0x40010000) != 0 )
{
if( (v25->Tcb.gap0[2] & 1) != 0 )
{
KiCopyCounters(&v25->Tcb);
v25 = (_ETHREAD *)KeGetCurrentThread();
}
if( (v25->Tcb.gap0[3] & 0x40) != 0 )
KiUmsExit(1);
}
_mm_setcsr(ADJ(TrapFrame)->_MxCsr);
if( LOWORD(ADJ(TrapFrame)->Dr7) )
KiRestoreDebugRegisterState();
R9 = ADJ(TrapFrame)->_R9;
R8 = ADJ(TrapFrame)->_R8;
__writegsbyte(0x853u, 0);
BpbUserSpecCtrl = KeGetPcr()->Prcb.BpbUserSpecCtrl;
if( KeGetPcr()->Prcb.BpbCurrentSpecCtrl != BpbUserSpecCtrl )
{
__writegsbyte(0x27Au, BpbUserSpecCtrl);
__writemsr(0x48u, BpbUserSpecCtrl);
}
v29 = _bittestandreset16(MK_FP(__GS__, 632i64), 2u);
if( v29 )
__writemsr(0x49u, 1ui64);
v29 = _bittestandreset16(MK_FP(__GS__, 632i64), 5u);
if( v29 )
__flush_rsb();
if( (KiKvaShadow & 1) == 0 )
{
__swapgs();
__iretq(retaddr, v34, v35, v36, v37);
}
KiKernelExit(ADJ(TrapFrame)->_Rcx, ADJ(TrapFrame)->_Rdx, R8, R9, a5);
}Referenced by:
KiBoundFaultShadow