FaridAgl Posted December 26, 2013 Share Posted December 26, 2013 Global Const $SIGNATURE = Binary(0xDEADBEEFDEADBEEF) ConsoleWrite($SIGNATURE & @CRLF) ;Output: 0xEFBEADDEEFBEADDE http://faridaghili.ir Link to comment Share on other sites More sharing options...
guinness Posted December 26, 2013 Share Posted December 26, 2013 Why? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
FaridAgl Posted December 26, 2013 Author Share Posted December 26, 2013 Shouldn't it output 0xDEADBEEFDEADBEEF ? http://faridaghili.ir Link to comment Share on other sites More sharing options...
guinness Posted December 26, 2013 Share Posted December 26, 2013 It does >> Binary('0xDEADBEEFDEADBEEF') ; When you pass a string. Why cast a binary value to binary? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
FaridAgl Posted December 26, 2013 Author Share Posted December 26, 2013 (edited) #include <FileConstants.au3> ;It's all OK with FileRead, the binary result gets stored in proper format Global $hFile = FileOpen("File.dat", BitOR($FO_READ, $FO_BINARY)) Global $bData = FileRead($hFile, 8) FileClose($hFile) ConsoleWrite(VarGetType($bData) & @TAB & ":" & @TAB & $bData & @CRLF) ;It's not what I want at all Global Const $iSignature = 0xDEADBEEFDEADBEEF ConsoleWrite(VarGetType($iSignature) & @TAB & ":" & @TAB & $iSignature & @CRLF) ;But here, it's amazing!!! Global Const $bSignature = Binary(0xDEADBEEFDEADBEEF) ConsoleWrite(VarGetType($bSignature) & @TAB & ":" & @TAB & $bSignature & @CRLF & @CRLF) ;I need $bSignature to be 0xDEADBEEFDEADBEEF, and not 0xEFBEADDEEFBEADDE ;And of course I want its type to be Binary ;So I can test its equality with $bData in binary mode ConsoleWrite("Invalid" & @TAB & ":" & @TAB & BitXOR($bData, $bSignature) & @CRLF) ;It's somehow odd, as both $bData and $bSignature are 0xDEADBEEFDEADBEEF ;The result should be like this Global Const $bOddSignature = Binary(0xEFBEADDEEFBEADDE) ConsoleWrite("Valid" & @TAB & ":" & @TAB & BitXOR($bData, $bOddSignature) & @CRLF) ;0 means they are equal I have attached the file I'm reading in the above code (File.dat): Edited December 26, 2013 by D4RKON3 http://faridaghili.ir Link to comment Share on other sites More sharing options...
czardas Posted December 27, 2013 Share Posted December 27, 2013 It's reversing the order of bytes. I just deleted what I first posted because guinness already answered it. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
jpm Posted December 27, 2013 Share Posted December 27, 2013 It does >> Binary('0xDEADBEEFDEADBEEF') ; When you pass a string. Why cast a binary value to binary? Perhaps this behavior should be described somewhere in the help. Not sure it is Cheers Jpm Link to comment Share on other sites More sharing options...
MHz Posted December 27, 2013 Share Posted December 27, 2013 ; Integer type as hexidecimal number cast to binary ConsoleWrite(VarGetType(0xDEADBEEFDEADBEEF) & @CRLF) ; = Int64 ConsoleWrite(0xDEADBEEFDEADBEEF & @CRLF) ; = -2401053088876216593 ConsoleWrite(Binary(0xDEADBEEFDEADBEEF) & @CRLF) ; = 0xEFBEADDEEFBEADDE ConsoleWrite(Binary(-2401053088876216593) & @CRLF) ; = 0xEFBEADDEEFBEADDE ; String type as string expression cast to binary ConsoleWrite(VarGetType('0xDEADBEEFDEADBEEF') & @CRLF) ; = String ConsoleWrite('0xDEADBEEFDEADBEEF' & @CRLF) ; = 0xDEADBEEFDEADBEEF ConsoleWrite(Binary('0xDEADBEEFDEADBEEF') & @CRLF) ; = 0xDEADBEEFDEADBEEF -2401053088876216593 to type binary. Not a good expression. Link to comment Share on other sites More sharing options...
guinness Posted December 27, 2013 Share Posted December 27, 2013 Perhaps this behavior should be described somewhere in the help. Not sure it is Cheers Jpm Should it? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Iczer Posted December 27, 2013 Share Posted December 27, 2013 I think it should - as any non logical behaviour should be documented. Otherwise its too close to bug. I mean 0xDEADBEEFDEADBEEF is valid expression Link to comment Share on other sites More sharing options...
jchd Posted December 27, 2013 Share Posted December 27, 2013 It IS perfectly logical behavior, unless you ignore the endianness of Intel processors (in which case you probably should keep away from messing up with anything binary). ConsoleWrite(Binary(1) & @CRLF) 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 hereRegExp tutorial: enough to get startedPCRE 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 More sharing options...
FaridAgl Posted December 27, 2013 Author Share Posted December 27, 2013 It's how data are stored (Low bytes & High bytes), that's true but the question is, shouldn't AutoIt handle it and return them in the proper format? http://faridaghili.ir Link to comment Share on other sites More sharing options...
trancexx Posted December 27, 2013 Share Posted December 27, 2013 ^^ It does. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
FaridAgl Posted December 27, 2013 Author Share Posted December 27, 2013 (edited) Does it? Global $bData1 = Binary(0x1234) Global $bData2 = Binary("0x1234") ConsoleWrite(VarGetType($bData1) & " : " & $bData1 & @CRLF) ;Binary : 0x34120000 ConsoleWrite(VarGetType($bData2) & " : " & $bData2 & @CRLF) ;Binary : 0x1234 ConsoleWrite(BitXOR($bData1, $bData2) & @CRLF) ;Returns 9766 ;BitXOR returns 0 for two equal binary value Edited December 27, 2013 by D4RKON3 http://faridaghili.ir Link to comment Share on other sites More sharing options...
jchd Posted December 27, 2013 Share Posted December 27, 2013 You have successfully demonstrated a correct behavior. 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 hereRegExp tutorial: enough to get startedPCRE 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 More sharing options...
GtaSpider Posted December 27, 2013 Share Posted December 27, 2013 This is a correct behavior! 0x1234 will be converted to 4660 integer. This is documented in helpfile under "Language Reference -> Datatypes". And jchd tells you the answer why its swapped (endians from intel processors) $bData1 = Binary(0x1234);0x1234 = 4660 --> int $bData2 = Binary(4660);is the same --> int $bData3 = Binary("4660");"4660" -> ASCII (0x34 + 0x36 + 0x36 + 0x30) $bData4 = Binary("0x1234"); = ASCII: DC2 and 4 characters (--> see SciTe console) ConsoleWrite($bData1 & @LF) ConsoleWrite($bData2 & @LF) ConsoleWrite($bData3 & @LF) ConsoleWrite($bData4 & @LF) ConsoleWrite(BinaryToString($bData4) & @LF) Greetz, Spider www.AutoIt.de - Moderator of the German AutoIt Forum Link to comment Share on other sites More sharing options...
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