古剑奇谭三(Gujian3) text tool

How to translate the files of a game
Lazy_Cat_2k3
Posts: 31
Joined: Sat Aug 22, 2020 12:43 am

Re: 古剑奇谭三(Gujian3) text tool

Post by Lazy_Cat_2k3 »

alanm wrote:A quick test reducing the size at offset 0x132d070 a little bit causing the game quit.


Mostly, the decryption/decompression algorithm won't work if we provide the wrong decrypted/decompressed size.
There're several solutions like: understanding the algorithm (maybe Kaplas still works on it), remove the decryption code (hard way) or change the size only after it decrypted the original buffer (should test), also try increasing the size (if the algorithm use this size just to create buffer to store decrypted data, then a larger buffer shouldn't be a problem)
Last edited by Lazy_Cat_2k3 on Thu Nov 11, 2021 8:22 am, edited 1 time in total.
Lazy_Cat_2k3
Posts: 31
Joined: Sat Aug 22, 2020 12:43 am

Re: 古剑奇谭三(Gujian3) text tool

Post by Lazy_Cat_2k3 »

alanm wrote:
The extracted file looks pretty complete. how to tell which strings are wrong?

If strings's wrong, it will look like these images.
viewtopic.php?f=12&t=14879#p67370

alanm wrote:What would be even better is if we can further reduce this file down to only show the localized strings of the 3 language version. , for example for a dialog line, the keyID shows up only once but with 3 language dialog text strings show up one after another. By doing that the translator know exactly which strings require translation since it will have 3 lines of texts pair with one key.


It's possible, but since it's json file with lots of format and tag, it will take more time to hardcoded these stuff.
I'm still thinking the easier way like extract text only if it match these tag (EN, Dialog, ...).
alanm
Posts: 21
Joined: Mon Aug 17, 2020 4:54 am

Re: 古剑奇谭三(Gujian3) text tool

Post by alanm »

Lazy_Cat_2k3 wrote:
alanm wrote:A quick test reducing the size at offset 0x132d070 a little bit causing the game quit.


Mostly, the decryption/decompression algorithm won't work if we provide the wrong decrypted/decompressed size.
There're several solutions like: understanding the algorithm (maybe Kaplas still works on it), remove the decryption code (hard way) or change the size only after it decrypted the original buffer (should test), also try increasing the size (if the algorithm use this size just to create buffer to store decrypted data, then a larger buffer shouldn't be a problem)


Had tried the following
-change the size to match the new text buffer only after decrypted the original buffer. game quitted after return to caller
-increase buffer size in .exe. game quitted before reaching the decrypt call.

Changing text buffer size is still not fesible. I am looking into how to insert translated strings back to the binary json buffer. need to shrink the unused language text to make more room if need.
alanm
Posts: 21
Joined: Mon Aug 17, 2020 4:54 am

Re: 古剑奇谭三(Gujian3) text tool

Post by alanm »

Good news. Found the buffer size checksum checking code of text buffer. Should not have problem with bigger buffer now.
Kaplas
Posts: 60
Joined: Fri Jan 25, 2019 2:47 pm

Re: 古剑奇谭三(Gujian3) text tool

Post by Kaplas »

Great work!
alanm
Posts: 21
Joined: Mon Aug 17, 2020 4:54 am

Re: 古剑奇谭三(Gujian3) text tool

Post by alanm »

Lazy_Cat_2k3 wrote:Here are all strings extracted with their offset (some strings are wrong because I haven't parsed all types and maybe I've parsed it wrong in the beggining :) )
https://www.mediafire.com/file/8xm20hza ... s.rar/file
The code behind:

Code: Select all

            while (input.Position < input.Length)
            {
                byte Type = input.ReadValueU8();
                int sizeString = 0;
                switch (Type)
                {
                    case 8:
                        sizeString = input.ReadValueU8();
                        output.WriteLine(input.ReadString(sizeString));
                        break;
                    case 9:
                        sizeString = input.ReadValueU16();
                        output.WriteLine(input.ReadString(sizeString));
                        break;
                    case 3:
                        input.ReadBytes(1);
                        break;
                    case 4:
                        input.ReadBytes(2);
                        break;
                    case 5:
                        input.ReadBytes(3);
                        break;
                    case 6:
                        input.ReadBytes(3);
                        break;
                    case 7:
                        input.ReadBytes(8);
                        break;
                    case 10:
                        input.ReadBytes(3);
                        break;
                    case 11:
                        input.ReadBytes(4);
                        break;
                    case 16:
                        input.ReadBytes(4);
                        break;
                }
            }


Hello Lazy_Cat_2k3,
I am not a .NET C# coder. I Notice in your attached strings file newline characater (\x0a) in strings all turn into "<n>". Does WirteLine() do that automatically or you set it up that way?
Lazy_Cat_2k3
Posts: 31
Joined: Sat Aug 22, 2020 12:43 am

Re: 古剑奇谭三(Gujian3) text tool

Post by Lazy_Cat_2k3 »

alanm wrote:Good news. Found the buffer size checksum checking code of text buffer. Should not have problem with bigger buffer now.

