WheapGetPreallocatedPacketBuffer

INT32 *__stdcall WheapGetPreallocatedPacketBuffer(UINT64 ErrorSourceId){
  INT64 v1; 
  UINT64 v2; 
  _WHEAP_ERROR_SOURCE *ErrorSource; 
  _QWORD *v4; 
  _WHEA_ERROR_SOURCE_DESCRIPTOR *p_Descriptor; 
  __int64 v6; 
  __int64 v7; 
  unsigned int v8; 
  volatile signed __int32 *v9; 
  __int64 v10; 
  volatile signed __int32 v11; 

  ErrorSource = WheapGetErrorSource(
                  (_WHEAP_ERROR_SOURCE_TABLE *)&WheapErrorSourceTable,
                  (unsigned int)ErrorSourceId,
                  v1,
                  v2);
  p_Descriptor = &ErrorSource->Descriptor;
  v6 = -(__int64)ErrorSource;
  if( ((unsigned __int64)p_Descriptor & -(__int64)(v6 != 0)) == 0 )
    return 0i64;
  v7 = *(unsigned int *)(((unsigned __int64)p_Descriptor & -(__int64)(v6 != 0)) + 0x40);
  v8 = 0;
  v9 = *(volatile signed __int32 **)(((unsigned __int64)p_Descriptor & -(__int64)(v6 != 0)) + 0x48);
  v10 = *(_QWORD *)(((unsigned __int64)p_Descriptor & -(__int64)(v6 != 0)) + 0x90);
  if( !*(_DWORD *)(((unsigned __int64)p_Descriptor & -(__int64)(v6 != 0)) + 0x44) )
    return 0i64;
  while( 1 )
  {
    if( (*v9 & 0xF0000000) != 0x80000000 )
    {
      v11 = *v9;
      if( v11 == _InterlockedCompareExchange(v9, *v9 | 0x80000000, *v9) )
        break;
    }
    v9 = (volatile signed __int32 *)((char *)v9 + v7);
    if( ++v8 >= *(_DWORD *)(((unsigned __int64)p_Descriptor & -(__int64)(v6 != 0)) + 0x44) )
      return 0i64;
  }
  if( v4 )
    *v4 = v10 + 104i64 * v8;
  return(INT32 *)v9;
}

Referenced by:

WheapInitErrorReportDeviceDriver