[PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
hhrhhr
Posts: 36
Joined: Sun Jan 18, 2015 11:22 pm

[PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Post by hhrhhr »

using the fact that part of the localization is not encrypted, I compare some lines. took as a basis the Spanish localization, here are a couple of lines from it:

Code: Select all

Armadura temeria
Botas temerias

the English version of these lines are encrypted and look like this (hex):

Code: Select all

0DEF D7DE 09BD B27A CFF5 13EB 95D6 99AD CE5B 9EB7 D76F 1FDF 9BBE AD7D
0DEF D7DE 09BD B27A CFF5 13EB 95D6 99AD CE5B 9DB7 CA6F 1DDF 80BE AC7D


I assumed that in the translation it should look like "Temerian armor" and "Temerian boots". hex view of UTF-16LE:

Code: Select all

0DEF D7DE 09BD B27A CFF5 13EB 95D6 99AD  CE5B  9EB7 D76F 1FDF 9BBE AD7D
5400 6500 6D00 6500 7200 6900 6100 6E00  2000  6100 7200 6D00 6F00 7200
T    e    m    e    r    i    a    n     " "   a    r    m    o    r

0DEF D7DE 09BD B27A CFF5 13EB 95D6 99AD  CE5B  9DB7 CA6F 1DDF 80BE AC7D
5400 6500 6D00 6500 7200 6900 6100 6E00  2000  6200 6F00 6F00 7400 7300
T    e    m    e    r    i    a    n     " "   b    o    o    t    s


is clearly not a direct replacement character by (xor) or (shift), as the same characters in one string are represented by different codes. have any ideas?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: [PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Post by aluigi »

It looks like a XOR with a long sequence of bytes but I don't know if it's a fixed "key" or is continuously generated byte-per-byte (like increment key + byte ^ key).
SLaYeR983
Posts: 13
Joined: Tue May 19, 2015 8:20 pm

Re: [PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Post by SLaYeR983 »

I waiting open tool editor tool and replace tool, for this files... Because this game have very hard language and We need it translate for game...
Nobody
Posts: 47
Joined: Sat May 16, 2015 11:58 pm

Re: [PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Post by Nobody »

I absolutely agree with the SLaYeR983. And I want to translate this game...
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: [PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Post by aluigi »

Just for curiosity, can you upload the english and spanish w3string?
Nobody
Posts: 47
Joined: Sat May 16, 2015 11:58 pm

Re: [PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Post by Nobody »

aluigi wrote:Just for curiosity, can you upload the english and spanish w3string?


of course.
https://yadi.sk/d/nJBAMaCagp7yH
hhrhhr
Posts: 36
Joined: Sun Jan 18, 2015 11:22 pm

Re: [PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Post by hhrhhr »

br-en-esMX from dlc (they are very small): https://mega.co.nz/#!WlgxRJxY!DNcs0lWJf ... U8cWlxuqLM
SLaYeR983
Posts: 13
Joined: Tue May 19, 2015 8:20 pm

Re: [PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Post by SLaYeR983 »

Is there any improvement?
hhrhhr
Posts: 36
Joined: Sun Jan 18, 2015 11:22 pm

Re: [PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Post by hhrhhr »

so, decoding strings were similar as in the Witcher 2.

Code: Select all

string_key = magic >> 8 & 0xffff
for (i = 0; i < strings_count; i += 2) {
    char_key = ((string_len + 1) * string_key) & 0xffff
    string_buffer[i+0] ^= ((char_key >> 0) & 0xff)
    string_buffer[i+1] ^= ((char_key >> 8) & 0xff)
    string_key = ((string_key << 1 ) | (string_key >> 15)) && 0xffff
}


Lua implementation is here. test output:

Code: Select all

>lua inspect_w3strings.lua DLC1\content\en.w3strings . debug
magic: 0x43975139 -> 0x79321793
block 1, count = 11     132 bytes
block 2, count = 11     88 bytes
block 3, count = 331    662 bytes
-- block 2 content ----------------
1:      0x13C88E93      0x00109992   <-- second column — some id/crc/hash
2:      0x1F2AC3DE      0x001083f6   <-- third column — string id, unique for the entire localization
3:      0x474BF324      0x001083ef
4:      0x4C4FF12E      0x00109994
5:      0x519C8F13      0x00109996
6:      0x59FEAB16      0x00109991
7:      0x692198D8      0x0010999f
8:      0x736E017E      0x00109390
9:      0xB1BB516D      0x00109997
10:     0xC0EB3DE0      0x00109993
11:     0xFC5E14AB      0x001083f7
-----------------------------------
sorting...
sorted.
done!

I do not know what to do with the second data block. also I do not know how to get linking between "item_category_light_armor_description" and "0x00109390" :(

ready strings from english part of dlc1:

Code: Select all

0x001083ef ## Saddlebags allow you to carry more weight.
0x001083f6 ## A horse equipped with blinders won't panic as easily.
0x001083f7 ## A horse equipped with a saddle won't tire as easily.
0x00109390 ## Light gear. Increases Armor and Stamina regeneration.
0x00109991 ## Temerian Armor
0x00109992 ## Temerian Boots
0x00109993 ## Temerian Gauntlets
0x00109994 ## Temerian Trousers
0x00109996 ## Temerian Horse Blinders
0x00109997 ## Temerian Saddle
0x0010999f ## Temerian Saddlebags
Nobody
Posts: 47
Joined: Sat May 16, 2015 11:58 pm

Re: [PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Post by Nobody »

hhrhhr wrote:so, decoding strings were similar as in the Witcher 2.

Code: Select all

string_key = magic >> 8 & 0xffff
for (i = 0; i < strings_count; i += 2) {
    char_key = ((string_len + 1) * string_key) & 0xffff
    string_buffer[i+0] ^= ((char_key >> 0) & 0xff)
    string_buffer[i+1] ^= ((char_key >> 8) & 0xff)
    string_key = ((string_key << 1 ) | (string_key >> 15)) && 0xffff
}


Lua implementation is here. test output:

Code: Select all

>lua inspect_w3strings.lua DLC1\content\en.w3strings . debug
magic: 0x43975139 -> 0x79321793
block 1, count = 11     132 bytes
block 2, count = 11     88 bytes
block 3, count = 331    662 bytes
-- block 2 content ----------------
1:      0x13C88E93      0x00109992   <-- second column — some id/crc/hash
2:      0x1F2AC3DE      0x001083f6   <-- third column — string id, unique for the entire localization
3:      0x474BF324      0x001083ef
4:      0x4C4FF12E      0x00109994
5:      0x519C8F13      0x00109996
6:      0x59FEAB16      0x00109991
7:      0x692198D8      0x0010999f
8:      0x736E017E      0x00109390
9:      0xB1BB516D      0x00109997
10:     0xC0EB3DE0      0x00109993
11:     0xFC5E14AB      0x001083f7
-----------------------------------
sorting...
sorted.
done!

I do not know what to do with the second data block. also I do not know how to get linking between "item_category_light_armor_description" and "0x00109390" :(

ready strings from english part of dlc1:

Code: Select all

0x001083ef ## Saddlebags allow you to carry more weight.
0x001083f6 ## A horse equipped with blinders won't panic as easily.
0x001083f7 ## A horse equipped with a saddle won't tire as easily.
0x00109390 ## Light gear. Increases Armor and Stamina regeneration.
0x00109991 ## Temerian Armor
0x00109992 ## Temerian Boots
0x00109993 ## Temerian Gauntlets
0x00109994 ## Temerian Trousers
0x00109996 ## Temerian Horse Blinders
0x00109997 ## Temerian Saddle
0x0010999f ## Temerian Saddlebags


Wow, you are awesome!
you can give directly tools? Unp/Repack?
hhrhhr
Posts: 36
Joined: Sun Jan 18, 2015 11:22 pm

Re: [PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Post by hhrhhr »

Nobody wrote:you can give directly tools?
hhrhhr wrote:Lua implementation is here.


Nobody wrote:Repack?
hhrhhr wrote:I do not know what to do with the second data block. also I do not know how to get linking between "item_category_light_armor_description" and "0x00109390"
SLaYeR983
Posts: 13
Joined: Tue May 19, 2015 8:20 pm

Re: [PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Post by SLaYeR983 »

This is good news...But, How to use this tool. This format foreign to me. preferably .exe format, as unpack.exe

There is a Gibbed red tool, for witcher 2. I guess, it will be help to you.

The Witcher 2 Gibbed Red Tool
SLaYeR983
Posts: 13
Joined: Tue May 19, 2015 8:20 pm

Re: [PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Post by SLaYeR983 »

Is there any news? Translate projects still wait, because of .w3strings file system...
ldkv
Posts: 1
Joined: Tue Sep 15, 2015 2:53 pm

Re: [PC] The Witcher 3 Wild Hunt (decoding .w3strings)

Post by ldkv »

Sarcenzzz on Nexus mod just released a tool to export and import w3strings file: http://www.nexusmods.com/witcher3/mods/676/?

Check it out.