It's awesome :D
alanm wrote:Does WirteLine() do that automatically or you set it up that way?

I replaced character "\n" (0x0A) to "<n>".

All types that I have parse, not a full parsing but are enough to extract all strings.

Code: Select all

Unk0 = 0,
Unk1 = 1,
Unk2 = 2,
Byte = 3,
Short = 4,
Int = 5,
Long = 6,
Float = 7,
ByteString = 8,
UShortString = 9,
Array = 11,
Unk13 = 13,
UShort = 15,
UInt = 16
Last edited by Lazy_Cat_2k3 on Sat Nov 13, 2021 4:31 pm, edited 2 times in total.
Lazy_Cat_2k3
Posts: 31
Joined: Sat Aug 22, 2020 12:43 am

Re: 古剑奇谭三(Gujian3) text tool

Post by Lazy_Cat_2k3 »

Outdated: please use Gujian 3 Manager for more features and improvements

Gujian 3 Text Editor

Download Binaries
Download tag list
Source Code


Changelog:

1.0.1
- Add more tag
- Support steam version (1.3.0)

Note: After editing/packing these string, you'll need to install Gujian3 text mod from alanm (See below)
Last edited by Lazy_Cat_2k3 on Sun Dec 12, 2021 11:31 am, edited 4 times in total.
alanm
Posts: 21
Joined: Mon Aug 17, 2020 4:54 am

Re: 古剑奇谭三(Gujian3) text tool

Post by alanm »

Lazy_Cat_2k3 wrote:Gujian 3 Text Editor

Download Binaries
Download tag list (still missing lots of tag)
Source Code


Excellent work! Lazy_Cat_2k3.

My text mod was created for v1.2.0.1890 version of .exe , it also works for Steam .exe of the same version. That is gone now because steam released a 1.3.0.2142 version just a day ago which added Japanese language support and have a different text buffer size and address. So no Steam until I figure it out.

