Code:
from struct import *
def bytes_from_file(filename, chunksize=8192):
with open(filename, "rb") as f:
while True:
chunk = f.read(chunksize)
if chunk:
for b in chunk:
yield b
else:
break
def findSig(filename,sig):
sigpos = 0
positionToPatch = 0
for byte in bytes_from_file(path):
if sig[sigpos] == 0 or byte == signature[sigpos]:
sigpos+=1
if sigpos == len(sig):
if byte == 0x76:
print("Signature found!, byte value is: ",hex(byte))
return positionToPatch
elif byte == 0xeb:
print("This file is already patched, byte value is: ",hex(byte))
return -1
else:
print("Signature found but byte value is ",hex(byte)," and not 0x76!")
print("Please update patcher!")
return -1
else:
sigpos = 0
positionToPatch +=1
print("not found!")
return -1
def patchFile(infile,outfile,position):
bytecounter = 0
f = open(outfile, 'wb')
for byte in bytes_from_file(infile):
if bytecounter == position:
f.write(pack('B',235))
else:
f.write(pack('B',byte))
bytecounter+=1
f.close()
print("start")
import win32ui
import win32file
o = win32ui.CreateFileDialog( 1, ".exe", "League of Legends.exe", 0, "Exe files (*.exe)|*.exe|All Files (*.*)|*.*|")
o.DoModal()
path = o.GetPathName()
##print("Copy original file:")
##print(path)
##print("To:")
##print(path+".bak")
##
##win32file.CopyFile(path,path+".bak",0)
##
##outpath = path
##path = path+".bak"
signature = bytes.fromhex('DF F1 DD D8 00 00 F3 0F 10 05 00 00 00 00 F3 0F 11 05 00 00 00 00 B0 01 5F 5E 5B 59 C2 04 00 F3 0F 10 0D 00 00 00 00 F3 0F 10 05 00 00 00 00 0F 2F C8 00')
patchPosition = findSig(path,signature)
if patchPosition != -1:
print("patch with 0xeb on: ",hex(patchPosition))
print("Copy original file:")
print(path)
print("To:")
print(path+".bak")
win32file.CopyFile(path,path+".bak",0)
outpath = path
path = path+".bak"
print("patching now....")
patchFile(path,outpath,patchPosition)
print("done")
else:
print("not patching")
print("end")






