Example #1
0
 static private void ValidateKeyOptions(RegistryOptions options)
 {
     if (options < RegistryOptions.None || options > RegistryOptions.Volatile)
     {
         ThrowHelper.ThrowArgumentException(SR.Argument_InvalidRegistryOptionsCheck, nameof(options));
     }
 }
 public RegistryCacheInitializer(IConfiguration configuration, IHostEnvironment hostEnvironment, ILoggerFactory loggerFactory, IOptions <RegistryOptions> registryOptionsAccessor, RegistryCacheSingleton registryCacheSingleton)
 {
     this.configuration          = configuration;
     this.hostEnvironment        = hostEnvironment;
     this.loggerFactory          = loggerFactory;
     registryOptions             = registryOptionsAccessor.Value;
     this.registryCacheSingleton = registryCacheSingleton;
 }
Example #3
0
        //============================================================
        // <T>创建一个新子项或打开一个现有子项以进行写访问。</T>
        //
        // @param path 要创建或打开的子项的名称或路径,
        // @param check 类型检查,
        // @param option 项的选项
        //============================================================
        public FRegister CreateSubKey(string path, RegistryKeyPermissionCheck check, RegistryOptions options)
        {
            FRegister   register = new FRegister();
            RegistryKey key      = _rootNode.CreateSubKey(path, check, options);

            register.Key = key;
            return(register);
        }
Example #4
0
 private static extern int RegCreateKeyEx(
     SafeRegistryHandle hKey,
     string lpSubKey,
     int Reserved,
     string lpClass,
     RegistryOptions dwOptions,
     RegistryRights samDesired,
     IntPtr lpSecurityAttributes,
     out SafeRegistryHandle phkResult,
     out int lpdwDisposition);
        public void RegistryOptionsTestsValid(bool alreadyExists, RegistryOptions options)
        {
            string subkey = "TEST_" + options.ToString();

            if (alreadyExists)
            {
                TestRegistryKey.CreateSubKey(subkey, true, options);
            }

            Assert.NotNull(TestRegistryKey.CreateSubKey(subkey, true, options));
        }
Example #6
0
        public void RegistryOptionsTestsValid(bool alreadyExists, RegistryOptions options)
        {
            string subkey = "TEST_" + options.ToString();

            if (alreadyExists)
            {
                TestRegistryKey.CreateSubKey(subkey, true, options).Dispose();
            }

            using RegistryKey created = TestRegistryKey.CreateSubKey(subkey, true, options);
            Assert.NotNull(created);
        }
Example #7
0
        public RegistryKey CreateSubKey(RegistryKey rkey, string keyName, RegistryOptions options)
        {
            IntPtr handle = GetHandle(rkey);
            IntPtr subKeyHandle;
            int    disposition;
            int    result = RegCreateKeyEx(handle, keyName, 0, IntPtr.Zero,
                                           options == RegistryOptions.Volatile ? RegOptionsVolatile : RegOptionsNonVolatile,
                                           OpenRegKeyRead | OpenRegKeyWrite, IntPtr.Zero, out subKeyHandle, out disposition);

            if (result != Win32ResultCode.Success)
            {
                GenerateException(result);
            }

            return(new RegistryKey(subKeyHandle, CombineName(rkey, keyName),
                                   true));
        }
Example #8
0
        private RegistryKey CreateSubKeyInternal(string subkey, bool writable, RegistryOptions registryOptions)
        {
            ValidateKeyOptions(registryOptions);
            ValidateKeyName(subkey);
            EnsureWriteable();
            subkey = FixupName(subkey); // Fixup multiple slashes to a single slash

            // only keys opened under read mode is not writable
            if (!_remoteKey)
            {
                RegistryKey key = InternalOpenSubKey(subkey, writable);
                if (key != null)
                {
                    // Key already exits
                    return(key);
                }
            }

            return(CreateSubKeyInternalCore(subkey, writable, registryOptions));
        }
Example #9
0
        public void RegistryOptionsTestsInvalid()
        {
            //Options is -1
            Action a = () =>
            {
                RegistryOptions options = (RegistryOptions)(-1);
                RegistryKey     rk2     = _rk.CreateSubKey(_testKeyName, true, options);
            };

            Assert.Throws <ArgumentException>(() => { a(); });

            //Options is 3
            Action a1 = () =>
            {
                RegistryOptions options = (RegistryOptions)(3);
                RegistryKey     rk2     = _rk.CreateSubKey(_testKeyName, true, options);
            };

            Assert.Throws <ArgumentException>(() => { a1(); });
        }
