Tyranna Posted July 23, 2017 Share Posted July 23, 2017 (edited) expandcollapse popup;Trying to format the output of my homemade hexdump displayer. ;Getting problems with the string output of the Hex() function. ;After I perform math or assignment to the variable I get junk. ; ; Many lines removed to obtain readability. ; ; Working Example that does not use Hex() ; This works, but, I do not want a decimal number for the ADDRESS. For $j = 1 to 16 $MEMOUT &= " " & $CurrentMemorySearchAddress & " | " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 007 , 001 ) ) ... $CurrentMemorySearchAddress += 1 $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 009 , 001 ) ) $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 010 , 001 ) ) ... Next " ADDRESS | B1B2 | B3B4 | B1B2 | B3B4 | B1B2 | B3B4 | B1B2 | B3B4 | ASCII OUTPUT " "=======================================================================================" " 4198418 | 3200 | 0090 | 9090 | 9090 | 9090 | 9090 | 9090 | 558B | 2.............U. " " 4198420 | EC8B | 4D08 | E855 | 0200 | 005D | C390 | 9090 | E80B | ..M..U...]...... " " 4198422 | 0000 | 00E9 | 1600 | 0000 | 9090 | 9090 | 9090 | B920 | ............... " ;Failing Example 2 ; now if I use the Hex() in there and I get this, first time it works, after math is performed on ; $CurrentMemorySearchAddress it seems the Hex() produces garbage. For $j = 1 to 16 $MEMOUT &= " " & Hex( $CurrentMemorySearchAddress ) & " | " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 007 , 001 ) ) ... $CurrentMemorySearchAddress += 1 $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 009 , 001 ) ) $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 010 , 001 ) ) ... Next " ADDRESS | B1B2 | B3B4 | B1B2 | B3B4 | B1B2 | B3B4 | B1B2 | B3B4 | ASCII OUTPUT " "=======================================================================================" " 00401000 | E99B | 2B00 | 0090 | 9090 | 9090 | 9090 | 9090 | 9090 | ..+............. " " 4150040080000000 | E9EB | 3200 | 0090 | 9090 | 9090 | 9090 | 9090 | 9090 | ..2............. " " 4150040100000000 | 558B | EC8B | 4D08 | E855 | 0200 | 005D | C390 | 9090 | U...M..U...].... " " 4150040180000000 | E80B | 0000 | 00E9 | 1600 | 0000 | 9090 | 9090 | 9090 | " Edited July 23, 2017 by Tyranna Link to comment Share on other sites More sharing options...
kylomas Posted July 23, 2017 Share Posted July 23, 2017 (edited) Tyranna, Try specifying the length...from the help file Remarks Omitting the second parameter (length) or using the keyword Default results in automatic sizing of the output; 8-characters display for numbers that can fit in that and 16-characters display for others. A pointer type parameter is displayed in size of pointer by default (8 characters for x86 and 16 characters for x64). 64bit integers have 16 characters displayed by default. kylomas Edited July 23, 2017 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Tyranna Posted July 23, 2017 Author Share Posted July 23, 2017 (edited) Already been there.... That just truncates off part of the corrupted string. Its is corrupted before the fomatting that the # of charachters value places on it. Maybe its turning signed? I do not know how to change the bad ouptut to non signed so I can ckeck. Edited July 23, 2017 by Tyranna Link to comment Share on other sites More sharing options...
RTFC Posted July 24, 2017 Share Posted July 24, 2017 You could try replacing Hex() with Ptr() for your memory address. However I'm unable to reproduce your error with what you provided (having to guess the contents of various vars). What you posted is not a reproducer script, as essential variables are not initialised. If you wish people to study what goes wrong, please provide a (smallest-possible) script that actually runs out-of-the-box and stand-alone, without external dependencies. Help us to help you. My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Tyranna Posted July 24, 2017 Author Share Posted July 24, 2017 Ok, trying to make something that is external, will post again soon. Link to comment Share on other sites More sharing options...
RTFC Posted July 24, 2017 Share Posted July 24, 2017 Before you do, did you try my Ptr() suggestion? My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Tyranna Posted July 24, 2017 Author Share Posted July 24, 2017 Not yet, I cant get the example I am trying to create to fail like my other script. I don't know what is affecting the Hex() I got a gui in the original with a Edit control takingoutput.... gimme a sec and i will have that done Link to comment Share on other sites More sharing options...
Tyranna Posted July 24, 2017 Author Share Posted July 24, 2017 Luckily the PTR help does not tell me what the " pointer representation of the expression." would be but is outputing hex numbers like 0x0401000. Ok, I just incorporated that into the script, and used a stringright function to chop the 0x offf the front and that seems to work, I am still super puzzled why I am getting the strange results from Hex() th0.... I can not be finished with this until I KNOW what is happeneing! arg! Link to comment Share on other sites More sharing options...
Tyranna Posted July 24, 2017 Author Share Posted July 24, 2017 I am thinking that my variable is being converted into a 64 bit signed int when I perform math on it. But I do not know how to prove that.. The first Hex() value is always correct, then I do math on it and it produces that funny output. myVar = 4198418 when it passed to the output function first output of hex(myVar) = 00401000 CORRECT! myVar +=1 now hex(myVar) = 4150040400000000 WTF! Link to comment Share on other sites More sharing options...
RTFC Posted July 24, 2017 Share Posted July 24, 2017 When I do this: $myVar = 4198418 consolewrite(hex($myVar) & @CRLF) $myVar+=1 consolewrite(hex($myVar) & @CRLF) I get this: 00401012 00401013 My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Tyranna Posted July 24, 2017 Author Share Posted July 24, 2017 I cannot get the Hex() function to fail in a seperate script that does the exact same thing! Link to comment Share on other sites More sharing options...
RTFC Posted July 24, 2017 Share Posted July 24, 2017 (edited) So that in itself should already tell you something... If it's script-specific, maybe even variable-specific, then somwhere your variable may get mangled/reassigned/converted. Try renaming it, duplicating/monitoring its state at different points. And this provides an another example of why writing a tiny reproducer script can be so useful. Edited July 24, 2017 by RTFC My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Tyranna Posted July 24, 2017 Author Share Posted July 24, 2017 Your right of course, and I have done that, and as you can see from the example I have up top in this post, in the second iteration of the loop, the number goes funny. This first iteration is not affected. That is where it is happenning. Cant tell why it is happening and can not reproduce it yet in another script doing the same thing. I am currently pulling massive chunks from the offending script and am not seeing anything fail yet. Link to comment Share on other sites More sharing options...
RTFC Posted July 24, 2017 Share Posted July 24, 2017 Keep stripping it down further, that's all I can recommend. What if you don't increment (+=1)? Is this variable used anywhere else? Do you have OnEvent or AdLib routines that may interfere? What if you use a new, separate variable just for these output loops? I'm going offline now, but best of luck. My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Tyranna Posted July 24, 2017 Author Share Posted July 24, 2017 Not incremeting produces: ADDRESS | B0B1 | B2B3 | B4B5 | B6B7 | B0B1 | B2B3 | B4B5 | B6B7 | ASCII OUTPUT ======================================================================================= 00401000 | E9 9B 2B 00 | 00 90 90 90 | 90 90 90 90 | 90 90 90 90 | ..+............. 00401000 | E9 EB 32 00 | 00 90 90 90 | 90 90 90 90 | 90 90 90 90 | ..2............. 00401000 | 55 8B EC 8B | 4D 08 E8 55 | 02 00 00 5D | C3 90 90 90 | U...M..U...].... 00401000 | E8 0B 00 00 | 00 E9 16 00 | 00 00 90 90 | 90 90 90 90 | ................ 00401000 | B9 20 AC A2 | 00 E9 26 00 | 00 00 90 90 | 90 90 90 90 | . ....&......... 00401000 | 68 60 10 40 | 00 E8 E5 0E | 19 00 59 C3 | 90 90 90 90 | h`.@......Y..... 00401000 | B9 20 AC A2 | 00 E9 26 00 | 00 00 90 90 | 90 90 90 90 | . ....&......... 00401000 | 56 8B F1 B9 | 30 AC A2 00 | E8 83 05 00 | 00 E8 AE 84 | V...0........... 00401000 | 06 00 8B C6 | 5E C3 90 90 | 90 90 90 90 | 90 90 90 90 | ....^........... 00401000 | 55 8B EC 83 | EC 18 A1 24 | AC A2 00 85 | C0 75 49 8B | U......$.....uI. 00401000 | 0D 9C B1 9C | 00 A1 98 B1 | 9C 00 8B 15 | A0 B1 9C 00 | ................ 00401000 | 89 4D EC 8D | 4D F4 89 45 | E8 8D 45 E8 | 51 68 00 11 | .M..M..E..E.Qh.. 00401000 | 40 00 B9 30 | AC A2 00 89 | 55 F0 C7 45 | F4 00 00 00 | @..0....U..E.... 00401000 | 00 C7 45 F8 | 01 00 00 00 | 89 45 FC E8 | 70 83 36 00 | ..E......E..p.6. 00401000 | 8B 4D F4 E8 | F8 00 00 00 | B9 30 AC A2 | 00 E8 3E 84 | .M.......0....>. 00401000 | 06 00 8B E5 | 5D C3 90 90 | 90 90 90 90 | 90 90 90 90 | ....]........... ======================================================================================= The Hex() function is reporting good. This var only appears in this output routine. It is not declared or used anywhere else. Link to comment Share on other sites More sharing options...
Tyranna Posted July 24, 2017 Author Share Posted July 24, 2017 You should see the whole routine.... expandcollapse popupFunc DisplayMemory( $MEMIN , $CurrentMemorySearchAddress ) GUICtrlSetData( $MemoryOutputBox , "" ) $MEMOUT = "" $MEMINDEX = 0 $MEMOUT &=" ADDRESS | B0B1 | B2B3 | B4B5 | B6B7 | B0B1 | B2B3 | B4B5 | B6B7 | ASCII OUTPUT " & @CRLF $MEMOUT &="=======================================================================================" & @CRLF For $j = 1 to 16 ;Out( Ptr( $CurrentMemorySearchAddress) & @CRLF ) ;$MEMOUT &= " " & StringRight( PTR( $CurrentMemorySearchAddress ) , 8 ) & " | " $MEMOUT &= " " & Hex( $CurrentMemorySearchAddress ) & " | " ;$MEMOUT &= " " & $CurrentMemorySearchAddress & " | " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 001 , 001 ) ) $MEMOUT &= " " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 002 , 001 ) ) $MEMOUT &= " " ;$MEMOUT &= " | " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 003 , 001 ) ) $MEMOUT &= " " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 004 , 001 ) ) $MEMOUT &= " " $MEMOUT &= "| " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 005 , 001 ) ) $MEMOUT &= " " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 006 , 001 ) ) $MEMOUT &= " " ;$MEMOUT &= "| " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 007 , 001 ) ) $MEMOUT &= " " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 008 , 001 ) ) $MEMOUT &= " " $MEMOUT &= "| " ;$CurrentMemorySearchAddress += 8 $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 009 , 001 ) ) $MEMOUT &= " " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 010 , 001 ) ) $MEMOUT &= " " ;$MEMOUT &= " | " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 011 , 001 ) ) $MEMOUT &= " " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 012 , 001 ) ) $MEMOUT &= " " $MEMOUT &= "| " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 013 , 001 ) ) $MEMOUT &= " " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 014 , 001 ) ) $MEMOUT &= " " ;$MEMOUT &= " | " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 015 , 001 ) ) $MEMOUT &= " " $MEMOUT &= Hex( BinaryMid ( $MEMIN , $MEMINDEX + 016 , 001 ) ) $MEMOUT &= " " $MEMOUT &= "| " ;$CurrentMemorySearchAddress += 8 For $i = 1 to 16 If Number( BinaryMid( $MEMIN , $MEMINDEX + $i , 001 ) ) < 31 Then $MEMOUT &= "." ElseIf Number( BinaryMid( $MEMIN , $MEMINDEX + $i , 001 ) ) > 127 Then $MEMOUT &= "." Else $MEMOUT &= Chr( Number( BinaryMid( $MEMIN , $MEMINDEX + $i , 001 ) ) ) EndIf Next $MEMINDEX += 16 $MEMOUT &= " " & @CRLF Next $MEMOUT &="=======================================================================================" GUICtrlSetData( $MemoryOutputBox , $MEMOUT ) EndFunc Link to comment Share on other sites More sharing options...
RTFC Posted July 24, 2017 Share Posted July 24, 2017 Put in ConsoleWrite's inside your loop to dump the mem address var. If these do not show the same error in console, then it might be the way the data are displayed in your output box. (And now I'm really gone.) My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Tyranna Posted July 24, 2017 Author Share Posted July 24, 2017 Ok, I got to go to work too. Link to comment Share on other sites More sharing options...
Tyranna Posted July 24, 2017 Author Share Posted July 24, 2017 (edited) ConsoleWrite("$CurrentMemorySearchAddress = " & Hex($CurrentMemorySearchAddress) & @CRLF ) produces: $CurrentMemorySearchAddress = 4150043400000000 $CurrentMemorySearchAddress = 4150043400000000 $CurrentMemorySearchAddress = 4150043600000000 $CurrentMemorySearchAddress = 4150043800000000 $CurrentMemorySearchAddress = 4150043800000000 $CurrentMemorySearchAddress = 4150043800000000 $CurrentMemorySearchAddress = 4150043A00000000 $CurrentMemorySearchAddress = 4150043C00000000 without incrementing: $CurrentMemorySearchAddress = 00401000 $CurrentMemorySearchAddress = 00401000 $CurrentMemorySearchAddress = 00401000 $CurrentMemorySearchAddress = 00401000 $CurrentMemorySearchAddress = 00401000 $CurrentMemorySearchAddress = 00401000 $CurrentMemorySearchAddress = 00401000 $CurrentMemorySearchAddress = 00401000 Edited July 24, 2017 by Tyranna Link to comment Share on other sites More sharing options...
cbruce Posted July 24, 2017 Share Posted July 24, 2017 Tyranna, can you provide a fully running script - including a simple framework that calls your function? That would allow us to run it and see what you are seeing. Troubleshooting someone else's script via code review is not much fun - and you get fewer responses. 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