Use an Expandable String
DWORD = dword: Expandable String = hex(2): Multi String = hex(7):
A DWORD is a 32-bit unsigned integer (range: 0 through 4294967295 decimal) In the registry, a DWORD always begins with 0x. In the registry, DWORDS always have 8 digits that follow 0x. This can be in decimal or hexadecimal format, 1000 can be written as: 0x00001000 or 0x000003e8
DWORDS can only make use of the digits 0-9. Strings, any kind, always use ASCII, in ACSII 1000 can only be written as 31,30,30,30 For the String data type, ASCII works in the background without you even knowing. It has to because the computer only understand 1s and 0s. For Expandable String and Multi String data types, these save your entries as a series of ASCII codes in a hexadecimal format, separated by a commas and hex zeroes. So, an Expandable String of 1000 would be: hex(2):31,00,30,00,30,00,30,00
So let's convert %PROGRAMFILES% into an expandable string. First, download this: https://hotfile.com/dl/244097278/55aa086/ASCII_2_HEX_Conversion_Tool.7z.html
Now open that in any modern browser. Put %PROGRAMFILES% into the ASCII box, and select encode it. It will give you %25%50%52%4F%47%52%41%4D%46%49%4C%45%53%25 Copy paste that into a text editor, move the first % to the end. Select the replace command, find all "%" and replace with ",00,". Remove the comma at the very end. You should get: 25,00,50,00,52,00,4F,00,47,00,52,00,41,00,4D,00,46,00,49,00,4C,00,45,00,53,00,25,00 And finally, hex(2):25,00,50,00,52,00,4F,00,47,00,52,00,41,00,4D,00,46,00,49,00,4C,00,45,00,53,00,25,00
Done.
Have you ever tried to convert a curious hex registry entry into ASCII and failed miserably. This lesson contains all the knowledge required to reverse engineer any hex coded registry entry that is not encrypted. Have Fun!
4Did you remember to Change the registry Setting to be a REG_EXPAND_SZ instead of a REG_SZ!? – Werner Henze – 2013-05-23T11:57:57.570
1By the way, part of your premise is faulty. on a 32bit PC, you cannot evaluate the env var %ProgramFiles(x86)%. you will recieve the message 'The system cannot find the path specified.'. Personally from a pathing perspective, its better to use regular old '%ProgramFiles%' since it will always resolve to a folder regardless of the bittedness of the host. – Frank Thomas – 2013-05-23T12:08:18.483
1Thank you both. Werner Henze, if you make an answer, I can accept it, this way I can't even give a Vote Up for your comment. – Martin Fejes – 2013-05-23T12:56:36.440
@Martin Fejes: Made it an answer. Please only accept it if you tested it and it worked. I am not sure if Explorer is expanding environment variables in these registry keys at all. – Werner Henze – 2013-05-23T13:19:30.880