from
__future__
import
print_function
import
ctypes, sys
import
os,time
binpath
=
r
"C:\Program Files (x86)\Synthesia"
filename
=
"Synthesia.exe"
backup_path
=
r
"c:\backup"
if
(os.path.isdir(backup_path)):
print
(
"Backup path already exsit!"
)
else
:
os.mkdir(backup_path)
def
backfiles():
os.system(
"copy "
+
filename
+
" "
+
backup_path)
print
(
"File has been backuped to "
+
backup_path)
def
patch_exe():
with
open
(backup_path
+
"\\" + filename,"
rb") as fr:
data
=
fr.read()
data
=
data.replace(b
'\x64\xA1\x2C\x00\x00\x00\x56\x8B\xF1'
, b
'\xB8\x01\x00\x00\x00\xC3\x56\x8B\xF1'
)
with
open
(binpath
+
'\\'
+
filename,
"wb"
) as fw:
fw.write(data)
print
(filename
+
" has been patached successfully!"
)
def
is_admin():
try
:
return
ctypes.windll.shell32.IsUserAnAdmin()
except
:
return
False
if
is_admin():
os.chdir(binpath)
try
:
print
(
"-------------First Step--------------\n"
)
backfiles()
time.sleep(
3
)
except
:
print
(
"Error occurred in backup procedure!"
)
try
:
print
(
"-------------Second Step--------------\n"
)
patch_exe()
time.sleep(
3
)
except
:
print
(
"Error occurred in patch procedure!\n"
)
else
:
if
sys.version_info[
0
]
=
=
3
:
ctypes.windll.shell32.ShellExecuteW(
None
,
"runas"
, sys.executable, __file__,
None
,
1
)
else
:
ctypes.windll.shell32.ShellExecuteW(
None
, u
"runas"
,
unicode
(sys.executable),
unicode
(__file__),
None
,
1
)