CmpResolveHiveLoadConflict

__int64 __fastcall CmpResolveHiveLoadConflict(
        __int64 a1,
        __int64 a2,
        __int16 a3,
        __int64 a4,
        void *a5,
        __int64 a6,
        char a7,
        __int64 *a8,
        _DMA_OPERATIONS **a9){
  INT64 v12; 
  int v13; 
  PADAPTER_OBJECT v14; 
  unsigned int v15; 
  INT64 v16; 
  int v17; 
  int v18; 
  INT64 v19; 
  INT64 v20; 
  int v21; 
  __int64 v22; 
  INT64 v24; 
  INT64 v25; 
  PADAPTER_OBJECT DmaAdapter; 
  INT64 v27; 
  __int64 *v28; 
  __int64 v29; 
  _DMA_OPERATIONS **v30; 
  INT64 result[12]; 
  int v32; 
  _QWORD v33[9]; 
  INT64 v34[11]; 
  v28 = a8;
  v29 = a2;
  v30 = a9;
  v27 = 0i64;
  v12 = 0i64;
  DmaAdapter = 0i64;
  memset((INT64)result, 0i64);
  v32 = -1;
  v33[1] = v33;
  v33[0] = v33;
  memset((INT64)v34, 0i64);
  LOBYTE(v24) = 0;
  v13 = ObReferenceObjectByNameEx(a1, 0i64, 0x20019u, (__int64)CmKeyObjectType, v24, (__int64)result, &DmaAdapter);
  v14 = DmaAdapter;
  if( v13 < 0 )
  {
    v15 = -1073741275;
    goto LABEL_28;
  }
  LOCK_HIVE_LOAD();
  CmpLockRegistryFreezeAware(1u);
  if( !a4 )
    goto LABEL_9;
  if( !CmpIsKeyDeletedForKeyBody(a4, 0i64) )
  {
    v12 = *(_QWORD *)(*(_QWORD *)(a4 + 8) + 32i64);
    v17 = CmpPerformTrustClassAccessCheck(v12, a7);
    v18 = v17;
    if( v17 < 0 )
    {
      LODWORD(v25) = 32;
      v19 = (unsigned int)v17;
      goto LABEL_8;
    }
LABEL_9:
    if( CmpIsHiveAlreadyLoaded((__int64)v14, v29, a3, (__int64)&v27, v28) )
    {
      v20 = v27;
      v21 = *(_DWORD *)(v27 + 160);
      if( ((v21 & 0x8000) == 0 || (a3 & 0x2000) != 0) && ((v21 & 0x8000) != 0 || (a3 & 0x2000) == 0) )
      {
        CmpLockKcbExclusive((__int64)v14->DmaOperations);
        if( (a3 & 0x800) != 0 )
        {
          CmpReferenceKeyControlBlock((UINT64)v14->DmaOperations);
          *v30 = v14->DmaOperations;
        }
        if( !a5 || (v18 = CmpRecordUnloadEventForHive(v20, a5), v18 >= 0) )
        {
          CmpUnlockKcb((UINT64)v14->DmaOperations);
          if( v12 )
          {
            CmpUnJoinClassOfTrust(v20);
            LOBYTE(v22) = a7;
            *(_DWORD *)(v20 + 4152) |= 1u;
            CmpJoinClassOfTrust(v20, v12, v22);
          }
          v18 = 0;
          goto LABEL_21;
        }
        CmpUnlockKcb((UINT64)v14->DmaOperations);
        v19 = (unsigned int)v18;
        LODWORD(v25) = 80;
LABEL_8:
        SetFailureLocation(a6, 0i64, 33i64, v19, v25);
LABEL_21:
        if( v18 == -1073741275 )
          v18 = -1073741823;
        v15 = v18;
        goto LABEL_27;
      }
      LODWORD(v25) = 64;
    }
    else
    {
      LODWORD(v25) = 48;
    }
    v16 = 3221225539i64;
    v15 = -1073741757;
    goto LABEL_26;
  }
  v15 = -1073741444;
  LODWORD(v25) = 16;
  v16 = 3221225852i64;
LABEL_26:
  SetFailureLocation(a6, 0i64, 33i64, v16, v25);
LABEL_27:
  CmpUnlockRegistry();
  UNLOCK_HIVE_LOAD();
LABEL_28:
  if( v14 )
    HalPutDmaAdapter(v14);
  CmpCleanupParseContext((__int64)result, 0);
  return v15;
}

Referenced by:

CmLoadKey