Example #10
0
        private unsafe RegistryKey CreateSubKeyInternalCore(string subkey, bool writable, RegistryOptions registryOptions)
        {
            Interop.mincore.SECURITY_ATTRIBUTES secAttrs = default(Interop.mincore.SECURITY_ATTRIBUTES);
            int disposition = 0;

            // By default, the new key will be writable.
            SafeRegistryHandle result = null;
            int ret = Interop.mincore.RegCreateKeyEx(_hkey,
                subkey,
                0,
                null,
                (int)registryOptions /* specifies if the key is volatile */,
                (int)GetRegistryKeyRights(writable) | (int)_regView,
                ref secAttrs,
                out result,
                out disposition);

            if (ret == 0 && !result.IsInvalid)
            {
                RegistryKey key = new RegistryKey(result, writable, false, _remoteKey, false, _regView);
                if (subkey.Length == 0)
                {
                    key._keyName = _keyName;
                }
                else
                {
                    key._keyName = _keyName + "\\" + subkey;
                }
                return key;
            }
            else if (ret != 0) // syscall failed, ret is an error code.
            {
                Win32Error(ret, _keyName + "\\" + subkey);  // Access denied?
            }

            Debug.Fail("Unexpected code path in RegistryKey::CreateSubKey");
            return null;
        }
Example #11
0
 public virtual IServiceRegistry CreateRegistry(RegistryOptions options)
 {
     return new GenericRegistry(options.RegistryDataStore, options.RegistryNotify, options.Watcher);
 }
Example #12
0
		public RegistryKey CreateSubKey (string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions,
			RegistrySecurity registrySecurity)
		{
			return CreateSubKey (subkey, permissionCheck, registryOptions);
		}
Example #13
0
		public RegistryKey CreateSubKey (RegistryKey rkey, string keyname, RegistryOptions options)
		{
			return CreateSubKey (rkey, keyname, true, options == RegistryOptions.Volatile);
		}
Example #14
0
        private unsafe RegistryKey CreateSubKeyInternal(String subkey, RegistryKeyPermissionCheck permissionCheck, object registrySecurityObj, RegistryOptions registryOptions)
        {
            ValidateKeyOptions(registryOptions);
            ValidateKeyName(subkey);
            ValidateKeyMode(permissionCheck);            
            EnsureWriteable();
            subkey = FixupName(subkey); // Fixup multiple slashes to a single slash
            
            // only keys opened under read mode is not writable
            if (!remoteKey) {
                RegistryKey key = InternalOpenSubKey(subkey, (permissionCheck != RegistryKeyPermissionCheck.ReadSubTree));
                if (key != null)  { // Key already exits
                    CheckPermission(RegistryInternalCheck.CheckSubKeyWritePermission, subkey, false, RegistryKeyPermissionCheck.Default);
                    CheckPermission(RegistryInternalCheck.CheckSubTreePermission, subkey, false, permissionCheck);
                    key.checkMode = permissionCheck;
                    return key;
                }
            }

            CheckPermission(RegistryInternalCheck.CheckSubKeyCreatePermission, subkey, false, RegistryKeyPermissionCheck.Default);      
            
            Win32Native.SECURITY_ATTRIBUTES secAttrs = null;
#if FEATURE_MACL
            RegistrySecurity registrySecurity = (RegistrySecurity)registrySecurityObj;
            // For ACL's, get the security descriptor from the RegistrySecurity.
            if (registrySecurity != null) {
                secAttrs = new Win32Native.SECURITY_ATTRIBUTES();
                secAttrs.nLength = (int)Marshal.SizeOf(secAttrs);

                byte[] sd = registrySecurity.GetSecurityDescriptorBinaryForm();
                // We allocate memory on the stack to improve the speed.
                // So this part of code can't be refactored into a method.
                byte* pSecDescriptor = stackalloc byte[sd.Length];
                Buffer.Memcpy(pSecDescriptor, 0, sd, 0, sd.Length);
                secAttrs.pSecurityDescriptor = pSecDescriptor;
            }
#endif
            int disposition = 0;

            // By default, the new key will be writable.
            SafeRegistryHandle result = null;
            int ret = Win32Native.RegCreateKeyEx(hkey,
                subkey,
                0,
                null,
                (int)registryOptions /* specifies if the key is volatile */,
                GetRegistryKeyAccess(permissionCheck != RegistryKeyPermissionCheck.ReadSubTree) | (int)regView,
                secAttrs,
                out result,
                out disposition);

            if (ret == 0 && !result.IsInvalid) {
                RegistryKey key = new RegistryKey(result, (permissionCheck != RegistryKeyPermissionCheck.ReadSubTree), false, remoteKey, false, regView);                
                CheckPermission(RegistryInternalCheck.CheckSubTreePermission, subkey, false, permissionCheck);                
                key.checkMode = permissionCheck;
                
                if (subkey.Length == 0)
                    key.keyName = keyName;
                else
                    key.keyName = keyName + "\\" + subkey;
                return key;
            }
            else if (ret != 0) // syscall failed, ret is an error code.
                Win32Error(ret, keyName + "\\" + subkey);  // Access denied?

            BCLDebug.Assert(false, "Unexpected code path in RegistryKey::CreateSubKey");
            return null;
        }
