PfpProcessScenarioPhase

INT64 __fastcall PfpProcessScenarioPhase(INT64 a1, CHAR a2){
  int v3; 
  unsigned int v4; 
  unsigned int v5; 
  INT64 v6; 
  int v8; 
  int ActiveConsoleId; 
  INT64 v10; 
  INT64 v11; 
  int v12; 
  INT64 v13; 
  int v14; 
  unsigned int v15; 
  struct _DMA_ADAPTER *v16; 
  if( *(_DWORD *)a1 != 4 )
    return(unsigned int)-1073741811;
  v3 = *(_DWORD *)(a1 + 4);
  if( (unsigned int)(v3 - 1) > 4 )
    return(unsigned int)-1073741701;
  v4 = *(_DWORD *)(a1 + 16) & 1;
  if( v3 <= 2 )
    goto LABEL_4;
  if( v3 != 3 )
  {
    if( v3 == 4 )
    {
      v8 = *(_DWORD *)(a1 + 8);
      v5 = 0;
      if( v8 )
      {
        if( v8 == 1 )
        {
          ActiveConsoleId = RtlGetActiveConsoleId();
          if( (unsigned int)PsGetCurrentProcessSessionId() == ActiveConsoleId )
          {
            PfpScenCtxScenarioSet((INT64)&qword_140C50020, 4i64, 0i64, 0i64);
            if( dword_140C4FB18 < (unsigned int)dword_140C4FB1C )
              PfpLogScenarioEvent();
          }
        }
        return v5;
      }
      v10 = 0i64;
      v11 = 4i64;
      goto LABEL_32;
    }
    if( v3 == 5 )
    {
LABEL_4:
      v5 = 0;
      if( a2 )
      {
        return(unsigned int)-1073741790;
      }
      else
      {
        v6 = v4 | 4;
        if( v3 != 5 )
          v6 = v4;
        PfPowerActionNotify(*(unsigned int *)(a1 + 8), v6, (unsigned __int64)*(unsigned int *)(a1 + 16) >> 1);
      }
      return v5;
    }
    return(unsigned int)-1073741811;
  }
  v12 = *(_DWORD *)(a1 + 8);
  v5 = 0;
  if( v12 )
  {
    if( v12 != 1 || dword_140C50050 != 3 )
      return v5;
    PfpScenCtxPrefetchWait((ULONG_PTR)&qword_140C50020, 3, 0x1388u);
    PfpLogScenarioEvent();
    v10 = 0i64;
    v13 = 3i64;
    v11 = 0i64;
LABEL_33:
    PfpScenCtxScenarioSet((INT64)&qword_140C50020, v13, v11, v10);
    return v5;
  }
  v14 = RtlGetActiveConsoleId();
  if( (unsigned int)PsGetCurrentProcessSessionId() == v14 && dword_140C4FB18 < (unsigned int)dword_140C4FB1C )
  {
    v15 = 0;
    LODWORD(v16) = MmGetNextSession(0i64);
    if( v16 )
    {
      while( ++v15 < 3 )
      {
        LODWORD(v16) = MmGetNextSession(v16);
        if( !v16 )
          goto LABEL_30;
      }
      HalPutDmaAdapter(v16);
LABEL_30:
      if( v15 >= 3 )
      {
        v10 = *(_QWORD *)(a1 + 24);
        v11 = 3i64;
LABEL_32:
        v13 = 0i64;
        goto LABEL_33;
      }
    }
  }
  return v5;
}

Referenced by:

PfSetSuperfetchInformation
PfSnSetPrefetcherInformation