Sebastiaan81 Posted January 2, 2009 Posted January 2, 2009 The way regwrite is used with reg_binary types had changed. Is there still a way to input the data as hex value? Or how should I write the string value. I want to use this to change the 'new signature' value for a signature script. For instance I used to write a value "74 00 65 00 73 00 74 00 00 00" which resulted in "t.e.s.t..." but when I write is as a string it reads the dots and i get; "74 2E 65 2E 73 2E 74 2E 2E 2E" but without the dots I dont get the desired result. Anybody got an idea? 24th December, 2008 - v3.3.0.0 Changed: RegRead() and RegWrite() no longer use hex strings for REG_BINARY types - native binary datatypes are enforced.
Zinthose Posted January 2, 2009 Posted January 2, 2009 The way regwrite is used with reg_binary types had changed. Is there still a way to input the data as hex value? Or how should I write the string value. I want to use this to change the 'new signature' value for a signature script. For instance I used to write a value "74 00 65 00 73 00 74 00 00 00" which resulted in "t.e.s.t..." but when I write is as a string it reads the dots and i get; "74 2E 65 2E 73 2E 74 2E 2E 2E" but without the dots I dont get the desired result. Anybody got an idea? 24th December, 2008 - v3.3.0.0 Changed: RegRead() and RegWrite() no longer use hex strings for REG_BINARY types - native binary datatypes are enforced. The value you are reading/writing is in UTF16 Little Endian unicode format. Since Null chars are used to terminate strings they are replaced with the "." char when read as a straight ASCII string. Dim $BinaryValue, $StringValue ;$BinaryValue = RegRead("HKLM\Software\Path", "BinaryValue") $BinaryValue = "7400650073007400" $BinaryValue = Binary("0x" & $BinaryValue) $StringValue = BinaryToString($BinaryValue, 2) ConsoleWrite('$StringValue = ' & $StringValue & @crlf) --- TTFN
Sebastiaan81 Posted January 5, 2009 Author Posted January 5, 2009 thanks Zinthose for your reply. When I use this, the value I get is with 00 at the end of the value, but not between each letter. 'test' becomes '0x74006500730074000000' in the registry it becomes '74 65 73 74 00 ' ('test.') Ok I get an extra dot at the end, according to my original I need it to be '74 00 65 00 73 00 74 00 00 00' ( 't.e.s.t...') Any thoughts? thanks...
PsaltyDS Posted January 5, 2009 Posted January 5, 2009 thanks Zinthose for your reply. When I use this, the value I get is with 00 at the end of the value, but not between each letter. 'test' becomes '0x74006500730074000000' in the registry it becomes '74 65 73 74 00 ' ('test.') Ok I get an extra dot at the end, according to my original I need it to be '74 00 65 00 73 00 74 00 00 00' ( 't.e.s.t...') Any thoughts? thanks... To complete the example: Global $sRegKey = "HKLM\SOFTWARE\Test", $sRegValue = "BinTest" Global $sWriteText = "test" ConsoleWrite("$sWriteText = " & $sWriteText & " Type = " & VarGetType($sWriteText) & @LF) Global $bRegWrite = StringToBinary($sWriteText, 2); 2 = UTF16 LE ConsoleWrite("$bRegWrite = " & $bRegWrite & " Type = " & VarGetType($bRegWrite) & @LF) RegWrite($sRegKey, $sRegValue, "REG_BINARY", $bRegWrite) $bRegRead = RegRead($sRegKey, $sRegValue) ConsoleWrite("$bRegRead = " & $bRegRead & " Type = " & VarGetType($bRegRead) & @LF) $sReadText = BinaryToString($bRegRead, 2); 2 = UTF16 LE ConsoleWrite("$sReadText = " & $sReadText & " Type = " & VarGetType($sReadText) & @LF) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Zinthose Posted January 5, 2009 Posted January 5, 2009 thanks Zinthose for your reply. When I use this, the value I get is with 00 at the end of the value, but not between each letter. 'test' becomes '0x74006500730074000000' in the registry it becomes '74 65 73 74 00 ' ('test.') Ok I get an extra dot at the end, according to my original I need it to be '74 00 65 00 73 00 74 00 00 00' ( 't.e.s.t...') Any thoughts? thanks... Ah, I see what your trying to do. ;## ASCII to Unicoded binary value $UnicodeValue = _AsciiToBinaryUnicode("test") ConsoleWrite("Binary Value: " & $UnicodeValue & @CRLF) ;## Save the Binary Value to a test registry location $Return = RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Test", "TestKey", "REG_BINARY", Hex($UnicodeValue) & "0000") ;## Convert the binary value into a Unicode string $UnicodeValue = BinaryToString($UnicodeValue, 2) ConsoleWrite("String Value: " & $UnicodeValue & @CRLF) Func _AsciiToBinaryUnicode($String) Local $Length, $typString, $typBinary Local $Value, $sValue, $bValue ;## Validate Parameters If Not IsString($String) Then Return SetError(1, 0, 0) ;## Define Structures $Length = StringLen($String) $typString = "wchar Value[" & $Length + 1 & "]"; <-- Unicode String $typBinary = "byte Value[" & $Length * 2 & "]"; <-- Binary Array ;## Perform type conversion of the provided ASCII string into a binary value $sValue = DllStructCreate($typString) DllStructSetData($sValue, "Value", $String) $bValue = DllStructCreate($typBinary, DllStructGetPtr($sValue)) $Value = DllStructGetData($bValue, "Value") Return $Value EndFunc --- TTFN
Sebastiaan81 Posted February 10, 2009 Author Posted February 10, 2009 Ok thanks guys, I will try this. I was on vacation a couple of weeks and need to catch up first before I can continue with this script, sorry for the late reaction
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now