PopPepUpdateConstraints

VOID __stdcall PopPepUpdateConstraints(
        _POP_PEP_DEVICE *Device,
        _POP_PEP_IDLE_CONSTRAINTS Constraint,
        UINT8 TransitionComplete){
  __int64 v4; 
  unsigned __int8 v6; 
  unsigned __int8 v7; 
  unsigned int v8; 
  _POP_PEP_DEVICE *v9; 
  unsigned int ready; 
  INT64 v11; 
  INT64 v12; 
  unsigned int i; 
  _POP_PEP_DEVICE *v14; 
  __int64 v15; 
  unsigned int WorkCountBefore; 

  v4 = Constraint;
  v6 = ExAcquireSpinLockExclusive((INT64 *)Device + 8);
  *((_BYTE *)Device + 125) = 1;
  v7 = v6;
  v8 = 0;
  for( WorkCountBefore = PopPepCountReadyActivities((unsigned int *)Device, 0i64, 3); v8 < Device[45]; ++v8 )
  {
    v9 = &Device[50 * v8 + 46];
    if( (v9[4] & 1) != 0 )
    {
      if( TransitionComplete )
      {
        v9[v4 + 38] = v9[47] - 1;
      }
      else
      {
        PopPepCancelActivityRange((__int64)(v9 + 14), 1, 1, 1, v9 + 26);
        v9[v4 + 38] = 0;
        KeResetEvent((_KEVENT *)(v9 + 8));
      }
      PopPepUpdateIdleState((__int64)Device, v9, TransitionComplete);
      v15 = *((_QWORD *)v9 + 8);
      if( !TransitionComplete )
      {
        if( *(_DWORD *)v15 )
          *(_BYTE *)(v15 + 16) = 1;
        else
          KeSetEvent((PRKEVENT)(v9 + 8), 0, 0);
      }
    }
  }
  PopPepPromoteActivities((__int64)Device, 0i64, 3);
  ready = PopPepCountReadyActivities((unsigned int *)Device, 0i64, 3);
  PopPepRequestWork(WorkCountBefore, ready, v11, v12);
  PopPepReleaseActivityLink((__int64)Device, 0i64, 1, v7);
  if( !TransitionComplete )
  {
    for( i = 0; i < Device[45]; ++i )
    {
      v14 = &Device[50 * i];
      if( (v14[50] & 1) != 0 )
        KeWaitForSingleObject((UINT64)(v14 + 54), 0, 0, 0, 0i64);
    }
  }
}

Referenced by:

PopPepDeviceDState
PopPepDeviceWaitWake
PopPluginDevicePower