Example #15
0
 public RegistryKey CreateSubKey(String subkey, bool writable, RegistryOptions options)
 {
     return CreateSubKeyInternal(subkey, writable ? RegistryKeyPermissionCheck.ReadWriteSubTree : RegistryKeyPermissionCheck.ReadSubTree, null, options);
 }
Example #16
0
 static private void ValidateKeyOptions(RegistryOptions options) {
     if (options < RegistryOptions.None || options > RegistryOptions.Volatile) {
         ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidRegistryOptionsCheck, ExceptionArgument.options);
     }
 }
Example #17
0
        private RegistryKey CreateSubKeyInternal(string subkey, bool writable, RegistryOptions registryOptions)
        {
            ValidateKeyOptions(registryOptions);
            ValidateKeyName(subkey);
            EnsureWriteable();
            subkey = FixupName(subkey); // Fixup multiple slashes to a single slash

            // only keys opened under read mode is not writable
            if (!_remoteKey)
            {
                RegistryKey key = InternalOpenSubKey(subkey, writable);
                if (key != null)
                { 
                    // Key already exits
                    return key;
                }
            }

            return CreateSubKeyInternalCore(subkey, writable, registryOptions);
        }
Example #18
0
 public virtual IServiceRegistry CreateRegistry(RegistryOptions options)
 {
     return(new GenericRegistry(options.RegistryDataStore, options.RegistryNotify, options.Watcher));
 }
Example #19
0
 public IServiceRegistry GetRegistry(RegistryOptions options)
 {
     return(CreateRegistry(options));
 }
Example #20
0
        public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions options)
        {
            AssertKeyStillValid();
            AssertKeyNameNotNull(subkey);
            AssertKeyNameLength(subkey);

            if (!IsWritable)
            {
                throw new UnauthorizedAccessException("Cannot write to the registry key.");
            }

            return(RegistryApi.CreateSubKey(this, subkey, options));
        }
Example #21
0
 public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions, RegistrySecurity registrySecurity)
 {
     throw new NotImplementedException();
 }
 private static RegistryKey CreateSubKeyInternalCore(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions)
 {
     throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
 }
 public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions, System.Security.AccessControl.RegistrySecurity registrySecurity)
 {
     return(default(RegistryKey));
 }
 public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions options)
 {
     return(default(RegistryKey));
 }
 public RegistryKey CreateSubKey(string subkey, bool writable, RegistryOptions options);
Example #26
0
 public IServiceRegistry GetRegistry(RegistryOptions options)
 {
     return CreateRegistry(options);
 }
Example #27
0
 public RegistryKey CreateSubKey(string subkey, bool writable, RegistryOptions options)
 {
     return(CreateSubKey(subkey, writable ? RegistryKeyPermissionCheck.ReadWriteSubTree : RegistryKeyPermissionCheck.ReadSubTree, options));
 }
