Wolfenstein II The New Colossus (.resources .texdb)

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
toxic72
Posts: 26
Joined: Sun Mar 20, 2016 10:25 pm

Re: Wolfenstein II The New Colossus (.resources .texdb)

Post by toxic72 »

infogram wrote:
folkemon1977 wrote:Hi friends,
please, can you help me with decrypting language strings from latest Wolfenstein?
I translated both New Order and Old Blood to the Czech language, but with this new format i'm at my wits' end.
Many thanks for your answer.
Kind regards


Link for download strings:
http://zenhax.com/download/file.php?id=3465


Seems the encryption method is the same as DOOM 2016, except now they decompress with Oodle after decryption.

You can use my idCrypt tool (http://redd.it/6u744t, src included for anyone interested) to decrypt the file, but you need to delete the first 4 bytes first though (seems to be Oodle-related, maybe the uncompressed-size)

eg. delete first 4 bytes from english.lang, rename english.lang to english.bfile and run "idCrypt english.bfile strings/english.lang"

AFAIK it's decrypting fine since BCryptDecrypt isn't giving any error code, don't know anything about Oodle though so not sure where to go from there, for now I guess I'll see if I can maybe get idCrypt to work with the games oo2core_5_win64.dll


https://github.com/dtzxporter/Siren Enjoy
BioLife
Posts: 6
Joined: Sat May 28, 2016 10:39 pm

Re: Wolfenstein II The New Colossus (.resources .texdb)

Post by BioLife »

Hello,

I've tried to extract some .resources with the aluigi's script, and it seems that files are not extracted in their right paths.
Eg. "strings" folder is used to be in the root (verified in idTech 6 with DOOM, Wolfenstein TNO & TOB), which is not actually the case.

Is this because we have not the .index file ?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Wolfenstein II The New Colossus (.resources .texdb)

Post by aluigi »

Maybe the script doesn't handle the filenames 100% correctly, the method used in the archive was weird.

Try removing the lines 72 and 73 (string NAME ...) and check if the situation is better or worst.

Anyway without the exact method to handle the filenames there is not much I can do.
BioLife
Posts: 6
Joined: Sat May 28, 2016 10:39 pm

Re: Wolfenstein II The New Colossus (.resources .texdb)

Post by BioLife »

I've tried without this lines, and it seems worst :/

In the same time I think I understand the structure to get the correct filenames and paths :

  • First, all files must be in folders
  • Complete path contains at least one "/" = line/string which does not contain "/" is a variable used by the engine or something else, for example the strings "durango" or "orbis" are codenames for PS4 and XBOX One
  • "$something" or "#something" or other strings that some filenames contains at the end seems to be also variables and should be cleaned from the final filename

Could you try to do a script that reflect this structure?

This is the file from which i've tried to understand the structure: https://1fichier.com/?me542l2agw

I continue to do some research...
BioLife
Posts: 6
Joined: Sat May 28, 2016 10:39 pm

Re: Wolfenstein II The New Colossus (.resources .texdb)

Post by BioLife »

I've modified the script to print all correct path and filenames, it's ugly but I think it reflects better the structure...

Using the .resources from my previous post, we can see that some filenames are wrong, i'll try to cleanup more..
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Wolfenstein II The New Colossus (.resources .texdb)

Post by aluigi »

Eh no, I need the real format and correct structure
BioLife
Posts: 6
Joined: Sat May 28, 2016 10:39 pm

Re: Wolfenstein II The New Colossus (.resources .texdb)

Post by BioLife »

What do you mean?

This structure is based on the other games which using idTech and I used an Hex Editor to compare.

In the script you made, most of the files extracted seems not to be a file, but a variable, or something like that..

The script that i'm trying to do, is to get all the real files.
masagrator
Posts: 82
Joined: Sat Dec 22, 2018 10:03 am

Re: Wolfenstein II The New Colossus (.resources .texdb)

Post by masagrator »

Hello.
I tried to unpack files from patch2.resources from Switch version of the game. I don't need to decrypt them, only i want to swap strings for language files and export them again to patch2.
Script for quickbms from main site works for gameresources.resources and patch1.resources, but for patch2.resources it shows after unpacking half of files

Code: Select all

Error: the script uses more array indexes (1279476809) than available (1401)


But showing only files without extracting works perfectly.
If it can help, here is file packed to zip for reducing size.
https://drive.google.com/file/d/1102BPT ... sp=sharing
masagrator
Posts: 82
Joined: Sat Dec 22, 2018 10:03 am

Re: Wolfenstein II The New Colossus (.resources .texdb)

Post by masagrator »

OK, I made a roundabout, because i wanted only access to language files and I got it.
Issue is with TYPE_ID.
Delete

Code: Select all

getarray STR1 0 TYPE_ID

and change

Code: Select all

        string NAME p "%s/%s" STR1 STR2

to

Code: Select all

        string NAME p "%s" STR2


It will mess with folders for most files, but some of them still will be in folders like language files in "strings".
infogram
Posts: 20
Joined: Fri Nov 03, 2017 8:31 pm

Re: Wolfenstein II The New Colossus (.resources .texdb)

Post by infogram »

Seems DOOM Eternal also uses the same IDCL format, no luck with wolfenstein2.bms though:

EDIT: Ah, a friend managed to fix the script to work with Eternal! Only ~3 lines changed or so.
This seems to extract all the files fine, lang files are encrypted with same algo as DOOM 2016, no compression or anything, so they can be decrypted/encrypted with idCrypt tool: https://github.com/emoose/DOOMExtract/t ... er/idCrypt
(to use just rename blang to use bfile extension, then to decrypt run "idCrypt <path/to/bfile>.bfile strings/english.blang", edit the .dec file it makes, then to reencrypt to bfile run "idCrypt <path/to/dec>.dec strings/english.blang", and finally rename back to blang - change english to the filename of the blang file though of course!)

(EDIT: whoops used wrong file path in the examples above, make sure to use strings/english.blang instead of strings/english.lang or it won't decrypt properly!)

Also attached a small app I made to work with the decrypted blangs (idLang, source included), converts blang <-> CSV for easier editing in Excel/Google Docs/etc.
CSV format is <keyHash>,<#key>,<value>, you should only modify the value part if you want the game to see your strings.
Value part can contain commas fine, only the first 2 on the line are used to split hash/key/value.
UTF-8 is used so hopefully any language should work fine... as long as the game also uses UTF-8 anyway.
Make sure to use the idCrypt tool I linked above to en/decrypt it before & after!

You can use "+com_loadlooseLanguages 1" launch parameter to let the game load loose blang files, you'll need to edit the EXE to give com_loadlooseLanguages the correct flags first though, otherwise game will ignore launch parameter:

Code: Select all

search for
CC CC CC CC CC CC CC CC 40 53 48 83 EC 50 48 8B 84 24 88 00 00 00 48 8B
change to
41 83 C9 10 53 EB 03 90 EB F6 48 83 EC 50 48 8B 84 24 88 00 00 00 48 8B
                              ^ rest are unchanged

(this has a nice side-effect of unlocking ~98% of the games cvars for use in the dev console too :) if you want the others, see SunBeam's unlocker)

If you want to patch your game to always read from custom blangs:

Code: Select all

search
44 39 70 08 0F 84 A3 00 00 00
change to
44 39 70 08 90 90 90 90 90 90

So in total to make game use custom strings:
  • Patch game EXE with a patch above
  • Set launch param "+com_loadlooseLanguages 1" (without quotes)
  • Unpack gameresources.resources
  • Rename english.blang -> english.bfile
  • Run "idCrypt english.bfile strings/english.blang"
  • Run "idLang english.bfile.dec"
  • Edit english.bfile.dec.csv
  • Run "idLang english.bfile.dec.csv"
  • Run "idCrypt english.bfile.dec.csv.bfile.dec strings/english.blang"
  • Rename english.bfile.dec.csv.bfile.dec.bfile -> english.blang
  • Move english.blang -> DOOMEternal\base\strings\english.blang
...and now it should use your strings :)

doometernal.bms:

Code: Select all

# Wolfenstein II: The New Colossus (0.3)
# script for QuickBMS http://quickbms.aluigi.org
# Edited for DOOM Eternal
 
comtype oodle
 
get EXT extension
if EXT == "texdb"
 
    print "Error: %EXT% is no longer supported: sorting arrays takes forever and the data seems obfuscated or useless"
    cleanexit
 
    callfunction NEED_64 1
 
    getdstring DUMMY 0x18
    get FILES longlong
    for i = 0 < FILES
        get SOME_CRC longlong
        get OFFSET longlong
        putarray 0 i OFFSET
    next i
 
        get OFFSET asize
        putarray 0 i OFFSET
 
    print "sorting array, wait some minutes..."
    sortarray 0
 
    for i = 0 < FILES
        getarray OFFSET 0 i
        math i + 1
        getarray SIZE   0 i
        math SIZE - OFFSET
        log "" OFFSET SIZE
    next
 
else
    # .resources, .pack and so on
 
    idstring "IDCL"
    get VER long  # 12
    get DUMMY longlong
    get ZERO long
    get DUMMY long  # 1
    get DUMMY long  # -1
    get DUMMY long
    #get DUMMY longlong
    get FILES long
    get DUMMY_NUM long
    get DUMMY2_NUM long
    get FILES_2 long
    get ZERO longlong
    get DUMMY2 longlong
    get NAMES_OFF longlong
    get DUMMY4_OFF longlong
    get INFO_OFF longlong
    get DUMMY6_OFF longlong
    get DUMMY7_OFF longlong
    get DATA_OFF longlong
 
    goto NAMES_OFF
    get NAMES longlong
    for i = 0 < NAMES
        get NAME_OFF longlong
        putarray 0 i NAME_OFF
    next i
    savepos NAMES_OFF
    for i = 0 < NAMES
        getarray NAME_OFF 0 i
        math NAME_OFF + NAMES_OFF
        goto NAME_OFF
        get NAME string
        string NAME % "$"
        string NAME | "#"
        putarray 0 i NAME
    next i
 
    # thanks toxic72 https://zenhax.com/viewtopic.php?p=27774#p27774
    goto DUMMY7_OFF
    for i = 0 < DUMMY2_NUM
        get DUMMY long
    next i
    savepos DUMMY7_OFF
 
    goto INFO_OFF
    for i = 0 < FILES
        get ZERO longlong
        get DUMMY longlong      # 1
        get DUMMY longlong      # -1
        get TYPE_ID longlong
        get NAME_ID longlong
        get ZERO longlong
        get ZERO longlong
        get OFFSET longlong
        get ZSIZE longlong
        get SIZE longlong
        get DUMMY longlong 
        get DUMMY long
        get DUMMY long
        get DUMMY longlong
 
        get DUMMY long          # ZIP related?
        get DUMMY long          # ZIP related?
        get ZIP_FLAGS longlong  # 0, 2, 4, 0x210002, 0x410002 and so on
        get ZERO longlong
        get FLAGS long          # 2
        get FLAGS2 long
        get ZERO longlong
 
        math TYPE_ID * 8
        math TYPE_ID + DUMMY7_OFF
        math NAME_ID + 1
        math NAME_ID * 8
        math NAME_ID + DUMMY7_OFF
        savepos TMP
        goto TYPE_ID
        get TYPE_ID longlong
        goto NAME_ID
        get NAME_ID longlong
        goto TMP
        #getarray STR1 0 TYPE_ID
        getarray STR2 0 NAME_ID
        #string NAME p "%s/%s" STR1 STR2
        string NAME p "%s" STR2
 
        if SIZE == ZSIZE
            log NAME OFFSET SIZE
        else
            if ZIP_FLAGS & 4
                math OFFSET + 12
                math ZSIZE  - 12
            endif
            clog NAME OFFSET ZSIZE SIZE
        endif
    next i
 
endif
 
startfunction NEED_64
    math TMP = 0x10000000
    math TMP * 16
    if TMP == 0
        print "you must use quickbms_4gb_files.exe with big archives"
        cleanexit
    endif
endfunction
dunder mifflin
Posts: 7
Joined: Tue Apr 21, 2020 6:42 pm

Re: Wolfenstein II The New Colossus (.resources .texdb)

Post by dunder mifflin »

infogram wrote:...cut by aluigi...


Doom does not open
dunder mifflin
Posts: 7
Joined: Tue Apr 21, 2020 6:42 pm

Re: Wolfenstein II The New Colossus (.resources .texdb)

Post by dunder mifflin »

dunder mifflin wrote:...cut by aluigi...


Doom does not open when use it. Here this error:https://ibb.co/NK6ZLDy also reimport doesnt work.
phill05
Posts: 11
Joined: Mon May 23, 2016 7:23 pm

Re: Wolfenstein II The New Colossus (.resources .texdb)

Post by phill05 »

idLang is not working anymore since last Eternal update, please update the tool. Thanks