Jump to content

idm hex to value how can?


Recommended Posts

  • Developers

Should that should HEX information contain the value 5460004555? 
Hex for 5460004555 is "0x145710ECB".

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create a hex string, e.g. using RegEx or string functions (remove commas) -> I'm sure you can do that yourself ;).

Local $sHexStr
$sHexStr = "f4c0bb7f00000000"
ConsoleWrite(_Hex2Dec('0x' & $sHexStr) & @CRLF & @CRLF)
$sHexStr = "f4c0bb7f"
ConsoleWrite(_Hex2Dec('0x' & $sHexStr) & @CRLF & @CRLF)

Func _Hex2Dec($iN)
    Local $aN, $ihex = 0
    $aN = StringSplit(StringTrimLeft($iN, 2), "", 1)
    For $x = 1 To UBound($aN) - 1
        $ihex += Dec($aN[$x]) * (16 ^ (UBound($aN) - 1 - $x))
    Next
    Return $ihex
EndFunc ;==>_Hex2Dec

EDIT Pay attention to the advice given by @jchd regarding endianness (two posts below). I neglected to mention that.

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

  • Developers
34 minutes ago, drmusti said:

dear only example

Yea right ...... So you post something to convert to a decimal value but they are unrelated...  smart. 

35 minutes ago, drmusti said:

please help me that this subject.

Sure, when you a capable of posting some related information -> input with the expected output. ;) 

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Beware of endianness:

0x7FBBC0F4 =                                            2 143 011 060 [10]
0xF4C0BB7F =                                            4 106 271 615 [10]
0xF4C0BB7F00000000 =      -810 441 778 791 448 576 [10] (signed)
0xF4C0BB7F00000000 = 17 636 302 294 918 103 040 [10] (unsigned)

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 comment
Share on other sites

A different approach displaying correctly the 64 bits integer :

Local $sHexStr = "f4c0bb7f00000000"
ConsoleWrite("0x" & $sHexStr & " = " & _Hex2Dec($sHexStr) & " [signed]" & @CRLF)
ConsoleWrite("0x" & $sHexStr & " = " & _Hex2Dec($sHexStr, False) & " [unsigned]" & @CRLF)
$sHexStr = "f4c0bb7f"
ConsoleWrite("0x" & $sHexStr & " = " & _Hex2Dec($sHexStr) & @CRLF)

Func _Hex2Dec($iN, $bSigned = True)
  If Mod(StringLen($iN),2) Then $iN = "0" & $iN
  Local $tByte = DllStructCreate ("byte string [8]")
  Local $tINT64 = DllStructCreate ("INT64 int", DllStructGetPtr ($tByte))
  Local $tUINT64 = DllStructCreate ("UINT64 uint", DllStructGetPtr ($tByte))
  Local $j = 1, $aResult
  For $i = StringLen($iN)-1 to 0 Step -2
    DllStructSetData ($tByte, "string", "0x" & StringMid($iN,$i,2),$j)
    $j += 1
  Next
  If $bSigned Then
    $aResult = DllCall("msvcrt.dll", "INT:cdecl", "sprintf", "STR", "", "STR", "%lli", "INT64", $tINT64.int)
  Else
    $aResult = DllCall("msvcrt.dll", "INT:cdecl", "sprintf", "STR", "", "STR", "%llu", "UINT64", $tUINT64.uint)
  EndIf
  Return $aResult[1]
EndFunc ;==>_Hex2Dec

 

Link to comment
Share on other sites

"FileSize"=hex(0):f4,c0,bb,7f,00,00,00,00    at Internet Download Manager result : 1,99  GB (2143011060 Bytes)     

i cant fix logic.

0xf4c0bb7f00000000 = -810441778791448576 [signed]

0xf4c0bb7f00000000 = 17636302294918103040 [unsigned]

0xf4c0bb7f = 4106271615

how can get "2143011060 Bytes" ?