Example #28
0
        private unsafe RegistryKey CreateSubKeyInternal(String subkey, RegistryKeyPermissionCheck permissionCheck, object registrySecurityObj, RegistryOptions registryOptions)
        {
            ValidateKeyOptions(registryOptions);
            ValidateKeyName(subkey);
            ValidateKeyMode(permissionCheck);            
            EnsureWriteable();
            subkey = FixupName(subkey); // Fixup multiple slashes to a single slash
            
            // only keys opened under read mode is not writable
            if (!remoteKey) {
                RegistryKey key = InternalOpenSubKey(subkey, (permissionCheck != RegistryKeyPermissionCheck.ReadSubTree));
                if (key != null)  { // Key already exits
                    CheckPermission(RegistryInternalCheck.CheckSubKeyWritePermission, subkey, false, RegistryKeyPermissionCheck.Default);
                    CheckPermission(RegistryInternalCheck.CheckSubTreePermission, subkey, false, permissionCheck);
                    key.checkMode = permissionCheck;
                    return key;
                }
            }

            CheckPermission(RegistryInternalCheck.CheckSubKeyCreatePermission, subkey, false, RegistryKeyPermissionCheck.Default);      

            Win32Native.SECURITY_ATTRIBUTES secAttrs = null;

            int disposition = 0;

            // By default, the new key will be writable.
            SafeRegistryHandle result = null;
            int ret = Win32Native.RegCreateKeyEx(hkey,
                subkey,
                0,
                null,
                (int)registryOptions /* specifies if the key is volatile */,
                GetRegistryKeyAccess(permissionCheck != RegistryKeyPermissionCheck.ReadSubTree) | (int)regView,
                secAttrs,
                out result,
                out disposition);

            if (ret == 0 && !result.IsInvalid) {
                RegistryKey key = new RegistryKey(result, (permissionCheck != RegistryKeyPermissionCheck.ReadSubTree), false, remoteKey, false, regView);                
                CheckPermission(RegistryInternalCheck.CheckSubTreePermission, subkey, false, permissionCheck);                
                key.checkMode = permissionCheck;
                
                if (subkey.Length == 0)
                    key.keyName = keyName;
                else
                    key.keyName = keyName + "\\" + subkey;
                return key;
            }
            else if (ret != 0) // syscall failed, ret is an error code.
                Win32Error(ret, keyName + "\\" + subkey);  // Access denied?

            BCLDebug.Assert(false, "Unexpected code path in RegistryKey::CreateSubKey");
            return null;
        }
Example #29
0
 public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions, RegistrySecurity registrySecurity)
 {
     return(CreateSubKey(subkey, permissionCheck, registryOptions));
 }
Example #30
0
 public RegistryKey CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions options) 
 {
     return CreateSubKeyInternal(subkey, permissionCheck, null, options);
 }
Example #31
0
 public RegistryCacheUpdater(RegistryCacheSingleton currentRegistryCache, ILogger <RegistryCacheUpdater> logger, IOptions <RegistryOptions> registryOptionsAccessor)
 {
     _currentRegistryCache = currentRegistryCache;
     _logger          = logger;
     _registryOptions = registryOptionsAccessor.Value;
 }
Example #32
0
 public unsafe RegistryKey CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck,  RegistryOptions registryOptions, RegistrySecurity registrySecurity) 
 {
     return CreateSubKeyInternal(subkey, permissionCheck, registrySecurity, registryOptions);
 }        
        public void RegistryOptionsTestsValid(bool alreadyExists, RegistryOptions options)
        {
            string subkey = "TEST_" + options.ToString();

            if (alreadyExists)
            {
                TestRegistryKey.CreateSubKey(subkey);
            }

            Assert.NotNull(TestRegistryKey.CreateSubKey(subkey));
        }
Example #34
0
 private static void ValidateKeyOptions(RegistryOptions options)
 {
 }
 public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions, System.Security.AccessControl.RegistrySecurity registrySecurity)
 {
   return default(RegistryKey);
 }
