├── README.md ├── patcher.py ├── patcher_linux.py ├── runpatcher.bat └── runpatcher_linux.bat /README.md: -------------------------------------------------------------------------------- 1 | # vscriptPatch 2 | Patch vscript.dll/so so we can use script in cs2 3 | How to use: 4 | - Install Python 5 | - Put your vscript.dll runpatcher.bat patcher.py in the same folder (linux put libvscript.so runpatcher_linux.bat patcher_linux.py) 6 | - double click the runpatcher (runpatcher_linux.bat) 7 | - done if shows :your vscript.dll patch successful (your libvscript.so patched successful) 8 | 9 | # ⚠️You should not assume VScript will always be available in CS2, it will likely be removed at some point. 10 | -------------------------------------------------------------------------------- /patcher.py: -------------------------------------------------------------------------------- 1 | import os 2 | import mmap 3 | 4 | # search: BE 01 ? ? ? 2B D6 74 61 3B D6 5 | # 6 | class Patcher: 7 | 8 | def patch_vscript(): 9 | if not Patcher.replace_bytes( 10 | "vscript.dll", b"\xBE\x01\x00\x00\x00\x2B\xD6\x74\x61\x3B\xD6", b"\xBE\x02\x00\x00\x00\x2B\xD6\x74\x61\x3B\xD6" 11 | ): 12 | print("failed to patch vscript.dll") 13 | else: 14 | print("your vscript.dll patched successful") 15 | 16 | def replace_bytes(filename, search_pattern, replace_bytes): 17 | try: 18 | with open(filename, "r+b") as f: 19 | mm = mmap.mmap(f.fileno(), 0) 20 | pos = mm.find(search_pattern) 21 | pos2 = mm.find(replace_bytes) 22 | if pos2 != -1: 23 | print("your vscript.dll has already patched!") 24 | return False 25 | if pos == -1: 26 | return False 27 | mm[pos : pos + len(search_pattern)] = replace_bytes 28 | return True 29 | except IOError: 30 | print("failed to open: %s" % filename) 31 | return False 32 | 33 | 34 | Patcher.patch_vscript() 35 | input('press any key to exit...') -------------------------------------------------------------------------------- /patcher_linux.py: -------------------------------------------------------------------------------- 1 | import os 2 | import mmap 3 | 4 | # search: 55 48 89 E5 41 55 41 54 53 48 83 EC 08 83 FE 01 5 | # 6 | class Patcher: 7 | 8 | def patch_vscript(): 9 | if not Patcher.replace_bytes( 10 | "libvscript.so", b"\x55\x48\x89\xE5\x41\x55\x41\x54\x53\x48\x83\xEC\x08\x83\xFE\x01\x0F\x84\x0A\x02\x00\x00\x83\xFE\x02", b"\x55\x48\x89\xE5\x41\x55\x41\x54\x53\x48\x83\xEC\x08\x83\xFE\x02\x0F\x84\x0A\x02\x00\x00\x83\xFE\x01" 11 | ): 12 | print("failed to patch libvscript.so") 13 | else: 14 | print("your libvscript.so patched successful") 15 | 16 | def replace_bytes(filename, search_pattern, replace_bytes): 17 | try: 18 | with open(filename, "r+b") as f: 19 | mm = mmap.mmap(f.fileno(), 0) 20 | pos = mm.find(search_pattern) 21 | pos2 = mm.find(replace_bytes) 22 | if pos2 != -1: 23 | print("your libvscript.so has already patched!") 24 | return False 25 | if pos == -1: 26 | return False 27 | mm[pos : pos + len(search_pattern)] = replace_bytes 28 | return True 29 | except IOError: 30 | print("failed to open: %s" % filename) 31 | return False 32 | 33 | 34 | Patcher.patch_vscript() 35 | input('press any key to exit...') -------------------------------------------------------------------------------- /runpatcher.bat: -------------------------------------------------------------------------------- 1 | python patcher.py -------------------------------------------------------------------------------- /runpatcher_linux.bat: -------------------------------------------------------------------------------- 1 | python patcher_linux.py --------------------------------------------------------------------------------