thank you very much for all helpings.

 

 

 

 

 

 

.

 

 

Link to comment
Share on other sites

3 hours ago, jchd said:

Beware of endianness:

0x7FBBC0F4 =                                            2 143 011 060 [10]
0xF4C0BB7F =                                            4 106 271 615 [10]
0xF4C0BB7F00000000 =      -810 441 778 791 448 576 [10] (signed)
0xF4C0BB7F00000000 = 17 636 302 294 918 103 040 [10] (unsigned)

how can find or convert this value. because true bytes for result.

0x7FBBC0F4 =                                            2 143 011 060 [10]

2 143 011 060  bytes true....

how can convert or find this?

 

Edited by drmusti
Link to comment
Share on other sites

3 hours ago, jchd said:

0x7FBBC0F4 =                                            2 143 011 060 [10]

Like that!

Place the bytes in little endianness order (reverse order).

Edited by jchd

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 comment
Share on other sites

  • Developers

Something like this?:

$kvalue = "hex(0):f4,c0,bb,7f,00,00,00,00"
$hSize = ""
$Akey = StringSplit(StringMid($kvalue, StringInStr($kvalue, ":") + 1), ",")
For $x = UBound($Akey) - 1 to 1 Step -1
    If ($Akey[$x] <> "00") Then
        $hSize &= $Akey[$x]
    EndIf
Next
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Dec($hSize) = ' & Dec($hSize) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

$kvalue = "hex(0):74,72,76,22,00,00,00,00"
$hSize = ""
$Akey = StringSplit(StringMid($kvalue, StringInStr($kvalue, ":") + 1), ",")
For $x = UBound($Akey) - 1 to 1 Step -1
    If ($Akey[$x] <> "00") Then
        $hSize &= $Akey[$x]
    EndIf
Next
;ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Dec($hSize) = ' & Dec($hSize) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

Local $idm_get_filesize= Dec($hSize)

 

great working but proplem regread get empty?

my OS : WIN7 x64 pro

i added attach reg file for test.

 

#include <MsgBoxConstants.au3>

Local $sFileSizeee = RegRead("HKEY_CURRENT_USER\Software\DownloadManager\4950", "FileSize")
MsgBox($MB_SYSTEMMODAL, "", "get idm file size: " & $sFileSizeee)

result:empty value

that cant get  value  hex(0):f4,c0,bb,7f,00,00,00,00

result:empty value

what is true function or code?
Sincerely

 

 

 

 

 

 

 

4705 test reg file.reg

4950 test reg file.reg

Edited by drmusti
update
Link to comment
Share on other sites

4 minutes ago, Nine said:

You shouldn't need to use it in HKCU, but try using #RequireAdmin, cause you should get a binary string. 

#include <MsgBoxConstants.au3>
#RequireAdmin

Local $sFileSizeee = RegRead("HKEY_CURRENT_USER\Software\DownloadManager\4950", "FileSize")
MsgBox($MB_SYSTEMMODAL, "", "get idm file size: " & $sFileSizeee)

i try but result empty dear.

 

 

Link to comment
Share on other sites

What is the console output when you run this script :

#include <AutoItConstants.au3>
Local $iError, $iVarType, $sVarTypeName
Local $sValue = RegRead("HKEY_CURRENT_USER\Software\DownloadManager\4950", "FileSize")
$iError   = @error
$iVarType = @extended

