diff --git a/GM/Program.cs b/GM/Program.cs index 345b388..59521b2 100644 --- a/GM/Program.cs +++ b/GM/Program.cs @@ -36,6 +36,9 @@ class Options [Option(SetName = "path", HelpText = "Program arguments.")] public string Arguments { get; set; } + [Option(SetName = "path", HelpText = "Set the working directory (Default: %SYSTEMROOT%\\system32)")] + public string WorkingDirectory { get; set; } + [Option(SetName = "path", HelpText = "Wait before attaching (ms).")] public int Delay { get; set; } @@ -207,6 +210,7 @@ static void RunOptions(Options opts) path: opts.Path, dataBasePath: opts.DBPath, args: opts.Arguments, + workingDirectory: opts.WorkingDirectory, delay: opts.Delay, dumpInterval: opts.Interval, dumpCount: opts.Count, diff --git a/GMLib/Collector.cs b/GMLib/Collector.cs index 68cbf0d..55051d8 100644 --- a/GMLib/Collector.cs +++ b/GMLib/Collector.cs @@ -29,6 +29,7 @@ public class Collector public int Count { get; set; } public string Path { get; set; } public string Args { get; set; } + public string WorkingDirectory { get; set; } public int Delay { get; set; } public string CrashDump { get; set; } public int Pid { get; set; } @@ -80,9 +81,11 @@ public Collector( DataBasePath = dataBasePath; } + // Added the option to set the working directory for the process public Collector( string path, string args, + string workingDirectory, int delay = 500, uint flags = Constants.COLLECT_EVERYTHING, uint initialFlags = Constants.COLLECT_EVERYTHING, @@ -92,6 +95,7 @@ public Collector( { Path = path; Args = args; + WorkingDirectory = workingDirectory; Delay = delay; Interval = dumpInterval; Count = dumpCount; @@ -158,6 +162,8 @@ public int Run() proc.StartInfo.FileName = Path; if (Args != null) proc.StartInfo.Arguments = Args; + if (WorkingDirectory != null) + proc.StartInfo.WorkingDirectory = WorkingDirectory; proc.StartInfo.CreateNoWindow = true; proc.Start(); Pid = proc.Id; diff --git a/GarbageMan/GarbageMan.csproj b/GarbageMan/GarbageMan.csproj index 2c490e0..fb9fd86 100644 --- a/GarbageMan/GarbageMan.csproj +++ b/GarbageMan/GarbageMan.csproj @@ -10,7 +10,7 @@ .NET heap analyzer MIT - 0.2.2 + 0.2.3 diff --git a/GarbageMan/RunExecutable.xaml b/GarbageMan/RunExecutable.xaml index 468ce40..1bc509a 100644 --- a/GarbageMan/RunExecutable.xaml +++ b/GarbageMan/RunExecutable.xaml @@ -5,20 +5,22 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:GarbageMan" mc:Ignorable="d" Closing="RunExecutable_Closing" - Title="RunExecutable" Height="400" Width="400" Icon="assets/Recycle.ico"> + Title="RunExecutable" Height="440" Width="400" Icon="assets/Recycle.ico"> - - - - - - - - + + + + + + + + + + - + @@ -26,9 +28,9 @@ -