def _decode_pointer(self, size, offset): pointer_size = ((size >> 3) & 0x3) + 1 new_offset = offset + pointer_size pointer_bytes = self._buffer[offset:new_offset] packed = pointer_bytes if pointer_size == 4 else struct.pack(b"!c", byte_from_int(size & 0x7)) + pointer_bytes unpacked = int_from_bytes(packed) pointer = unpacked + self._pointer_base + self._pointer_value_offset[pointer_size] if self._pointer_test: return pointer, new_offset (value, _) = self.decode(pointer) return value, new_offset
def _decode_pointer(self, size, offset): pointer_size = ((size >> 3) & 0x3) + 1 new_offset = offset + pointer_size pointer_bytes = self._buffer[offset:new_offset] packed = pointer_bytes if pointer_size == 4 else struct.pack( b'!c', byte_from_int(size & 0x7)) + pointer_bytes unpacked = int_from_bytes(packed) pointer = unpacked + self._pointer_base + \ self._pointer_value_offset[pointer_size] if self._pointer_test: return pointer, new_offset (value, _) = self.decode(pointer) return value, new_offset
def _decode_uint(self, size, offset): new_offset = offset + size uint_bytes = self._buffer[offset:new_offset] return int_from_bytes(uint_bytes), new_offset