Skip to content

Commit 726ff56

Browse files
committed
initial commit
1 parent e59896c commit 726ff56

File tree

6 files changed

+350
-1
lines changed

6 files changed

+350
-1
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
# CS2-VScript-Patcher
2-
For mappers
2+
## Usage
3+
One-click tool to enable VScript function for mappers who can't use CS2Fixes etc.
4+
5+
## Tutorial
6+
Place this into your game folder then run it.
7+
e.g. G:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\game
8+
9+
## Credits
10+
[RealSkid - Client.dll automated patch](https://www.unknowncheats.me/forum/counter-strike-2-a/587993-client-dll-automated-patch.html)
11+
[Source2ZE - CS2Fixes](https://github.com/Source2ZE/CS2Fixes)

VScriptAutoPatcher.sln

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#include <iostream>
2+
#include <Windows.h>
3+
#include <vector>
4+
#include <cstdint>
5+
6+
bool readFile(const std::string& filename, std::vector<uint8_t>& buffer)
7+
{
8+
HANDLE fileHandle = CreateFileA(
9+
filename.c_str(),
10+
GENERIC_READ,
11+
FILE_SHARE_READ,
12+
NULL,
13+
OPEN_EXISTING,
14+
FILE_ATTRIBUTE_NORMAL,
15+
NULL
16+
);
17+
18+
if (fileHandle == INVALID_HANDLE_VALUE)
19+
{
20+
std::cerr << "[ERROR] " << "Failed to create handle to: " << filename << std::endl;
21+
//std::cout << "[REMINDER] " << "Make sure the executable is in same folder with: " << filename << std::endl;
22+
return false;
23+
}
24+
25+
DWORD fileSize = GetFileSize(fileHandle, NULL);
26+
buffer.resize(fileSize);
27+
28+
DWORD bytesRead = 0;
29+
ReadFile(fileHandle, buffer.data(), fileSize, &bytesRead, NULL);
30+
31+
CloseHandle(fileHandle);
32+
33+
return true;
34+
}
35+
36+
std::vector<size_t> findHexArray(std::vector<uint8_t>& buffer, const std::vector<uint8_t>& hexArray)
37+
{
38+
std::vector<size_t> positions;
39+
40+
size_t bufferSize = buffer.size();
41+
size_t arraySize = hexArray.size();
42+
43+
for (size_t i = 0; i <= bufferSize - arraySize; ++i)
44+
{
45+
bool found = true;
46+
47+
for (size_t j = 0; j < arraySize; ++j) {
48+
if (buffer[i + j] != hexArray[j] && hexArray[j] != 0x2a) {
49+
found = false;
50+
break;
51+
}
52+
}
53+
54+
if (found)
55+
{
56+
for (size_t j = 0; j < arraySize; ++j) {
57+
buffer[i + j] = hexArray[j];
58+
}
59+
60+
positions.push_back(i);
61+
}
62+
}
63+
64+
return positions;
65+
}
66+
67+
bool writeFile(const std::string& filename, const std::vector<uint8_t>& buffer)
68+
{
69+
HANDLE fileHandle = CreateFileA(
70+
filename.c_str(),
71+
GENERIC_WRITE,
72+
0,
73+
NULL,
74+
CREATE_ALWAYS,
75+
FILE_ATTRIBUTE_NORMAL,
76+
NULL
77+
);
78+
79+
if (fileHandle == INVALID_HANDLE_VALUE)
80+
{
81+
std::cerr << "[ERROR] " << "Failed to create handle to: " << filename << std::endl;
82+
//std::cout << "[REMINDER] " << "Make sure the executable is in same folder with: " << filename << std::endl;
83+
84+
return false;
85+
}
86+
87+
DWORD bytesWritten = 0;
88+
WriteFile(fileHandle, buffer.data(), buffer.size(), &bytesWritten, NULL);
89+
90+
CloseHandle(fileHandle);
91+
92+
return (bytesWritten == buffer.size());
93+
}
94+
95+
void PatchFile(std::string fileName, std::vector<uint8_t> originalArray, std::vector<uint8_t> replacedArray)
96+
{
97+
std::vector<uint8_t> buffer;
98+
if (!readFile(fileName, buffer))
99+
{
100+
return;
101+
}
102+
103+
std::vector<size_t> positions = findHexArray(buffer, originalArray);
104+
105+
if (positions.empty())
106+
{
107+
std::cout << "[ERROR] " << fileName << " is already patched" << std::endl;
108+
return;
109+
}
110+
111+
for (size_t pos : positions)
112+
{
113+
for (size_t i = 0; i < originalArray.size(); ++i)
114+
{
115+
buffer[pos + i] = replacedArray[i];
116+
}
117+
}
118+
119+
if (!writeFile(fileName, buffer))
120+
{
121+
return;
122+
}
123+
124+
std::cout << "[SUCCESS] " << fileName << " has been patched." << std::endl;
125+
}
126+
127+
int main()
128+
{
129+
std::string filePath = "./bin/win64/vscript.dll";
130+
131+
SetConsoleTitleA("���Ҿ�У VScript Patcher");
132+
133+
std::cout << "[VScript Patcher]" << std::endl;
134+
std::cout << "Created by Kroytz (https://github.com/Kroytz)" << std::endl;
135+
std::cout << "Code mainly from RealSkid (https://www.unknowncheats.me/forum/members/3339879.html)" << std::endl;
136+
std::cout << "Method from Source2ZE (https://github.com/Source2ZE/CS2Fixes)" << std::endl;
137+
std::cout << "Place this executable in your <game> folder" << std::endl;
138+
std::cout << " " << std::endl;
139+
std::cout << " " << std::endl;
140+
141+
PatchFile(filePath, { 0xBE, 0x01, 0x2A, 0x2A, 0x2A, 0x2B, 0xD6, 0x74, 0x2A, 0x3B, 0xD6 }, { 0xBE, 0x02, 0x2A, 0x2A, 0x2A, 0x2B, 0xD6, 0x74, 0x2A, 0x3B, 0xD6 });
142+
std::cout << " " << std::endl;
143+
std::cout << " " << std::endl;
144+
145+
system("pause");
146+
147+
return 0;
148+
}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>17.0</VCProjectVersion>
23+
<Keyword>Win32Proj</Keyword>
24+
<ProjectGuid>{b05fc70f-bec8-46c8-b6d5-b509d26ca55d}</ProjectGuid>
25+
<RootNamespace>VScriptAutoPatcher</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>Application</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v143</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>Application</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v143</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>Application</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v143</PlatformToolset>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>Application</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v143</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74+
<ClCompile>
75+
<WarningLevel>Level3</WarningLevel>
76+
<SDLCheck>true</SDLCheck>
77+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
78+
<ConformanceMode>true</ConformanceMode>
79+
</ClCompile>
80+
<Link>
81+
<SubSystem>Console</SubSystem>
82+
<GenerateDebugInformation>true</GenerateDebugInformation>
83+
</Link>
84+
</ItemDefinitionGroup>
85+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
86+
<ClCompile>
87+
<WarningLevel>Level3</WarningLevel>
88+
<FunctionLevelLinking>true</FunctionLevelLinking>
89+
<IntrinsicFunctions>true</IntrinsicFunctions>
90+
<SDLCheck>true</SDLCheck>
91+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
92+
<ConformanceMode>true</ConformanceMode>
93+
</ClCompile>
94+
<Link>
95+
<SubSystem>Console</SubSystem>
96+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
97+
<OptimizeReferences>true</OptimizeReferences>
98+
<GenerateDebugInformation>true</GenerateDebugInformation>
99+
</Link>
100+
</ItemDefinitionGroup>
101+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
102+
<ClCompile>
103+
<WarningLevel>Level3</WarningLevel>
104+
<SDLCheck>true</SDLCheck>
105+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
106+
<ConformanceMode>true</ConformanceMode>
107+
</ClCompile>
108+
<Link>
109+
<SubSystem>Console</SubSystem>
110+
<GenerateDebugInformation>true</GenerateDebugInformation>
111+
</Link>
112+
</ItemDefinitionGroup>
113+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
114+
<ClCompile>
115+
<WarningLevel>Level3</WarningLevel>
116+
<FunctionLevelLinking>true</FunctionLevelLinking>
117+
<IntrinsicFunctions>true</IntrinsicFunctions>
118+
<SDLCheck>true</SDLCheck>
119+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
120+
<ConformanceMode>true</ConformanceMode>
121+
</ClCompile>
122+
<Link>
123+
<SubSystem>Console</SubSystem>
124+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
125+
<OptimizeReferences>true</OptimizeReferences>
126+
<GenerateDebugInformation>true</GenerateDebugInformation>
127+
</Link>
128+
</ItemDefinitionGroup>
129+
<ItemGroup>
130+
<ClCompile Include="VScriptAutoPatcher.cpp" />
131+
</ItemGroup>
132+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
133+
<ImportGroup Label="ExtensionTargets">
134+
</ImportGroup>
135+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="VScriptAutoPatcher.cpp">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
</Project>

0 commit comments

Comments
 (0)