ExHandleSPCall2

NTSTATUS __stdcall ExHandleSPCall2(_SYSTEM_POLICY_INFORMATION *SPCall2Information){
  __m128i *v1; 
  __m128i *v2; 
  int v3; 
  VOID **v4; 
  int v5; 
  int v6; 
  unsigned int v7; 
  unsigned __int64 v8; 
  size_t v9; 
  VOID **PoolWithTag; 
  VOID *v11; 
  size_t v12; 
  __m128i Src; 
  __m128i v15; 
  UINT64 Length; 
  __m128i *v17; 
  PVOID P; 

  v17 = v1;
  v2 = v1;
  v3 = 0;
  v4 = 0i64;
  v5 = 0;
  P = 0i64;
  LODWORD(Length) = 0;
  v6 = 0;
  if( !v1 )
  {
    v3 = -1073741789;
    goto LABEL_24;
  }
  if( (unsigned __int64)&v1[2] > 0x7FFFFFFF0000i64 || &v1[2] < v1 )
    MEMORY[0x7FFFFFFF0000] = 0;
  Src = *v1;
  v15 = v1[1];
  v7 = _mm_cvtsi128_si32(v15);
  if( v7 )
  {
    v8 = Src.m128i_i64[0] + v7;
    if( v8 > 0x7FFFFFFF0000i64 || v8 < Src.m128i_i64[0] )
      MEMORY[0x7FFFFFFF0000] = 0;
  }
  if( Src.m128i_i64[0] && v7 )
  {
    v5 = v7;
    v9 = v7;
    PoolWithTag = ExAllocatePoolWithTag(1ui64, v7, 542329939i64);
    v4 = PoolWithTag;
    if( PoolWithTag )
    {
      memmove(PoolWithTag, (const VOID *)Src.m128i_i64[0], v9);
      v11 = (VOID *)Src.m128i_i64[1];
      if( Src.m128i_i64[1] )
        v6 = v15.m128i_i32[1];
      goto LABEL_17;
    }
    v3 = -1073741801;
  }
  else
  {
    v3 = -1073741789;
  }
  v11 = (VOID *)Src.m128i_i64[1];
LABEL_17:
  if( v3 >= 0 )
  {
    v3 = sub_1406F301C((__int64)v4, v5, v6, &P, &Length);
    if( v3 >= 0 )
    {
      if( v11 )
      {
        v12 = Length;
        if( v15.m128i_i32[1] < (unsigned int)Length )
        {
          v3 = -1073741789;
        }
        else
        {
          ProbeForWrite((UINT64)v11, (unsigned int)Length, 1i64);
          memmove(v11, P, v12);
          v2[1].m128i_i32[1] = v12;
        }
      }
      else
      {
        v2[1].m128i_i32[1] = Length;
      }
    }
  }
LABEL_24:
  if( v4 )
    ExFreePoolWithTag(v4, 0);
  if( P )
    ExFreePoolWithTag(P, 0x20534C53u);
  return v3;
}

Referenced by:

ExpQuerySystemInformation
NtSetSystemInformation