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 @@
-
+
-
+
@@ -36,11 +38,19 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
@@ -56,7 +66,7 @@
-
+
@@ -78,7 +88,7 @@
-
+
@@ -88,7 +98,7 @@
-
+
@@ -98,7 +108,7 @@
-
+
diff --git a/GarbageMan/RunExecutable.xaml.cs b/GarbageMan/RunExecutable.xaml.cs
index d9cd5e3..c085907 100644
--- a/GarbageMan/RunExecutable.xaml.cs
+++ b/GarbageMan/RunExecutable.xaml.cs
@@ -94,6 +94,7 @@ private void RunExecutableStartButton_Click(object sender, RoutedEventArgs e)
// Get all the settings
string path = RunExecutablePathTextBox.Text;
string args = RunExectableArgsTextBox.Text;
+ string workingDirectory = RunExectableWorkingDirTextBox.Text;
int delay = int.Parse((RunExecutableDelayTextBox.Text == "") ? "" : RunExecutableDelayTextBox.Text);
int count = int.Parse((RunExecutableSnapshotCountTextBox.Text == "") ? "1" : RunExecutableSnapshotCountTextBox.Text);
int interval = int.Parse((RunExecutableSnapshotIntervalTextBox.Text == "") ? "0" : RunExecutableSnapshotIntervalTextBox.Text);
@@ -121,7 +122,9 @@ private void RunExecutableStartButton_Click(object sender, RoutedEventArgs e)
{
string cmdLine = $"--path \"{path}\" --delay {delay} --dbpath {RealPath} --items {initialFlags} ";
if (args != "")
- cmdLine += $"--arguments \"{args}\" ";
+ cmdLine += $"--arguments=\"{args}\" ";
+ if (workingDirectory != "")
+ cmdLine += $"--workingdirectory=\"{workingDirectory}\" ";
if (count > 1)
cmdLine += $"--count {count} --interval {interval} --nextitems {nextFlags}";
diff --git a/README.md b/README.md
index a2d3ce4..577b5fb 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,8 @@ Crash course:
If you need to use `psnotify` for dumping, you need to extract it to `C:\psnotify` (yes, that's fixed for now). Just run `psnotify.exe` and stop it with `Ctrl+C` when done. It will create minidumps in `C:\dumps`. You can later then analyze those dumps with GarbageMan.
+**Note**: If you'd like to specify a working directory for the program to execute from, make sure psnotify isn't running as it will conflict with GarbageMan.
+
## How to compile the GUI tool