Matmaus / LnkParse3

Windows Shortcut file (LNK) parser
MIT License
63 stars 13 forks source link

Adding support for Unknown Extra block and appended data after Terminal block #28

Closed gdesmar closed 4 months ago

gdesmar commented 4 months ago

I modified the Unknown block to not use a property, since none of the other block does. I regenerated the tests to pass, and realized you already had a file with data following the Terminal block, so I added it also as a txt output test.

Regarding text output, I modified the print_lnk_file function to fit the current coding style, but I'm not a fan of hard-coding keys for which there is different behaviour. I went down a very deep rabbit hole to make it all agnostic. It would make those hard-coded list items re-use their parent instead: Serialized property values having many Property under it, in the agnostic first version, those got transformed from Property: to Serialized property values - <N>: with being the index, and Storage: under Property store: to Property store - <N>:, thinking that now any list would be handled. I then decided that the extra layers for lists were long and probably not needed and did something similar to yaml where list items have a - in front. It's nice looking but the code got a little complicated, I would rather open a new PR if I was to offer it. :D There is one little tweak I did in the text output, for the nice_id, it will uppercase the key name if it's a hash algorithm, so that SHA256 does not show up as Sha256.

gdesmar commented 4 months ago

If you were curious to see what difference the agnostic+yaml changes makes in the output (and the code 😨), I uploaded a new branch with it. I tried to stick as closely to the original for the early print levels, such that level 1 are not nice'd but has a colon, level 2 are not nice'd and no colon, while other levels are nice'd and has a colon. It was an interesting journey. 😃