Esempio n. 1
0
        public override bool Equals(object obj)
        {
            if (base.Equals(obj))
            {
                return(true);
            }

            COMAppIDServiceEntry right = obj as COMAppIDServiceEntry;

            if (right == null)
            {
                return(false);
            }

            return(DisplayName == right.DisplayName && Name == right.Name && ServiceType == right.ServiceType && UserName == right.UserName && ProtectionLevel == right.ProtectionLevel);
        }
Esempio n. 2
0
        private void LoadFromKey(RegistryKey key)
        {
            RunAs = key.GetValue("RunAs") as string;
            string name = key.GetValue(null) as string;

            if (!string.IsNullOrWhiteSpace(name))
            {
                Name = name.ToString();
            }
            else
            {
                Name = AppId.FormatGuidDefault();
            }

            AccessPermission = key.ReadSddl("AccessPermission");
            LaunchPermission = key.ReadSddl("LaunchPermission");

            DllSurrogate = key.GetValue("DllSurrogate") as string;
            if (DllSurrogate != null)
            {
                if (string.IsNullOrWhiteSpace(DllSurrogate))
                {
                    DllSurrogate = "dllhost.exe";
                }
                else
                {
                    string dllexe = key.GetValue("DllSurrogateExecutable") as string;
                    if (!string.IsNullOrWhiteSpace(dllexe))
                    {
                        DllSurrogate = dllexe;
                    }
                }
            }
            else
            {
                DllSurrogate = string.Empty;
            }

            object flags = key.GetValue("AppIDFlags");

            if (flags != null)
            {
                Flags = (COMAppIDFlags)flags;
            }

            string local_service = key.GetValue("LocalService") as string;

            if (!string.IsNullOrWhiteSpace(local_service))
            {
                try
                {
                    using (RegistryKey serviceKey = Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Services\" + local_service))
                    {
                        using (ServiceController service = new ServiceController(local_service))
                        {
                            LocalService = new COMAppIDServiceEntry(serviceKey, service);
                        }
                    }
                }
                catch
                {
                }
            }

            if (string.IsNullOrWhiteSpace(RunAs))
            {
                RunAs = string.Empty;
            }

            object rotflags = key.GetValue("ROTFlags");

            if (rotflags != null && rotflags is int)
            {
                RotFlags = (COMAppIDRotFlags)rotflags;
            }

            object bitness = key.GetValue("PreferredServerBitness");

            if (bitness != null && bitness is int)
            {
                PreferredServerBitness = (PreferredServerBitness)bitness;
            }

            Source = key.GetSource();
        }