コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
0
 /// <summary>
 /// This method will insert a value into the VREG.
 /// </summary>
 /// <param name="hKey">A handle to an open registry key.</param>
 /// <param name="lpValueName">
 /// The name of the value to be set. If a value with this name is not already present in the key,
 /// the function adds it to the key.
 /// If lpValueName is NULL or an empty string, "", the function sets the type and data for
 /// the key's unnamed or default value.
 /// </param>
 /// <param name="reserved">This parameter is reserved and must be zero.</param>
 /// <param name="dwType">The type of data pointed to by the <paramref name="lpData"/> parameter.</param>
 /// <param name="lpData">The data to be stored.</param>
 /// <param name="cbData">The size of the information pointed to by the lpData parameter, in bytes.</param>
 /// <returns>A WinError code.</returns>
 public NativeResultCode SetValueEx(UIntPtr hKey, [MarshalAs(UnmanagedType.LPWStr)] string lpValueName,
                                       uint reserved, ValueType dwType, IntPtr lpData, uint cbData)
 {
   uint handle;
   if (!TryParse(hKey, out handle))
     return NativeResultCode.InvalidHandle;
   using (EngineCore.Engine.GetEngineProcessingSpace())
   {
     var data = lpData.Read<byte[]>(cbData);
     var registryValue = new VirtualRegistryValue(lpValueName, data, dwType);
     var resultCode = _registry.SetValue(handle, registryValue);
     EngineCore.Log.Debug("SetValue(HKey={0} Name={1} Type={2}) => {3}",
                         handle, lpValueName, dwType, resultCode);
     return resultCode;
   }
 }
コード例 #4
0
 public RegDbTests()
 {
   _entryValue = new VirtualRegistryValue("myValue", new ASCIIEncoding().GetBytes("someData"), ValueType.REG_SZ);
   _entryKey = new VirtualRegistryKey(456, @"HKEY_USERS\MyTestUser\TestEntry",
                                     new Dictionary<string, VirtualRegistryValue> { { _entryValue.Name, _entryValue } });
 }
コード例 #5
0
 public NativeResultCode DeleteValue(uint hKey, string valueName)
 {
   if (HiveHelper.IsHiveHandle(hKey))
     return NativeResultCode.AccessDenied;
   var value = new VirtualRegistryValue {Name = valueName};
   var request = new RegistryValueRequest { Handle = hKey, Value = value };
   var registry = _switch.GetRegistryFor(request);
   return registry != null
            ? registry.DeleteValue(request)
            : NativeResultCode.InvalidHandle;
 }
コード例 #6
0
 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;
 }