Пример #1
0
 public static void ExtractWow64Options(Win32Api.KeySecurity value,
                                        out KeySecurity keySecurity, out Win32Api.RegWow64Options wow64Options)
 {
     wow64Options = (Win32Api.RegWow64Options)((int)value &
                                               (int)(Win32Api.RegWow64Options.KEY_WOW64_32KEY | Win32Api.RegWow64Options.KEY_WOW64_64KEY));
     keySecurity = new KeySecurity(value & (Win32Api.KeySecurity) ~wow64Options);
 }
Пример #2
0
        internal void OpenKey(IntPtr hKey,
                              string lpSubKey,
                              int ulOptions,
                              Win32Api.KeySecurity samDesired,
                              out IntPtr phkResult)
        {
            // ulOptions are ignored as this is a reserved parameter
            phkResult = IntPtr.Zero;
            KeySecurity keySecurity;

            Win32Api.RegWow64Options wowOptions;
            KeySecurity.ExtractWow64Options(samDesired, out keySecurity, out wowOptions);
            KeyIdentity baseIdentity = GetKey(hKey).Identity;

            OpenKey(baseIdentity, new KeyIdentity(baseIdentity, wowOptions, lpSubKey),
                    keySecurity, out phkResult);
        }
Пример #3
0
        internal void CreateKey(IntPtr hKey,
                                string lpSubKey,
                                int Reserved,
                                string lpClass,
                                Win32Api.RegOption dwOptions,
                                Win32Api.KeySecurity samDesired,
                                IntPtr lpSecurityAttributes,
                                out IntPtr phkResult,
                                IntPtr lpdwDisposition)
        {
            phkResult = IntPtr.Zero;
            // Reserved is ignored as this is a reserved parameter

            try
            {
                OpenKey(hKey, lpSubKey, 0, samDesired, out phkResult);
                if (lpdwDisposition != IntPtr.Zero)
                {
                    Marshal.WriteInt32(lpdwDisposition,
                                       (int)Win32Api.RegKeyDisposition.REG_OPENED_EXISTING_KEY);
                }
                return;
            }
            catch (FileNotFoundException) {}
            KeySecurity keySecurity;

            Win32Api.RegWow64Options wowOptions;
            KeySecurity.ExtractWow64Options(samDesired, out keySecurity, out wowOptions);
            VirtualKey key = factory_.CreateKey(
                new KeyIdentity(GetKey(hKey).Identity, wowOptions, lpSubKey), lpClass, dwOptions,
                lpSecurityAttributes);

            if (lpdwDisposition != IntPtr.Zero)
            {
                Marshal.WriteInt32(lpdwDisposition,
                                   (int)Win32Api.RegKeyDisposition.REG_CREATED_NEW_KEY);
            }
            phkResult = keyStorage_.Add(key);
        }
Пример #4
0
 public void RelaxToReadAccess()
 {
     value_ = (Win32Api.KeySecurity)((int)value_ & (int)Win32Api.KeySecurity.KEY_READ);
     Debug.Assert(IsOnlyForRead());
 }
Пример #5
0
 public KeySecurity(Win32Api.KeySecurity value)
 {
     value_ = value;
 }