Findloc get the end offset

Doubts, help and support about QuickBMS and other game research tools
crushedice2000
Posts: 32
Joined: Sun Nov 08, 2015 8:37 pm

Findloc get the end offset

Post by crushedice2000 »

When I use findloc I get the start offset of the found pattern, but, can I get the offset of the pattern end?

Example of input:

Code: Select all

Magic Header 1.0


Example of code:

Code: Select all

findloc OFFSET string "Magic Header "
goto OFFSET
get VERSION string
print "VERSION: %VERSION%"


Expected output:

Code: Select all

1.0


Current output:

Code: Select all

Magic Header 1.0
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Findloc get the end offset

Post by aluigi »

Just add the length of the searched string to OFFSET:

Code: Select all

findloc OFFSET string "Magic Header "
math OFFSET + 13
goto OFFSET
get VERSION string
print "VERSION: %VERSION%"
crushedice2000
Posts: 32
Joined: Sun Nov 08, 2015 8:37 pm

Re: Findloc get the end offset

Post by crushedice2000 »

Thank you! However I need to make you two questions more:

1. How can I get the string length to clarify the code (no need for anybody to guess what means 13):

Code: Select all

set MAGIC string "Magic Header "
findloc OFFSET string MAGIC
math OFFSET + len(MAGIC)
goto OFFSET
get VERSION string
print "VERSION: %VERSION%"


2. Is there any QuickBMS reference manual to avoid bother you with silly questions? :twisted:
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Findloc get the end offset

Post by aluigi »

You can use the strlen command to get the length:
strlen MAGICSZ MAGIC
math OFFSET + MAGICSZ

The main concept of the bms/mexscript language is that it's basic and uses just one command per line, that's why a "math OFFSET + len(MAGIC)" is not possible because that would be like having 2 commands in the same line.


The reference manual of quickbms is just quickbms.txt, the file located in the quickbms package and mirrored here:
http://aluigi.org/papers/quickbms.txt

It contains the full list of commands and what their arguments do.
The language has been improved during the last years with some features that weren't planned and sometimes were difficult to "fit" inside the original syntax.
For example the operators of the String command are far from being intuitive but they cover all the operations encountered till now during the working on file formats.
crushedice2000
Posts: 32
Joined: Sun Nov 08, 2015 8:37 pm

Re: Findloc get the end offset

Post by crushedice2000 »

Wow! I figured out that quickbms.txt was only for usage and not programming reference... :o Now I see that I have a complete BMS documentation.

Is a pity to be restricted to one command per line. However, this simplifies the program.

Thank you! I'm learning QuickBMS because it can help me a lot... Now I'm working with raw binary data files. :)