Page 1 of 1

trying to make a bms script

Posted: Sun Jul 03, 2016 6:27 am
by happydance
sorry for the noob question, I was trying to learn how to make my own bms script but having difficulty if I'm getting the right value or offset. I little guidance is appreciated so I could get started.

Code: Select all

00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 20 
00 09 93 F0 00 00 00 00 00 00 01 5D 00 00 00 00
so I was trying to get the 00 00 00 20

so how would I do this?

like this

Code: Select all

endian big

goto 0c
get unknown long
or like this

Code: Select all

endian big

get unknown1 THREEBYTE
get unknown2 long

can I also display the values saved for example on unknown1 and unknown2? just to make sure i'm getting the right values

maybe like this

Code: Select all

print "%unknown1%"

Re: trying to make a bms script

Posted: Sun Jul 03, 2016 7:19 pm
by Gh0stBlade
The snippets of BMS script your provided should work. Are you having any syntax errors?

I would personally:

Code: Select all

endian big
goto 0xC
get unknown long
QuickBMS probably wants the hex offset prefixed by "0x". And yes, you can always print variables to ensure you are reading the correct data.

Re: trying to make a bms script

Posted: Mon Jul 04, 2016 11:09 am
by happydance
I revised my script to this and it seems to be working but there are some problems with it

Code: Select all

endian big
goto 0xc
get TMP1 long
get TMP2 long
get null long
xmath archiveSize "TMP2 - TMP1"
get FILENUM long
get null long
get null long
get unknown1 long
get null long
get unknown1 long
get unknown2 long
for i = 0 < FILENUM
  get OFFSET1 long
  get OFFSET2 long
  Math OFFSET1 + TMP1
  Math OFFSET2 + TMP1
  xmath SIZE "OFFSET2 - OFFSET1"
  log "" OFFSET1 SIZE
next I

Code: Select all

00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 20
00 09 93 F0 00 00 00 00 00 00 01 5D 00 00 00 00
00 00 00 00 00 00 01 5D 00 00 00 00 00 00 00 10
00 00 00 00 00 00 0B 00 00 00 24 40 00 00 33 B0
00 00 4B E0 00 00 5C D0 00 00 6B 60 00 00 7E 70
it only extract haft of the file mentioned on 00 00 01 5D...
it was supposed to extract from 00 00 00 0B 00 to 00 00 24 40 then from 00 00 24 40 to 00 00 33 B0.
but it extract from 00 00 00 0B 00 to 00 00 24 40 then from 00 00 33 B0 to 00 00 4B E0

but I was wrong and the size of the individual files are located at the end after all the offsets location of the individual files

Code: Select all

endian big
goto 0xc
get TMP1 long
get TMP2 long
get null long
xmath archiveSize "TMP2 - TMP1"
get FILENUM long
get null long
get null long
get SIZENUM long
get null long
get unknown1 long
get unknown2 long
xMath sizepad "FILENUM * 4 + TMP1"
for i = 0 < FILENUM
	get OFFSET long
	Math OFFSET + TMP1
	Padding sizepad
	get SIZE long
	goto OFFSET
	Print %SIZE%
	Print %OFFSET%
next ii
so my problem is how to I go to offset of the location to get the size then back to the next offset location of the second file then back to the offset of the second file

Re: trying to make a bms script

Posted: Mon Jul 04, 2016 1:06 pm
by chrrox
just keep your current position in the file table and use the log command for files.
example
goto 0xC - my position is 0xC
get offset long
get size long
my position in the file is 0x14
but i can store the data from anywhere in the file now
log name offset size
offset can be anywhere in the file and size is the amount of data to read from the offset.
my position ill remain at 0x14.

Re: trying to make a bms script

Posted: Mon Jul 04, 2016 3:20 pm
by happydance
my problem is the offset of the files are located from 0x34 to 0x5A4 and the sizes of the files are located on 0x5A8 to 0xB18

I think I managed to get the files with my messy unsure noob script

Code: Select all

endian big
goto 0xc
get TMP1 long
get TMP2 long
get null long
xmath archiveSize "TMP2 - TMP1"
get FILENUM long
get null long
get null long
get SIZENUM long
get null long
get unknown1 long
get unknown2 long
for i = 0 < FILENUM
	get OFFSET long
	Math OFFSET + TMP1
	Math OFFSETloc = OFFSET
	SavePos OFFSETloc
	xMath sizepad "FILENUM * 4"
	Math sizepad + OFFSETloc
	Math sizepad - 4
	Padding sizepad
	Get SIZE long
	log "" OFFSET SIZE
	Goto OFFSETloc	
next i
is this fine? while the extracted files are nameless, can I change the automatically generated names be decimal numbers and not hexadecimal? and would it code also work for reimport/reinject?

Re: trying to make a bms script

Posted: Mon Jul 04, 2016 11:12 pm
by chrrox
you can loop through saving the pos in each file table like this

set filetbloff 0x50
set sizetbloff 0x80

for i = 0 < files
goto filetbloff
get fileoff long
savepos filetbloff
goto sizetbloff
get filesize long
savepos sizetbloff
log "' offset size
next i

or you can use arrays in quickbms
goto filetbloff

for i = 0 < files
get off long
putarray 0 i off
next i

goto sizetbloff
for i = 0 < files
get size long
putarray 1 i size
next i

then you can do one mor eloop and grab the variables
example

for i = 0 < FILES
getarray FULLNAME 10 i
getarray OFFSET 2 i
getarray ZSIZE 3 i
getarray SIZE 4 i
getarray PACKED 5 i

log file here
next i

Re: trying to make a bms script

Posted: Tue Jul 05, 2016 6:35 pm
by happydance
thanks will try using that code and see if I can get it to work

*edit*

Code: Select all

endian big
goto 0xc
get headerpad long
goto 0x18
get FILENUM long
Padding 9
get SIZENUM long
xMath sizeoff "SIZENUM * 4 + 52"
set filetbloff 0x34
set sizetbloff "sizeoff"
for i = 0 < FILENUM
	goto filetbloff
	get OFFSET long
	math OFFSET + headerpad
	savepos filetbloff
	goto sizetbloff
	get SIZE long
	savepos sizetbloff
	xmath HEXNAME "OFFSET - headerpad"
	string NAME p= "%08x.bin" HEXNAME
	log "NAME" OFFSET SIZE	
next i
I tried the 1st code you've provided since it's the one I barely understand and it works great.I think i'm beginning to understand it a bit thanks!!

one last question, what to do with no IDstring files? they got same file extentions and the one obvious difference the whole 0x0 to 0x10, cant seem to understand if using the "findloc OFFSET string" would work

Code: Select all

findloc HEADER string "\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x20"