Ejemplo n.º 1
0
        /// <summary>
        ///     Add a fake registry item to runtime.
        /// </summary>
        internal bool AddRegistryEntry(
            string root,
            string subkey,
            string valueName,
            string dataType,
            string data)
        {
            try
            {
                var original = new REGISTRY_ENTRY64
                {
                    Root      = _regKeyFlags[root],
                    SubKey    = new UNICODE_STRING64(),
                    ValueName = new UNICODE_STRING64(),
                    DataType  = _regTypeFlags[dataType],
                    Data      = 0,
                    DataSize  = 0
                };

                AddStringData(subkey,
                              out original.SubKey.Buffer,
                              out original.SubKey.Length,
                              out original.SubKey.MaximumLength);

                AddStringData(valueName,
                              out original.ValueName.Buffer,
                              out original.ValueName.Length,
                              out original.ValueName.MaximumLength);

                AddObjectData(dataType, data, out original.Data, out original.DataSize);

                var entry = new REGISTRY_REDIRECTION_ENTRY64 {
                    Original = original, Redirected = original
                };

                _registryReplacement.Add(entry);

                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);

                return(false);
            }
        }
        /// <summary>
        ///     Add a fake registry item to runtime.
        /// </summary>
        internal bool AddRegistryEntry(
            string root,
            string subkey,
            string valueName,
            string dataType,
            string data)
        {
            try
            {
                var original = new REGISTRY_ENTRY64
                               {
                                   Root = _regKeyFlags[root],
                                   SubKey = new UNICODE_STRING64(),
                                   ValueName = new UNICODE_STRING64(),
                                   DataType = _regTypeFlags[dataType],
                                   Data = 0,
                                   DataSize = 0,
                               };

                AddStringData(subkey,
                              out original.SubKey.Buffer,
                              out original.SubKey.Length,
                              out original.SubKey.MaximumLength);

                AddStringData(valueName,
                              out original.ValueName.Buffer,
                              out original.ValueName.Length,
                              out original.ValueName.MaximumLength);

                AddObjectData(dataType, data, out original.Data, out original.DataSize);

                var entry = new REGISTRY_REDIRECTION_ENTRY64 {Original = original, Redirected = original};

                _registryReplacement.Add(entry);

                return true;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);

                return false;
            }
        }