137 if (vm.count(
"help"))
143 std::string
const binary_path(std::move(vm[
"path"].as<std::string>()));
144 std::string renamed_binary_path(binary_path);
146 std::cout <<
"Creating patched binary..." << std::endl;
148 Patcher patcher(binary_path);
154 if (wowBuild == 0 || wowBuild < 10000 || wowBuild > 65535)
155 throw std::runtime_error(
"Build number was out of range. Build: " + std::to_string(wowBuild));
157 std::cout <<
"Determined build number: " << std::to_string(wowBuild) << std::endl;
159 switch (patcher.GetType())
161 case Constants::BinaryTypes::Pe32:
162 std::cout <<
"Win32 client...\n";
164 boost::algorithm::replace_all(renamed_binary_path,
".exe",
"_Patched.exe");
165 do_patches<Patches::Windows::x86, Patterns::Windows::x86>
166 (&patcher, renamed_binary_path, wowBuild);
167 WriteCertificateBundle(boost::filesystem::path(binary_path).remove_filename() /
"tc_bundle.txt");
169 case Constants::BinaryTypes::Pe64:
170 std::cout <<
"Win64 client...\n";
172 boost::algorithm::replace_all(renamed_binary_path,
".exe",
"_Patched.exe");
173 do_patches<Patches::Windows::x64, Patterns::Windows::x64>
174 (&patcher, renamed_binary_path, wowBuild);
175 WriteCertificateBundle(boost::filesystem::path(binary_path).remove_filename() /
"tc_bundle.txt");
177 case Constants::BinaryTypes::Mach64:
178 std::cout <<
"Mac client...\n";
180 boost::algorithm::replace_all(renamed_binary_path,
".app",
" Patched.app");
181 Helper::CopyDir(boost::filesystem::path(binary_path).parent_path().parent_path().parent_path()
182 , boost::filesystem::path(renamed_binary_path).parent_path().parent_path().parent_path()
185 do_patches<Patches::Mac::x64, Patterns::Mac::x64>
186 (&patcher, renamed_binary_path, wowBuild);
190 fs::permissions(renamed_binary_path, fs::add_perms | fs::others_exe | fs::group_exe | fs::owner_exe);
192 WriteCertificateBundle(boost::filesystem::path(binary_path).parent_path().parent_path().parent_path().parent_path() /
"tc_bundle.txt");
195 throw std::runtime_error(
"Type: " + std::to_string(static_cast<uint32_t>(patcher.GetType())) +
" not supported!");
198 std::cout <<
"Successfully created your patched binaries.\n";
202 catch (std::exception
const& ex)
204 std::cerr <<
"EX: " << ex.what() << std::endl;
205 std::cerr <<
"An error occurred. Press ENTER to continue...";
void CopyDir(boost::filesystem::path const &source, boost::filesystem::path const &destination)
Definition: Helper.cpp:26
po::variables_map GetConsoleArguments(int argc, char **argv)
Definition: Program.cpp:96
Definition: Helper.cpp:21
uint32_t GetBuildNumber(std::vector< unsigned char > const &binary)
Definition: Helper.cpp:169