SepReadAndInsertCaps

__int64 __fastcall SepReadAndInsertCaps(HANDLE KeyHandle, int a2, __int64 a3){
  int v3; 
  unsigned int v4; 
  PRTL_DYNAMIC_HASH_TABLE_ENTRY v6; 
  _DWORD *PoolWithTag; 
  NTSTATUS v8; 
  _DWORD *v9; 
  unsigned int v10; 
  unsigned int v11; 
  NTSTATUS v12; 
  _DWORD *v13; 
  int v14; 
  NTSTATUS v15; 
  _DWORD *v16; 
  int SingleCap; 
  RTL_DYNAMIC_HASH_TABLE *v18; 
  __int64 v19; 
  UINT64 v20; 
  PULONG ResultLength; 
  PULONG ResultLengtha; 
  UINT64 Length; 
  HANDLE KeyHandlea; 
  PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry; 
  int v27; 
  __int64 v28; 
  PRTL_DYNAMIC_HASH_TABLE HashTable; 
  wchar_t pszDest[344]; 
  v3 = *(_DWORD *)(a3 + 48);
  v4 = a2 + 50;
  HashTable = (PRTL_DYNAMIC_HASH_TABLE)a3;
  v6 = 0i64;
  v28 = *(_QWORD *)(a3 + 56);
  Entry = 0i64;
  KeyHandlea = 0i64;
  LODWORD(Length) = 0;
  v27 = v3;
  PoolWithTag = ExAllocatePoolWithTag(PagedPool, (unsigned int)(a2 + 50), 0x70536553ui64);
  if( !PoolWithTag )
    goto LABEL_2;
  v8 = ZwQueryKey(KeyHandle, KeyFullInformation, PoolWithTag, v4, &Length);
  if( v8 >= 0 )
    goto LABEL_8;
  if( v8 != -2147483643 && v8 != -1073741789 )
  {
LABEL_28:
    if( v8 >= 0 )
      goto LABEL_33;
LABEL_29:
    if( v6 )
      ExFreePoolWithTag(v6, 0x70536553u);
    goto LABEL_31;
  }
  LODWORD(v9) = SepRmCapPoolExpand(PoolWithTag, (unsigned int)Length);
  PoolWithTag = v9;
  if( !v9 )
  {
LABEL_2:
    v8 = -1073741670;
    goto LABEL_31;
  }
  v4 = Length;
  v8 = ZwQueryKey(KeyHandle, KeyFullInformation, v9, (unsigned int)Length, &Length);
  if( v8 >= 0 )
  {
LABEL_8:
    v10 = PoolWithTag[5];
    v11 = 0;
    if( v10 )
    {
      while( 1 )
      {
        LODWORD(ResultLength) = v4;
        v12 = ZwEnumerateKey(KeyHandle, v11, KeyBasicInformation, PoolWithTag, (UINT64)ResultLength, &Length);
        v8 = v12;
        if( v12 < 0 )
        {
          if( v12 != -2147483643 && v12 != -1073741789 )
            goto LABEL_28;
          LODWORD(v13) = SepRmCapPoolExpand(PoolWithTag, (unsigned int)Length);
          PoolWithTag = v13;
          if( !v13 )
            goto LABEL_2;
          v4 = Length;
          LODWORD(ResultLengtha) = Length;
          v8 = ZwEnumerateKey(KeyHandle, v11, KeyBasicInformation, v13, (UINT64)ResultLengtha, &Length);
          if( v8 < 0 )
            goto LABEL_31;
        }
        *((_WORD *)PoolWithTag + ((unsigned __int64)(unsigned int)PoolWithTag[3] >> 1) + 8) = 0;
        RtlStringCchPrintfW(pszDest, 0x156ui64, (WCHAR *)L"%s\\%s");
        v8 = v14;
        if( v14 < 0 )
          goto LABEL_31;
        v8 = SepRegOpenKey(pszDest, 0x201ui64, &KeyHandlea);
        if( v8 < 0 )
          goto LABEL_31;
        v15 = ZwQueryKey(KeyHandlea, KeyFullInformation, PoolWithTag, v4, &Length);
        v8 = v15;
        if( v15 < 0 )
        {
          if( v15 != -2147483643 && v15 != -1073741789 )
            goto LABEL_28;
          LODWORD(v16) = SepRmCapPoolExpand(PoolWithTag, (unsigned int)Length);
          PoolWithTag = v16;
          if( !v16 )
            goto LABEL_2;
          v4 = Length;
          v8 = ZwQueryKey(KeyHandlea, KeyFullInformation, v16, (unsigned int)Length, &Length);
          if( v8 < 0 )
            goto LABEL_31;
        }
        SingleCap = SepReadSingleCap(KeyHandlea, PoolWithTag[10], v27, v28, (__int64)&Entry);
        v6 = Entry;
        v8 = SingleCap;
        if( SingleCap < 0 )
          goto LABEL_29;
        v18 = HashTable;
        Entry[1].Linkage.Blink = (_LIST_ENTRY *)HashTable;
        v19 = *((unsigned int *)&v6[1].Linkage.Flink->Flink + (unsigned int)BYTE1(v6[1].Linkage.Flink->Flink) + 1);
        v20 = v19 + 1;
        if( (_DWORD)v19 )
          v20 = *((unsigned int *)&v6[1].Linkage.Flink->Flink + (unsigned int)BYTE1(v6[1].Linkage.Flink->Flink) + 1);
        if( !RtlInsertEntryHashTable(v18, v6, v20, 0i64) )
        {
          v8 = -1073741670;
          goto LABEL_28;
        }
        v6 = 0i64;
        Entry = 0i64;
        ZwClose(KeyHandlea);
        ++v11;
        KeyHandlea = 0i64;
        if( v11 >= v10 )
          goto LABEL_28;
      }
    }
    goto LABEL_28;
  }
LABEL_31:
  if( KeyHandlea )
    ZwClose(KeyHandlea);
LABEL_33:
  if( PoolWithTag )
    ExFreePoolWithTag(PoolWithTag, 0x70536553u);
  return(unsigned int)v8;
}

Referenced by:

No references.