KiLockServiceTable

INT64 __stdcall KiLockServiceTable(PVOID BugCheckParameter1){
  int v1; 
  int v2; 
  INT64 result; 
  UINT64 CallersAddress; 
  __int64 v6; 
  unsigned int v7; 
  unsigned __int64 v8; 
  unsigned int *v9; 
  int v10; 
  int v11; 
  int v12; 
  __int64 v13; 
  __int64 v14; 
  int v15; 
  __int64 UnwindData; 
  ULONG i; 
  IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY *FunctionTable[2]; 
  UINT64 TableSize; 
  v2 = v1;
  if( v1 )
    KeExitRetpoline();
  else
    _mm_lfence();
  result = KiLockExtendedServiceTable(BugCheckParameter1);
  if( !v2 )
  {
    _mm_lfence();
    RtlCaptureImageExceptionValues((PVOID)0x140000000i64, FunctionTable, &TableSize);
    if( !FunctionTable[0] )
      KeBugCheck(0x31ui64);
    CallersAddress = KiFastGetCallersAddress();
    v7 = (unsigned int)TableSize / 0xC;
    if( !((unsigned int)TableSize / 0xC) )
      goto LABEL_31;
    v8 = CallersAddress - 0x140000000i64;
    v9 = (unsigned int *)(v6 + 12i64 * (v7 - 1));
    if( v8 < *v9 )
    {
      v10 = 0;
      v11 = v7 - 2;
      while( v11 >= v10 )
      {
        v12 = (v10 + v11) >> 1;
        v9 = (unsigned int *)(v6 + 12i64 * v12);
        if( v8 < *v9 )
        {
          v11 = v12 - 1;
        }
        else
        {
          if( v8 < v9[3] )
            break;
          v10 = v12 + 1;
        }
      }
    }
    if( v8 < *v9 || v8 >= v9[1] )
      v9 = 0i64;
    if( !v9 )
LABEL_31:
      KeBugCheck(0x31ui64);
    v13 = RtlpConvertFunctionEntry((INT64)v9, 0x140000000ui64);
    v15 = RtlLookupExceptionHandler(v13, 0x140000000ui64, 1u, v14, 0i64, FunctionTable);
    if( v15 < 0 )
      KeBugCheckEx(0x31u, v15, 0i64, 0i64, 0i64);
    UnwindData = 1i64;
    for( i = 0; i < FunctionTable[0]->BeginAddress; ++i )
    {
      if( i )
      {
        if( FunctionTable[0][2 * i + 1].UnwindData != (_DWORD)UnwindData )
          KeBugCheck(0x31ui64);
      }
      UnwindData = FunctionTable[0][2 * i + 1].UnwindData;
    }
    if( (_DWORD)UnwindData == 1 )
      KeBugCheck(0x31ui64);
    return((__int64(__fastcall *)(_QWORD, _QWORD, __int64, IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY *))(0x140000000i64
                                                                                                  + (unsigned int)UnwindData))(
             0i64,
             0i64,
             UnwindData,
             FunctionTable[0]);
  }
  return result;
}

Referenced by:

KeCompactServiceTable