PnprAllocateMappingReserves

__int64 __fastcall PnprAllocateMappingReserves(_QWORD *a1, _QWORD *a2, unsigned int a3){
  UINT64 v5; 
  VOID **PoolWithTag; 
  int v7; 
  VOID **v8; 
  __int64 v9; 
  __int64 v10; 
  __int64 v11; 
  __int64 v12; 

  v5 = 24 * a3;
  PoolWithTag = ExAllocatePoolWithTag(0x200ui64, v5, 1366322768i64);
  if( !PoolWithTag )
    return(unsigned int)-1073741670;
  v8 = ExAllocatePoolWithTag(0x200ui64, v5, 1366322768i64);
  if( v8 )
  {
    memset(PoolWithTag, 0i64, v5);
    memset(v8, 0i64, v5);
    v9 = 0i64;
    if( a3 )
    {
      while( 1 )
      {
        v7 = PnprInitializeMappingReserve(2, (__int64)&PoolWithTag[3 * v9]);
        if( v7 < 0 )
          break;
        v7 = PnprInitializeMappingReserve(2050, (__int64)&v8[3 * v9]);
        if( v7 < 0 )
        {
          PnprFreeMappingReserve((__int64)&PoolWithTag[3 * v9]);
          goto LABEL_10;
        }
        v9 = (unsigned int)(v9 + 1);
        if( (unsigned int)v9 >= a3 )
          goto LABEL_9;
      }
    }
    else
    {
LABEL_9:
      v7 = 0;
LABEL_10:
      if( v7 >= 0 )
        goto LABEL_17;
    }
  }
  else
  {
    v7 = -1073741670;
  }
  if( v8 && *PoolWithTag && *v8 )
  {
    v10 = PnprContext;
    v11 = *(unsigned int *)(PnprContext + 180);
    if( !PoolWithTag[3 * v11] )
    {
      *(_OWORD *)&PoolWithTag[3 * v11] = *(_OWORD *)PoolWithTag;
      PoolWithTag[3 * v11 + 2] = PoolWithTag[2];
      v12 = 3i64 * *(unsigned int *)(v10 + 180);
      *(_OWORD *)&v8[v12] = *(_OWORD *)v8;
      v8[v12 + 2] = v8[2];
      *(_OWORD *)PoolWithTag = 0i64;
      PoolWithTag[2] = 0i64;
      *(_OWORD *)v8 = 0i64;
      v8[2] = 0i64;
    }
    v7 = 0;
LABEL_17:
    *a1 = PoolWithTag;
    *a2 = v8;
    return(unsigned int)v7;
  }
  ExFreePoolWithTag(PoolWithTag, 0x51706E50u);
  if( v8 )
    ExFreePoolWithTag(v8, 0x51706E50u);
  return(unsigned int)v7;
}

Referenced by:

No references.