Skip to content

Commit

Permalink
path->wstring in program option inputs
Browse files Browse the repository at this point in the history
because otherwise it wouldn't handle paths with spaces for some reason.

updated --help examples
  • Loading branch information
blole committed Dec 3, 2015
1 parent 43f7b9e commit 31f0afa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion injectory/library.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Library
: Library(boost::filesystem::path(path_))
{}

Library(const wchar_t* path_)
Library(const wstring& path_)
: Library(boost::filesystem::path(path_))
{}

Expand Down
44 changes: 22 additions & 22 deletions injectory/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ namespace po = boost::program_options;

#define VERSION "5.1-SNAPSHOT"

template <typename T>
po::typed_value<vector<T>, wchar_t>* wvector()
{
return po::wvalue<vector<T>>()->multitoken()->default_value({}, "");
}

Process proc;

int main(int argc, char *argv[])
Expand All @@ -26,8 +32,8 @@ int main(int argc, char *argv[])
"<exe> and <dll> can be relative paths\n"
"\n"
"Examples:\n"
" injectory -l a.exe -i b.dll --args \"1 2 3\" --wii\n"
" injectory -p 12345 -i b.dll --mm --wait-for-exit\n"
" injectory --launch a.exe -map b.dll --args \"1 2 3\"\n"
" injectory --pid 12345 -inject b.dll --wait-for-exit\n"
"\n"
"Options");

Expand All @@ -36,22 +42,16 @@ int main(int argc, char *argv[])
//("procname", po::value<string>()->value_name("NAME"), "injection via process name")
//("wndtitle", po::value<string>()->value_name("TITLE"), "injection via window title")
//("wndclass", po::value<string>()->value_name("CLASS"), "injection via window class")
("launch,l", po::value<path>()->value_name("EXE"), "launches the target in a new process")
("launch,l", po::wvalue<wstring>()->value_name("EXE"), "launches the target in a new process")
("args,a", po::wvalue<wstring>()->value_name("STRING")->default_value(L"", ""),
"arguments for --launch:ed process\n")

("inject,i", po::value<vector<path>>()->value_name("DLL...")->multitoken()->default_value(vector<path>(),""),
"inject libraries before main")
("injectw,I", po::value<vector<path>>()->value_name("DLL...")->multitoken()->default_value(vector<path>(), ""),
"inject libraries when input idle")
("map,m", po::value<vector<path>>()->value_name("DLL...")->multitoken()->default_value(vector<path>(),""),
"map file into target before main")
("mapw,M", po::value<vector<path>>()->value_name("DLL...")->multitoken()->default_value(vector<path>(), ""),
"map file into target when input idle")
("eject,e", po::value<vector<path>>()->value_name("DLL...")->multitoken()->default_value(vector<path>(), ""),
"eject libraries before main")
("ejectw,E", po::value<vector<path>>()->value_name("DLL...")->multitoken()->default_value(vector<path>(), ""),
"eject libraries when input idle\n")
("inject,i", wvector<wstring>()->value_name("DLL..."), "inject libraries before main")
("injectw,I", wvector<wstring>()->value_name("DLL..."), "inject libraries when input idle")
("map,m", wvector<wstring>()->value_name("DLL..."), "map file into target before main")
("mapw,M", wvector<wstring>()->value_name("DLL..."), "map file into target when input idle")
("eject,e", wvector<wstring>()->value_name("DLL..."), "eject libraries before main")
("ejectw,E", wvector<wstring>()->value_name("DLL..."), "eject libraries when input idle\n")

("print-own-pid", "print the pid of this process")
("print-pid", "print the pid of the target process")
Expand Down Expand Up @@ -104,7 +104,7 @@ int main(int argc, char *argv[])
else if (vars.count("launch"))
{
using boost::none;
path app = vars["launch"].as<path>();
path app = vars["launch"].as<wstring>();
wstring args = vars["args"].as<wstring>();

proc = Process::launch(app, args, none, none, false, CREATE_SUSPENDED).process;
Expand Down Expand Up @@ -134,12 +134,12 @@ int main(int argc, char *argv[])
job.setInfo(JobObjectExtendedLimitInformation, jeli);
}

auto& inject = vars["inject"] .as<vector<path>>();
auto& map = vars["map"] .as<vector<path>>();
auto& eject = vars["eject"] .as<vector<path>>();
auto& injectw = vars["injectw"].as<vector<path>>();
auto& mapw = vars["mapw"] .as<vector<path>>();
auto& ejectw = vars["ejectw"] .as<vector<path>>();
auto& inject = vars["inject"] .as<vector<wstring>>();
auto& map = vars["map"] .as<vector<wstring>>();
auto& eject = vars["eject"] .as<vector<wstring>>();
auto& injectw = vars["injectw"].as<vector<wstring>>();
auto& mapw = vars["mapw"] .as<vector<wstring>>();
auto& ejectw = vars["ejectw"] .as<vector<wstring>>();

for (const Library& lib : inject) proc.inject(lib, verbose);
for (const Library& lib : map) proc.mapRemoteModule(lib, verbose);
Expand Down
1 change: 0 additions & 1 deletion output.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<ItemGroup>
<BuildMacro Include="BuildDir">
<Value>$(BuildDir)</Value>
<EnvironmentVariable>true</EnvironmentVariable>
</BuildMacro>
</ItemGroup>
</Project>

0 comments on commit 31f0afa

Please # to comment.