I want to read 4 bytes and convert them to a string so that for instance [44 4A 44 3A] look like "444A443A" so that I can name the files after a series of bytes.
Looked around the documentation for hours, but can't find how to do that, if that can be done.
How is this done in a BMS script?
Edit: Just saw that there WAS a help section for QuickBMS. wow I have missed that for years lol. So, move this there if you want to.
Reading 4 bytes "long" and literally converting to String [BMS]
-
- Posts: 290
- Joined: Fri Mar 30, 2018 2:48 am
-
- Site Admin
- Posts: 12984
- Joined: Wed Jul 30, 2014 9:32 pm
Re: Reading 4 bytes "long" and literally converting to String [BMS]
Anyway one method is the following:
Code: Select all
math VAR = 0x444A443A
string STR = VAR
print "%STR%"
-
- Posts: 290
- Joined: Fri Mar 30, 2018 2:48 am
Re: Reading 4 bytes "long" and literally converting to String [BMS]
aluigi wrote:Anyway one method is the following:Code: Select all
math VAR = 0x444A443A
string STR = VAR
print "%STR%"
I tried this, but it displays the string of the value, so "48 8A BA DE" becomes "HŠºÞ".
I want to read 4 bytes from the file and use the hexadecimal values as the name of the file, but it always translate them to the string counterpart(or an integer)
So to further explain, I want to read hexadecimals and also display the hexadecimals and NOT the strings or integers that those hexadecimals represent.
I want 48 8A BA DE to display as the same thing but as a string, but NOT convert it to a string, but display 48 8A BA DE when i do "print" or name a file.
Edit: Here is how I am setting the name:
Code: Select all
string NAME p "%s\%s\%s" FOLDER "OFFSET" "AES1"
AES1 is just
Code: Select all
get AES1 long
Edit2: After LOTS of looking in the documentation, I figured out you need to use "%x" to display the Hex values.
So the end result should look like this:
Code: Select all
string NAME p "%s\%s\%x" FOLDER "OFFSET" "AES1"
or
Code: Select all
string NAME p "%s\%s\%X" FOLDER "OFFSET" "AES1"
for uppercase letters.
-
- Site Admin
- Posts: 12984
- Joined: Wed Jul 30, 2014 9:32 pm
Re: Reading 4 bytes "long" and literally converting to String [BMS]
ok you already found the solution
Maybe you want to use %08x instead of %x for giving a fixed size to the hex
Maybe you want to use %08x instead of %x for giving a fixed size to the hex