PopTriggerMonitorPowerEvent

__int64 __fastcall PopTriggerMonitorPowerEvent(char a1, int a2){
  NTSTATUS v3; 
  __int64 v4; 
  _DWORD *i; 
  unsigned int v6; 
  __int64 v7; 
  _DWORD *j; 
  __int64(__fastcall **v9)(__int64, INT64 *); 
  __int64 v10; 
  __int64(__fastcall *v11)(__int64, INT64 *); 
  __int64 v12; 
  NPTEXTMETRIC *v13; 
  INT64 v14; 
  INT64 v16; 

  LODWORD(v16) = 0;
  if( PopPlatformAoAc )
  {
    v4 = 0i64;
    for( i = &PopMonitorEventMapping; *i != a2; i += 2 )
    {
      v4 = (unsigned int)(v4 + 1);
      if( (unsigned int)v4 >= 0x33 )
        return(unsigned int)-1073741811;
    }
    v6 = *((_DWORD *)&PopMonitorEventMapping + 2 * v4 + 1);
    if( !v6 )
      return(unsigned int)-1073741811;
    v7 = 0i64;
    for( j = &PopPowerEventTable; *j != v6; j += 12 )
    {
      v7 = (unsigned int)(v7 + 1);
      if( (unsigned int)v7 >= 0x30 )
        return(unsigned int)-1073741823;
    }
    v9 = (__int64(__fastcall **)(__int64, INT64 *))((char *)&PopPowerEventTable + 48 * v7);
    if( !v9 )
      return(unsigned int)-1073741823;
    PopAcquireRwLockExclusive((_POP_RW_LOCK *)&PopIrpWorkerControlEvent + 65);
    LOBYTE(v10) = a1;
    v3 = v9[3](v10, &v16);
    v11 = *(__int64(__fastcall **)(__int64, INT64 *))&KUSER_SHARED_DATA.InterruptTime.LowPart;
    v12 = *(&PopIrpWorkerControlEvent + 256);
    v9[4] = (__int64(__fastcall *)(__int64, INT64 *))((char *)v9[4] + 1);
    v9[5] = v11;
    v13 = (NPTEXTMETRIC *)(3 * v12);
    *((_DWORD *)&PopIrpWorkerControlEvent + 2 * (_QWORD)v13 + 64) = v6;
    *(&PopIrpWorkerControlEvent + 256) = ((_BYTE)v12 + 1) & 0x1F;
    v14 = (unsigned int)v16;
    *((_DWORD *)&PopIrpWorkerControlEvent + 2 * (_QWORD)v13 + 66) = v16;
    *((_DWORD *)&PopIrpWorkerControlEvent + 2 * (_QWORD)v13 + 65) = v3;
    *((_QWORD *)&PopIrpWorkerControlEvent + (_QWORD)v13 + 34) = v11;
    if( v3 >= 0 )
    {
      PopDiagTracePowerStateEvent(v6, v14, v13);
      if( (_DWORD)v16 )
        v3 = PopPowerAggregatorHandleIntent((unsigned int)v16, *((unsigned int *)v9 + 4), *(unsigned int *)v9);
    }
    PopReleaseRwLock((_POP_RW_LOCK *)&PopIrpWorkerControlEvent + 65);
  }
  else
  {
    return(unsigned int)-1073741637;
  }
  return(unsigned int)v3;
}

Referenced by:

PoTtmInitiatePowerStateTransition
PopProcessSessionDisplayStateChange