IzNoGoD
7th February 2015, 13:17
Edit: This is outdated. Go to the next post.
Here's a python-based patch switcher for CoD2:
import socket
import StringIO
import csv
import os
import shutil
import _winreg as wreg
import sys
import subprocess
import Tkinter as tk
def switch_patch(version, frame):
source = "C:\\Program Files (x86)\\Activision\\Call of Duty 2 Patch switcher\\" + version + "\\"
dest = "C:\\Program Files (x86)\\Activision\\Call of Duty 2\\"
files = ["main\\iw_15.iwd", "CoD2MP_s.exe", "gfx_d3d_mp_x86_s.dll", "gfx_d3d_x86_s.dll"]
for file in files:
if os.path.exists(dest + file):
os.remove(dest + file)
if os.path.exists(source + file):
shutil.copyfile(source + file, dest + file)
if frame is not None:
frame.destroy()
return
version = '0.0'
if len(sys.argv) >= 2:
args = " ".join(sys.argv[2:])
if "+connect" in sys.argv[2:]:
index = sys.argv[2:].index("+connect")
info = sys.argv[2:][index + 1].split(":")
if len(info) >= 2:
ip = info[0]
port = int(info[1])
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.settimeout(2.0)
packet = "\xff\xff\xff\xffgetstatus"
try:
sock.sendto(packet, (ip, port))
response = sock.recvfrom(8196)[0]
f = StringIO.StringIO(response[4:])
reader = csv.reader(f, delimiter='\\')
for row in reader:
if 'shortversion' in row:
version = row[row.index('shortversion') + 1]
except:
pass
if version == "0.0":
root = tk.Tk()
args = ""
root.title("Patch Switcher")
versions = ["1.0", "1.2", "1.3"]
for v in versions:
tk.Button(root, text=v, width=25, height=3, command=lambda v=v:switch_patch(v, root)).pack()
root.mainloop()
else:
switch_patch(version, None)
key = wreg.CreateKey(wreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\CoD2MP_s.exe")
try:
wreg.DeleteValue(key, 'Debugger')
except WindowsError:
pass
key.Close()
subprocess.call("C:\\Program Files (x86)\\Activision\\Call of Duty 2\\CoD2MP_s.exe " + args, cwd="C:\\Program Files (x86)\\Activision\\Call of Duty 2\\")
key = wreg.CreateKey(wreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\CoD2MP_s.exe")
wreg.SetValueEx(key, 'Debugger', 0, wreg.REG_SZ, "\"C:\\Python27\\Pythonw.exe\" \"Versionswitcher.pyw\"")
key.Close()
Requirements:
Python 2.7 installed in C:/python27
CoD2 installed in C:/program files (x86)/activision/call of duty 2/
Cod2 patch switcher installed in C:/program files (x86)/activision/call of duty 2 patch switcher (www.iznogod.tweak.nl/cod2ps.rar )
How to install: Save the file as VersionSwitcher.pyw in C:/program files (x86)/activision/call of duty 2/ , then doubleclick the file once, it should set everything correctly.
From then on out it should hijack all calls to cod2mp_s.exe, get the +connect server version, switch patch and connect.
If no +connect is given, a UI will pop up asking for a version.
Here's a python-based patch switcher for CoD2:
import socket
import StringIO
import csv
import os
import shutil
import _winreg as wreg
import sys
import subprocess
import Tkinter as tk
def switch_patch(version, frame):
source = "C:\\Program Files (x86)\\Activision\\Call of Duty 2 Patch switcher\\" + version + "\\"
dest = "C:\\Program Files (x86)\\Activision\\Call of Duty 2\\"
files = ["main\\iw_15.iwd", "CoD2MP_s.exe", "gfx_d3d_mp_x86_s.dll", "gfx_d3d_x86_s.dll"]
for file in files:
if os.path.exists(dest + file):
os.remove(dest + file)
if os.path.exists(source + file):
shutil.copyfile(source + file, dest + file)
if frame is not None:
frame.destroy()
return
version = '0.0'
if len(sys.argv) >= 2:
args = " ".join(sys.argv[2:])
if "+connect" in sys.argv[2:]:
index = sys.argv[2:].index("+connect")
info = sys.argv[2:][index + 1].split(":")
if len(info) >= 2:
ip = info[0]
port = int(info[1])
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.settimeout(2.0)
packet = "\xff\xff\xff\xffgetstatus"
try:
sock.sendto(packet, (ip, port))
response = sock.recvfrom(8196)[0]
f = StringIO.StringIO(response[4:])
reader = csv.reader(f, delimiter='\\')
for row in reader:
if 'shortversion' in row:
version = row[row.index('shortversion') + 1]
except:
pass
if version == "0.0":
root = tk.Tk()
args = ""
root.title("Patch Switcher")
versions = ["1.0", "1.2", "1.3"]
for v in versions:
tk.Button(root, text=v, width=25, height=3, command=lambda v=v:switch_patch(v, root)).pack()
root.mainloop()
else:
switch_patch(version, None)
key = wreg.CreateKey(wreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\CoD2MP_s.exe")
try:
wreg.DeleteValue(key, 'Debugger')
except WindowsError:
pass
key.Close()
subprocess.call("C:\\Program Files (x86)\\Activision\\Call of Duty 2\\CoD2MP_s.exe " + args, cwd="C:\\Program Files (x86)\\Activision\\Call of Duty 2\\")
key = wreg.CreateKey(wreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\CoD2MP_s.exe")
wreg.SetValueEx(key, 'Debugger', 0, wreg.REG_SZ, "\"C:\\Python27\\Pythonw.exe\" \"Versionswitcher.pyw\"")
key.Close()
Requirements:
Python 2.7 installed in C:/python27
CoD2 installed in C:/program files (x86)/activision/call of duty 2/
Cod2 patch switcher installed in C:/program files (x86)/activision/call of duty 2 patch switcher (www.iznogod.tweak.nl/cod2ps.rar )
How to install: Save the file as VersionSwitcher.pyw in C:/program files (x86)/activision/call of duty 2/ , then doubleclick the file once, it should set everything correctly.
From then on out it should hijack all calls to cod2mp_s.exe, get the +connect server version, switch patch and connect.
If no +connect is given, a UI will pop up asking for a version.