RegRtlCreateTreeTransacted

NTSTATUS __stdcall RegRtlCreateTreeTransacted(
        VOID *Handle,
        WCHAR *pszSrc,
        UINT64 RegOptions,
        _ACCESS_MASK DesiredAccess,
        VOID *pSecurityDescriptor,
        UINT8 InheritHandle,
        VOID **phkResult,
        UINT64 *lpRegDisposition,
        VOID *hTransaction){
  unsigned int v10; 
  int KeyTransacted; 
  UINT64 v14; 
  VOID **PoolWithTag; 
  wchar_t *v16; 
  unsigned __int64 v17; 
  __int64 v18; 
  const WCHAR *v19; 
  WORD *v20; 
  INT64 v21; 
  UINT8 v22; 
  UINT64 *v23; 
  VOID *v24; 
  INT64 v25; 
  INT64 dwFlags; 
  INT64 dwFlagsa; 
  INT64 dwFlagsb; 
  VOID *v29; 
  _SIZE_T pcchLength[2]; 

  v10 = RegOptions;
  LOBYTE(dwFlags) = InheritHandle;
  *(_QWORD *)pcchLength = 0i64;
  v29 = 0i64;
  KeyTransacted = RegRtlCreateKeyTransacted(
                    Handle,
                    pszSrc,
                    RegOptions,
                    *(INT64 *)&DesiredAccess,
                    pSecurityDescriptor,
                    dwFlags,
                    phkResult,
                    lpRegDisposition,
                    hTransaction);
  if( KeyTransacted == -1073741772 )
  {
    KeyTransacted = RtlUnalignedStringCchLengthW(pszSrc, 0x7FFF, pcchLength);
    if( KeyTransacted >= 0 )
    {
      v14 = *(_QWORD *)pcchLength + 1i64;
      PoolWithTag = ExAllocatePoolWithTag(1ui64, 2 * (*(_QWORD *)pcchLength + 1i64), 1279739218i64);
      v16 = (wchar_t *)PoolWithTag;
      if( PoolWithTag )
      {
        LODWORD(dwFlagsa) = 256;
        KeyTransacted = RtlStringCchCopyExW((WCHAR *)PoolWithTag, v14, pszSrc, 0i64, 0i64, dwFlagsa);
        if( !KeyTransacted )
        {
          v17 = (unsigned __int64)v16;
          v18 = (__int64)Handle;
          if( !Handle && !wcsnicmp(v16, L"\\REGISTRY\\MACHINE\\", 0x12u) )
          {
            v18 = 2147483650i64;
            v17 = (unsigned __int64)(v16 + 18);
          }
          while( 1 )
          {
            v19 = (const WCHAR *)v17;
            v20 = wcschr((WORD *)v17, 92);
            v17 = (unsigned __int64)v20;
            if( v20 )
            {
              *v20 = 0;
              do
                v17 += 2i64;
              while( *(_WORD *)v17 == 92 );
              v17 &= -(__int64)(*(_WORD *)v17 != 0);
            }
            v21 = (unsigned int)DesiredAccess;
            v22 = InheritHandle;
            v23 = lpRegDisposition;
            if( v17 )
              v21 = 4i64;
            if( v17 )
              v22 = 0;
            v24 = pSecurityDescriptor;
            if( v17 )
              v23 = 0i64;
            v25 = v10;
            if( v17 )
              v24 = 0i64;
            LOBYTE(dwFlagsb) = v22;
            if( v17 )
              v25 = v10 & 0xFFFFFFFC;
            KeyTransacted = RegRtlCreateKeyTransacted(
                              (VOID *)v18,
                              v19,
                              v25,
                              v21,
                              v24,
                              dwFlagsb,
                              &v29,
                              v23,
                              hTransaction);
            if( (VOID *)v18 != Handle && v18 != 2147483650i64 )
              ZwClose(v18);
            if( KeyTransacted )
              break;
            if( !v17 )
            {
              *phkResult = v29;
              break;
            }
            v18 = (__int64)v29;
          }
        }
        ExFreePoolWithTag(v16, 0);
      }
      else
      {
        return -1073741801;
      }
    }
  }
  return KeyTransacted;
}

Referenced by:

SysCtxRegCreateTree