├── .gitignore ├── README.md ├── VScriptAutoPatcher.sln └── VScriptAutoPatcher ├── VScriptAutoPatcher.cpp ├── VScriptAutoPatcher.vcxproj ├── VScriptAutoPatcher.vcxproj.filters └── VScriptAutoPatcher.vcxproj.user /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Visual Studio 35 | /.vs 36 | x64/ 37 | x86/ 38 | build/ 39 | VScriptAutoPatcher/x64 40 | VScriptAutoPatcher/x86 41 | *.vcxproj.user 42 | 43 | # Visual Studio Code 44 | .vscode/ 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CS2-VScript-Patcher 2 | 3 | ## Usage 4 | 5 | One-click tool to enable VScript function for mappers who can't use CS2Fixes etc. 6 | 7 | ## Tutorial 8 | 9 | Place this into your game folder (or where u want) then run it. 10 | 11 | e.g. G:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\game 12 | 13 | ## Credits 14 | 15 | [RealSkid - Client.dll automated patch](https://www.unknowncheats.me/forum/counter-strike-2-a/587993-client-dll-automated-patch.html) 16 | 17 | [Source2ZE - CS2Fixes](https://github.com/Source2ZE/CS2Fixes) 18 | -------------------------------------------------------------------------------- /VScriptAutoPatcher.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.8.34316.72 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VScriptAutoPatcher", "VScriptAutoPatcher\VScriptAutoPatcher.vcxproj", "{B05FC70F-BEC8-46C8-B6D5-B509D26CA55D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {B05FC70F-BEC8-46C8-B6D5-B509D26CA55D}.Debug|x64.ActiveCfg = Debug|x64 17 | {B05FC70F-BEC8-46C8-B6D5-B509D26CA55D}.Debug|x64.Build.0 = Debug|x64 18 | {B05FC70F-BEC8-46C8-B6D5-B509D26CA55D}.Debug|x86.ActiveCfg = Debug|Win32 19 | {B05FC70F-BEC8-46C8-B6D5-B509D26CA55D}.Debug|x86.Build.0 = Debug|Win32 20 | {B05FC70F-BEC8-46C8-B6D5-B509D26CA55D}.Release|x64.ActiveCfg = Release|x64 21 | {B05FC70F-BEC8-46C8-B6D5-B509D26CA55D}.Release|x64.Build.0 = Release|x64 22 | {B05FC70F-BEC8-46C8-B6D5-B509D26CA55D}.Release|x86.ActiveCfg = Release|Win32 23 | {B05FC70F-BEC8-46C8-B6D5-B509D26CA55D}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {6BBE60E8-380D-4EF5-999E-E3474CE54BD0} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /VScriptAutoPatcher/VScriptAutoPatcher.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #ifdef _WIN32 8 | #include 9 | #include 10 | 11 | static std::string SelectPEFile() 12 | { 13 | TCHAR szBuffer[MAX_PATH] = { 0 }; 14 | OPENFILENAME file = { 0 }; 15 | 16 | ZeroMemory(&file, sizeof(file)); 17 | 18 | file.hwndOwner = NULL; 19 | file.lStructSize = sizeof(file); 20 | file.lpstrFilter = L"vscript.dll(vscript.dll)\0vscript.dll\0所有文件(*.*)\0*.*\0\0"; 21 | file.lpstrInitialDir = L""; 22 | file.lpstrFile = szBuffer; 23 | file.nMaxFile = sizeof(szBuffer) / sizeof(*szBuffer); 24 | file.nFilterIndex = 0; 25 | file.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; 26 | 27 | if (GetOpenFileName(&file)) 28 | { 29 | int size = WideCharToMultiByte(CP_ACP, 0, file.lpstrFile, -1, NULL, 0, NULL, NULL); 30 | if (size == 0) 31 | { 32 | return std::string(); 33 | } 34 | std::string result(size - 1, 0); 35 | WideCharToMultiByte(CP_ACP, 0, file.lpstrFile, -1, &result[0], size, NULL, NULL); 36 | return result; 37 | } 38 | else 39 | { 40 | return std::string(); 41 | } 42 | } 43 | 44 | static void Pause() 45 | { 46 | std::cout << "Press any key to continue..." << std::flush; 47 | (void)_getch(); 48 | } 49 | 50 | #else 51 | 52 | static void Pause() 53 | { 54 | 55 | } 56 | 57 | #endif // _WIN32 58 | 59 | static bool readFile(const std::string & fileName, std::vector & buffer) 60 | { 61 | std::ifstream file(fileName, std::ios::binary); 62 | 63 | if (!file.is_open()) 64 | { 65 | std::cerr << "[ERROR] " << "Failed to open file: " << fileName << std::endl; 66 | return false; 67 | } 68 | 69 | file.seekg(0, std::ios::end); 70 | std::streamsize fileSize = file.tellg(); 71 | file.seekg(0, std::ios::beg); 72 | 73 | buffer.resize(static_cast(fileSize)); 74 | file.read(reinterpret_cast(buffer.data()), fileSize); 75 | 76 | file.close(); 77 | return true; 78 | } 79 | 80 | static std::vector findHexArray(const std::vector & buffer, const std::vector & hexArray) 81 | { 82 | std::vector positions; 83 | 84 | size_t bufferSize = buffer.size(); 85 | size_t arraySize = hexArray.size(); 86 | 87 | for (size_t i = 0; i <= bufferSize - arraySize; ++i) 88 | { 89 | if (std::ranges::equal(buffer.begin() + i, buffer.begin() + i + arraySize, hexArray.begin(), hexArray.end(), 90 | [](uint8_t a, uint8_t b) 91 | { 92 | return a == b || b == 0x2A; 93 | })) 94 | { 95 | std::cout << "[INFO] " << "Found position at buffer index: " << i << std::endl; 96 | positions.push_back(i); 97 | } 98 | } 99 | 100 | return positions; 101 | } 102 | 103 | static bool writeFile(const std::string & fileName, const std::vector & buffer) 104 | { 105 | std::ofstream file(fileName, std::ios::binary); 106 | 107 | if (!file.is_open()) 108 | { 109 | std::cerr << "[ERROR] " << "Failed to open file: " << fileName << std::endl; 110 | return false; 111 | } 112 | 113 | file.write(reinterpret_cast(buffer.data()), buffer.size()); 114 | 115 | file.close(); 116 | 117 | return true; 118 | } 119 | 120 | static void patchFile(const std::string & fileName, const std::vector & originalArray, const std::vector & replacedArray) 121 | { 122 | std::vector buffer; 123 | 124 | if (!readFile(fileName, buffer)) 125 | { 126 | return; 127 | } 128 | 129 | std::vector positions = findHexArray(buffer, originalArray); 130 | 131 | if (positions.empty()) 132 | { 133 | std::cerr << "[ERROR] " << fileName << " is already patched" << std::endl; 134 | return; 135 | } 136 | 137 | if (std::filesystem::exists(fileName + ".bak")) 138 | { 139 | std::filesystem::remove(fileName + ".bak"); 140 | } 141 | std::filesystem::copy(fileName, fileName + ".bak"); 142 | 143 | for (size_t pos : positions) 144 | { 145 | std::ranges::copy(replacedArray.begin(), replacedArray.end(), buffer.begin() + pos); 146 | } 147 | 148 | if (!writeFile(fileName, buffer)) 149 | { 150 | return; 151 | } 152 | 153 | std::cout << "[SUCCESS] " << fileName << " has been patched." << std::endl; 154 | } 155 | 156 | int main(int argc, const char * const * argv) 157 | { 158 | std::string filePath; 159 | 160 | SetConsoleTitleA("黄埔军校 VScript Patcher"); 161 | 162 | std::cout << "[VScript Patcher]" << std::endl; 163 | std::cout << "Created by Kroytz (https://github.com/Kroytz)" << std::endl; 164 | std::cout << "Method from Source2ZE (https://github.com/Source2ZE/CS2Fixes)" << std::endl; 165 | std::cout << "Code mainly from RealSkid (https://www.unknowncheats.me/forum/members/3339879.html)" << std::endl; 166 | //std::cout << "Place this executable in your folder" << std::endl; 167 | std::cout << " " << std::endl; 168 | std::cout << " " << std::endl; 169 | 170 | //PatchFile(filePath, { 0xBE, 0x01, 0x2A, 0x2A, 0x2A, 0x2B, 0xD6, 0x74, 0x2A, 0x3B, 0xD6 }, { 0xBE, 0x02 }); 171 | 172 | try 173 | { 174 | if (argc > 1) 175 | { 176 | filePath = argv[1]; 177 | if (!std::filesystem::exists(filePath)) 178 | { 179 | std::cerr << "Specified file path does not exist." << std::endl; 180 | return 2; 181 | } 182 | } 183 | else 184 | { 185 | filePath = "./bin/win64/vscript.dll"; 186 | } 187 | #ifdef _WIN32 188 | if (!std::filesystem::exists(filePath)) 189 | { 190 | filePath = SelectPEFile(); 191 | } 192 | #endif // _WIN32 193 | if (std::filesystem::exists(filePath)) 194 | { 195 | patchFile(filePath, { 0xBE, 0x01, 0x2A, 0x2A, 0x2A, 0x2B, 0xD6, 0x74, 0x2A, 0x3B, 0xD6 }, { 0xBE, 0x02 }); 196 | } 197 | else 198 | { 199 | std::cerr << "File doesn't exist" << std::endl; 200 | return 2; 201 | } 202 | } 203 | catch (const std::exception & e) 204 | { 205 | std::cerr << "An error occurred: " << e.what() << std::endl; 206 | 207 | Pause(); 208 | 209 | return 1; 210 | } 211 | 212 | std::cout << " " << std::endl; 213 | std::cout << " " << std::endl; 214 | 215 | //system("pause"); 216 | Pause(); 217 | 218 | return 0; 219 | } -------------------------------------------------------------------------------- /VScriptAutoPatcher/VScriptAutoPatcher.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 17.0 23 | Win32Proj 24 | {b05fc70f-bec8-46c8-b6d5-b509d26ca55d} 25 | VScriptAutoPatcher 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | true 77 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 78 | true 79 | 80 | 81 | Console 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | true 89 | true 90 | true 91 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | true 93 | 94 | 95 | Console 96 | true 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 106 | true 107 | stdcpplatest 108 | 109 | 110 | Console 111 | true 112 | 113 | 114 | 115 | 116 | Level3 117 | true 118 | true 119 | true 120 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | true 122 | stdcpp20 123 | 124 | 125 | Console 126 | true 127 | true 128 | true 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /VScriptAutoPatcher/VScriptAutoPatcher.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /VScriptAutoPatcher/VScriptAutoPatcher.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | --------------------------------------------------------------------------------