Beispiel #1
0
        public bool Exists()
        {
            bool PathMissing = (ID.Path != null && ID.Path.Length > 0 && !File.Exists(ID.Path));

            switch (ID.Type)
            {
            case ProgramID.Types.Program:   return(!PathMissing);

            case ProgramID.Types.Service:   return((ServiceHelper.GetServiceStatus(ID.GetServiceId()) != ServiceHelper.ServiceState.NotFound) && !PathMissing);

            case ProgramID.Types.App:       return(App.PkgMgr?.GetAppInfoBySid(ID.GetPackageSID()) != null && !PathMissing);

            default:        return(true);
            }
        }
Beispiel #2
0
        protected string GetDescription()
        {
            string Name = "";
            string Info = null;

            switch (ID.Type)
            {
            case ProgramID.Types.System:
                Name = "Windows NT-Kernel/System";     // Translate.fmt("name_system");
                break;

            case ProgramID.Types.Global:
                Name = "All Processes";     // Translate.fmt("name_global");
                break;

            case ProgramID.Types.Program:
                Name = System.IO.Path.GetFileName(ID.Path);
                Info = NtUtilities.GetExeDescription(ID.Path);
                break;

            case ProgramID.Types.Service:
                Name = ID.GetServiceId();
                Info = ProcessMonitor.GetServiceName(Name);
                break;

            case ProgramID.Types.App:
                var SID    = ID.GetPackageSID();
                var AppPkg = App.engine.FirewallManager.GetAppPkgBySid(SID);
                if (AppPkg != null)
                {
                    Name = AppPkg.ID;
                    Info = App.GetResourceStr(AppPkg.Name);
                }
                else
                {
                    Name = SID;
                }
                break;
            }

            if (Info != null && Info.Length > 0)
            {
                return(Info + " (" + Name + ")");
            }
            return(Name);
        }
Beispiel #3
0
        public Program(ProgramID progID)
        {
            //guid = Guid.NewGuid();

            ID = progID.Duplicate();

            string Name = "";
            string Info = null;

            switch (ID.Type)
            {
            case ProgramID.Types.System:
                Name = Translate.fmt("name_system");
                break;

            case ProgramID.Types.Global:
                Name = Translate.fmt("name_global");
                break;

            case ProgramID.Types.Program:
                Name = System.IO.Path.GetFileName(ID.Path);
                Info = MiscFunc.GetExeDescription(ID.Path);
                break;

            case ProgramID.Types.Service:
                Name = ID.GetServiceId();
                Info = ID.GetServiceName();
                break;

            case ProgramID.Types.App:
                Name = ID.GetPackageName();
                var AppPkg = App.engine.FirewallManager.GetAppPkgBySid(ID.GetPackageSID());
                Info = AppPkg?.Name;
                break;
            }

            if (Info != null && Info.Length > 0)
            {
                Description = Info + " (" + Name + ")";
            }
            else
            {
                Description = Name;
            }
        }
Beispiel #4
0
        public static string GetIcon(ProgramID ProgId)
        {
            if (ProgId.Type == ProgramID.Types.App)
            {
                var AppPkg = AppModel.GetInstance().GetAppPkgBySid(ProgId.GetPackageSID());
                if (AppPkg != null && AppPkg.Logo != null)
                {
                    return(AppPkg.Logo);
                }
            }

            if (ProgId.Type == ProgramID.Types.Service) // || (ProgId.IsSystem() && ProgId.Path.Length == 0))
            {
                return(SvcIconPath);
            }

            return(ProgId.Path);
        }
Beispiel #5
0
        public void SetProgID(ProgramID progID)
        {
            ProgID = progID;

            switch (progID.Type)
            {
            case ProgramID.Types.Global:
                BinaryPath = null;
                break;

            case ProgramID.Types.System:
                BinaryPath = "System";
                break;

            default:
                if (progID.Path != null && progID.Path.Length > 0)
                {
                    BinaryPath = progID.Path;
                }
                break;
            }

            if (progID.Type == ProgramID.Types.App)
            {
                AppSID = progID.GetPackageSID();
            }
            else
            {
                AppSID = null;
            }

            if (progID.Type == ProgramID.Types.Service)
            {
                ServiceTag = progID.GetServiceId();
            }
            else
            {
                ServiceTag = null;
            }
        }
Beispiel #6
0
        public string GetDescription()
        {
            string Name = "";
            string Info = null;

            switch (ID.Type)
            {
            case ProgramID.Types.System:
                Name = "Windows NT-Kernel/System";     // Translate.fmt("name_system");
                break;

            case ProgramID.Types.Global:
                Name = "All Processes";     // Translate.fmt("name_global");
                break;

            case ProgramID.Types.Program:
                Name = System.IO.Path.GetFileName(ID.Path);
                Info = MiscFunc.GetExeDescription(ID.Path);
                break;

            case ProgramID.Types.Service:
                Name = ID.GetServiceId();
                Info = ID.GetServiceName();
                break;

            case ProgramID.Types.App:
                Name = ID.GetPackageName();
                var AppPkg = App.engine.FirewallManager.GetAppPkgBySid(ID.GetPackageSID());
                Info = App.GetResourceStr(AppPkg?.Name);
                break;
            }

            if (Info != null && Info.Length > 0)
            {
                return(Info + " (" + Name + ")");
            }
            return(Name);
        }