Example #36
0
		public RegistryKey CreateSubKey (string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions options)
		{
			AssertKeyStillValid ();
			AssertKeyNameNotNull (subkey);
			AssertKeyNameLength (subkey);

			if (!IsWritable)
				throw new UnauthorizedAccessException ("Cannot write to the registry key.");

			return RegistryApi.CreateSubKey (this, subkey, options);
		}
 private unsafe RegistryKey CreateSubKeyInternal(string subkey, RegistryKeyPermissionCheck permissionCheck, object registrySecurityObj, RegistryOptions registryOptions)
 {
     ValidateKeyOptions(registryOptions);
     ValidateKeyName(subkey);
     ValidateKeyMode(permissionCheck);
     this.EnsureWriteable();
     subkey = FixupName(subkey);
     if (!this.remoteKey)
     {
         RegistryKey key = this.InternalOpenSubKey(subkey, permissionCheck != RegistryKeyPermissionCheck.ReadSubTree);
         if (key != null)
         {
             this.CheckPermission(RegistryInternalCheck.CheckSubKeyWritePermission, subkey, false, RegistryKeyPermissionCheck.Default);
             this.CheckPermission(RegistryInternalCheck.CheckSubTreePermission, subkey, false, permissionCheck);
             key.checkMode = permissionCheck;
             return key;
         }
     }
     this.CheckPermission(RegistryInternalCheck.CheckSubKeyCreatePermission, subkey, false, RegistryKeyPermissionCheck.Default);
     Win32Native.SECURITY_ATTRIBUTES structure = null;
     RegistrySecurity security = (RegistrySecurity) registrySecurityObj;
     if (security != null)
     {
         structure = new Win32Native.SECURITY_ATTRIBUTES {
             nLength = Marshal.SizeOf(structure)
         };
         byte[] securityDescriptorBinaryForm = security.GetSecurityDescriptorBinaryForm();
         byte* pDest = stackalloc byte[(IntPtr) securityDescriptorBinaryForm.Length];
         Buffer.memcpy(securityDescriptorBinaryForm, 0, pDest, 0, securityDescriptorBinaryForm.Length);
         structure.pSecurityDescriptor = pDest;
     }
     int lpdwDisposition = 0;
     SafeRegistryHandle hkResult = null;
     int errorCode = Win32Native.RegCreateKeyEx(this.hkey, subkey, 0, null, (int) registryOptions, GetRegistryKeyAccess(permissionCheck != RegistryKeyPermissionCheck.ReadSubTree, this.regView), structure, out hkResult, out lpdwDisposition);
     if ((errorCode == 0) && !hkResult.IsInvalid)
     {
         RegistryKey key2 = new RegistryKey(hkResult, permissionCheck != RegistryKeyPermissionCheck.ReadSubTree, false, this.remoteKey, false, this.regView);
         this.CheckPermission(RegistryInternalCheck.CheckSubTreePermission, subkey, false, permissionCheck);
         key2.checkMode = permissionCheck;
         if (subkey.Length == 0)
         {
             key2.keyName = this.keyName;
             return key2;
         }
         key2.keyName = this.keyName + @"\" + subkey;
         return key2;
     }
     if (errorCode != 0)
     {
         this.Win32Error(errorCode, this.keyName + @"\" + subkey);
     }
     return null;
 }
Example #38
0
        public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions)
        {
            ValidateKeyOptions(registryOptions);
            ValidateKeyName(subkey);
            ValidateKeyMode(permissionCheck);
            EnsureWriteable();
            subkey = FixupName(subkey); // Fixup multiple slashes to a single slash

            // only keys opened under read mode is not writable
            if (!_remoteKey)
            {
                RegistryKey key = InternalOpenSubKeyWithoutSecurityChecks(subkey, (permissionCheck != RegistryKeyPermissionCheck.ReadSubTree));
                if (key != null)
                {
                    // Key already exits
                    key._checkMode = permissionCheck;
                    return(key);
                }
            }

            return(CreateSubKeyInternalCore(subkey, permissionCheck, registryOptions));
        }
Example #39
0
 /// <summary>
 /// TODO: Add Comment
 /// </summary>
 /// <param name="subkey"></param>
 /// <param name="permissionCheck"></param>
 /// <param name="registryOptions"></param>
 /// <param name="registrySecurity"></param>
 /// <returns></returns>
 public IRegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions, IRegistrySecurity registrySecurity)
 {
     RegistryKey key = RegistryKeyInstance.CreateSubKey(subkey, permissionCheck, registryOptions, registrySecurity.RegistrySecurityInstance);
     if (null == key)
         return null;
     else
         return new RegistryKeyWrap(key);
 }
