MmGetEnclaveModuleList

INT64 __fastcall MmGetEnclaveModuleList(UINT64 a1, _QWORD *a2, UINT64 *a3){
  unsigned int v3; 
  INT64 v6; 
  void *v7; 
  __int64 **v9; 
  int v10; 
  __int64 **v11; 
  __int64 v12; 
  __int64 v13; 
  __int64 *v14; 
  unsigned int v15; 
  __int64 v16; 
  __int64 v17; 
  INT64 v18; 
  v3 = 0;
  LODWORD(v18) = 0;
  v6 = MiObtainReferencedVadEx(a1, 2, &v18);
  v7 = (void *)v6;
  if( !v6 )
    return(unsigned int)v18;
  if( (*(_DWORD *)(v6 + 48) & 0x3100000) != 34603008 || (*(_DWORD *)(v6 + 64) & 1) != 0 )
  {
    v3 = -1073741800;
  }
  else
  {
    v9 = (__int64 **)(v6 + 80);
    v10 = 0;
    v11 = *(__int64 ***)(v6 + 80);
    while( v11 != v9 )
    {
      if( v10 == -1 )
        goto LABEL_10;
      v11 = (__int64 **)*v11;
      ++v10;
    }
    LODWORD(v12) = MiAllocatePool((struct _SLIST_ENTRY *)0x100);
    v13 = v12;
    if( !v12 )
    {
LABEL_10:
      v3 = -1073741670;
      goto LABEL_16;
    }
    v14 = *v9;
    v15 = 0;
    while( v14 != (__int64 *)v9 )
    {
      v16 = v15++;
      v17 = 3 * v16;
      *(_QWORD *)(v13 + 8 * v17) = v14[2];
      *(_QWORD *)(v13 + 8 * v17 + 8) = v14[3];
      *(_DWORD *)(v13 + 8 * v17 + 16) = *((_DWORD *)v14 + 9);
      *(_DWORD *)(v13 + 8 * v17 + 20) = *((_DWORD *)v14 + 10);
      v14 = (__int64 *)*v14;
    }
    *a2 = v13;
    *(_DWORD *)a3 = v15;
  }
LABEL_16:
  MiUnlockAndDereferenceVadShared(v7);
  return v3;
}

Referenced by:

PsGetProcessEnclaveModuleInfo