Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

QuickBMS errors [programming, scripting, quickbms.exe tool... NOT games]

Featured Replies

  • Author
  • Localization

aluigi, posted Thu Jul 30, 2015 9:13 am (6693)


I guess I will release it this weekend
  • Replies 671
  • Views 45
  • Created
  • Last Reply

Top Posters In This Topic

  • Author
  • Localization

NullRd, posted Fri Jul 31, 2015 9:02 pm (6739)


"set varsz strlen var" in some cases returns 273

Code:
string teststr = "qwerty"
set testlen strlen teststr
print %testlen%          // - SCRIPT's MESSAGE:  6

set teststr "qwerty"
set testlen strlen teststr
print %testlen%          // - SCRIPT's MESSAGE:  273

set teststr string "asdf"
set testlen strlen teststr
print %testlen%          // - SCRIPT's MESSAGE:  273
  • Author
  • Localization

aluigi, posted Fri Jul 31, 2015 9:17 pm (6740)


Good catch.
Basically "set VARSZ strlen VAR" is just a call for "strlen VARSZ VAR", but recently I added the possibility to return the whole size of the variable if a third argument is different than zero. The code in "Set" didn't set this number to zero and so that's why you get those results.
It will be fixed in the next version of quickbms that will be released in the next days.
Thanks.
  • Author
  • Localization

tigerr101, posted Sun Aug 02, 2015 10:54 am (6751)


Hello.

I have a problem with extracting voice files from 'Sword Art Online : Infinity moment' and hope to get some help.

At first, I followed
http://wiki.vg-resource.com/wiki/Sword_Art_Online:_Infinity_Moment
for decryption and succeeded to get a lot of extensionless files in sound\ folder, which are .afs2 archives according to the link.

I tried to extract files(.hca) from those archives with QuichBMS 0.6.5 and afs2 script I found here,
http://aluigi.altervista.org/papers/bms/others/awb_afs2.bms
and it worked for some, but almost half of them failed; only gives error message and extract nothing.

Added some examples in ex.zip;
4pro.zip - it is the one perfectly extracted.
4q0e.zip - it gives message
t30.zip - it gives message

Thank you.
  • Author
  • Localization

aluigi, posted Sun Aug 02, 2015 11:06 am (6752)