Example #40
0
        private unsafe RegistryKey CreateSubKeyInternalCore(string subkey, RegistryKeyPermissionCheck permissionCheck, object registrySecurityObj, RegistryOptions registryOptions)
        {
            Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs = default(Interop.Kernel32.SECURITY_ATTRIBUTES);
            int disposition = 0;

            // By default, the new key will be writable.
            SafeRegistryHandle result = null;
            int ret = Interop.Advapi32.RegCreateKeyEx(_hkey,
                                                      subkey,
                                                      0,
                                                      null,
                                                      (int)registryOptions /* specifies if the key is volatile */,
                                                      GetRegistryKeyAccess(permissionCheck != RegistryKeyPermissionCheck.ReadSubTree) | (int)_regView,
                                                      ref secAttrs,
                                                      out result,
                                                      out disposition);

            if (ret == 0 && !result.IsInvalid)
            {
                RegistryKey key = new RegistryKey(result, (permissionCheck != RegistryKeyPermissionCheck.ReadSubTree), false, _remoteKey, false, _regView);
                CheckPermission(RegistryInternalCheck.CheckSubTreePermission, subkey, false, permissionCheck);
                key._checkMode = permissionCheck;

                if (subkey.Length == 0)
                {
                    key._keyName = _keyName;
                }
                else
                {
                    key._keyName = _keyName + "\\" + subkey;
                }
                return(key);
            }
            else if (ret != 0)                             // syscall failed, ret is an error code.
            {
                Win32Error(ret, _keyName + "\\" + subkey); // Access denied?
            }

            Debug.Fail("Unexpected code path in RegistryKey::CreateSubKey");
            return(null);
        }
Example #41
0
        private unsafe RegistryKey CreateSubKeyInternal(String subkey, bool writable, RegistryOptions registryOptions)
        {
            ValidateKeyOptions(registryOptions);
            ValidateKeyName(subkey);
            EnsureWriteable();
            subkey = FixupName(subkey); // Fixup multiple slashes to a single slash

            // only keys opened under read mode is not writable
            if (!remoteKey)
            {
                RegistryKey key = InternalOpenSubKey(subkey, writable);
                if (key != null)
                { // Key already exits
                    return key;
                }
            }

            Interop.mincore.SECURITY_ATTRIBUTES secAttrs = default(Interop.mincore.SECURITY_ATTRIBUTES);
            int disposition = 0;

            // By default, the new key will be writable.
            SafeRegistryHandle result = null;
            int ret = Interop.mincore.RegCreateKeyEx(hkey,
                subkey,
                0,
                null,
                (int)registryOptions /* specifies if the key is volatile */,
                GetRegistryKeyAccess(writable) | (int)regView,
                ref secAttrs,
                out result,
                out disposition);

            if (ret == 0 && !result.IsInvalid)
            {
                RegistryKey key = new RegistryKey(result, writable, false, remoteKey, false, regView);

                if (subkey.Length == 0)
                    key.keyName = keyName;
                else
                    key.keyName = keyName + "\\" + subkey;
                return key;
            }
            else if (ret != 0) // syscall failed, ret is an error code.
                Win32Error(ret, keyName + "\\" + subkey);  // Access denied?

            Debug.Fail("Unexpected code path in RegistryKey::CreateSubKey");
            return null;
        }
 public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions options)
 {
   return default(RegistryKey);
 }
Example #43
0
 private static void ValidateKeyOptions(RegistryOptions options)
 {
 }
Example #44
0
 public RegistryKey CreateSubKey(string subkey, bool writable, RegistryOptions options)
 {
     return(CreateSubKeyInternal(subkey, writable, options));
 }
Example #45
0
 public virtual RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions options)
 {
     return(this.CreateSubKey(subkey, permissionCheck, options, null));
 }
Example #46
0
 static extern int RegCreateKeyEx(
             SafeRegistryHandle hKey,
             string lpSubKey,
             int Reserved,
             string lpClass,
             RegistryOptions dwOptions,
             RegistryRights samDesired,
             IntPtr lpSecurityAttributes,
             out SafeRegistryHandle phkResult,
             out int lpdwDisposition);
