Skip to content

Commit c6e87cb

Browse files
committed
version v1.0.0
fix: mispatch cause file damaged refactor: replace method
1 parent 6ea4d4f commit c6e87cb

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

VScriptAutoPatcher/VScriptAutoPatcher.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,15 @@ std::vector<size_t> findHexArray(std::vector<uint8_t>& buffer, const std::vector
4545
bool found = true;
4646

4747
for (size_t j = 0; j < arraySize; ++j) {
48-
if (buffer[i + j] != hexArray[j] && hexArray[j] != 0x2a) {
48+
if (buffer[i + j] != hexArray[j] && hexArray[j] != 0x2A) {
4949
found = false;
5050
break;
5151
}
5252
}
5353

5454
if (found)
5555
{
56-
for (size_t j = 0; j < arraySize; ++j) {
57-
buffer[i + j] = hexArray[j];
58-
}
59-
56+
std::cout << "[INFO] " << "Found position at buffer index: " << i << std::endl;
6057
positions.push_back(i);
6158
}
6259
}
@@ -110,9 +107,12 @@ void PatchFile(std::string fileName, std::vector<uint8_t> originalArray, std::ve
110107

111108
for (size_t pos : positions)
112109
{
113-
for (size_t i = 0; i < originalArray.size(); ++i)
110+
for (size_t i = 0; i < replacedArray.size(); ++i)
114111
{
115-
buffer[pos + i] = replacedArray[i];
112+
if (replacedArray[i] != 0x2A)
113+
{
114+
buffer[pos + i] = replacedArray[i];
115+
}
116116
}
117117
}
118118

@@ -128,17 +128,17 @@ int main()
128128
{
129129
std::string filePath = "./bin/win64/vscript.dll";
130130

131-
SetConsoleTitleA("���Ҿ�У VScript Patcher");
131+
SetConsoleTitleA("黄埔军校 VScript Patcher");
132132

133133
std::cout << "[VScript Patcher]" << std::endl;
134134
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;
136135
std::cout << "Method from Source2ZE (https://github.com/Source2ZE/CS2Fixes)" << std::endl;
136+
std::cout << "Code mainly from RealSkid (https://www.unknowncheats.me/forum/members/3339879.html)" << std::endl;
137137
std::cout << "Place this executable in your <game> folder" << std::endl;
138138
std::cout << " " << std::endl;
139139
std::cout << " " << std::endl;
140140

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 });
141+
PatchFile(filePath, { 0xBE, 0x01, 0x2A, 0x2A, 0x2A, 0x2B, 0xD6, 0x74, 0x2A, 0x3B, 0xD6 }, { 0xBE, 0x02 });
142142
std::cout << " " << std::endl;
143143
std::cout << " " << std::endl;
144144

0 commit comments

Comments
 (0)