コード例 #1
0
        /// <summary>
        /// Returns the registry that must be used to handle te specified <see cref="RegistryRequest"/> with.
        /// </summary>
        /// <param name="request">The <see cref="RegistryRequest"/> to get the handling registry for.</param>
        /// <param name="recoverHandle">Indicates whether or not a possible unknown <see cref="RegistryRequest.Handle"/> should be recovered and virtualized.</param>
        /// <returns></returns>
        public RegistryBase GetRegistryFor(RegistryRequest request, bool recoverHandle)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            RegistryBase result = null;

            if (_virtualRegistry.IsKnownKey(request))
            {
                result = _virtualRegistry;
            }
            else if (_transparentRegistry.IsKnownKey(request))
            {
                result = _transparentRegistry;
            }
            else if (HiveHelper.IsHiveHandle(request.Handle))
            {
                request.KeyFullPath = HiveHelper.GetHive(request.Handle).AsRegistryHiveName();
                result = GetDefaultRegistryFor(request);
            }
            else if (recoverHandle)
            {
                // Unknown handle, and allowed to be recovered and virtualized.
                result = TryRecoverUnknownHandle(request);
            }
            else
            {
                EngineCore.Log.Error("Unknown registry key handle => {0}", request.Handle);
            }
            request.VirtualizationType = GetVirtualizationType(request.KeyFullPath);
            return(result);
        }
コード例 #2
0
ファイル: RegistryProvider.cs プロジェクト: lulzzz/appstract
        public NativeResultCode SetValue(uint hKey, VirtualRegistryValue value)
        {
            if (HiveHelper.IsHiveHandle(hKey))
            {
                return(NativeResultCode.AccessDenied);
            }
            var request = new RegistryValueRequest {
                Handle = hKey, Value = value
            };
            var registry = _switch.GetRegistryFor(request);

            return(registry != null
               ? registry.SetValue(request)
               : NativeResultCode.InvalidHandle);
        }
コード例 #3
0
ファイル: RegistryProvider.cs プロジェクト: lulzzz/appstract
        public NativeResultCode DeleteKey(uint hKey)
        {
            if (HiveHelper.IsHiveHandle(hKey))
            {
                return(NativeResultCode.AccessDenied);
            }
            var request = new RegistryRequest {
                Handle = hKey
            };
            var registry = _switch.GetRegistryFor(request);

            return(registry != null
               ? registry.DeleteKey(request)
               : NativeResultCode.InvalidHandle);
        }
コード例 #4
0
ファイル: RegistryProvider.cs プロジェクト: lulzzz/appstract
        public NativeResultCode QueryValue(uint hKey, string valueName, out VirtualRegistryValue value)
        {
            NativeResultCode result;
            var request = new RegistryValueRequest(valueName)
            {
                Handle = hKey
            };

            if (!HiveHelper.IsHiveHandle(hKey))
            {
                var registry = _switch.GetRegistryFor(request);
                result = registry != null
                   ? registry.QueryValue(request)
                   : NativeResultCode.InvalidHandle;
            }
            else
            {
                result = NativeResultCode.AccessDenied;
            }
            value = request.Value;
            return(result);
        }