The files without "_" suffix are created with the CRI sdk but they are not supported by the cpk.bms script (you can't use awb_afs2.bms on them).
While 4q0e_ (flag 0x020201 instead of 0x020401) doesn't seems to have valid information about the offset and size of the files that are located at offset 0x20, 0x1800 and 0x3520. So there is no way for the script to extract them.
  • Author
  • Localization

tigerr101, posted Sun Aug 02, 2015 11:38 am (6753)


aluigi wrote:
The files without "_" suffix are created with the CRI sdk but they are not supported by the cpk.bms script (you can't use awb_afs2.bms on them).
While 4q0e_ (flag 0x020201 instead of 0x020401) doesn't seems to have valid information about the offset and size of the files that are located at offset 0x20, 0x1800 and 0x3520. So there is no way for the script to extract them.


Wow. Thanks for your quick response.
hmm..I will forget about files like '4q0e_'. :cry:
'not supported by the cpk.bms' means that files like 't30' are not extracted correctly from .CPK file?(with QuickBMS and cpk.bms?)
or I just need to find another way to unpack afs2 archives?
I would appreciate it if you could give me some advice to extract voice file from them..
  • Author
  • Localization

aluigi, posted Sun Aug 02, 2015 11:43 am (6754)


Just to recap: 4q0e_ and 4pro_ are the only AFS2 archives (but only 4pro_ can be extracted) while the others are CRI archives but they are not supported by cpk.bms.
  • Author
  • Localization

starcraft2chn, posted Sun Aug 09, 2015 1:09 pm (6813)


watch here 3 pictures; maybe you can fix this
1st
Image
2nd
Image
3rd
Image

you will make this in a new version? i think this will help; or modify my script?
it is 0.6.6
  • Author
  • Localization

aluigi, posted Thu Aug 13, 2015 2:29 pm (6846)


Is it a new error?

I mean, did you have the same problem with quickbms 0.6.5?
If you want to make some tests with the previous version, you can download it from http://aluigi.org/papers/quickbms_0.6.5.zip
  • Author
  • Localization

spider91, posted Thu Aug 27, 2015 3:35 pm (6950)


Image
  • Author
  • Localization

aluigi, posted Sat Aug 29, 2015 5:39 am (6959)


@spider91
Can you provide the samples and script to replicate the problem?
  • Author
  • Localization

spider91, posted Sat Aug 29, 2015 8:53 am (6962)


Here are sample files and script. Works fine with older versions.

http://www81.zippyshare.com/v/Ej94hFgS/file.html


Also i've made some test with Slog and it doesn't work propperly with MEMORY_FILE's. It saves file named "MEMORY_FILE" to the hdd and that's a "good" file, since file with propper NAME is the same size, but empty. It seems i've deleted sample files with slog, so i can't provide it now. Maybe i'll do another sample later.
  • Author
  • Localization

aluigi, posted Sat Aug 29, 2015 3:15 pm (6983)


Thanks for the samples.

Regarding slog, you shouldn't use MEMORY_FILEs as output.
It's just a simple log-to-file command so I guess you are using it in a way which is not the one for which it was created :)

My yoyo script is a perfect example of how it should be used:
http://aluigi.org/papers/bms/yoyogames.bms
  • Author
  • Localization

Zim, posted Sun Aug 30, 2015 12:46 am (7009)


I've met the same issue as spider91 did with log on 0.6.6a, it's because of append mode:

Causes an error (can't create this file):
Code:
append
log "TestFile" 0 0
Doesn't cause any error (file is created successfully):
Code:
log "TestFile" 0 0
On 0.6.5 both examples are working properly.


Also why we can't use any "0xAB" as a real string? We always get numbers/their bytes instead of strings and even with "0x" or "1x2" etc:
Code:
set TestString string "1x2"           # it's treated as 0x12 number:
print "%TestString%"                  # - SCRIPT's MESSAGE:  18   

string TestString = "1x2"
print "%TestString%"                  # - SCRIPT's MESSAGE:  
Or like this:
Code:
string TestString = "text~1x23~text"
string TestString R "1x2" ""          # doesn't work:
print "%TestString%"                  # - SCRIPT's MESSAGE:  text~1x23~text

string TestString R "1x2~" "~"        # still doesn't work:
print "%TestString%"                  # - SCRIPT's MESSAGE:  text~1x23~text

string TestString R "~1x2" "~"        # now it's working:
print "%TestString%"                  # - SCRIPT's MESSAGE:  text~3~text
but print is fine:
Code:
print "1x2"                           # - SCRIPT's MESSAGE:  1x2

And same problem with "-" which becomes a 0 instead:
Code:
set TestString string "-"
print "%TestString%"                  # - SCRIPT's MESSAGE:  0

string TestString = "-"
print "%TestString%"                  # - SCRIPT's MESSAGE:  0

string TestString = "text-text"
string TestString R "-" ""            # doesn't work:
print "%TestString%"                  # - SCRIPT's MESSAGE:  text-text
Especially that string replace frustrating me.

I understand that this is happening because of QuickBMS is trying to convert such strings to numbers for some reason (which I don't see in documentation) - my bad, I just missed it in Notes, but it's annoying when we want it as a string and we specify it as a string, without any conversions...
  • Author
  • Localization

aluigi, posted Sun Aug 30, 2015 12:14 pm (7018)


Yeah the tool should create the file if doesn't exist, so it's a bug.
Anyway the correct behaviour would be to create the file and then using the append mode, or the existent file with the same name (if any) will be updated instead of being recreated:
Code:
log "TestFile" 0 0
append
log "TestFile" 0 0
...
I will fix it in the next version.

Instead the behaviour you see with strings is normal and it's written in the Notes of section 6 in quickbms.txt.
It's caused by how number and strings are handled internally.
I agree that it's frustrating, the only thing I can do is making this mechanism more strict so that "-" will remain "-" and "-1" will be considered the number -1, and the same would be valid for strings like "1x2" that is not a hex or number.
  • Author
  • Localization

Zim, posted Sun Aug 30, 2015 2:17 pm (7022)


aluigi wrote:
Instead the behaviour you see with strings is normal and it's written in the Notes of section 6 in quickbms.txt.
Oops I'm sorry my bad, thx for pointing that out! :D

aluigi wrote:
I agree that it's frustrating, the only thing I can do is making this mechanism more strict so that "-" will remain "-" and "-1" will be considered the number -1, and the same would be valid for strings like "1x2" that is not a hex or number.
Thank you very much, that would be enough I guess.


Is it possible to use any other string operator besides "=" (copy) with P (Print equivalent) operator (also with p, x, etc), like the most frequent case for me (e.g. used in my logging functions, but with more variables/arguments):
Code:
string TestString = "Value"
string TestString P "%TestString%"   # nope, it seems it's still "P=":
print "%TestString%"                  # - SCRIPT's MESSAGE:  Value

Also is it a bug or a limitation?
Code:
string TestString P= "Line1\nLine2"   # well, not a full Print equivalent:
print "%TestString%"                  # - SCRIPT's MESSAGE:  Line1\nLine2

But of course it's easy to find any workaround, like x= "Line1\x0aLine2" or if you need it in P= (e.g. for same logging functions):
Code:
string N = 0x0a0d                     # reverse order because of the little-endian
# set N binary \x0d\x0a               # more strict alternative
string TestString P= "Line1%N%Line2"
print "%TestString%"


Also I remembered more old bug (or maybe it's a hidden feature!) with goto EOF - it's alway seeking to the end offset of the input file (0), not of the specified one, unlike the SEEK_END (so they are not equivalent). You can check it on files of different sizes:
Code:
open FDSE "somefile" 1

get SIZE asize
print "Size(0): %SIZE%"
get SIZE asize 1
print "Size(1): %SIZE%"

goto EOF 1
SavePos OFFSET 1
print "%OFFSET%"         # Size(0)

goto SEEK_END 1
SavePos OFFSET 1
print "%OFFSET%"         # Size(1)

goto 0 1 SEEK_END
SavePos OFFSET 1
print "%OFFSET%"         # Size(1)

goto -1 1
SavePos OFFSET 1
print "%OFFSET%"         # Size(1) - 1


Also as far as I can see, if we are usind -w command-line option then the open command create a file if it doesn't exist and QuickBMS doesn't "terminates with an error if the file doesn't exist", also open FOLDER NAME FILENUM EXISTS will always set EXISTS to 1 in that case. I believe this is important enough to point it out in quickbms.txt.
And thanks for this, I guess - this behavior has more pros than cons (imho): if we need to create a file only if it doesn't exist and then open it (e.g. for "put") - we don't need append & log "file" 0 0 anymore; but we can't check if it already exists just with EXISTS var - but it's not a problem in most cases, cause we can compare its size with 0. Of course it could already exist with 0 size, but the existence of contents is usually more important than the existence of the file itself. Usually :)
  • Author
  • Localization

aluigi, posted Sun Aug 30, 2015 5:24 pm (7024)


In the manual quickbms.txt the fields that are handled as C strings (basically those strings that are parsed by quickbms for escape characters) are tagged as "c string".
The conversion is performed while parsing the bms script and the binary operator of the String command is the one that gets escaped strings:
set VAR binary "hello\nbye"

The reason why handling strings in quickbms may be bad in some situations it's just because it's not a scripting language for string manipulation and the escaped strings have been introduced in some specific commands/operators to avoid confusion to users not used to them.

"goto EOF 1" doesn't work but I guess it's an old compatibility with the old multiex language. It's something that should be never used and I guess I forgot it in the manual (I will check if I can fix it anyway).
"goto SEEK_END 1" and "goto 0 1 SEEK_END" work correctly.

Regarding the EXISTS field of the Open command in -w mode, well it's both right and wrong and the same time... it depends by the point of view.
Basically the -w option simply makes the opened files both readable and writable instead of read-only. With writable currently it means that it gets created if doesn't exist.
It's a behaviour that I think "may" be changed but I would avoid to create new bugs because it's a core function, anyway I will check and fix it in the next version because it may cause problems also while reimporting some scripts that check existent files.

Thanks for the feedbacks, feel free to provide more tips and suggestions.
  • Author
  • Localization

Zim, posted Sun Aug 30, 2015 5:51 pm (7029)


Thanks.

Well if open with -w will ("may" be) stop creating a files, at least we still have an append mode and log 0 0.
But if you mean changes ("may") in behavior of its EXISTS field only, without removing the possibility of creating a files - I will not be upset at all :)

As for EOF - it's not a problem but I believe it would be nice to see it quickbms.txt too (as well as about creating a files with open and -w) cause it's really important.

So if I understood correctly, we can only use string P=, p=, x= and not any P etc?
Of course this is also not a problem, because we can use multiple variables and just add more commands like regular string VAR VAR :)

P.S. I understand that QuickBMS is not a scripting language for string or some other complex manipulations, but it's really so awesome tool that many ppl using it like a powerful hex processor for many complex things, and not just for manipulation of game resources. And me too :) Though it's slower than native compiled program, but it's very flexible and easy. Thank you very much for it!


Added:
aluigi wrote:
P= and P are the same because only the first char is the operator.
The '=' after it is only a C-like notation that means nothing to quickbms, so P or P= is the same.
Omg thanks, I finally realized that P/p/x just uses only one input argument :D And the VAR is just output only. So the "=" is not any second operator but syntactic sugar.
  • Author
  • Localization

aluigi, posted Sun Aug 30, 2015 6:03 pm (7030)


P= and P are the same because only the first char is the operator.
The '=' after it is only a C-like notation that means nothing to quickbms, so P or P= is the same.
The reason I used it often in my scripts (at least till some weeks ago) is just because I'm used to other programming languages (var = var2).

Regarding EOF and -w/open/exists I will fix them.
  • Author
  • Localization

Zim, posted Tue Sep 01, 2015 1:36 am (7072)


Is it a bug or a limitation?
Code:
StartFunction Function
    if Function_arg1 == "Function_arg1"
        print "No arguments"
    else
        print "%Function_arg1%"
    endif
EndFunction

CallFunction Function 1                   # - SCRIPT's MESSAGE:  No arguments
CallFunction Function 1 "string"          # - SCRIPT's MESSAGE:  No arguments
CallFunction Function 1 1                 # - SCRIPT's MESSAGE:  No arguments

I was just trying to find a simple way to check whether argument was passed to the function or wasn't...

Well if you replace condition from == to ^ at least you will be able to check for numeric arguments:
Code:
CallFunction Function 1                   # - SCRIPT's MESSAGE:  No arguments
CallFunction Function 1 "string"          # - SCRIPT's MESSAGE:  No arguments
CallFunction Function 1 1                 # - SCRIPT's MESSAGE:  1

So it's because QuickBMS just turns strings "Function_arg1" into a Function_arg1 variables (where 1 is any number) for some reason (probably optimisation?):
Code:
StartFunction Function
    set String1 string "Function_arg1"
    string String2 = "Function_arg1"
    print "Strings: '%String1%' / '%String2%'"
EndFunction

CallFunction Function 1                   # - SCRIPT's MESSAGE:  Strings: 'Function_arg1' / 'Function_arg1'
CallFunction Function 1 "string"          # - SCRIPT's MESSAGE:  Strings: 'string' / 'string'
CallFunction Function 1 1                 # - SCRIPT's MESSAGE:  Strings: '1' / ''


Offtopic below (not about bugs).
So for now I'm using this:
Code:
StartFunction Function
    string Check_arg1 = "~Function_arg1"
    string Check_arg1 < 1
    if Function_arg1 == Check_arg1
        print "No arguments"
    else
        print "%Function_arg1%"
    endif
EndFunction

CallFunction Function 1                   # - SCRIPT's MESSAGE:  No arguments
CallFunction Function 1 "string"          # - SCRIPT's MESSAGE:  string
CallFunction Function 1 1                 # - SCRIPT's MESSAGE:  1
But maybe there is some easier way?

P.S. I placed function definition in the beginning for better readability, guys you better place it at the end of your scripts. For the same reason =)

Added:
Omg I was stupid, we don't have to assigning Check-var inside the function (also each time it's called), so here is an easier way:
Code:
# combined name of var because we may have more than 1 function
string Null_Function_arg1 = "Function_arg1"
# string Null_AnotherFunction_arg1 = "AnotherFunction_arg1"
# ...
# place your CallFunction here
# ...
StartFunction Function
    if Function_arg1 == Null_Function_arg1
        print "No arguments"
    else
        print "%Function_arg1%"
    endif
