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 ?? ""); }
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; } }
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); }