PopPdcCsDeviceNotification

INT64 __fastcall PopPdcCsDeviceNotification(INT64 a1){
  unsigned int v1; 
  _ETHREAD *CurrentThread; 
  void **v4; 
  void **v5; 
  char v6; 
  _OWORD *PoolWithTag; 
  _QWORD *v8; 
  void **v9; 
  _QWORD *v10; 
  void **v11; 
  INT64 v12; 
  v1 = 0;
  if( !PopPlatformAoAc )
    return v1;
  if( *(_DWORD *)(a1 + 8) > 4u )
    return(unsigned int)-1073741811;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  --*((_WORD *)CurrentThread + 242);
  ExAcquirePushLockExclusiveEx((UINT64)PopPdcDeviceListLock, 0i64);
  v4 = (void **)PopPdcDeviceList;
  v5 = 0i64;
  v6 = 0;
  if( PopPdcDeviceList != &PopPdcDeviceList )
  {
    while( 1 )
    {
      v5 = v4;
      if( v4[2] == *(void **)a1 )
        break;
      v4 = (void **)*v4;
      if( v4 == &PopPdcDeviceList )
        goto LABEL_8;
    }
    v6 = 1;
  }
LABEL_8:
  if( *(_BYTE *)(a1 + 12) )
  {
    if( v6 )
    {
      ++*((_DWORD *)v5 + 7);
    }
    else
    {
      PoolWithTag = ExAllocatePoolWithTag(PagedPool, 0x28ui64, 0x6F435343ui64);
      v8 = PoolWithTag;
      if( PoolWithTag )
      {
        *PoolWithTag = 0i64;
        PoolWithTag[1] = 0i64;
        *((_QWORD *)PoolWithTag + 4) = 0i64;
        *((_QWORD *)PoolWithTag + 2) = *(_QWORD *)a1;
        *((_DWORD *)PoolWithTag + 6) = *(_DWORD *)(a1 + 8);
        *((_BYTE *)PoolWithTag + 32) = *(_BYTE *)(a1 + 13);
        *((_DWORD *)PoolWithTag + 7) = 1;
        v9 = off_140C0EDC0;
        if( *off_140C0EDC0 == &PopPdcDeviceList )
        {
          *v8 = &PopPdcDeviceList;
          v8[1] = v9;
          *v9 = v8;
          off_140C0EDC0 = (void **)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();
          v12 = *(int *)(a1 + 8);
          if( (((_DWORD)v12 - 1) & 0xFFFFFFFC) != 0 || (_DWORD)v12 == 3 )
          {
            if( PopCsDeviceCompliance[v12] == -1 )
              PopNetNonCompliantDeviceUpdate(*(_BYTE *)(a1 + 12), v12);
          }
          else
          {
            if( *(_BYTE *)(a1 + 13) )
              PopNetCompliantNicUpdate(*(_BYTE *)(a1 + 12));
            PopNetUpdateCsConsumptionFlags();
          }
          PopReleasePolicyLock();
          goto LABEL_30;
        }
      }
LABEL_28:
      __fastfail(3u);
    }
  }
  else
  {
    v1 = -1073741811;
  }
LABEL_30:
  if( (_InterlockedExchangeAdd64((volatile signed __int64 *)PopPdcDeviceListLock, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
    ExfTryToWakePushLock((volatile INT64 *)PopPdcDeviceListLock);
  KeAbPostRelease(PopPdcDeviceListLock);
  KeLeaveCriticalRegionThread((__int64)KeGetCurrentThread());
  return v1;
}

Referenced by:

NtPowerInformation
PopPdcCsCheckSystemVolumeDevice