From 11b2f605863039f4e5f24d7703ed56339b7b130f Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Sun, 29 Sep 2019 16:59:45 +0200 Subject: [PATCH] Tools/Patcher: fixed x86 windows patterns and fixed patching battle.net dll file --- .../connection_patcher/Patches/Common.hpp | 2 +- .../connection_patcher/Patterns/Common.hpp | 2 +- .../connection_patcher/Patterns/Windows.hpp | 4 +- src/tools/connection_patcher/Program.cpp | 55 ++++++++++++++++--- 4 files changed, 51 insertions(+), 12 deletions(-) diff --git a/src/tools/connection_patcher/Patches/Common.hpp b/src/tools/connection_patcher/Patches/Common.hpp index 24472422df0..b409995aa20 100644 --- a/src/tools/connection_patcher/Patches/Common.hpp +++ b/src/tools/connection_patcher/Patches/Common.hpp @@ -27,7 +27,7 @@ namespace Connection_Patcher { struct Common { - static const std::vector Portal() { return { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; } + static const std::vector Portal() { return { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; } static const std::vector Modulus() { return diff --git a/src/tools/connection_patcher/Patterns/Common.hpp b/src/tools/connection_patcher/Patterns/Common.hpp index ddb9b08aea4..6f1f64ec8c5 100644 --- a/src/tools/connection_patcher/Patterns/Common.hpp +++ b/src/tools/connection_patcher/Patterns/Common.hpp @@ -27,7 +27,7 @@ namespace Connection_Patcher { struct Common { - static const std::vector Portal() { return { '.', 'l', 'o', 'g', 'o', 'n', '.', 'b', 'a', 't', 't', 'l', 'e', '.', 'n', 'e', 't', 0x00 }; } + static const std::vector Portal() { return { '.', 'l', 'o', 'g', 'o', 'n', '.', 'b', 'a', 't', 't', 'l', 'e', '.', 'n', 'e', 't' }; } static const std::vector Modulus() { return { 0x91, 0xD5, 0x9B, 0xB7, 0xD4, 0xE1, 0x83, 0xA5 }; } }; } diff --git a/src/tools/connection_patcher/Patterns/Windows.hpp b/src/tools/connection_patcher/Patterns/Windows.hpp index 024cdb2a0e7..3c1b6c706f5 100644 --- a/src/tools/connection_patcher/Patterns/Windows.hpp +++ b/src/tools/connection_patcher/Patterns/Windows.hpp @@ -29,9 +29,9 @@ namespace Connection_Patcher { struct x86 { - static const std::vector BNet() { return { 0x8B, 0x75, 0x08, 0x8D, 0x78, 0x0C }; } + static const std::vector BNet() { return { 0x8B, 0x55, 0x08, 0x89, 0x48, 0x08 }; } static const std::vector Password() { return { 0x74, 0x89, 0x8B, 0x16, 0x8B, 0x42, 0x04 }; } - static const std::vector Signature() { return { 0xE8, 0x00, 0x00, 0x00, 0x00, 0x84, 0xC0, 0x75, 0x5F, 0x33, 0xC0 }; } + static const std::vector Signature() { return { 0xE8, 0x00, 0x00, 0x00, 0x00, 0x84, 0xC0, 0x0F, 0x085, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x85, 0xF0, 0xBD, 0xFF, 0xFF }; } }; struct x64 diff --git a/src/tools/connection_patcher/Program.cpp b/src/tools/connection_patcher/Program.cpp index fd7cdae17e0..f8fc32b7269 100644 --- a/src/tools/connection_patcher/Program.cpp +++ b/src/tools/connection_patcher/Program.cpp @@ -101,14 +101,28 @@ namespace Connection_Patcher } template - void do_patches(Patcher* patcher, boost::filesystem::path output) + void do_client_patches(Patcher* patcher, boost::filesystem::path output) { + std::cout << "Patching client binary...\n"; + + std::cout << "patching redirect RSA Modulus\n"; + patcher->Patch(Patches::Common::Modulus(), Patterns::Common::Modulus()); + patcher->Finish(output); + + std::cout << "Patching done.\n"; + } + + template + void do_dll_patches(Patcher* patcher, boost::filesystem::path output) + { + std::cout << "Patching battle.net binary...\n"; + std::cout << "patching Portal\n"; patcher->Patch(Patches::Common::Portal(), Patterns::Common::Portal()); - std::cout << "patching redirect RSA Modulus\n"; - patcher->Patch(Patches::Common::Modulus(), Patterns::Common::Modulus()); - std::cout << "patching BNet\n"; + + std::cout << "patching Bnet\n"; patcher->Patch(PATCH::BNet(), PATTERN::BNet()); + std::cout << "patching Signature\n"; patcher->Patch(PATCH::Signature(), PATTERN::Signature()); patcher->Finish(output); @@ -220,7 +234,6 @@ int main(int argc, char** argv) throw std::invalid_argument("Wrong number of arguments: Missing client file."); std::string const binary_path(argv[1]); - std::string renamed_binary_path(binary_path); wchar_t* commonAppData(nullptr); @@ -235,31 +248,57 @@ int main(int argc, char** argv) switch (patcher.Type) { case Constants::BinaryTypes::Pe32: + { std::cout << "Win32 client...\n"; boost::algorithm::replace_all(renamed_binary_path, ".exe", "_Patched.exe"); - do_patches + do_client_patches (&patcher, renamed_binary_path); + boost::filesystem::path p(binary_path); + p.remove_filename(); + p.append("Battle.net.dll"); + + std::string renamed_dll_path(p.string()); + Patcher bnetPatcher(p.string()); + + boost::algorithm::replace_all(renamed_dll_path, ".dll", "_Patched.dll"); + do_dll_patches + (&bnetPatcher, renamed_dll_path); + do_module ("8f52906a2c85b416a595702251570f96d3522f39237603115f2f1ab24962043c.auth" , std::wstring(commonAppData) + std::wstring(L"/Blizzard Entertainment/Battle.net/Cache/") ); break; + } case Constants::BinaryTypes::Pe64: + { std::cout << "Win64 client...\n"; boost::algorithm::replace_all(renamed_binary_path, ".exe", "_Patched.exe"); - do_patches + do_client_patches (&patcher, renamed_binary_path); + boost::filesystem::path p(binary_path); + p.remove_filename(); + p.append("Battle.net-64.dll"); + + std::string renamed_dll_path(p.string()); + Patcher bnetPatcher(p.string()); + + boost::algorithm::replace_all(renamed_dll_path, ".dll", "_Patched.dll"); + do_dll_patches + (&bnetPatcher, renamed_dll_path); + do_module ("0a3afee2cade3a0e8b458c4b4660104cac7fc50e2ca9bef0d708942e77f15c1d.auth" , std::wstring(commonAppData) + std::wstring(L"/Blizzard Entertainment/Battle.net/Cache/") ); break; + } case Constants::BinaryTypes::Mach64: std::cout << "Mac client...\n"; @@ -268,7 +307,7 @@ int main(int argc, char** argv) , boost::filesystem::path(renamed_binary_path).parent_path()/*MacOS*/.parent_path()/*Contents*/.parent_path() ); - do_patches + do_client_patches (&patcher, renamed_binary_path); do_module