Results 1 to 2 of 2

Thread: Patch switcher for cod2

  1. #1
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts

    Patch switcher for cod2

    Edit: This is outdated. Go to the next post.

    Here's a python-based patch switcher for CoD2:

    PHP Code:
    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
    (versionframe):
        
    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 filedest 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_INETsocket.SOCK_DGRAM)
                
    sock.settimeout(2.0)
                
    packet "\xff\xff\xff\xffgetstatus"
                
    try:
                    
    sock.sendto(packet, (ipport))
                    
    response sock.recvfrom(8196)[0]
                    
    StringIO.StringIO(response[4:])
                    
    reader csv.reader(fdelimiter='\\')
                    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(roottext=vwidth=25height=3command=lambda v=v:switch_patch(vroot)).pack()
        
    root.mainloop()
    else:
        
    switch_patch(versionNone)
    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 " argscwd="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'0wreg.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.
    Last edited by IzNoGoD; 7th February 2015 at 17:27.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  2. The Following 5 Users Say Thank You to IzNoGoD For This Useful Post:

    BurntToast (7th February 2015),kung foo man (7th February 2015),Mitch (7th February 2015),php (7th February 2015),thOuMta (12th February 2015)

  3. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Ok, major update:

    PHP Code:
    import socket
    import io 
    as StringIO
    import csv
    import os
    import shutil
    import winreg 
    as wreg
    import sys
    import subprocess
    import tkinter 
    as tk
    import urllib
    .request
    import zipfile

    ps_path 
    "_patchSwitcher"

    def hook_cod2():
        
    key wreg.CreateKey(wreg.HKEY_LOCAL_MACHINE"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\CoD2MP_s.exe")
        
    wreg.SetValueEx(key'Debugger'0wreg.REG_SZ"\"pythonw.exe\" \"Versionswitcher.py\"")
        
    key.Close()

    def unhook_cod2():
        
    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()

    def install(frame):
        if 
    os.path.exists(ps_path):
            
    shutil.rmtree(ps_path)
        
    os.mkdir(ps_path)
        
    urllib.request.urlretrieve("http://www.iznogod.tweak.nl/cod2ps.zip"os.path.join(ps_path"cod2ps.zip"))
        
    with zipfile.ZipFile(os.path.join(ps_path'cod2ps.zip'), 'r') as zf:
            
    zf.extractall(ps_path)
        
    os.remove(os.path.join(ps_path"cod2ps.zip"))
        
    hook_cod2()
        
    frame.destroy()

    def uninstall(frame):
        if 
    os.path.exists(ps_path):
            
    shutil.rmtree(ps_path)
        
    unhook_cod2()
        
    frame.destroy()
        
    sys.exit()

    def switch_patch(versionframe):
        
    source os.path.join(ps_pathversion)
        
    files = [os.path.join("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(file):
                
    os.remove(file)
            if 
    os.path.exists(os.path.join(sourcefile)):
                
    shutil.copyfile(os.path.join(sourcefile), 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_INETsocket.SOCK_DGRAM)
                
    sock.settimeout(3.0)
                try:
                    
    sock.sendto(b'\xff'b'\xff'b'\xff'b'\xff'b'getstatus', (ipport))
                    
    response sock.recvfrom(8196)[0]
                    
    StringIO.StringIO(str(response[4:]))
                    
    reader csv.reader(fdelimiter='\\')
                    for 
    row in reader:
                        if 
    'shortversion' in row:
                            
    version row[row.index("shortversion") + 2]
                
    except:
                    
    pass
    else:
        
    #user is installing/uninstalling the utility
        
    if os.path.exists(ps_path):
            
    #uninstall and reinstall only
            
    root tk.Tk()
            
    args ""
            
    root.title("Patch Switcher")
            
    root.protocol('WM_DELETE_WINDOW'sys.exit)
            
    tk.Button(roottext="Reinstall"width=25height=3command=lambda:install(root)).pack()
            
    tk.Button(roottext="Uninstall"width=25height=3command=lambda:uninstall(root)).pack()
            
    root.mainloop()
        else:
            
    #install only
            
    root tk.Tk()
            
    args ""
            
    root.title("Patch Switcher")
            
    root.protocol('WM_DELETE_WINDOW'sys.exit)
            
    tk.Button(roottext="Install"width=25height=3command=lambda:install(root)).pack()
            
    tk.Button(roottext="Uninstall"state='disabled'width=25height=3).pack()
            
    root.mainloop()
    if 
    version == "0.0":
        
    root tk.Tk()
        
    args ""
        
    root.title("Patch Switcher")
        
    root.protocol('WM_DELETE_WINDOW'sys.exit)
        
    versions = ["1.0""1.2""1.3"]
        for 
    v in versions:
            
    tk.Button(roottext=vwidth=25height=3command=lambda v=v:switch_patch(vroot)).pack()
        
    root.mainloop()
    else:
        
    switch_patch(versionNone)

    unhook_cod2()

    subprocess.call("CoD2MP_s.exe " args)

    hook_cod2() 
    Minor update:

    Save as VersionSwitcher.py in your cod2 root (next to cod2mp_s.exe)

    Install python 3.x with option: Add to path in the installer

    Double-click the VersionSwitcher.py file

    Done.
    Last edited by IzNoGoD; 7th February 2015 at 17:25.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •