Skip to content

Commit 9fe40ec

Browse files
committed
Refactor CLI argument parsing to use -- delimiter
Replace `--args="..."` flag with standard `--` delimiter for passing arguments to the target executable. This follows conventional CLI patterns where arguments after `--` are forwarded directly to the spawned process rather than being parsed by Syringe. Changes: - Update usage message to reflect new `--` syntax - Modify `parse_command_line` to recognize `--` as the delimiter - Append all arguments after `--` to the game arguments string - Remove deprecated `--args=` flag handling Signed-off-by: 舰队的偶像-岛风酱 <frg2089@outlook.com>
1 parent 54be1c3 commit 9fe40ec

3 files changed

Lines changed: 20 additions & 12 deletions

File tree

Main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int Run(const std::vector<std::string>& arguments)
8484
{
8585
MessageBoxA(
8686
nullptr, "Syringe cannot be run like that.\n\n"
87-
"Usage:\nSyringe.exe <exe name> [-i=<injectedfile.dll> ...] [--args=\"<arguments>\"]",
87+
"Usage:\nSyringe.exe <exe name> [-i=<injectedfile.dll> ...] [-- <arguments>]",
8888
VersionString, MB_OK | MB_ICONINFORMATION);
8989

9090
Log::WriteLine(

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ syringe.exe game.exe
3030

3131
### Passing Arguments to the Target Executable
3232

33-
Use `--args="..."` to provide arguments for the launched process:
33+
Use `--` as a delimiter to pass arguments to the launched process. All arguments after `--` will be forwarded directly to the target executable:
3434

3535
```
36-
syringe.exe game.exe --args="-CD. -SPAWN"
36+
syringe.exe game.exe -- -CD. -SPAWN
3737
```
3838

3939
### DLL Injection Behavior

Support.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ inline auto trim(std::string_view string) noexcept
2828

2929
inline auto parse_command_line(const std::vector<std::string>& arguments)
3030
{
31-
static constexpr std::string_view ARGS_FLAG = "--args=";
32-
3331
struct argument_set
3432
{
3533
std::vector<std::string> syringe_arguments;
@@ -45,6 +43,8 @@ inline auto parse_command_line(const std::vector<std::string>& arguments)
4543
// First non-flag argument becomes executable name
4644
bool exe_found = false;
4745

46+
bool exe_arguments = false;
47+
4848
for (const auto& arg : arguments)
4949
{
5050
// executable name: first argument not starting with '-'
@@ -55,22 +55,30 @@ inline auto parse_command_line(const std::vector<std::string>& arguments)
5555
continue;
5656
}
5757

58-
// game arguments: --args="blob"
59-
if (arg.starts_with(ARGS_FLAG))
58+
if (arg == "--")
6059
{
61-
// extract after --args=
62-
std::string blob = arg.substr(ARGS_FLAG.size());
63-
ret.game_arguments = blob;
60+
exe_arguments = true;
6461
continue;
6562
}
6663

67-
// Syringe arguments
68-
ret.syringe_arguments.push_back(arg);
64+
if (exe_arguments)
65+
{
66+
// game arguments
67+
ret.game_arguments += " ";
68+
ret.game_arguments += arg;
69+
}
70+
else
71+
{
72+
// Syringe arguments
73+
ret.syringe_arguments.push_back(arg);
74+
}
6975
}
7076

7177
if (!exe_found || ret.executable_name.empty())
7278
throw invalid_command_arguments{};
7379

80+
ret.game_arguments = ret.game_arguments.substr(1);
81+
7482
return ret;
7583
}
7684

0 commit comments

Comments
 (0)