Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
continue
# Skip this unknown data type, research pending :)
# TODO: Add actual parsing
if int(vk.data_type) == 0x200000:
continue
data_type = str(vk.data_type)
if data_type in ['REG_SZ', 'REG_EXPAND', 'REG_EXPAND_SZ']:
if vk.data_size >= 0x80000000:
# data is contained in the data_offset field
value.size -= 0x80000000
actual_value = vk.data_offset
elif vk.data_size > 0x3fd8 and value.value[:2] == b'db':
data = self._parse_indirect_block(substream, value)
actual_value = try_decode_binary(data, as_json=as_json)
else:
actual_value = try_decode_binary(value.value, as_json=as_json)
elif data_type in ['REG_BINARY', 'REG_NONE']:
if vk.data_size >= 0x80000000:
# data is contained in the data_offset field
actual_value = vk.data_offset
elif vk.data_size > 0x3fd8 and value.value[:2] == b'db':
try:
actual_value = self._parse_indirect_block(substream, value)
actual_value = try_decode_binary(actual_value, as_json=True) if as_json else actual_value
except ConstError:
logger.error(f'Bad value at {actual_vk_offset}')
continue
else:
# Return the actual data
elif data_type == 'REG_DWORD':
# If the data size is bigger than 0x80000000, data is actually stored in the VK data offset.
actual_value = vk.data_offset if vk.data_size >= 0x80000000 else Int32ul.parse(value.value)
elif data_type == 'REG_QWORD':
actual_value = vk.data_offset if vk.data_size >= 0x80000000 else Int64ul.parse(value.value)
elif data_type == 'REG_MULTI_SZ':
parsed_value = GreedyRange(CString('utf-16-le')).parse(value.value)
# Because the ListContainer object returned by Construct cannot be turned into a list,
# we do this trick
actual_value = [x for x in parsed_value if x]
# We currently dumps this as hex string or raw
# TODO: Add actual parsing
elif data_type in ['REG_RESOURCE_REQUIREMENTS_LIST', 'REG_RESOURCE_LIST']:
actual_value = binascii.b2a_hex(value.value).decode()[:max_len] if as_json else value.value
else:
actual_value = try_decode_binary(value.value, as_json=as_json)
yield Value(name=value_name, value_type=str(value.value_type), value=actual_value,
is_corrupted=is_corrupted)
if vk.data_size >= 0x80000000:
# data is contained in the data_offset field
actual_value = vk.data_offset
elif vk.data_size > 0x3fd8 and value.value[:2] == b'db':
try:
actual_value = self._parse_indirect_block(substream, value)
actual_value = try_decode_binary(actual_value, as_json=True) if as_json else actual_value
except ConstError:
logger.error(f'Bad value at {actual_vk_offset}')
continue
else:
# Return the actual data
actual_value = binascii.b2a_hex(value.value).decode()[:max_len] if as_json else value.value
elif data_type == 'REG_SZ':
actual_value = try_decode_binary(value.value, as_json=as_json)
elif data_type == 'REG_DWORD':
# If the data size is bigger than 0x80000000, data is actually stored in the VK data offset.
actual_value = vk.data_offset if vk.data_size >= 0x80000000 else Int32ul.parse(value.value)
elif data_type == 'REG_QWORD':
actual_value = vk.data_offset if vk.data_size >= 0x80000000 else Int64ul.parse(value.value)
elif data_type == 'REG_MULTI_SZ':
parsed_value = GreedyRange(CString('utf-16-le')).parse(value.value)
# Because the ListContainer object returned by Construct cannot be turned into a list,
# we do this trick
actual_value = [x for x in parsed_value if x]
# We currently dumps this as hex string or raw
# TODO: Add actual parsing
elif data_type in ['REG_RESOURCE_REQUIREMENTS_LIST', 'REG_RESOURCE_LIST']:
actual_value = binascii.b2a_hex(value.value).decode()[:max_len] if as_json else value.value
else:
actual_value = try_decode_binary(value.value, as_json=as_json)
value.size -= 0x80000000
actual_value = vk.data_offset
elif vk.data_size > 0x3fd8 and value.value[:2] == b'db':
data = self._parse_indirect_block(substream, value)
actual_value = try_decode_binary(data, as_json=as_json)
else:
actual_value = try_decode_binary(value.value, as_json=as_json)
elif data_type in ['REG_BINARY', 'REG_NONE']:
if vk.data_size >= 0x80000000:
# data is contained in the data_offset field
actual_value = vk.data_offset
elif vk.data_size > 0x3fd8 and value.value[:2] == b'db':
try:
actual_value = self._parse_indirect_block(substream, value)
actual_value = try_decode_binary(actual_value, as_json=True) if as_json else actual_value
except ConstError:
logger.error(f'Bad value at {actual_vk_offset}')
continue
else:
# Return the actual data
actual_value = binascii.b2a_hex(value.value).decode()[:max_len] if as_json else value.value
elif data_type == 'REG_SZ':
actual_value = try_decode_binary(value.value, as_json=as_json)
elif data_type == 'REG_DWORD':
# If the data size is bigger than 0x80000000, data is actually stored in the VK data offset.
actual_value = vk.data_offset if vk.data_size >= 0x80000000 else Int32ul.parse(value.value)
elif data_type == 'REG_QWORD':
actual_value = vk.data_offset if vk.data_size >= 0x80000000 else Int64ul.parse(value.value)
elif data_type == 'REG_MULTI_SZ':
parsed_value = GreedyRange(CString('utf-16-le')).parse(value.value)
# Because the ListContainer object returned by Construct cannot be turned into a list,
# Skip this unknown data type, research pending :)
# TODO: Add actual parsing
if int(vk.data_type) == 0x200000:
continue
data_type = str(vk.data_type)
if data_type in ['REG_SZ', 'REG_EXPAND', 'REG_EXPAND_SZ']:
if vk.data_size >= 0x80000000:
# data is contained in the data_offset field
value.size -= 0x80000000
actual_value = vk.data_offset
elif vk.data_size > 0x3fd8 and value.value[:2] == b'db':
data = self._parse_indirect_block(substream, value)
actual_value = try_decode_binary(data, as_json=as_json)
else:
actual_value = try_decode_binary(value.value, as_json=as_json)
elif data_type in ['REG_BINARY', 'REG_NONE']:
if vk.data_size >= 0x80000000:
# data is contained in the data_offset field
actual_value = vk.data_offset
elif vk.data_size > 0x3fd8 and value.value[:2] == b'db':
try:
actual_value = self._parse_indirect_block(substream, value)
actual_value = try_decode_binary(actual_value, as_json=True) if as_json else actual_value
except ConstError:
logger.error(f'Bad value at {actual_vk_offset}')
continue
else:
# Return the actual data
actual_value = binascii.b2a_hex(value.value).decode()[:max_len] if as_json else value.value
elif data_type == 'REG_SZ':