Skip to content

Commit 83e3ec6

Browse files
committed
Add support for quoted arguments in CLI parsing
Handle quoted strings in command-line arguments to properly parse paths with spaces. Both executable names and injection DLL paths can now be wrapped in double quotes. Changes: - Strip surrounding quotes from executable name if present - Parse `-i="path with spaces.dll"` format by removing quotes - Preserve argument integrity when paths contain spaces Signed-off-by: 舰队的偶像-岛风酱 <frg2089@outlook.com>
1 parent dd41765 commit 83e3ec6

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

Support.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,18 @@ inline auto parse_command_line(const std::vector<std::string>& arguments)
4444
bool exe_found = false;
4545

4646
bool exe_arguments = false;
47-
47+
4848
for (const auto& arg : arguments)
4949
{
5050
// executable name: first argument not starting with '-'
5151
if (!exe_found && !arg.starts_with("-"))
5252
{
5353
exe_found = true;
54-
ret.executable_name = arg;
54+
if (arg.starts_with('"') && arg.ends_with('"'))
55+
ret.executable_name = arg.substr(1, arg.length() - 2);
56+
else
57+
ret.executable_name = arg;
58+
5559
continue;
5660
}
5761

@@ -70,7 +74,10 @@ inline auto parse_command_line(const std::vector<std::string>& arguments)
7074
else
7175
{
7276
// Syringe arguments
73-
ret.syringe_arguments.push_back(arg);
77+
if (arg.starts_with("-i=\"") && arg.ends_with('"'))
78+
ret.syringe_arguments.push_back("-i=" + arg.substr(4, arg.length() - 5));
79+
else
80+
ret.syringe_arguments.push_back(arg);
7481
}
7582
}
7683

0 commit comments

Comments
 (0)