PopFxInitializeSocSubsystemStaticInfo

INT64 __stdcall PopFxInitializeSocSubsystemStaticInfo(UINT64 PlatformIdleStateIndex, UINT64 Flags){
  unsigned int v2; 
  INT64 v3; 
  int v4; 
  unsigned int v5; 
  unsigned int *v6; 
  unsigned int *PoolWithTag; 
  __int64 v8; 
  unsigned int v9; 
  __int64 v10; 
  __int128 v11; 
  char v12; 
  unsigned int v13; 
  unsigned int v14; 
  __int64 v15; 
  unsigned int v16; 
  WCHAR *v17; 
  __int64 v18; 
  int v19; 
  GUID *v20; 
  unsigned __int16 v21; 
  unsigned int **v22; 
  char v24; 
  __int128 v25; 
  __int128 v26; 
  __int128 v27; 
  __int64 v28; 
  _DWORD v29[4]; 
  wchar_t pszDest[64]; 
  v2 = PlatformIdleStateIndex;
  v28 = 0i64;
  v25 = 0i64;
  v26 = 0i64;
  v27 = 0i64;
  memset((INT64)pszDest, 0i64);
  if( PopFxProcessorPlugin
    && (v29[0] = v2, *(_QWORD *)&v29[1] = 0i64, (unsigned __int8)PopPluginQuerySocSubsystemCount(v3, (INT64)v29)) )
  {
    v5 = v29[1];
    v6 = (unsigned int *)PopFxLookupSocSubsystemsByPlatformIdleState(v2);
    if( v6 )
    {
      v4 = -1073741585;
LABEL_29:
      ExFreePoolWithTag(v6, 0x4D584650u);
      return(unsigned int)v4;
    }
    PoolWithTag = (unsigned int *)ExAllocatePoolWithTag(PagedPool, (int)(344 * v5) + 24i64, 0x4D584650ui64);
    v6 = PoolWithTag;
    if( PoolWithTag )
    {
      memset((INT64)PoolWithTag, 0i64);
      v6[4] = v2;
      v9 = 0;
      v6[5] = v5;
      if( v5 )
      {
        while( 1 )
        {
          v10 = 86i64 * v9;
          *(_QWORD *)&v6[v10 + 8] = &v6[v10 + 27];
          v6[v10 + 6] = 0x800000;
          LOWORD(v6[v10 + 10]) = 0;
          *(_QWORD *)&v6[v10 + 12] = &v6[v10 + 59];
          HIWORD(v6[v10 + 10]) = 128;
          v6[v10 + 14] = v9;
          LODWORD(v25) = v2;
          *((_QWORD *)&v25 + 1) = 0i64;
          DWORD1(v25) = v6[v10 + 14];
          v26 = *(_OWORD *)&v6[v10 + 6];
          v11 = *(_OWORD *)&v6[v10 + 10];
          v28 = 0i64;
          v27 = v11;
          PopPluginInitializeSocSubsystemStaticInfo(v8, (__int64)&v25);
          LOWORD(v6[v10 + 10]) = v27;
          LOWORD(v6[v10 + 6]) = v26;
          *(_QWORD *)&v6[v10 + 16] = *((_QWORD *)&v25 + 1);
          v6[v10 + 26] = v28;
          v4 = RtlHashUnicodeString((const _UNICODE_STRING *)&v6[v10 + 10], 0, 0i64, (UINT64 *)&v6[v10 + 15]);
          if( v4 < 0 )
            break;
          v5 = v6[5];
          if( ++v9 >= v5 )
            goto LABEL_11;
        }
      }
      else
      {
LABEL_11:
        v24 = 0;
        v12 = 0;
        v13 = 0;
        if( v5 )
        {
          while( 1 )
          {
            v14 = 0;
            v15 = 86i64 * v13;
            v16 = v6[v15 + 14];
            *(GUID *)&v6[v15 + 18] = GUID_SLEEPSTUDY_BLOCKER_TOP_LEVEL_SOC_SUBSYSTEM;
            LOWORD(v6[v15 + 19]) = v2;
            HIWORD(v6[v15 + 19]) = v16 + 1;
            v17 = *(WCHAR **)&v6[v15 + 8];
            if( v6[5] )
            {
              while( 1 )
              {
                v18 = 86i64 * v14;
                if( v14 != v13
                  && !(unsigned int)wcsncmp(*(const WCHAR **)&v6[v15 + 12], *(const WCHAR **)&v6[v18 + 12], 0x40ui64) )
                {
                  PopFxBugCheck(0x706ui64, 0x25ui64, 0x4E616D65ui64, v14);
                }
                if( !(unsigned int)wcsncmp(v17, *(const WCHAR **)&v6[v18 + 12], 0x40ui64) )
                  break;
                if( ++v14 >= v6[5] )
                {
                  v12 = v24;
                  goto LABEL_18;
                }
              }
              v19 = v6[v18 + 14] + 1;
              v20 = (GUID *)&v6[v15 + 22];
              v21 = v2;
            }
            else
            {
LABEL_18:
              if( v12 )
              {
                if( (unsigned int)wcsncmp(v17, pszDest, 0x40ui64) )
                  PopFxBugCheck(0x706ui64, 0x25ui64, 0x50617265ui64, v13);
              }
              else
              {
                RtlStringCchCopyW(pszDest, 0x40ui64, v17);
                v24 = 1;
              }
              LOWORD(v19) = 0;
              v20 = (GUID *)&v6[v15 + 22];
              v21 = 0;
            }
            ++v13;
            *v20 = GUID_SLEEPSTUDY_BLOCKER_TOP_LEVEL_SOC_SUBSYSTEM;
            v20->Data2 = v21;
            v20->Data3 = v19;
            if( v13 >= v6[5] )
              break;
            v12 = v24;
          }
        }
        v4 = 0;
      }
      if( v4 )
        goto LABEL_29;
      v22 = (unsigned int **)qword_140C246A8;
      if( *(__int64 **)qword_140C246A8 != &SocSubsystemsList )
        __fastfail(3u);
      *(_QWORD *)v6 = &SocSubsystemsList;
      *((_QWORD *)v6 + 1) = v22;
      *v22 = v6;
      qword_140C246A8 = (__int64)v6;
    }
    else
    {
      return(unsigned int)-1073741670;
    }
  }
  else
  {
    return(unsigned int)-1073741822;
  }
  return(unsigned int)v4;
}

Referenced by:

PopFxEnablePlatformStates