-
-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathrgb_25027_rm2.py
executable file
·32 lines (29 loc) · 1.13 KB
/
rgb_25027_rm2.py
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
#!/usr/bin/env python3
## rgb patch for xochitl (could work on future versions)
import sys,mmap
diffs = [('01 c0 a0 13 14 c0 8d e5 0d 30 a0 03 04 c0 a0 03 08 c0 a0 13 10 c0 8d e5 18 30 a0 13',
'03 c0 a0 13 14 c0 8d e5 0d 30 a0 03 04 c0 a0 03 00 c0 a0 13 10 c0 8d e5 04 30 a0 13')]
if __name__ == "__main__":
if len(sys.argv) < 2:
sys.stderr.write("Usage: xochitl\n")
sys.exit(1)
file = sys.argv[1]
with open(file,'rb+') as f:
m = mmap.mmap(f.fileno(), 0)
indexes = []
idx = 0
for s,r in diffs:
m.seek(0)
idx += 1
bytes_to_find = bytes.fromhex(s)
bytes_to_write = bytes.fromhex(r)
i = m.find(bytes_to_find)
if i < 0:
sys.stderr.write(f'pattern at index: {idx} not found\n')
sys.stderr.write(s)
sys.stderr.write("\n")
sys.exit(1)
indexes.append((i, bytes_to_write))
for i, r in indexes:
m.seek(i)
m.write(r)