CmpPerformCompleteKcbCacheLookup

INT64 __fastcall CmpPerformCompleteKcbCacheLookup(
        UINT64 a1,
        UINT64 a2,
        INT64 a3,
        INT64 a4,
        INT64 arg20,
        INT64 *a6,
        CHAR *arg30,
        _WORD *arg38){
  unsigned int v8; 
  __int16 v10; 
  unsigned int v11; 
  unsigned int v12; 
  UINT64 v14; 
  __int64 v15; 
  CHAR v16; 
  INT64 v18; 
  INT64 v19; 
  _UNICODE_STRING *ComponentNameAtIndex; 
  UINT64 v21; 
  UINT8 v22; 
  char v23; 
  __int64 BugCheckParameter4[9]; 
  INT64 a8; 
  INT64 a7; 
  unsigned int v27; 
  v27 = a3;
  v8 = 0;
  LOWORD(a8) = 0;
  v10 = 0;
  BugCheckParameter4[0] = 0i64;
  v11 = a3;
  LOBYTE(a7) = 0;
  v12 = a2;
  v14 = a1;
  while( 1 )
  {
    CmpPerformSingleKcbCacheLookup(
      (volatile INT64 *)v14,
      *(PVOID *)(v14 + 32),
      v12,
      v11,
      a4,
      (INT64)BugCheckParameter4,
      (INT64)&a7,
      (INT64)&a8);
    if( v14 != a1 )
      CmpDereferenceKeyControlBlockUnsafe((volatile INT64 *)v14);
    v15 = BugCheckParameter4[0];
    v12 += (__int16)a8;
    v16 = a7;
    v10 += a8;
    if( (*(_DWORD *)(BugCheckParameter4[0] + 184) & 0x20000) == 0 )
      goto LABEL_5;
    CmpLockKcbShared((_CM_KEY_CONTROL_BLOCK *)BugCheckParameter4[0]);
    if( (*(_DWORD *)(v15 + 184) & 0x20000) == 0 )
      goto LABEL_15;
    v14 = *(_QWORD *)(v15 + 104);
    CmpReferenceKeyControlBlockUnsafe((volatile INT64 *)v14);
    if( CmpIsHiveLoadingOnOtherThread(*(_QWORD *)(v14 + 32)) )
      break;
    if( (*(_DWORD *)(v14 + 8) & 0x40000) != 0 )
    {
      v18 = 394496i64;
      v8 = -1073740763;
      goto LABEL_24;
    }
    CmpUnlockKcb(v15);
    if( v16 )
      CmpUnlockHashEntryByKcb(v15);
    CmpDereferenceKeyControlBlock(v15);
    BugCheckParameter4[0] = 0i64;
    if( v16 )
    {
      v15 = v14;
      CmpLockHashEntrySharedByKcb((_CM_KEY_CONTROL_BLOCK *)v14);
      CmpLockKcbShared((_CM_KEY_CONTROL_BLOCK *)v14);
LABEL_15:
      CmpUnlockKcb(v15);
LABEL_5:
      *a6 = v15;
      *arg30 = v16;
      *arg38 = v10;
      return v8;
    }
    v11 = v27;
  }
  v8 = -1073741772;
  if( !CmpLoadingSystemHivesActive )
    goto LABEL_23;
  if( (struct _KTHREAD *)CmpMountThread == KeGetCurrentThread()
    || (v19 = arg20) == 0
    || (ComponentNameAtIndex = (_UNICODE_STRING *)CmpGetComponentNameAtIndex(a4, v12 - 1),
        !CmpWaitForHiveMount(ComponentNameAtIndex, v21, v22, (UINT64 *)(v19 + 136))) )
  {
    v15 = BugCheckParameter4[0];
LABEL_23:
    v18 = 394240i64;
    goto LABEL_24;
  }
  *(_DWORD *)v19 |= 0x100u;
  v18 = 393984i64;
  v15 = BugCheckParameter4[0];
  v8 = 259;
LABEL_24:
  CmpRecordParseFailure(arg20, v18, v8);
  CmpDereferenceKeyControlBlockUnsafe((volatile INT64 *)v14);
  v23 = a7;
  CmpUnlockKcb(v15);
  if( v23 )
    CmpUnlockHashEntryByKcb(v15);
  if( v15 )
    CmpDereferenceKeyControlBlock(v15);
  return v8;
}

Referenced by:

CmpDoParseKey
CmpGetSymbolicLinkTarget