static void Main(string[] args) { bool is_verbose = false; bool show_help = false; CLRPH_DEMANGLER demangler_name = CLRPH_DEMANGLER.Default; OptionSet opts = new OptionSet() { { "v|verbose", "redirect debug traces to console", v => is_verbose = v != null }, { "h|help", "show this message and exit", v => show_help = v != null }, { "d=|demangler=", "Choose demangler name", v => demangler_name = ParseDemanglerName(v) }, }; List <string> eps = opts.Parse(args); if (show_help) { ShowHelp(opts); return; } if (is_verbose) { // Redirect debug log to the console Debug.Listeners.Add(new TextWriterTraceListener(Console.Out)); Debug.AutoFlush = true; } // always the first call to make Phlib.InitializePhLib(); Demangler demangler; switch (args.Length) { case 0: demangler = new Demangler(CLRPH_DEMANGLER.Microsoft); TestKnownInputs(demangler); break; default: case 1: demangler = new Demangler(demangler_name); string Filepath = args[1]; if (NativeFile.Exists(Filepath)) { TestFilepath(Filepath, demangler); } else { string undecoratedName = demangler.UndecorateName(args[1]).Item2; Console.WriteLine(undecoratedName); } break; } // Force flushing out buffer Console.Out.Flush(); }
void App_Startup(object sender, StartupEventArgs e) { Phlib.InitializePhLib(); BinaryCache.Instance.Load(); MainWindow mainWindow = new MainWindow(); mainWindow.IsMaster = true; switch (Phlib.GetClrPhArch()) { case CLRPH_ARCH.x86: mainWindow.Title = "Dependencies (x86)"; break; case CLRPH_ARCH.x64: mainWindow.Title = "Dependencies (x64)"; break; case CLRPH_ARCH.WOW64: mainWindow.Title = "Dependencies (WoW64)"; break; } mainWindow.Show(); // Process command line args if (e.Args.Length > 0) { mainWindow.OpenNewDependencyWindow(e.Args[0]); } }
public NativeDepend() { if (!_PhInited) { Phlib.InitializePhLib(); _PhInited = true; } }
/// <summary> /// Initial from a PE File /// </summary> /// <param name="file">The file name</param> public NativeDepend(string file) { filename = file; if (!_PhInited) { Phlib.InitializePhLib(); _PhInited = true; } }
void App_Startup(object sender, StartupEventArgs e) { (Application.Current as App).PropertyChanged += App_PropertyChanged; Phlib.InitializePhLib(); // Load singleton for binary caching if (Dependencies.BinaryCacheOption.GetGlobalBehaviour() == Dependencies.BinaryCacheOption.BinaryCacheOptionValue.Yes) { string ApplicationLocalAppDataPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Dependencies" ); BinaryCache.Instance = new BinaryCacheImpl(ApplicationLocalAppDataPath, 200); } else { BinaryCache.Instance = new BinaryNoCacheImpl(); } BinaryCache.Instance.Load(); // https://www.red-gate.com/simple-talk/blogs/wpf-menu-displays-to-the-left-of-the-window/ SetDropDownMenuToBeRightAligned(); mainWindow = new MainWindow(); mainWindow.IsMaster = true; switch (Phlib.GetClrPhArch()) { case CLRPH_ARCH.x86: mainWindow.Title = "Dependencies (x86)"; break; case CLRPH_ARCH.x64: mainWindow.Title = "Dependencies (x64)"; break; case CLRPH_ARCH.WOW64: mainWindow.Title = "Dependencies (WoW64)"; break; } mainWindow.Show(); // Process command line args if (e.Args.Length > 0) { mainWindow.OpenNewDependencyWindow(e.Args[0]); } }
static void Main(string[] args) { // always the first call to make Phlib.InitializePhLib(); int recursion_depth = 0; bool early_exit = false; bool show_help = false; bool export_as_json = false; DumpCommand command = null; OptionSet opts = new OptionSet() { { "h|help", "show this message and exit", v => show_help = v != null }, { "json", "Export results in json format", v => export_as_json = v != null }, { "d|depth=", "limit recursion depth when analyisng loaded modules or dependency chain. Default value is infinite", (int v) => recursion_depth = v }, { "knowndll", "List all known dlls", v => { DumpKnownDlls(GetObjectPrinter(export_as_json)); early_exit = true; } }, { "apisets", "List apisets redirections", v => { DumpApiSets(GetObjectPrinter(export_as_json)); early_exit = true; } }, { "apisetsdll", "List apisets redirections from apisetschema.dll", v => command = DumpApiSets }, { "manifest", "show manifest information embedded in PE file", v => command = DumpManifest }, { "sxsentries", "dump all of FILE's sxs dependencies", v => command = DumpSxsEntries }, { "imports", "dump FILE imports", v => command = DumpImports }, { "exports", "dump FILE exports", v => command = DumpExports }, { "chain", "dump FILE whole dependency chain", v => command = DumpDependencyChain }, { "modules", "dump FILE resolved modules", v => command = DumpModules }, }; List <string> eps = opts.Parse(args); if (early_exit) { return; } if ((show_help) || (args.Length == 0) || (command == null)) { DumpUsage(); return; } String FileName = eps[0]; //Console.WriteLine("[-] Loading file {0:s} ", FileName); PE Pe = new PE(FileName); if (!Pe.Load()) { Console.Error.WriteLine("[x] Could not load file {0:s} as a PE", FileName); return; } command(Pe, GetObjectPrinter(export_as_json), recursion_depth); }
public MainWindow() { Phlib.InitializePhLib(); InitializeComponent(); PopulateRecentFilesMenuItems(true); this.AboutPage = new About(); this.UserSettings = new UserSettings(); // TODO : understand how to reliably bind in xaml this.TabControl.InterTabController.InterTabClient = DoNothingInterTabClient; this._Master = false; }
void App_Startup(object sender, StartupEventArgs e) { Phlib.InitializePhLib(); BinaryCache.Instance.Load(); MainWindow mainWindow = new MainWindow(); mainWindow.IsMaster = true; mainWindow.Show(); // Process command line args if (e.Args.Length > 0) { mainWindow.OpenNewDependencyWindow(e.Args[0]); } }
static void Main(string[] args) { bool is_verbose = false; bool show_help = false; OptionSet opts = new OptionSet() { { "v|verbose", "redirect debug traces to console", v => is_verbose = v != null }, { "h|help", "show this message and exit", v => show_help = v != null }, }; List <string> eps = opts.Parse(args); if (show_help) { ShowHelp(opts); return; } if (is_verbose) { // Redirect debug log to the console Debug.Listeners.Add(new TextWriterTraceListener(Console.Out)); Debug.AutoFlush = true; } // always the first call to make Phlib.InitializePhLib(); BinaryCache.Instance.Load(); foreach (var peFilePath in eps) { PE Pe = BinaryCache.LoadPe(peFilePath); Console.WriteLine("Loaded PE file : {0:s}", Pe.Filepath); } BinaryCache.Instance.Unload(); }
static void Main(string[] args) { // always the first call to make Phlib.InitializePhLib(); Demangler demangler; switch (args.Length) { case 0: demangler = new Demangler("Microsoft"); TestKnownInputs(demangler); break; case 1: demangler = new Demangler(); TestFilepath(args[0], demangler); break; default: case 2: string demanglerName = args[0].TrimStart(new char[] { '-' }); string Filepath = args[1]; demangler = new Demangler(demanglerName); if (NativeFile.Exists(Filepath)) { TestFilepath(Filepath, demangler); } else { Console.WriteLine(demangler.UndecorateName(args[1])); } break; } }
static void Main(string[] args) { String FileName = null; var ProgramArgs = ParseArgs(args); Action <IPrettyPrintable> ObjectPrinter = PrettyPrinter; // always the first call to make Phlib.InitializePhLib(); if (ProgramArgs.ContainsKey("file")) { FileName = ProgramArgs["file"]; } if (ProgramArgs.ContainsKey("-json")) { ObjectPrinter = JsonPrinter; } // no need to load PE for those commands if ((args.Length == 0) || ProgramArgs.ContainsKey("-h") || ProgramArgs.ContainsKey("-help")) { DumpUsage(); return; } if (ProgramArgs.ContainsKey("-knowndll")) { DumpKnownDlls(ObjectPrinter); return; } if (ProgramArgs.ContainsKey("-apisets")) { DumpApiSets(ObjectPrinter); return; } //Console.WriteLine("[-] Loading file {0:s} ", FileName); PE Pe = new PE(FileName); if (!Pe.Load()) { Console.Error.WriteLine("[x] Could not load file {0:s} as a PE", FileName); return; } if (ProgramArgs.ContainsKey("-manifest")) { DumpManifest(Pe, ObjectPrinter); } else if (ProgramArgs.ContainsKey("-sxsentries")) { DumpSxsEntries(Pe, ObjectPrinter); } else if (ProgramArgs.ContainsKey("-imports")) { DumpImports(Pe, ObjectPrinter); } else if (ProgramArgs.ContainsKey("-exports")) { DumpExports(Pe, ObjectPrinter); } else if (ProgramArgs.ContainsKey("-chain")) { DumpDependencyChain(Pe, ObjectPrinter); } else if (ProgramArgs.ContainsKey("-modules")) { DumpModules(Pe, ObjectPrinter); } }
static void Main(string[] args) { Phlib.InitializePhLib(); var ProgramArgs = ParseArgs(args); String FileName = null; if (ProgramArgs.ContainsKey("file")) { FileName = ProgramArgs["file"]; } if (ProgramArgs.ContainsKey("-verbose")) { VerboseOutput = true; } // no need to load PE for those commands if ((args.Length == 0) || ProgramArgs.ContainsKey("-h") || ProgramArgs.ContainsKey("-help")) { DumpUsage(); return; } if (ProgramArgs.ContainsKey("-knowndll")) { DumpKnownDlls(); return; } if (ProgramArgs.ContainsKey("-apisets")) { DumpApiSets(); return; } VerboseWriteLine("[-] Loading file {0:s} ", FileName); PE Pe = new PE(FileName); if (!Pe.LoadSuccessful) { Console.Error.WriteLine("[x] Could not load file {0:s} as a PE", FileName); return; } if (ProgramArgs.ContainsKey("-manifest")) { DumpManifest(Pe); } if (ProgramArgs.ContainsKey("-sxsentries")) { DumpSxsEntries(Pe); } if (ProgramArgs.ContainsKey("-imports")) { DumpImports(Pe); } if (ProgramArgs.ContainsKey("-exports")) { DumpExports(Pe); } }
static void Main(string[] args) { // always the first call to make Phlib.InitializePhLib(); int recursion_depth = 0; bool early_exit = false; bool show_help = false; bool export_as_json = false; bool use_bin_cache = false; DumpCommand command = null; OptionSet opts = new OptionSet() { { "h|help", "show this message and exit", v => show_help = v != null }, { "json", "Export results in json format", v => export_as_json = v != null }, { "cache", "load and use binary cache to prevent dll file locking", v => use_bin_cache = v != null }, { "d|depth=", "limit recursion depth when analysing loaded modules or dependency chain. Default value is infinite", (int v) => recursion_depth = v }, { "knowndll", "List all known dlls", v => { DumpKnownDlls(GetObjectPrinter(export_as_json)); early_exit = true; } }, { "apisets", "List apisets redirections", v => { DumpApiSets(GetObjectPrinter(export_as_json)); early_exit = true; } }, { "apisetsdll", "List apisets redirections from apisetschema <FILE>", v => command = DumpApiSets }, { "manifest", "show manifest information embedded in <FILE>", v => command = DumpManifest }, { "sxsentries", "dump all of <FILE>'s sxs dependencies", v => command = DumpSxsEntries }, { "imports", "dump <FILE> imports", v => command = DumpImports }, { "exports", "dump <FILE> exports", v => command = DumpExports }, { "assemblyrefs", "dump <FILE> assemblyrefs", v => command = DumpAssemblyReferences }, { "modulerefs", "dump <FILE> modulerefs", v => command = DumpModuleReferences }, { "chain", "dump <FILE> whole dependency chain", v => command = DumpDependencyChain }, { "modules", "dump <FILE> resolved modules", v => command = DumpModules }, }; List <string> eps = opts.Parse(args); if (early_exit) { return; } if ((show_help) || (args.Length == 0) || (command == null)) { DumpUsage(); return; } BinaryCache.InitializeBinaryCache(use_bin_cache); if (eps.Count == 0) { Console.Error.WriteLine("[x] Command {0:s} needs to have a PE <FILE> argument", command.Method.Name); Console.Error.WriteLine(""); DumpUsage(); return; } String FileName = eps[0]; if (!NativeFile.Exists(FileName)) { Console.Error.WriteLine("[x] Could not find file {0:s} on disk", FileName); return; } Debug.WriteLine("[-] Loading file {0:s} ", FileName); PE Pe = new PE(FileName); if (!Pe.Load()) { Console.Error.WriteLine("[x] Could not load file {0:s} as a PE", FileName); return; } command(Pe, GetObjectPrinter(export_as_json), recursion_depth); }