Example #47
0
 /// <summary>
 /// TODO: Add Comment
 /// </summary>
 /// <param name="subkey"></param>
 /// <param name="permissionCheck"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public IRegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions options)
 {
     RegistryKey key = RegistryKeyInstance.CreateSubKey(subkey, permissionCheck, options); ;
     if (null == key)
         return null;
     else
         return new RegistryKeyWrap(key);
 }
Example #48
0
 public abstract RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions, RegistrySecurity registrySecurity);
 private RegistryKey CreateSubKeyInternalCore(string subkey, RegistryKeyPermissionCheck permissionCheck, object registrySecurityObj, RegistryOptions registryOptions)
 {
     throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
 }
        public void ReadWritePermissionCheckWithRegistryOptionsTestsValid(bool alreadyExists, RegistryOptions options)
        {
            string subkey = "TEST_" + options.ToString();

            if (alreadyExists)
            {
                TestRegistryKey.CreateSubKey(subkey, RegistryKeyPermissionCheck.ReadWriteSubTree, options);
            }

            Assert.NotNull(TestRegistryKey.CreateSubKey(subkey, RegistryKeyPermissionCheck.ReadWriteSubTree, options));
        }
 private RegistryKey CreateSubKeyInternalCore(string subkey, bool writable, RegistryOptions registryOptions)
 {
     // TODO: Implement this
     throw new PlatformNotSupportedException();
 }
Example #52
0
		public RegistryKey CreateSubKey (RegistryKey rkey, string keyName, RegistryOptions options)
		{
			IntPtr handle = GetHandle (rkey);
			IntPtr subKeyHandle;
			int disposition;
			int result = RegCreateKeyEx (handle , keyName, 0, IntPtr.Zero,
				options == RegistryOptions.Volatile ? RegOptionsVolatile : RegOptionsNonVolatile,
				OpenRegKeyRead | OpenRegKeyWrite, IntPtr.Zero, out subKeyHandle, out disposition);

			if (result == Win32ResultCode.MarkedForDeletion)
				throw RegistryKey.CreateMarkedForDeletionException ();

			if (result != Win32ResultCode.Success)
				GenerateException (result);
			
			return new RegistryKey (subKeyHandle, CombineName (rkey, keyName),
				true);
		}
Example #53
0
 public RegistryKey CreateSubKey(RegistryKey rkey, string keyname, RegistryOptions options)
 {
     return(CreateSubKey(rkey, keyname, true, options == RegistryOptions.Volatile));
 }
Example #54
0
 public RegistryKey CreateSubKey(string subkey, bool writable, RegistryOptions options)
 {
     return CreateSubKeyInternal(subkey, writable, options);
 }
Example #55
0
        private unsafe RegistryKey CreateSubKeyInternalCore(string subkey, bool writable, RegistryOptions registryOptions)
        {
            Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs = default(Interop.Kernel32.SECURITY_ATTRIBUTES);
            int disposition = 0;

            // By default, the new key will be writable.
            SafeRegistryHandle result = null;
            int ret = Interop.mincore.RegCreateKeyEx(_hkey,
                                                     subkey,
                                                     0,
                                                     null,
                                                     (int)registryOptions /* specifies if the key is volatile */,
                                                     (int)GetRegistryKeyRights(writable) | (int)_regView,
                                                     ref secAttrs,
                                                     out result,
                                                     out disposition);

            if (ret == 0 && !result.IsInvalid)
            {
                RegistryKey key = new RegistryKey(result, writable, false, _remoteKey, false, _regView);
                if (subkey.Length == 0)
                {
                    key._keyName = _keyName;
                }
                else
                {
                    key._keyName = _keyName + "\\" + subkey;
                }
                return(key);
            }
            else if (ret != 0)                             // syscall failed, ret is an error code.
            {
                Win32Error(ret, _keyName + "\\" + subkey); // Access denied?
            }

            Debug.Fail("Unexpected code path in RegistryKey::CreateSubKey");
            return(null);
        }
Example #56
0
 static private void ValidateKeyOptions(RegistryOptions options)
 {
     if (options < RegistryOptions.None || options > RegistryOptions.Volatile)
     {
         ThrowHelper.ThrowArgumentException(SR.Argument_InvalidRegistryOptionsCheck, nameof(options));
     }
 }
Example #57
0
		public RegistryKey CreateSubKey (String subkey, bool writable, RegistryOptions options)
		{
			throw new PlatformNotSupportedException ();
		}