Skip to content

Commit

Permalink
Improve printing of Serialized property values
Browse files Browse the repository at this point in the history
  • Loading branch information
Matmaus committed Oct 7, 2023
1 parent d44406f commit 0f4d61f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
9 changes: 8 additions & 1 deletion LnkParse3/lnk_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,14 @@ def nice_id(identifier):
for extra_key, extra_value in self.extras.as_dict().items():
cprint(f"{extra_key}", 2)
for key, value in extra_value.items():
cprint(f"{nice_id(key)}: {value}", 3)
if extra_key == "METADATA_PROPERTIES_BLOCK" and isinstance(value, list):
cprint(f"{nice_id(key)}:", 3)
for item in value:
cprint("Property:", 4)
for item_key, item_value in item.items():
cprint(f"{nice_id(item_key)}: {item_value}", 5)
else:
cprint(f"{nice_id(key)}: {value}", 3)

def format_linkFlags(self):
return " | ".join(self.header.link_flags())
Expand Down
7 changes: 6 additions & 1 deletion tests/json/readable_with_local_info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,9 @@ Windows Shortcut Information:
Storage size: 125
Version: 0x53505331
Format id: DABD30ED-0043-4789-A7F8-D013A4736622
Serialized property values: [{'value_size': 97, 'id': 100, 'value': 'Roaming (C:\\Usuários\\Jonathan\\AppData)', 'value_type': 'VT_LPWSTR'}]
Serialized property values:
Property:
Value size: 97
Id: 100
Value: Roaming (C:\Usuários\Jonathan\AppData)
Value type: VT_LPWSTR
27 changes: 26 additions & 1 deletion tests/json/readable_with_network_info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,29 @@ Windows Shortcut Information:
Storage size: 229
Version: 0x53505331
Format id: B725F130-47EF-101A-A5F1-02608C9EEBAC
Serialized property values: [{'value_size': 73, 'id': 10, 'value': 'ETN-lift programme 2017.pdf', 'value_type': 'VT_LPWSTR'}, {'value_size': 21, 'id': 15, 'value': None, 'value_type': 'VT_FILETIME'}, {'value_size': 21, 'id': 12, 'value': None, 'value_type': 'VT_UI8'}, {'value_size': 65, 'id': 4, 'value': 'Adobe Acrobat Document', 'value_type': 'VT_LPWSTR'}, {'value_size': 21, 'id': 14, 'value': None, 'value_type': 'VT_FILETIME'}]
Serialized property values:
Property:
Value size: 73
Id: 10
Value: ETN-lift programme 2017.pdf
Value type: VT_LPWSTR
Property:
Value size: 21
Id: 15
Value: None
Value type: VT_FILETIME
Property:
Value size: 21
Id: 12
Value: None
Value type: VT_UI8
Property:
Value size: 65
Id: 4
Value: Adobe Acrobat Document
Value type: VT_LPWSTR
Property:
Value size: 21
Id: 14
Value: None
Value type: VT_FILETIME

0 comments on commit 0f4d61f

Please sign in to comment.