private static Type FindImpl() { Platform.OS os = Platform.GetOS(); Type type = typeof(T); var cls = ClassLoader.FindTypeByAttribute <PlatformImplAttribute>((t, a) => a.OS == os && (t.BaseType == type || t.GetInterfaces().Contains(type))); if (cls == null) { throw new TypeLoadException("Could not find an instance of '" + type.FullName + "' for the " + os + " platform."); } return(cls); }
private static T LoadInstance() { Platform.OS os = Platform.GetOS(); Type type = typeof(T); var cls = ClassLoader.FindTypeByAttribute <PlatformImplAttribute>((t, a) => a.OS == os && t.GetInterfaces().Contains(type)); if (cls == null) { throw new TypeLoadException("Could not find an instance of '" + type.FullName + "' for the " + os + " platform."); } object obj = Activator.CreateInstance(cls); T ret = obj as T; return(ret); }
private static IClipboard DetermineClipboard() { Platform.OS os = Platform.Current(); if (os == Platform.OS.WINDOWS) { return(new ClipboardWindows()); } else if (os == Platform.OS.LINUX) { return(new ClipboardLinux()); } else if (os == Platform.OS.OSX) { return(new ClipboardOsx()); } else if (os == Platform.OS.UNKNOWN) { return(new ClipboardLocal()); } throw new Exception("Unrecognized OS for Clipboard determination"); }
public FormMain() { InitializeComponent(); foreach (var strategy in ClassLoader.GetAllByAttribute <MutationStrategyAttribute>(null)) { comboBoxFuzzingStrategy.Items.Add(strategy.Key.Name); } //tabControl.TabPages.Remove(tabPageGUI); tabControl.TabPages.Remove(tabPageFuzzing); //tabControl.TabPages.Remove(tabPageOutput); LoadPlatformAssembly(); // Check OS and load side assembly Platform.OS os = Platform.GetOS(); switch (os) { case Platform.OS.OSX: tabControl.TabPages.Remove(tabPageDebuggerLinux); tabControl.TabPages.Remove(tabPageDebuggerWin); tabControl.TabPages.Remove(tabPageGUI); richTextBoxOSX.LoadFile(Assembly.GetExecutingAssembly().GetManifestResourceStream("PeachFuzzBang.OSXDebugging.rtf"), RichTextBoxStreamType.RichText); break; case Platform.OS.Linux: tabControl.TabPages.Remove(tabPageDebuggerOSX); tabControl.TabPages.Remove(tabPageDebuggerWin); tabControl.TabPages.Remove(tabPageGUI); richTextBoxLinux.LoadFile(Assembly.GetExecutingAssembly().GetManifestResourceStream("PeachFuzzBang.LinuxDebugging.rtf"), RichTextBoxStreamType.RichText); break; case Platform.OS.Windows: { comboBoxAttachToServiceServices.Items.Clear(); foreach (ServiceController srv in ServiceController.GetServices()) { comboBoxAttachToServiceServices.Items.Add(srv.ServiceName); } textBoxAttachToProcessProcessName.Items.Clear(); foreach (Process proc in Process.GetProcesses()) { textBoxAttachToProcessProcessName.Items.Add(proc.ProcessName); proc.Close(); } tabControl.TabPages.Remove(tabPageDebuggerOSX); tabControl.TabPages.Remove(tabPageDebuggerLinux); if (!Environment.Is64BitProcess && Environment.Is64BitOperatingSystem) { MessageBox.Show("Warning: The 64bit version of Peach 3 must be used on 64 bit Operating Systems.", "Warning"); } string windbg = null; Type t = ClassLoader.FindTypeByAttribute <MonitorAttribute>((x, y) => y.Name == "WindowsDebugger"); if (t != null) { windbg = t.InvokeMember("FindWinDbg", BindingFlags.InvokeMethod, null, null, null) as string; } if (windbg != null) { textBoxDebuggerPath.Text = windbg; } else { textBoxDebuggerPath.Text = "Error, could not locate windbg!"; } } break; } if (os != Platform.OS.Windows) { // Update default settings to include full path to PeachFuzzBang // When double clicking the app to run it, the current working // directory is $HOME string cwd = Environment.CurrentDirectory + Path.DirectorySeparatorChar; string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar; if (path.StartsWith(cwd)) { path = path.Substring(cwd.Length); } if (!string.IsNullOrEmpty(path)) { textBoxFuzzedFile.Text = Path.Combine(path, textBoxFuzzedFile.Text); textBoxTemplateFiles.Text = Path.Combine(path, textBoxTemplateFiles.Text); textBoxLinuxArguments.Text = Path.Combine(path, textBoxLinuxArguments.Text); textBoxOSXArguments.Text = Path.Combine(path, textBoxOSXArguments.Text); } } buttonStartFuzzing.Enabled = true; buttonSaveConfiguration.Enabled = false; buttonStopFuzzing.Enabled = false; comboBoxPitDataModel.SelectedIndexChanged += new EventHandler(comboBoxPitDataModel_SelectedIndexChanged); richTextBoxIntroduction.LoadFile(Assembly.GetExecutingAssembly().GetManifestResourceStream("PeachFuzzBang.Introduction.rtf"), RichTextBoxStreamType.RichText); }
public PlatformImplAttribute(Platform.OS OS) { this.OS = OS; }