aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Murphy <alec@checksum.fail>2017-04-28 11:18:17 -0400
committerAlec Murphy <alec@checksum.fail>2017-04-28 11:18:17 -0400
commit99e5308ce4f8b3f1ecc24afe1fe057ece223f341 (patch)
tree3db7268cdb3d22eb91016855131b754acea46c46
parent23553bbae1579e1b296c87b55b194e1945c595cc (diff)
Add ISO9660 boot block offset
-rwxr-xr-xisoc.py27
1 files changed, 7 insertions, 20 deletions
diff --git a/isoc.py b/isoc.py
index abed2c4..051353d 100755
--- a/isoc.py
+++ b/isoc.py
@@ -46,6 +46,7 @@ RS_ATTR_COMPRESSED = 0x400 #Z
RS_ATTR_CONTIGUOUS = 0x800 #C
RS_ATTR_FIXED = 0x1000 #F
RS_BLK_SIZE = 512
+RS_DRV_OFFSET = 0xB000
RS_ROOT_CLUS = 0x5A
mon_start_days1=[
@@ -187,7 +188,7 @@ def write_iso_c(self, iso_c_file):
file.write(self.data[(d+'/'+f['filename']).replace("//","/")])
# Write to EOF
- file.seek(0xb000+int(de_clus_ctr*RS_BLK_SIZE))
+ file.seek(RS_DRV_OFFSET+int(de_clus_ctr*RS_BLK_SIZE))
file.write(chr(0))
# Write boot sector
@@ -212,7 +213,7 @@ def write_iso_c(self, iso_c_file):
bs[0x1FE] = 0x55 # signature
bs[0x1FF] = 0xAA # signature
- file.seek(0xB000)
+ file.seek(RS_DRV_OFFSET)
for byte in bs:
file.write(chr(byte))
file.close()
@@ -273,23 +274,6 @@ def Unix2CDate(dt):
_time=(100*(100*(dt.tm_sec+60*(dt.tm_min+60*dt.tm_hour)))<<21)/(15*15*3*625)
return binascii.unhexlify(format(int(_date), '08X')) + binascii.unhexlify(format(int(_time), '08X'))
-def get_blkdev_offset(f):
- # Naive way to get RedSea offset (fuck all that ISO9660 noise)
- f_ctr = 0
- m_bytes = [ 0x2E, 0xC7, 0x55, 0xAA, 0x88 ]
- m_ctr = 0
- while f_ctr < len(f):
- if m_ctr >= len(m_bytes):
- if ord(f[f_ctr]) == 0x88:
- return (f_ctr-3)
- if m_ctr < len(m_bytes):
- if ord(f[f_ctr]) == m_bytes[m_ctr]:
- m_ctr += 1
- else:
- m_ctr = 0
-
- f_ctr += 1
-
class RedSea(LoggingMixIn, Operations):
def __init__(self, iso_c_file):
@@ -305,7 +289,7 @@ class RedSea(LoggingMixIn, Operations):
if os.path.exists(iso_c_file):
f = bytes(open(iso_c_file, "rb").read())
- blkdev_offset = get_blkdev_offset(f)
+ blkdev_offset = RS_DRV_OFFSET
de_list = { '': blkdev_offset + int((1+int(ord(f[blkdev_offset+0x20])))*RS_BLK_SIZE) }
else:
de_list = {}
@@ -343,6 +327,9 @@ class RedSea(LoggingMixIn, Operations):
self.data[dir + de_filename] = f[RS_BLK_SIZE*de_clus:(RS_BLK_SIZE*de_clus)+de_size]
pos += 64
+ if os.path.exists(iso_c_file):
+ del(f)
+
def chmod(self, path, mode):
self.files[path]['st_mode'] &= 0o770000
self.files[path]['st_mode'] |= mode