Exemple #1
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);
        }
Exemple #2
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);
            }
        }
Exemple #3
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);
        }
Exemple #4
0
        public static string FormatProgID(ProgramID ProgID)
        {
            string Name = "";
            string Path = ProgID.Path;

            switch (ProgID.Type)
            {
            case ProgramID.Types.System:
                Path = MiscFunc.NtOsKrnlPath;
                break;

            case ProgramID.Types.Program:
                break;

            case ProgramID.Types.Service:
                Name = ProgID.GetServiceId();
                if (Name != null && Name.Length > 0)
                {
                    Name = Translate.fmt("name_service") + " " + Name;
                }
                break;

            case ProgramID.Types.App:
                Name = ProgID.GetPackageName();
                if (Name != null && Name.Length > 0)
                {
                    Name = Translate.fmt("name_app") + " " + Name;
                }
                break;

            default:
            case ProgramID.Types.Global:
                Name = Translate.fmt("name_global");
                break;
            }
            if (Name == null || Name.Length == 0)
            {
                Name = Path;
            }
            else if (Path != null && Path.Length > 0)
            {
                Name += " (" + Path + ")";
            }
            return(Name ?? "");
        }
Exemple #5
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;
            }
        }
Exemple #6
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;
            }
        }