EndFunction

Also for integer numeric arguments which must not be equal to 0 (so if you will check it anyway) you can just use datatype conversion:
Code:
StartFunction Function
    set Function_arg1 long Function_arg1  # byte, short
    if Function_arg1 != 0
  # if Function_arg1 > 0                  # > 17
  # if Function_arg1 < 0                  # < -8
  # etc
        # your code
        # ...
    endif
EndFunction
Because any strings will become a 0, including in the case of lack of argument.
  • Author
  • Localization

aluigi, posted Tue Sep 01, 2015 8:26 am (7076)


In quickbms there are no differences between strings and variables because (at least at the moment) there is no handling of constant values so VARIABLE and "VARIABLE" are referred to the same variable with equal name and content.

Checking if an argument is set requires the usage of work-arounds like the one used in http://aluigi.org/papers/bms/others/next_car_game.bms for quickbms_arg1.
It would be better if you consider the argument as already set, so mandatory instead of optional.

Are you sure isn't better to use python, perl or ruby for these tasks?
  • Author
  • Localization

Zim, posted Tue Sep 01, 2015 2:09 pm (7093)


Thanks.
Yeah, Function_arg1 & "Function_arg" is working fine too, I was just obsessed with too strict checking :) But there is no real point to do this strictly.
I'm gonna fix my post to shorten it.
I agree that in QuickBMS scripts it's better to make the arguments mandatory, but sometimes it's really useful to make it optional, especially when the function is used many times with different sets of args.