Switch $iVarType
    Case $iVarType = 0
        $sVarTypeName = "$REG_NONE"
    Case $iVarType = 1
        $sVarTypeName = "$REG_SZ"
    Case $iVarType = 2
        $sVarTypeName = "$REG_EXPAND_SZ"
    Case $iVarType = 3
        $sVarTypeName = "$REG_BINARY"
    Case $iVarType = 4
        $sVarTypeName = "$REG_DWORD / $REG_DWORD_LITTLE_ENDIAN"
    Case $iVarType = 5
        $sVarTypeName = "$REG_DWORD_BIG_ENDIAN"
    Case $iVarType = 6
        $sVarTypeName = "$REG_LINK"
    Case $iVarType = 7
        $sVarTypeName = "$REG_MULTI_SZ"
    Case $iVarType = 8
        $sVarTypeName = "$REG_RESOURCE_LIST"
    Case $iVarType = 9
        $sVarTypeName = "$REG_FULL_RESOURCE_DESCRIPTOR"
    Case $iVarType = 10
        $sVarTypeName = "$REG_RESOURCE_REQUIREMENTS_LIST"
    Case $iVarType = 11
        $sVarTypeName = "$REG_QWORD / $REG_QWORD_LITTLE_ENDIAN"
Case Else
    $sVarTypeName = "UNKNOWN"
EndSwitch

ConsoleWrite("Value       : " & $sValue & @CRLF)
ConsoleWrite("Error       : " & $iError & @CRLF)
ConsoleWrite("VarType     : " & $iVarType & @CRLF)
ConsoleWrite("VarTypeName : " & $sVarTypeName & @CRLF)

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

7 minutes ago, Musashi said:

What is the console output when you run this script :

#include <AutoItConstants.au3>
Local $iError, $iVarType, $sVarTypeName
Local $sValue = RegRead("HKEY_CURRENT_USER\Software\DownloadManager\4950", "FileSize")
$iError   = @error
$iVarType = @extended

Switch $iVarType
    Case $iVarType = 0
        $sVarTypeName = "$REG_NONE"
    Case $iVarType = 1
        $sVarTypeName = "$REG_SZ"
    Case $iVarType = 2
        $sVarTypeName = "$REG_EXPAND_SZ"
    Case $iVarType = 3
        $sVarTypeName = "$REG_BINARY"
    Case $iVarType = 4
        $sVarTypeName = "$REG_DWORD / $REG_DWORD_LITTLE_ENDIAN"
    Case $iVarType = 5
        $sVarTypeName = "$REG_DWORD_BIG_ENDIAN"
    Case $iVarType = 6
        $sVarTypeName = "$REG_LINK"
    Case $iVarType = 7
        $sVarTypeName = "$REG_MULTI_SZ"
    Case $iVarType = 8
        $sVarTypeName = "$REG_RESOURCE_LIST"
    Case $iVarType = 9
        $sVarTypeName = "$REG_FULL_RESOURCE_DESCRIPTOR"
    Case $iVarType = 10
        $sVarTypeName = "$REG_RESOURCE_REQUIREMENTS_LIST"
    Case $iVarType = 11
        $sVarTypeName = "$REG_QWORD / $REG_QWORD_LITTLE_ENDIAN"
Case Else
    $sVarTypeName = "UNKNOWN"
EndSwitch

ConsoleWrite("Value       : " & $sValue & @CRLF)
ConsoleWrite("Error       : " & $iError & @CRLF)
ConsoleWrite("VarType     : " & $iVarType & @CRLF)
ConsoleWrite("VarTypeName : " & $sVarTypeName & @CRLF)

 

i done result

Value       :

error       : -2

type name       : $REG_SZ

 

empty.   dear error -2 what mean?

i cant read .

 

 

Link to comment
Share on other sites

2 minutes ago, drmusti said:

dear error -2 what mean?

see help :

@error: 1 = unable to open requested key
 2 = unable to open requested main key
 3 = unable to remote connect to the registry
-1 = unable to open requested value
-2 = value type not supported

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

1 minute ago, Musashi said:

see help :

@error: 1 = unable to open requested key
 2 = unable to open requested main key
 3 = unable to remote connect to the registry
-1 = unable to open requested value
-2 = value type not supported

result: readreg that value impossible?   or any solution?

 

Link to comment
Share on other sites

11 minutes ago, drmusti said:

or any solution?

What happens, when you use :

Local $sValue = RegRead("HKCU64\Software\DownloadManager\4950", "FileSize")

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...