Year of Python (YOP) – Week Twenty Seven

06Jul15

Hello Reader!

This week we’re wrapping up my Windows LNK file header parsing scripts.  And it’s ending with the Hotkey value of the shortcut which is at file offset 64.

This value is somewhat unique in that it’s a two byte value, and each byte refers to one part of the hotkey combination.  The low byte value (the first byte) references the alphanumeric key in the hotkey combination.  The high byte value (the second byte) shows if you need to press the Alt, Ctrl, or Shift key (or some combination of the two) along with the alphanumeric key.

To that end, I created three functions to parse out this data.  The first function takes the file offset value and splits it into two parts, the low and high byte.  The second function parses the high byte value.  What I decided to do with this function is create a dictionary with all the combinations, and assign the corresponding key combination(s) to it.  Then it just reads the hex value of the high byte and returns what key combination it refers to.  Finally the third function parses out the low byte value.  This turned out to be relatively easy, because it uses the ASCII character set to define the key.  So you just use the built in python chr function on the hex value to find out what it is.

After all that I just changed the print statement to print out what the Hotkey is.

Until next week!

https://github.com/CdtDelta/YOP

Advertisements


No Responses Yet to “Year of Python (YOP) – Week Twenty Seven”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: