Last active
January 15, 2016 13:12
-
-
Save four0four/431ef053c4cdba3ff5cc to your computer and use it in GitHub Desktop.
EagleCAD 7.5.0 patcher script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2 | |
import sys | |
import md5 | |
if len(sys.argv) < 2: | |
print "Usage: " + sys.argv[0] + " [eagle 7.5.0 binary]\nWindows patches will be applied if .exe" | |
sys.exit() | |
# offsets | |
# no OSX patch here | |
# idk if this runs right on win32 | |
if "exe" in sys.argv[1]: | |
platform = "win32" | |
splash_off = 0xd791c | |
md5_chk = "bfb346e40aa3f3b8f0753b0939fd2f15" | |
else: | |
platform = "linux" | |
splash_off = 0x10dafb | |
md5_chk = "9afd663ed0ec5b3c9889c6665136d92f" | |
f = open(sys.argv[1],'r') | |
backup_f = open(sys.argv[1] + ".bak", 'w+') | |
m = md5.md5(f.read()).hexdigest() | |
if m != md5_chk: | |
print "Fatal: MD5 checksum failed :( " + m | |
sys.exit() | |
print "checksum passed" | |
f.seek(splash_off) | |
orig = f.read(5) | |
if platform == "linux": | |
if orig != "\xe8\x20\x43\xf4\xff": | |
print "Fatal: original bytes not in place - WTF?" | |
sys.exit() | |
elif platform == 'win32': | |
if orig != "\xe8\x8f\xe4\xff\xff": | |
print "Fatal: original bytes not in place - WTF?" | |
sys.exit() | |
# oh god, 25M buffer | |
# this is all really really bad | |
# should've done in C | |
f.seek(0) | |
buf = f.read() | |
backup_f.seek(0) | |
backup_f.write(buf) | |
backup_f.close() | |
f.close() | |
f = open(sys.argv[1], 'w+') | |
print "backup written to " + sys.argv[1]+".bak" | |
print "...applying patch...", | |
patch_buf = buf[:splash_off] + "\x90"*5 + buf[splash_off+5:] | |
print "done!" | |
f.seek(0) | |
f.write(patch_buf) | |
f.close() | |
print("???:D???") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment