Yugioh file

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Yugioh file

Post by hackspeedok »

I'm translating a Yugioh file. Please help me convert this file to txt and reconvert it. Thanks :)
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Yugioh file

Post by aluigi »

The file is just a sequence of utf16 unicode strings with a NULL delimiter.
I don't know if the game reads them sequentially (good for you) or at fixed offsets (bad for you).
Do this simple test, open the file with a hex editor and at offset 8 add the following bytes in hex:

Code: Select all

61 00 62 00 63 00 64 00 65 00
They are "abcde", remember to add (insert) the bytes and not to replace them. So the size of your bin file will be bigger of 10 bytes.

If the game crashes or visualizes all the strings with some missing characters at their beginning, it means that it uses the "fixed offsets" method.
If the game works as usual, I can make a script on the file to extract and rebuilding the bin file.
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: Yugioh file

Post by hackspeedok »

aluigi wrote:The file is just a sequence of utf16 unicode strings with a NULL delimiter.
I don't know if the game reads them sequentially (good for you) or at fixed offsets (bad for you).
Do this simple test, open the file with a hex editor and at offset 8 add the following bytes in hex:

Code: Select all

61 00 62 00 63 00 64 00 65 00
They are "abcde", remember to add (insert) the bytes and not to replace them. So the size of your bin file will be bigger of 10 bytes.

If the game crashes or visualizes all the strings with some missing characters at their beginning, it means that it uses the "fixed offsets" method.
If the game works as usual, I can make a script on the file to extract and rebuilding the bin file.


it work normally :D
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Yugioh file

Post by aluigi »

Ok so let's try... it "may" work.
The following script automatically converts the bin in a txt file and the txt in bin.

Code: Select all

get EXT extension
log MEMORY_FILE 0 0
get SIZE asize
for
    savepos OFFSET
    if OFFSET >= SIZE
        break
    endif
    if EXT == "bin"
        get TEXT unicode
        put TEXT line MEMORY_FILE
    else
        get TEXT line
        put TEXT unicode MEMORY_FILE
    endif
next
get SIZE asize MEMORY_FILE
get NAME basename
if EXT == "bin"
    string NAME += ".txt"
else
    string NAME += ".bin"
endif
log NAME 0 SIZE MEMORY_FILE
You will probably notice that if you don't modify the txt file, when you reconvert it to bin it's not the same as the original.
That's caused by how some characters are decoded and re-encoded, hopefully it will be not a big problem.
Anyway try and let us know if the trick works.
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: Yugioh file

Post by hackspeedok »

aluigi wrote:Ok so let's try... it "may" work.
The following script automatically converts the bin in a txt file and the txt in bin.

Code: Select all

get EXT extension
log MEMORY_FILE 0 0
get SIZE asize
for
    savepos OFFSET
    if OFFSET >= SIZE
        break
    endif
    if EXT == "bin"
        get TEXT unicode
        put TEXT line MEMORY_FILE
    else
        get TEXT line
        put TEXT unicode MEMORY_FILE
    endif
next
get SIZE asize MEMORY_FILE
get NAME basename
if EXT == "bin"
    string NAME += ".txt"
else
    string NAME += ".bin"
endif
log NAME 0 SIZE MEMORY_FILE
You will probably notice that if you don't modify the txt file, when you reconvert it to bin it's not the same as the original.
That's caused by how some characters are decoded and re-encoded, hopefully it will be not a big problem.
Anyway try and let us know if the trick works.


thanks, game didn't crash or error, but desc text of each card not normal, some cards are missing, some card are empty. Can you help me :(
http://i.imgur.com/uSqdNqC.png

http://i.imgur.com/QeaAY9q.png
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Yugioh file

Post by aluigi »

Unfortunately I can't help.
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: Yugioh file

Post by hackspeedok »

aluigi wrote:Unfortunately I can't help.

thank you so much for your script :)
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: Yugioh file

Post by hackspeedok »

Aluigi, can you edit your script ? I need you extract each "." of "...." at the end of each description as "*". Thanks.
Example: If the monster is destroyed and sent to the Graveyard, destroy this Token******.
http://i.imgur.com/UKUwQ3l.png
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: Yugioh file

