RtlpStdExtendUpperWatermark

VOID *__stdcall RtlpStdExtendUpperWatermark(_STACK_TRACE_DATABASE *Database, VOID *Size){
  VOID *v3; 
  __int64 v4; 
  char v5; 
  char *v6; 
  unsigned __int64 v7; 
  unsigned __int64 v8; 
  UINT64 AllocationType; 
  UINT64 Protect; 
  UINT64 RegionSize; 
  VOID *BaseAddress; 

  BaseAddress = Size;
  RegionSize = 0i64;
  v3 = 0i64;
  *((_BYTE *)Database + 8) = KeAcquireSpinLockRaiseToDpc((UINT64 *)Database);
  v4 = *((_QWORD *)Database + 21);
  v5 = *((_BYTE *)Database + 128);
  v6 = (char *)*((_QWORD *)Database + 19);
  BaseAddress = v6;
  v7 = v4 - 8;
  if( !v5 )
  {
    if( v7 < (unsigned __int64)v6 )
    {
      RegionSize = 4096i64;
      if( (unsigned __int64)(v6 - 4096) <= *((_QWORD *)Database + 18) )
        goto LABEL_9;
      LODWORD(Protect) = 4;
      LODWORD(AllocationType) = 4096;
      BaseAddress = v6 - 4096;
      if( ZwAllocateVirtualMemory(
             (VOID *)0xFFFFFFFFFFFFFFFFi64,
             &BaseAddress,
             0i64,
             &RegionSize,
             AllocationType,
             Protect) < 0 )
        goto LABEL_9;
      *((_QWORD *)Database + 19) = BaseAddress;
    }
LABEL_8:
    ++Database[45];
    v3 = (VOID *)(v4 - 8);
    *((_QWORD *)Database + 21) = v4 - 8;
    goto LABEL_9;
  }
  if( v7 >= *((_QWORD *)Database + 20) )
    goto LABEL_8;
LABEL_9:
  v8 = *((unsigned __int8 *)Database + 8);
  KxReleaseSpinLock((UINT64 *)Database);
  __writecr8(v8);
  return v3;
}

Referenced by:

RtlpStdGetRecordedStackTraceIndex