# struct.unpack(fmt, buffer)
# Unpack from the buffer buffer (presumably packed by pack(fmt, ...)) according to the format string fmt. The result is # a tuple even if it contains exactly one item. The buffer’s size in bytes must match the size required by the format, # as reflected by calcsize().
(self.firstIndex, self.lastIndex) = unpack('<II', self.img[:8])
# byte = ord(self.img[offset]) # 此处做了修改,将ord()去掉了
byte = self.img[offset]
if byte == 1 or byte == 2:
# 第一个字节为1或者2时,取得2-4字节作为一个偏移量调用自己
p = self.getLong3(offset + 1)
return self.getAreaAddr(p)
else:
return self.getString(offset)
def getAddr(self, offset, ip = 0): # 这里丢弃ip了么,貌似是
img = self.img
o = offset
# byte = ord(img[o])
byte = img[o] # 发现直接打印出来本身就是数字, 此处做了修改
# ord(c)
# Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. For example, ord('a') returns the integer 97 and ord('€') (Euro sign) returns 8364. This is the inverse of chr().
print('getAddr--byte:',byte)