CmpDoReOpenTransKey

INT64 __stdcall CmpDoReOpenTransKey(_CM_TRANS *CmTrans, _UNICODE_STRING *KeyName, UINT64 AccessMask, PVOID *KeyHandle){
  _UNICODE_STRING v4; 
  int v7; 
  NTSTATUS v9; 
  bool v10; 
  unsigned __int16 Length; 
  bool v12; 
  void *v13; 
  NTSTATUS v14; 
  _ADAPTER_OBJECT *v15; 
  char v16; 
  NTSTATUS v17; 
  UINT64 DesiredAccess; 
  UINT64 DesiredAccessa; 
  PVOID Object; 
  UINT64 v22; 
  _HANDLE Handle[2]; 
  _UNICODE_STRING v24; 
  VOID *v25; 
  __int128 v26; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  INT64 ParseContext[38]; 

  v4 = *KeyName;
  LODWORD(v22) = AccessMask;
  *(&ObjectAttributes.Length + 1) = 0;
  *(&ObjectAttributes.Attributes + 1) = 0;
  v25 = 0i64;
  v24 = v4;
  *(_QWORD *)Handle = 0i64;
  v7 = AccessMask;
  v26 = 0i64;
  v9 = -1073741762;
  v10 = ExIsResourceAcquiredSharedLite((UINT64)&CmpRegistryLock, (INT64)KeyName, AccessMask) != 0;
  if( !v4.Length )
    return(unsigned int)v9;
  while( 1 )
  {
    memset(ParseContext, 0i64, 0x128u);
    LODWORD(ParseContext[12]) = -1;
    ParseContext[19] = (INT64)&ParseContext[18];
    ParseContext[18] = (INT64)&ParseContext[18];
    memset(&ParseContext[27], 0i64, 0x50u);
    ObjectAttributes.ObjectName = &v24;
    LODWORD(ParseContext[3]) = 8;
    ObjectAttributes.Length = 48;
    LODWORD(DesiredAccess) = v7;
    ObjectAttributes.RootDirectory = 0i64;
    ObjectAttributes.Attributes = 4928;
    *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
    v9 = ObOpenObjectByName(
           &ObjectAttributes,
           (_OBJECT_TYPE *)CmKeyObjectType,
           0,
           0i64,
           DesiredAccess,
           ParseContext,
           (VOID **)Handle);
    CmpCleanupParseContext((INT64)ParseContext, v10);
    if( v9 >= 0 )
      break;
    Length = v24.Length;
    if( v24.Length )
    {
      do
      {
        if( v24.Buffer[((unsigned __int64)Length >> 1) - 1] == 92 )
          break;
        v12 = Length == 2;
        Length -= 2;
        v24.Length = Length;
      }
      while( !v12 );
    }
    LOWORD(v26) = KeyName->Length - Length;
    *((_QWORD *)&v26 + 1) = &v24.Buffer[(unsigned __int64)Length >> 1];
    v24.Length = Length - 2;
    if( Length == 2 )
    {
      v13 = *(void **)Handle;
      goto LABEL_29;
    }
  }
  v13 = *(void **)Handle;
  Object = 0i64;
  v14 = ObReferenceObjectByHandle(*(VOID **)Handle, 0i64, (_OBJECT_TYPE *)CmKeyObjectType, 0, &Object, 0i64);
  v15 = (_ADAPTER_OBJECT *)Object;
  v9 = v14;
  if( v14 >= 0 )
  {
    if( !v10 )
      CmpLockRegistry();
    v16 = !v10;
    if( CmTrans->CmRm != (_CM_RM *)*((_QWORD *)v15->AdapterObject.DmaHeader.DmaOperations->AllocateAdapterChannel + 524) )
      goto LABEL_12;
    if( v16 )
      CmpUnlockRegistry();
    *(_QWORD *)&v15->AdapterObject.ContiguousTranslationEnd.Offset = &CmTrans->KtmUow;
    HalPutDmaAdapter(v15);
    v15 = 0i64;
    v16 = 0;
    if( (_WORD)v26 )
    {
      memset(ParseContext, 0i64, 0x128u);
      LODWORD(ParseContext[12]) = -1;
      ParseContext[19] = (INT64)&ParseContext[18];
      ParseContext[18] = (INT64)&ParseContext[18];
      memset(&ParseContext[27], 0i64, 0x50u);
      ObjectAttributes.ObjectName = (_UNICODE_STRING *)&v26;
      LODWORD(ParseContext[3]) = 8;
      ObjectAttributes.Length = 48;
      LODWORD(DesiredAccessa) = v22;
      ObjectAttributes.RootDirectory = v13;
      ObjectAttributes.Attributes = 4928;
      *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
      v9 = ObOpenObjectByName(
             &ObjectAttributes,
             (_OBJECT_TYPE *)CmKeyObjectType,
             0,
             0i64,
             DesiredAccessa,
             ParseContext,
             &v25);
      CmpCleanupParseContext((INT64)ParseContext, v10);
      v16 = 0;
      if( v9 < 0
        || (Object = 0i64,
            v17 = ObReferenceObjectByHandle(v13, 0i64, (_OBJECT_TYPE *)CmKeyObjectType, 0, &Object, 0i64),
            v15 = (_ADAPTER_OBJECT *)Object,
            v9 = v17,
            v16 = 0,
            v17 < 0) )
      {
LABEL_25:
        if( v16 )
          CmpUnlockRegistry();
        goto LABEL_27;
      }
      if( !v10 )
      {
        CmpLockRegistry();
        v16 = 1;
      }
      if( CmTrans->CmRm != (_CM_RM *)*((_QWORD *)v15->AdapterObject.DmaHeader.DmaOperations->AllocateAdapterChannel
                                      + 524) )
      {
LABEL_12:
        v9 = -1073741762;
        goto LABEL_25;
      }
      if( v16 )
        CmpUnlockRegistry();
      *(_QWORD *)&v15->AdapterObject.ContiguousTranslationEnd.Offset = &CmTrans->KtmUow;
      HalPutDmaAdapter(v15);
      ZwClose((_HANDLE)v13);
      v13 = v25;
      v16 = 0;
    }
    *KeyHandle = v13;
    v9 = 0;
    v13 = 0i64;
    v15 = 0i64;
    goto LABEL_25;
  }
LABEL_27:
  if( v15 )
    HalPutDmaAdapter(v15);
LABEL_29:
  if( v13 )
    ZwClose((_HANDLE)v13);
  return(unsigned int)v9;
}

Referenced by:

CmpDoReDoCreateKey
CmpDoReDoDeleteValue
CmpDoReDoRecord
CmpDoReDoSetKeyUserFlags
CmpDoReDoSetLastWriteTime
CmpDoReDoSetSecurityDescriptor
CmpDoReDoSetValueExisting