KeExpandKernelStackAndCalloutInternal

INT64 __stdcall KeExpandKernelStackAndCalloutInternal(PVOID BugCheckParameter2, PVOID BugCheckParameter3, INT64 a3){
  char v3; 
  INT64 result; 
  unsigned __int8 CurrentIrql; 
  _ETHREAD *CurrentThread; 
  int v9; 
  char v10; 
  unsigned __int8 v11; 
  __int64 v12; 
  result = KiExpandKernelStackAndCalloutSwitchStack(
             (void(*)(void))BugCheckParameter2,
             (ULONG_PTR)BugCheckParameter3,
             a3,
             v3,
             v12);
  if( (_DWORD)result == -1073740661 )
  {
    CurrentIrql = KeGetCurrentIrql();
    CurrentThread = (_ETHREAD *)KeGetCurrentThread();
    v9 = *((_DWORD *)CurrentThread + 29);
    if( (v9 & 0x1000) != 0 )
    {
      v10 = 1;
    }
    else
    {
      *((_DWORD *)CurrentThread + 29) = v9 | 0x1000;
      v10 = 0;
    }
    ((void(__fastcall *)(PVOID))BugCheckParameter2)(BugCheckParameter3);
    if( !v10 )
      *((_DWORD *)CurrentThread + 29) &= ~0x1000u;
    if( KeGetCurrentIrql() != CurrentIrql )
    {
      v11 = KeGetCurrentIrql();
      KeBugCheckEx(
        0xC8u,
        ((CurrentIrql | ((unsigned __int64)v11 << 8)) << 8) | 2,
        (ULONG_PTR)BugCheckParameter2,
        (ULONG_PTR)BugCheckParameter3,
        0i64);
    }
    return 0i64;
  }
  return result;
}

Referenced by:

KeExpandKernelStackAndCallout
KeExpandKernelStackAndCalloutEx
KeInitSystem
MiDoStackCopy
MiSwapStackPage
SMKM_STORE::SmStDirectRead