The source is not ready for release , it was based on this DX wrapper project (https://github.com/elishacloud/DirectX-Wrappers) with modification that access game code for text mod. The same license and disclaimer applied, not responsible if your machine catch on fire :|.

Gujian3 text mod binary is available here: ( check later post for version that support new version of Steam .exe)

https://www.mediafire.com/file/v0nfvqz6ttzny35/G3TextMod.zip/file

It contains 2 files. Dsound.dll and text.bin. put them both in your game bin64/ directory next to the gujian3.exe
text.bin is the decrypted text buffer. I've tested it lightly with Lazy_Cat_2k3's Gujian3TextEditor. Generated a bigger text.bin with longer text seems to work so far. Remember there is no integrity check of the text.bin format. If you modify a tag insteads of a display string by mistake, game will likely crash or worse.
Last edited by alanm on Sun Nov 14, 2021 4:58 pm, edited 1 time in total.
Kaplas
Posts: 60
Joined: Fri Jan 25, 2019 2:47 pm

Re: 古剑奇谭三(Gujian3) text tool

Post by Kaplas »

alanm wrote:My text mod was created for v1.2.0.1890 version of .exe , it also works for Steam .exe of the same version. That is gone now because steam released a 1.3.0.2142 version just a day ago which added Japanese language support and have a different text buffer size and address. So no Steam until I figure it out.


If I'm not wrong, the new buffer size is 0x0494818D and the encrypted section is at offset 0x01364F10 in the new exe file.
alanm
Posts: 21
Joined: Mon Aug 17, 2020 4:54 am

Re: 古剑奇谭三(Gujian3) text tool

Post by alanm »

Kaplas wrote:
alanm wrote:My text mod was created for v1.2.0.1890 version of .exe , it also works for Steam .exe of the same version. That is gone now because steam released a 1.3.0.2142 version just a day ago which added Japanese language support and have a different text buffer size and address. So no Steam until I figure it out.


If I'm not wrong, the new buffer size is 0x0494818D and the encrypted section is at offset 0x01364F10 in the new exe file.


You got it right! how did you figure it out this quickly? This really helps in updating the text mod. thank you.

Here is the decrypted text buffer file for Stream version 1.3.0.2142.
https://www.mediafire.com/file/wo3yh6pwcyfilnm/1302142_text.zip/file
bruhmoment
Posts: 5
Joined: Sun Feb 14, 2021 3:36 pm

Re: 古剑奇谭三(Gujian3) text tool

Post by bruhmoment »

guys you are awesome thank you so much
Kaplas
Posts: 60
Joined: Fri Jan 25, 2019 2:47 pm

Re: 古剑奇谭三(Gujian3) text tool

Post by Kaplas »

alanm wrote:You got it right! how did you figure it out this quickly? This really helps in updating the text mod. thank you.

I supposed that the section would follow the same pattern than before, so I made a "bruteforce" search in the exe trying to find 4 contiguous integers using these rules:

- The first integer is greater than 0x03000000 and lower than 0x06000000
- The second and fourth integer are 0
- The third integer is not 0
Lazy_Cat_2k3
Posts: 31
Joined: Sat Aug 22, 2020 12:43 am

Re: 古剑奇谭三(Gujian3) text tool

Post by Lazy_Cat_2k3 »

alanm wrote:Here is the decrypted text buffer file for Stream version 1.3.0.2142.
https://www.mediafire.com/file/wo3yh6pwcyfilnm/1302142_text.zip/file

Text editor updated, works fine with new steam version.
Also, added more tags.
alanm
Posts: 21
Joined: Mon Aug 17, 2020 4:54 am

Re: 古剑奇谭三(Gujian3) text tool

Post by alanm »

Kaplas wrote:I supposed that the section would follow the same pattern than before, so I made a "bruteforce" search in the exe trying to find 4 contiguous integers using these rules:

- The first integer is greater than 0x03000000 and lower than 0x06000000
- The second and fourth integer are 0
- The third integer is not 0


Very resourceful, I learned something new. thank you.

I updated the text mod DLL to support Steam .exe 1.3.0.2142 which should be the current version. Original disclaimer applied. Text mod now come with text.bin and text1302142.bin files. Current Stream game get text from text1302142.bin only. This is not ideal as when game .exe got updated with bigger text buffer, modifications to old text.bin has to be redone to new text.bin file. Until someone come up with a tool to migrate text to new bin, have to live with this limitation.

https://www.mediafire.com/file/cpp100wbd3v5p2o/G3TextMod_0_2.zip/file

Text Mod source : https://github.com/alanm20/Gujian3TextMod

Change log text mod 0.2:
- Support Steam game version 1.3.0.2142
- Added text1302142.bin to support new game version.

Credits to:
Kaplas - Gujian3Manager for extracting and building game data. Finding decrypted data size and buffer sizing solution ideas.
Lazy_Cat_2k3 - game text editor and buffer sizing solution ideas.
Last edited by alanm on Tue Dec 14, 2021 2:57 pm, edited 3 times in total.
Kaplas
Posts: 60
Joined: Fri Jan 25, 2019 2:47 pm

Re: 古剑奇谭三(Gujian3) text tool

Post by Kaplas »

I've just updated my GuJian3Manager tool: https://github.com/Kaplas80/GuJian3Manager

With it, you can:
- Extract and rebuild game data files.
- Decrypt and encrypt game ".xxx" files.
- Convert full text.bin from/to JSON file.
- Convert text strings in text.bin from/to PO files for translation.

Thanks to:
- Lazy_Cat_2k3 for the text editor, it has been very useful to get the text.bin format.
- alanm for the mod loader.
wowisi8473
Posts: 23
Joined: Mon Nov 01, 2021 3:33 pm

Re: 古剑奇谭三(Gujian3) text tool

Post by wowisi8473 »

alanm wrote:
Kaplas wrote:I supposed that the section would follow the same pattern than before, so I made a "bruteforce" search in the exe trying to find 4 contiguous integers using these rules:

- The first integer is greater than 0x03000000 and lower than 0x06000000
- The second and fourth integer are 0
- The third integer is not 0


Very resourceful, I learned something new. thank you.

I updated the text mod DLL to support Steam .exe 1.3.0.2142 which should be the current version. Original disclaimer applied. Text mod now come with text.bin and text1302142.bin files. Current Stream game get text from text1302142.bin only. This is not ideal as when game .exe got updated with bigger text buffer, modifications to old text.bin has to be redone to new text.bin file. Until someone come up with a tool to migrate text to new bin, have to live with this limitation.

https://www.mediafire.com/file/cpp100wbd3v5p2o/G3TextMod_0_2.zip/file

Text Mod source : https://github.com/alanm20/Gujian3TextMod

Change log text mod 0.2:
- Support Steam game version 1.3.0.2142
- Added text1302142.bin to support new game version.

Credits to:
Kaplas - Gujian3Manager for extracting and building game data. Finding decrypted data size and buffer sizing solution ideas.
Lazy_Cat_2k3 - game text editor and buffer sizing solution ideas.

hello, I edited text.bin and copied it with dsound.dll to gujian 3\bin64, but the texts are not visible in the game
malakito
Posts: 2
Joined: Wed Jun 30, 2021 7:48 pm

Re: 古剑奇谭三(Gujian3) text tool

Post by malakito »

wowisi8473 wrote:hello, I edited text.bin and copied it with dsound.dll to gujian 3\bin64, but the texts are not visible in the game


If your game is up to date, you've to edit the text1302142.bin file. The text.bin is the previos version.
wowisi8473
Posts: 23
Joined: Mon Nov 01, 2021 3:33 pm

Re: 古剑奇谭三(Gujian3) text tool

Post by wowisi8473 »

malakito wrote:
wowisi8473 wrote:hello, I edited text.bin and copied it with dsound.dll to gujian 3\bin64, but the texts are not visible in the game


If your game is up to date, you've to edit the text1302142.bin file. The text.bin is the previos version.

version 1.2.0.1890
wowisi8473
Posts: 23
Joined: Mon Nov 01, 2021 3:33 pm

Re: 古剑奇谭三(Gujian3) text tool

Post by wowisi8473 »

problem solved thanks