PopPdcCsDeviceNotification

NTSTATUS __stdcall PopPdcCsDeviceNotification(PO_CS_DEVICE_NOTIFICATION *Notification){
  NTSTATUS v1; 
  _ETHREAD *CurrentThread; 
  void **v4; 
  void **v5; 
  char v6; 
  VOID **PoolWithTag; 
  VOID **v8; 
  void **v9; 
  _QWORD *v10; 
  void **v11; 
  __int64 DeviceType; 

  v1 = 0;
  if( !PopPlatformAoAc )
    return v1;
  if( Notification->DeviceType > (unsigned int)PoCsDeviceNotificationEthernet )
    return -1073741811;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  --CurrentThread->Tcb.KernelApcDisable;
  ExAcquirePushLockExclusiveEx((_EX_PUSH_LOCK *)&PopIrpWorkerControlEvent + 243, 0i64);
  v4 = (void **)PopPdcDeviceList;
  v5 = 0i64;
  v6 = 0;
  if( PopPdcDeviceList != &PopPdcDeviceList )
  {
    while( 1 )
    {
      v5 = v4;
      if( v4[2] == Notification->Device )
        break;
      v4 = (void **)*v4;
      if( v4 == &PopPdcDeviceList )
        goto LABEL_8;
    }
    v6 = 1;
  }
LABEL_8:
  if( Notification->Arriving )
  {
    if( v6 )
    {
      ++*((_DWORD *)v5 + 7);
    }
    else
    {
      PoolWithTag = ExAllocatePoolWithTag(1ui64, 0x28ui64, 1866683203i64);
      v8 = PoolWithTag;
      if( PoolWithTag )
      {
        *(_OWORD *)PoolWithTag = 0i64;
        *((_OWORD *)PoolWithTag + 1) = 0i64;
        PoolWithTag[4] = 0i64;
        PoolWithTag[2] = Notification->Device;
        *((_DWORD *)PoolWithTag + 6) = Notification->DeviceType;
        *((_BYTE *)PoolWithTag + 32) = Notification->Compliant;
        *((_DWORD *)PoolWithTag + 7) = 1;
        v9 = off_140C0EDC0;
        if( *off_140C0EDC0 == &PopPdcDeviceList )
        {
          *v8 = &PopPdcDeviceList;
          v8[1] = v9;
          *v9 = v8;
          off_140C0EDC0 = v8;
          goto LABEL_20;
        }
        goto LABEL_28;
      }
      v1 = -1073741801;
    }
  }
  else if( v6 )
  {
    if( (int)--*((_DWORD *)v5 + 7) <= 0 )
    {
      v10 = *v4;
      if( *((void ***)*v4 + 1) == v4 )
      {
        v11 = (void **)v4[1];
        if( *v11 == v4 )
        {
          *v11 = v10;
          v10[1] = v11;
          ExFreePoolWithTag(v5, 0x6F435343u);
LABEL_20:
          PopPdcUpdateDeviceCompliance();
          PopAcquirePolicyLock();
          DeviceType = Notification->DeviceType;
          if( (((_DWORD)DeviceType - 1) & 0xFFFFFFFC) != 0 || (_DWORD)DeviceType == 3 )
          {
            if( PopCsDeviceCompliance[DeviceType] == -1 )
              PopNetNonCompliantDeviceUpdate(Notification->Arriving, (PO_CS_DEVICE_NOTIFICATION_TYPE)DeviceType);
          }
          else
          {
            if( Notification->Compliant )
              PopNetCompliantNicUpdate(Notification->Arriving, (PO_CS_DEVICE_NOTIFICATION_TYPE)DeviceType);
            PopNetUpdateCsConsumptionFlags();
          }
          PopReleasePolicyLock();
          goto LABEL_30;
        }
      }
LABEL_28:
      __fastfail(3u);
    }
  }
  else
  {
    v1 = -1073741811;
  }
LABEL_30:
  if( (_InterlockedExchangeAdd64((_QWORD *)&PopIrpWorkerControlEvent + 243, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
    ExfTryToWakePushLock((_EX_PUSH_LOCK *)&PopIrpWorkerControlEvent + 243);
  KeAbPostRelease((char *)&PopIrpWorkerControlEvent + 1944);
  KeLeaveCriticalRegionThread(KeGetCurrentThread());
  return v1;
}

Referenced by:

NtPowerInformation
PopPdcCsCheckSystemVolumeDevice