Well I'm not sure isn't better to use python etc, but I'm using QuickBMS for game resources too, so I wanna discover such unusual tricks and methods anyway :)
  • Author
  • Localization

Zim, posted Tue Sep 01, 2015 11:10 pm (7106)


quickbms.txt:
Quote:
Math VAR OP VAR
...
????????????????v radix (also //)
????????????????p power (also **)
Code:
set BASE 4
math BASE ** 2            # Error: invalid operator ' '
Code:
set BASE 4
math BASE // 2            # Error: invalid command "math" or arguments -1 at line 2
But it's not a problem cause we still have v and p.

The real problem is in xmath:
Quote:
XMath VAR INSTR
...
????????** power
????????// root
Code:
set BASE 4
set EXP 2

xmath OUT "BASE ** 2"
print "%OUT%"             # - SCRIPT's MESSAGE:  16
xmath OUT "BASE ** EXP"
print "%OUT%"             # - SCRIPT's MESSAGE:  1

xmath OUT "BASE // 2"
print "%OUT%"             # - SCRIPT's MESSAGE:  2
xmath OUT "BASE // EXP"
print "%OUT%"             # - SCRIPT's MESSAGE:  0
So here xmath takes the 2nd argument as 0 if it's a var.

P.S. I didn't check another operators of math/xmath except the basic = -*/%
  • Author
  • Localization

aluigi, posted Wed Sep 02, 2015 1:39 pm (7119)


Regarding the first, I guess I didn't update quickbms.txt or something similar, but I will simply add a "** -> p" and "// -> v" replacer (same for >>> and <<< and <>) in quickbms to solve the problem.

The second one is interesting because it happens only with the operators of more than one char (>>> and others too), will fix it too.

Thanks a lot
  • Author
  • Localization

Zim, posted Wed Sep 02, 2015 9:23 pm (7145)


Unfortunately arrays inside the variables like Array[i] don't work in xmath either (always treated as 0).
But math and string are fine with them.

Also I found a problem with optional arguments of user functions:
Code:
StartFunction Function
    print "'%Function_arg1%'"
EndFunction

CallFunction Function 1 "argument"    # - SCRIPT's MESSAGE:  'argument'
CallFunction Function 1               # - SCRIPT's MESSAGE:  'argument'

# compare with mandatory argument:
CallFunction Function 1 ""            # - SCRIPT's MESSAGE:  ''

It looks the same as this:
Code:
set VAR "VALUE"
string VAR = ""           # Nope, you can't kill me this way
print "'%VAR%'"           # - SCRIPT's MESSAGE:  'VALUE'

# compare with set:
set VAR ""
print "'%VAR%'"           # - SCRIPT's MESSAGE:  ''

I'm not sure if it is an issues, but I wanna warn the others.
So guys use set and always flush any optional arguments in the end of your function:
Code:
StartFunction Function
    # place your check for argument/s here (see below)
    print "'%Function_arg1%'"

    # flush optional arguments
    set Function_arg1 ""              # (or any string)
                                      # for numeric optional arguments, strict condition:
                                      #   if Function_arg1 ^ Function_arg1
                                      #       # not a numeric argument
    # or
    set Function_arg1 "Function_arg"  # for any optional arguments, non-strict (check your strings):
                                      #   if Function_arg1 & "Function_arg"
                                      #       # no arguments
EndFunction
Quotes in the last flush & argument check were used for better readability only and are not really necessary. So never assign any value to Function_arg as a var.
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.