-
Notifications
You must be signed in to change notification settings - Fork 27
/
patch.py
executable file
·44 lines (32 loc) · 1.23 KB
/
patch.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
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
'''
This utility merges my CV with the bootloader,
this way makes it work in Adobe Reader as well
as in all the rest I have tested.
'''
import os
import sys
if not os.path.isfile('boot.bin'):
print("boot.bin does not exist, please follow the instructions to create it.")
sys.exit(-1)
if not os.path.isfile('uncompressed.pdf'):
print("uncompressed.pdf does not exist, please follow the instructions to create it.")
sys.exit(-1)
with open("boot.bin", "rb") as binaryfile :
bootloader = bytearray(binaryfile.read())
# Delete the manual padding I added for the PDF magic numbers
# please refer to boot.asm for more information
bootloader_magic = bytearray(b'\xEB\x44\x25\x50\x44\x46\x2D\x31\x2E\x35') #Bootloader + PDF magic numbers
bootloader_start = bootloader[2:62]
bootloader_end = bootloader[70:]
bootloader = bootloader_magic + bootloader_start + bootloader_end
binaryfile.close()
# Open PDF
with open("uncompressed.pdf", "rb") as binaryfile:
cv = bytearray(binaryfile.read())
cv = cv[8:] #Remove the magic numbers
cv = bootloader + cv #Append bootloader
binaryfile.close()
with open("pablo_jimenez_mateo_cv.pdf", "wb") as binaryfile:
binaryfile.write(cv)
binaryfile.close()