From 96d88a6bc9af9857417b9fb6e8b35cf3d5a2baec Mon Sep 17 00:00:00 2001 From: ultramagnus_tcv Date: Thu, 30 Jul 2015 10:31:30 -0500 Subject: [PATCH] Merging work from Michael --- Beginning.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/Beginning.py b/Beginning.py index b30a54a..8347c38 100644 --- a/Beginning.py +++ b/Beginning.py @@ -1,21 +1,15 @@ -import struct -import binascii +from struct import unpack + +#Is File a SOS DRIVER file? SOSfile = open('SOSCFFA.DRIVER', 'rb') -try: - SOS = SOSfile.read() -finally: - SOSfile.close() +SOS = SOSfile.read(10) +filetype, offset = unpack('< 8s H', SOS) +print "Filetype is: %s. Offset is: %04x" % (filetype, offset) -# encode file as hexadecimal -SOSHex = SOS.encode('hex_codec') +#Seek to first driver +SOSfile.seek(offset,1) +SOS = SOSfile.read(2) # Read two bytes +marker = unpack('< H', SOS) +if marker == \x0000 : -#Search for 0x2205 byte pair -print 'Searching for first bytepair...' -SOSfindbyte = SOSHex.find('2205') -print 'I found it.' - -#Reorder for Little Endian -MSB = SOSHex[SOSfindbyte+2:SOSfindbyte+4] -LSB = SOSHex[SOSfindbyte:SOSfindbyte+2] - -print "In File: " + LSB, MSB + "\nLittle Endian: " + MSB, LSB +SOSfile.close()