The Forum is up for sale: XeNTaX Forum looking for new owner

quickbms loops and filexor issue

Coders and would-be coders alike, this is the place to talk about programming.
Post Reply
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 307 times

quickbms loops and filexor issue

Post by finale00 »

I was doing some loops and xor'ing and it seems to be unintuitive.

The following snippets apparently don't result in the same things:

Code: Select all

filexor my_key
for i = 0 < 2
   get one long
   get two long
   getdstring name two
next i

Code: Select all

filexor my_key
get one long
get two long
getdstring name two

filexor my_key
get one long
get two long
getdstring name two
With the loop, the filexor seems to be xor'ing with something else after the first iteration, which results in a bad "two" value, resulting in the wrong filename.

The second snippet works correctly and gets the names as expected.

I'm using 0.5.13

EDIT: hmm I found the issue.
Turns out my idea of filexor is not what quickbms is actually doing lol

If I say

Code: Select all

for i = 0 < 2
   savepos curpos
   filexor my_key curpos
   get one long
   get two long
   getdstring name two
next i
Then it works.

Though, that doesn't explain why this worked.

Code: Select all

filexor my_key
get one long
get two long
getdstring name two

filexor my_key
get one long
get two long
getdstring name two
User avatar
aluigi
VVIP member
VVIP member
Posts: 1916
Joined: Thu Dec 08, 2005 12:26 pm
Location: www.ZENHAX.com
Has thanked: 4 times
Been thanked: 661 times
Contact:

Re: quickbms loops and filexor issue

Post by aluigi »

filexor uses the key from the offset 0, so the first byte of the key is at offset 0x0 of the file.
if the key is used for each entry then you must tell quickbms to use it in that way, so first byte of the key is at the offset you get with savepos.
Post Reply