PpmQueryPlatformStateResidency

NTSTATUS __fastcall PpmQueryPlatformStateResidency(UINT64 StateIndex, UINT64 *TransitionCount){
  __int64 v2; 
  int v3; 
  unsigned int v4; 
  VOID **PoolWithTag; 
  _DWORD *v6; 
  _ETHREAD *CurrentThread; 
  _PPM_IDLE_STATES *IdleStates; 

  LODWORD(v2) = -1;
  v3 = StateIndex;
  if( PpmPlatformStates )
  {
    if( *(_QWORD *)(PpmPlatformStates + 40) )
    {
      v4 = *(_DWORD *)PpmPlatformStates;
      if( (_DWORD)StateIndex != -1 && (unsigned int)StateIndex < v4 )
      {
        PoolWithTag = ExAllocatePoolWithTag(0x200ui64, 16 * v4 + 8, 1766674512i64);
        v6 = PoolWithTag;
        if( PoolWithTag )
        {
          memset(PoolWithTag, 0i64, 16 * v4 + 8);
          *v6 = v4;
          CurrentThread = (_ETHREAD *)KeGetCurrentThread();
          --CurrentThread->Tcb.KernelApcDisable;
          ExAcquirePushLockSharedEx((_EX_PUSH_LOCK *)&stru_140C23628 + 123, 0i64);
          IdleStates = KeGetCurrentPrcb()->PowerState.IdleStates;
          if( IdleStates
            && (*(int(__fastcall **)(void *, _DWORD *))(PpmPlatformStates + 40))(IdleStates->PrepareInfo.Context, v6) >= 0 )
          {
            v2 = *(_QWORD *)&v6[4 * v3 + 2];
          }
          PopReleaseRwLock((_POP_RW_LOCK *)((char *)&stru_140C23628 + 984));
          ExFreePoolWithTag(v6, 0x694D5050u);
        }
      }
    }
  }
  return v2;
}

Referenced by:

PopCalculateIdleInformation
PopQueryBootSessionStandbyActivationInfo
PpmQueryDripsResidency