Post by hackspeedok »

Aluigi please help me
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Yugioh file

Post by aluigi »

I don't know what you mean but use a hex editor to perform the modifications.
quickbms extracts files, working with strings is not its primary job yet.
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: Yugioh file

Post by hackspeedok »

Aluigi, can you help me to see this index file ?
https://mega.co.nz/#!htMhCbRA!K5cEAH3oU ... 7pjwPkbfic
And, your script didn't work with BIN files in new version (crash when import new file), but i had a way to edit its. However, that way is quite slow and i hope you edit your script if you have free time. This link is a BIN file in new version
https://mega.co.nz/#!Eh1j2KLI!W5I4mfZ7E ... WfQpsz6KYY
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Yugioh file

Post by aluigi »

I have checked the script and it's correct.
I guess that a possible reason for the crash may be the bad handling of some unicode chars, but it's not something I can change.
Try replacing the bad chars with ANSI chars.
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: Yugioh file

Post by hackspeedok »

aluigi wrote:I have checked the script and it's correct.
I guess that a possible reason for the crash may be the bad handling of some unicode chars, but it's not something I can change.
Try replacing the bad chars with ANSI chars.

I will check again. Can you help me see index file?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Yugioh file

Post by aluigi »

From now on I have to automatically avoid to check threads about game language files and localization.
The reason is that I have no tools to easily work on this type of files.

I was writing a script for converting the file to text and viceversa, it was ok when I noticed two problems:
- there is a 32bit value in the Index that is not clear what it represent
- the Desc contains also multi-line strings ("\r\n") so it's not possible to store the string "as-is" on the output text file

Long story short, the following script is totally useless and I post it here just as reference... do NOT use it:

Code: Select all

log MEMORY_FILE  0 0
log MEMORY_FILE2 0 0
get EXT extension

if EXT == "bin"

    put 0xff byte MEMORY_FILE
    put 0xfe byte MEMORY_FILE

    get NAME filename
    string NAME R= "Desc" "Indx"
    open FDSE NAME
    string NAME R= "Indx" "Desc"
    open FDSE NAME 1

    get DESC_SIZE asize 1
    get INDEX_SIZE asize
    xmath STRINGS "INDEX_SIZE / 8"
    for i = 0 < STRINGS
        get DUMMY long
        get OFFSET long

        if OFFSET != DESC_SIZE
            goto OFFSET 1
            do
                get TMP short 1
                if TMP == 0
                    put 0x0d short MEMORY_FILE
                    put 0x0a short MEMORY_FILE
                else
                    put TMP short MEMORY_FILE
                endif
            while TMP != 0
        endif
    next i

    get SIZE asize MEMORY_FILE
    get NAME basename
    string NAME += ".txt"
    log NAME 0 SIZE MEMORY_FILE

else

    get UNICODE_MAGIC short
    put 0 long MEMORY_FILE  # Desc

    get TEXT_SIZE asize
    for TEXT_OFFSET = 0 < TEXT_SIZE
        savepos OFFSET MEMORY_FILE

        do
            get TMP short
            if TMP == 0x0d  # ignore
            elif TMP == 0x0a
                put 0 short MEMORY_FILE
            else
                put TMP short MEMORY_FILE
            endif
        while TMP != 0x0a
        savepos TEXT_OFFSET

        savepos NEXT_OFFSET MEMORY_FILE
        if NEXT_OFFSET & 3
            put 0 short MEMORY_FILE
        endif

        put 0 long MEMORY_FILE2
        put OFFSET long MEMORY_FILE2
    next

    get NAME basename
    string NAME += ".bin"

    string NAME R= "Desc" "Indx"
    get SIZE asize MEMORY_FILE2
    log NAME 0 SIZE MEMORY_FILE2

    string NAME R= "Indx" "Desc"
    get SIZE asize MEMORY_FILE
    log NAME 0 SIZE MEMORY_FILE

endif
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: Yugioh file

Post by hackspeedok »

thanks