Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def load_disassembly_hunk(f, program_data):
program_data.branch_addresses = persistence.read_dict_uint32_to_set_of_uint32s(f)
program_data.reference_addresses = persistence.read_dict_uint32_to_set_of_uint32s(f)
program_data.symbols_by_address = persistence.read_dict_uint32_to_string(f)
program_data.post_segment_addresses = persistence.read_dict_uint32_to_list_of_uint32s(f)
program_data.flags = persistence.read_uint32(f)
program_data.processor_id = persistence.read_uint32(f)
# Reconstitute the segment block list.
num_blocks = persistence.read_uint32(f)
program_data.blocks = [ None ] * num_blocks
for i in range(num_blocks):
program_data.blocks[i] = read_SegmentBlock(f)
## POST PROCESSING
# Rebuild the segment block list indexing lists.
program_data.block_addresses = [ 0 ] * num_blocks
program_data.block_line0s_dirtyidx = 0
program_data.block_line0s = program_data.block_addresses[:]
def load_disassembly_hunk(f, program_data):
program_data.branch_addresses = persistence.read_dict_uint32_to_set_of_uint32s(f)
program_data.reference_addresses = persistence.read_dict_uint32_to_set_of_uint32s(f)
program_data.symbols_by_address = persistence.read_dict_uint32_to_string(f)
program_data.post_segment_addresses = persistence.read_dict_uint32_to_list_of_uint32s(f)
program_data.flags = persistence.read_uint32(f)
program_data.processor_id = persistence.read_uint32(f)
# Reconstitute the segment block list.
num_blocks = persistence.read_uint32(f)
program_data.blocks = [ None ] * num_blocks
for i in range(num_blocks):
program_data.blocks[i] = read_SegmentBlock(f)
## POST PROCESSING
# Rebuild the segment block list indexing lists.
program_data.block_addresses = [ 0 ] * num_blocks
program_data.block_line0s_dirtyidx = 0
expected_hunk_version = SNAPSHOT_HUNK_VERSIONS[hunk_id]
if expected_hunk_version != actual_hunk_version:
logger.error("convert_project_format_3_to_4: hunk %d version mismatch %d != %d", hunk_id, expected_hunk_version, actual_hunk_version)
return None
logger.debug("convert_project_format_3_to_4: file hunk %d", hunk_id)
# Copy unaffected hunks verbatim.
if hunk_id != SAVEFILE_HUNK_DISASSEMBLY:
input_file.seek(hunk_header_offset, os.SEEK_SET)
raw_hunk_length = (hunk_payload_offset - hunk_header_offset) + hunk_length
output_file.write(input_file.read(raw_hunk_length))
continue
## 1. Load the hunk payload.
branch_addresses = persistence.read_dict_uint32_to_set_of_uint32s(input_file)
reference_addresses = persistence.read_dict_uint32_to_set_of_uint32s(input_file)
symbols_by_address = persistence.read_dict_uint32_to_string(input_file)
post_segment_addresses = persistence.read_dict_uint32_to_list_of_uint32s(input_file)
flags = persistence.read_uint32(input_file)
processor_name = persistence.read_string(input_file)
# Reconstitute the segment block list.
num_blocks = persistence.read_uint32(input_file)
input_file_offset = input_file.tell()
block_data_length = hunk_length - (input_file_offset - hunk_payload_offset)
block_data_string = input_file.read(block_data_length)
#blocks = [ None ] * num_blocks
#for i in range(num_blocks):
# blocks[i] = read_SegmentBlock(input_file)
## 2. Write the generic hunk header, then the payload, then fill in the header.
# Only these two are likely to have been in use.
def load_loader_hunk(f, program_data):
program_data.loader_system_name = persistence.read_string(f)
program_data.loader_segments = read_segment_list(f)
program_data.loader_relocated_addresses = persistence.read_dict_uint32_to_set_of_uint32s(f)
program_data.loader_relocatable_addresses = persistence.read_set_of_uint32s(f)
program_data.loader_entrypoint_segment_id = persistence.read_uint16(f)
program_data.loader_entrypoint_offset = persistence.read_uint32(f)
## POST PROCESSING
program_data.loader_data_types = loaderlib.get_system_data_types(program_data.loader_system_name)
actual_hunk_version = persistence.read_uint16(input_file)
expected_hunk_version = SNAPSHOT_HUNK_VERSIONS[hunk_id]
if expected_hunk_version != actual_hunk_version:
logger.error("convert_project_format_3_to_4: hunk %d version mismatch %d != %d", hunk_id, expected_hunk_version, actual_hunk_version)
return None
logger.debug("convert_project_format_3_to_4: file hunk %d", hunk_id)
# Copy unaffected hunks verbatim.
if hunk_id != SAVEFILE_HUNK_DISASSEMBLY:
input_file.seek(hunk_header_offset, os.SEEK_SET)
raw_hunk_length = (hunk_payload_offset - hunk_header_offset) + hunk_length
output_file.write(input_file.read(raw_hunk_length))
continue
## 1. Load the hunk payload.
branch_addresses = persistence.read_dict_uint32_to_set_of_uint32s(input_file)
reference_addresses = persistence.read_dict_uint32_to_set_of_uint32s(input_file)
symbols_by_address = persistence.read_dict_uint32_to_string(input_file)
post_segment_addresses = persistence.read_dict_uint32_to_list_of_uint32s(input_file)
flags = persistence.read_uint32(input_file)
processor_name = persistence.read_string(input_file)
# Reconstitute the segment block list.
num_blocks = persistence.read_uint32(input_file)
input_file_offset = input_file.tell()
block_data_length = hunk_length - (input_file_offset - hunk_payload_offset)
block_data_string = input_file.read(block_data_length)
#blocks = [ None ] * num_blocks
#for i in range(num_blocks):
# blocks[i] = read_SegmentBlock(input_file)
## 2. Write the generic hunk header, then the payload, then fill in the header.