CmpDoReOpenTransKey

__int64 __fastcall CmpDoReOpenTransKey(__int64 a1, __int128 *a2, DWORD a3, _QWORD *a4){
  __int128 v4; 
  NTSTATUS v9; 
  bool v10; 
  unsigned __int16 v11; 
  bool v12; 
  HANDLE v13; 
  NTSTATUS v14; 
  struct _DMA_ADAPTER *v15; 
  char v16; 
  NTSTATUS v17; 
  PVOID Object; 
  DWORD v20; 
  HANDLE Handle; 
  __int128 v22; 
  void *v23; 
  __int128 v24; 
  int v25[2]; 
  HANDLE v26; 
  __int128 *v27; 
  int v28; 
  int v29; 
  __int128 v30; 
  INT64 result[3]; 
  int v32; 
  int v33; 
  _QWORD *v34; 
  _QWORD **v35; 
  INT64 v36[11]; 
  v4 = *a2;
  v20 = a3;
  v25[1] = 0;
  v29 = 0;
  v23 = 0i64;
  v22 = v4;
  Handle = 0i64;
  v24 = 0i64;
  v9 = -1073741762;
  v10 = ExIsResourceAcquiredSharedLite((PERESOURCE)&CmpRegistryLock) != 0;
  if( !(_WORD)v4 )
    return(unsigned int)v9;
  while( 1 )
  {
    memset((INT64)result, 0i64);
    v33 = -1;
    v35 = &v34;
    v34 = &v34;
    memset((INT64)v36, 0i64);
    v27 = &v22;
    v32 = 8;
    v25[0] = 48;
    v26 = 0i64;
    v28 = 4928;
    v30 = 0i64;
    v9 = ObOpenObjectByName((__int64)v25, (__int64)CmKeyObjectType, 0, 0i64, a3, (__int64)result, &Handle);
    CmpCleanupParseContext((__int64)result, v10);
    if( v9 >= 0 )
      break;
    v11 = v22;
    if( (_WORD)v22 )
    {
      do
      {
        if( *(_WORD *)(*((_QWORD *)&v22 + 1) + 2 * ((unsigned __int64)v11 >> 1) - 2) == 92 )
          break;
        v12 = v11 == 2;
        v11 -= 2;
        LOWORD(v22) = v11;
      }
      while( !v12 );
    }
    LOWORD(v24) = *(_WORD *)a2 - v11;
    *((_QWORD *)&v24 + 1) = *((_QWORD *)&v22 + 1) + 2 * ((unsigned __int64)v11 >> 1);
    LOWORD(v22) = v11 - 2;
    if( v11 == 2 )
    {
      v13 = Handle;
      goto LABEL_29;
    }
  }
  v13 = Handle;
  Object = 0i64;
  v14 = ObReferenceObjectByHandle(Handle, 0, (POBJECT_TYPE)CmKeyObjectType, 0, &Object, 0i64);
  v15 = (struct _DMA_ADAPTER *)Object;
  v9 = v14;
  if( v14 >= 0 )
  {
    if( !v10 )
      CmpLockRegistry();
    v16 = !v10;
    if( *(_QWORD *)(a1 + 64) != *((_QWORD *)v15->DmaOperations->AllocateAdapterChannel + 524) )
      goto LABEL_12;
    if( v16 )
      CmpUnlockRegistry();
    *(_QWORD *)&v15[4].Version = a1 + 88;
    HalPutDmaAdapter(v15);
    v15 = 0i64;
    v16 = 0;
    if( (_WORD)v24 )
    {
      memset((INT64)result, 0i64);
      v33 = -1;
      v35 = &v34;
      v34 = &v34;
      memset((INT64)v36, 0i64);
      v27 = &v24;
      v32 = 8;
      v25[0] = 48;
      v26 = v13;
      v28 = 4928;
      v30 = 0i64;
      v9 = ObOpenObjectByName((__int64)v25, (__int64)CmKeyObjectType, 0, 0i64, v20, (__int64)result, &v23);
      CmpCleanupParseContext((__int64)result, v10);
      v16 = 0;
      if( v9 < 0
        || (Object = 0i64,
            v17 = ObReferenceObjectByHandle(v13, 0, (POBJECT_TYPE)CmKeyObjectType, 0, &Object, 0i64),
            v15 = (struct _DMA_ADAPTER *)Object,
            v9 = v17,
            v16 = 0,
            v17 < 0) )
      {
LABEL_25:
        if( v16 )
          CmpUnlockRegistry();
        goto LABEL_27;
      }
      if( !v10 )
      {
        CmpLockRegistry();
        v16 = 1;
      }
      if( *(_QWORD *)(a1 + 64) != *((_QWORD *)v15->DmaOperations->AllocateAdapterChannel + 524) )
      {
LABEL_12:
        v9 = -1073741762;
        goto LABEL_25;
      }
      if( v16 )
        CmpUnlockRegistry();
      *(_QWORD *)&v15[4].Version = a1 + 88;
      HalPutDmaAdapter(v15);
      ZwClose(v13);
      v13 = v23;
      v16 = 0;
    }
    *a4 = v13;
    v9 = 0;
    v13 = 0i64;
    v15 = 0i64;
    goto LABEL_25;
  }
LABEL_27:
  if( v15 )
    HalPutDmaAdapter(v15);
LABEL_29:
  if( v13 )
    ZwClose(v13);
  return(unsigned int)v9;
}

Referenced by:

CmpDoReDoCreateKey
CmpDoReDoDeleteValue
CmpDoReDoRecord
CmpDoReDoRenameKey
CmpDoReDoSetKeyUserFlags
CmpDoReDoSetLastWriteTime
CmpDoReDoSetSecurityDescriptor
CmpDoReDoSetValueExisting