forked from sherpya/ris-linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfixloader.py
More file actions
executable file
·38 lines (31 loc) · 1.14 KB
/
fixloader.py
File metadata and controls
executable file
·38 lines (31 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
# -*- Mode: Python; tab-width: 4 -*-
#
# Fix for setuploader
#
# Copyright (C) 2005-2006 Gianluigi Tiesi <sherpya@netfarm.it>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
# ======================================================================
from sys import argv, exit as sys_exit
if __name__ == '__main__':
if len(argv) < 2:
print('Usage: fixloader.py ntldr')
sys_exit()
data = open(argv[1], 'rb').read()
if data.find(b'setupldr.exe')==-1:
print('Wrong file')
sys_exit()
if data[:2] == b'MZ':
print('Loader already fixed')
sys_exit()
data = b'MZ' + data.split(b'MZ', 1).pop()
open(argv[1], 'wb').write(data)
print('Loader fixed')