PopProcessPowerRequestOverrideQueryResponse

void __fastcall PopProcessPowerRequestOverrideQueryResponse(unsigned int *a1){
  unsigned int v1; 
  unsigned int v3; 
  _EPROCESS *v4; 
  char v5; 
  POP_POWER_REQUEST_ENTRY *EntryById; 
  INT64 v7; 
  __int64 v8; 
  bool v9; 
  int v10; 
  unsigned int v11; 
  int *v12; 
  unsigned int v13; 
  int *v14; 
  signed int v15; 
  int v16; 
  int *v17; 
  int v18; 
  int v19; 
  int v20; 
  int v21; 
  unsigned int v22; 
  _KLOCK_QUEUE_HANDLE LockHandle; 
  int v24; 
  __int16 v25; 
  int v26; 
  __int16 v27; 

  v1 = a1[2];
  v24 = 0;
  v3 = 0;
  v25 = 0;
  v21 = 0;
  memset(&LockHandle, 0, sizeof(LockHandle));
  v26 = 0;
  v4 = 0i64;
  v27 = 0;
  v5 = 0;
  v22 = v1;
  PopAcquirePowerRequestPushLock(0);
  EntryById = PopPowerRequestFindEntryById(*a1);
  if( EntryById )
  {
    v7 = *(_QWORD *)EntryById;
    KeAcquireInStackQueuedSpinLock((PKSPIN_LOCK)&stru_140C23628 + 751, &LockHandle);
    v9 = *(_DWORD *)(v7 + 24) == v1;
    v10 = *(_DWORD *)(v7 + 24) ^ v1;
    *(_DWORD *)(v7 + 24) = v1;
    if( !v9 )
    {
      do
      {
        _BitScanForward((unsigned int *)&v15, v10);
        v16 = 1 << v15;
        if( *(_DWORD *)(v7 + 4i64 * v15 + 32) )
        {
          if( *(_DWORD *)(v7 + 88) && *(&stru_140C23628 + 6016) && (unsigned int)v15 <= 3 )
            v5 = 1;
          if( !v15 && *(_QWORD *)(v7 + 120) )
          {
            v4 = *(_EPROCESS **)(v7 + 120);
            ObfReferenceObjectWithTag(v4, 0x72506F50ui64);
          }
          v17 = &PopPowerRequestAttributes[4 * v15];
          v18 = *v17;
          if( (v16 & v22) != 0 )
          {
            v19 = v18 - 1;
            v21 = 2;
            *v17 = v19;
            if( !v15 || v15 == 3 || !v19 )
              --*(_BYTE *)(v15 + v7 + 72);
            if( v5 )
              *((_BYTE *)&v26 + v15) = 1;
          }
          else
          {
            v21 = 1;
            if( v18 != -1 )
            {
              v20 = v18 + 1;
              *v17 = v20;
              if( !v15 || v15 == 3 || v20 == 1 )
                ++*(_BYTE *)(v15 + v7 + 72);
            }
            if( v5 )
              *((_BYTE *)&v24 + v15) = 1;
          }
        }
        v10 &= ~v16;
      }
      while( v10 );
    }
    LOBYTE(v8) = 1;
    PopQueuePowerRequestCallbacks(v7, v8, 1i64);
    KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
    __writecr8(LockHandle.OldIrql);
    v11 = 0;
    v12 = &v24;
    do
    {
      if( *(_BYTE *)v12 )
        PopNotifyUserPowerRequestAction(v7, v11, 1);
      ++v11;
      v12 = (int *)((char *)v12 + 1);
    }
    while( v11 < 6 );
    v13 = 0;
    v14 = &v26;
    do
    {
      if( *(_BYTE *)v14 )
        PopNotifyUserPowerRequestAction(v7, v13, 0);
      ++v13;
      v14 = (int *)((char *)v14 + 1);
    }
    while( v13 < 6 );
    v3 = v21;
  }
  PopReleasePowerRequestPushLock();
  if( v4 )
  {
    PopProcessDisplayRequiredChange(v4, v3);
    ObfDereferenceObjectWithTag(v4, 0x72506F50ui64);
  }
}

Referenced by:

PopUmpoProcessPowerMessage