PopDirectedDripsUmDirectedFxAddTestDevice

NTSTATUS __stdcall PopDirectedDripsUmDirectedFxAddTestDevice(UINT64 a1, INT64 a2){
  PVOID v2; 
  int v4; 
  unsigned int v5; 
  unsigned __int64 v6; 
  UINT8 NewElement; 
  UINT64 BufferSize; 
  PVOID P; 

  LODWORD(BufferSize) = 0;
  v2 = 0i64;
  NewElement = 0;
  P = 0i64;
  if( (unsigned int)a1 < 0x10 )
    return -1073741811;
  v5 = *(_DWORD *)(a2 + 12);
  v6 = 2i64 * v5;
  if( v6 > 0xFFFFFFFF || (unsigned int)v6 > (int)a1 - 16 )
  {
    v4 = -1073741811;
  }
  else
  {
    v4 = PopDirectedDripsUmCreateTestDevice(v5, (_WORD *)(a2 + 16), (CHAR **)&P, &BufferSize);
    if( v4 < 0 )
    {
      v2 = P;
    }
    else
    {
      PopAcquireRwLockExclusive(&PopDirectedDripsUmLock);
      v2 = P;
      if( RtlInsertElementGenericTableAvl(&PopDirectedDripsUmTestDeviceTable, P, (unsigned int)BufferSize, &NewElement) )
      {
        if( NewElement )
        {
          _InterlockedIncrement(&PopDirectedDripsUmTestDeviceCount);
          v2 = P;
          v4 = 0;
        }
        else
        {
          v4 = -1073740008;
        }
      }
      else
      {
        v4 = -1073741670;
      }
      PopReleaseRwLock(&PopDirectedDripsUmLock);
    }
  }
  if( v2 )
    ExFreePoolWithTag(v2, 0x4D554444u);
  return v4;
}

Referenced by:

PopDirectedDripsUmPowerInformationInternal