WheapGetPreallocatedPacketBuffer

INT32 *__fastcall WheapGetPreallocatedPacketBuffer(UINT64 ErrorSourceId){
  INT64 *ErrorSource; 
  _QWORD *v2; 
  unsigned __int64 v3; 
  __int64 v4; 
  __int64 v5; 
  unsigned int v6; 
  volatile signed __int32 *v7; 
  __int64 v8; 
  volatile signed __int32 v9; 
  ErrorSource = WheapGetErrorSource((INT64)&WheapErrorSourceTable, (unsigned int)ErrorSourceId);
  v3 = (unsigned __int64)(ErrorSource + 12);
  v4 = -(__int64)ErrorSource;
  if( (v3 & -(__int64)(v4 != 0)) == 0 )
    return 0i64;
  v5 = *(unsigned int *)((v3 & -(__int64)(v4 != 0)) + 0x40);
  v6 = 0;
  v7 = *(volatile signed __int32 **)((v3 & -(__int64)(v4 != 0)) + 0x48);
  v8 = *(_QWORD *)((v3 & -(__int64)(v4 != 0)) + 0x90);
  if( !*(_DWORD *)((v3 & -(__int64)(v4 != 0)) + 0x44) )
    return 0i64;
  while( 1 )
  {
    if( (*v7 & 0xF0000000) != 0x80000000 )
    {
      v9 = *v7;
      if( v9 == _InterlockedCompareExchange(v7, *v7 | 0x80000000, *v7) )
        break;
    }
    v7 = (volatile signed __int32 *)((char *)v7 + v5);
    if( ++v6 >= *(_DWORD *)((v3 & -(__int64)(v4 != 0)) + 0x44) )
      return 0i64;
  }
  if( v2 )
    *v2 = v8 + 104i64 * v6;
  return(INT32 *)v7;
}

Referenced by:

WheapInitErrorReportDeviceDriver