Jump to content

Converting exported binary reg values into strings?

Recommended Posts

I've written a program that automatically converts a registry export file (.reg) into an AutoIT script for easy import into an existing AutoIT program. The exported binary values are listed like ... "hex:31,32,33,34,80,ff" for their string equivalent of "1234" + chr(128) + chr(255). I need to convert this binary data into string.

I'm sure this is a long shot, but ... Does AutoIT have a way to internally convert a binary registry value into its string equivalent? I'm not asking for a bunch of code. I'm just wondering if AutoIT has it built in.

Link to post
Share on other sites

Ok, my next issue ... Due to the fact that the output from my program is saved to a file, and must be user-readable, and that not all binary/expanded binary values are user readable, I've set up my program to create a string of chrs like such:

Binary: chr(49) & chr(50) & chr(51) & chr(52) & chr(128) & chr(255)

MultiString: chr(49) & chr(0) & chr(50) & chr(0) & chr(51) & chr(0) & chr(52) & chr(0) & chr(172) & chr(32) & chr(255) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0)

ExpandedString: chr(49) & chr(0) & chr(50) & chr(0) & chr(51) & chr(0) & chr(52) & chr(0) & chr(172) & chr(32) & chr(255) & chr(0) & chr(0) & chr(0)

I think my Binary conversion is correct. But the Multi and Expanded strings are still problematic, as they have 2 values. For instance, decimal 172 and 32 somehow are calculated to create chr(128). Can someone explain how this is calculated?

Edit: for clarification ...

The values I saved to Registry were "1234" +chr(128)+chr(255).

The data saved in the chr(128) position for Expanded and Multi strings is "AC 20", which when pulled from the registry and converted to decimal are "172 and 32". So I need to understand how I can calculate these values to equal back to 128.

Another edit ...

Here is the function I wrote to convert the information pulled from the registry export file. $BinaryData is the value data exactly as it was extracted from the file. e.g.:

31,32,33,34,80,ff for Binary (which works fine)

31,00,32,00,33,00,34,00,ac,20,ff,00,00,00 for ExString (which has 2 values for each character).

func ConvertBinaryToStringOfChrs($BinaryData)
$BinaryValues = stringsplit($BinaryData,",")
$BinaryData = ""
if $BinaryValues[0] > 0 Then
  for $intA = 1 to $BinaryValues[0]
   $BinaryData = $BinaryData & "chr(" & dec($BinaryValues[$intA]) & ") & "
  $BinaryData = stringleft($BinaryData,stringlen($BinaryData)-3) ;remove trailing " & "
return $BinaryData

I realize the function is not yet working for multi character conversion, but that's not the issue. I just need to understand how I can combine the 2 characters for ExString into one correct value.

Edited by SlowCoder74
Link to post
Share on other sites

69255, SlowCoder74,

Those binary strings are Unicode UTF-8. Lookup BinaryToString parameters to convert them correctly in all cases.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...