• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[Release] Source - C9U Text String Decompiler/Compiler

Put Community First
Loyal Member
Joined
Oct 2, 2014
Messages
1,115
Reaction score
833
Hi all,

Spent an hour digging and found this for us all. It seems to only convert text strings from C9U files, but it's start, no?

Attached is a compile and below is the source. Credits to Brouznouf.

Instructions

1) Download and place this .exe in a folder - View attachment c9udecode.zip.
2) This is a console app, so it runs via command line only.
3) Place any C9U file you want in the same folder as c9udecode.exe
4) Run the .exe like this:

Code:
c9udecode.exe 0 filenamehere

0 = Decode, 1 = Encode

NOTE: When encoding, you need to have the _translate_file.txt document for the file in that same location as well as the .new.c9u file.

Source:

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace ConsoleApplication1
{
    class Program
    {
        
        static void Main(string[] args)
        {
            Int32 mode;
            //First Args the Mode
            mode = Int32.Parse(args[0]);
            //Second Args the C9U File
            String c9uName = args[1];


            byte testByte;
            Int32 textSize;
            FileStream c9u = File.Open(c9uName + ".c9u", FileMode.Open);
            FileStream translateFile = File.Open(c9uName + "_translate_file.txt", FileMode.Create);
            FileStream newC9u = File.Open(c9uName + ".new.c9u", FileMode.Create);
            StreamReader lineReadFile = null;
            if (mode != 0)
            {
                lineReadFile = File.OpenText(c9uName + "_line_file.txt");
            }
            BinaryWriter tWriter = new BinaryWriter(translateFile);
            BinaryReader c9uReader = new BinaryReader(c9u, Encoding.Unicode);
            BinaryWriter c9uWriter = new BinaryWriter(newC9u, Encoding.Unicode);


            //On recherche une occurent de BaseFont
            while (c9uReader.BaseStream.Position < c9uReader.BaseStream.Length)
            {
                testByte = c9uReader.ReadByte();
                if (mode != 0) {
                    c9uWriter.Write(testByte);
                }
                if (testByte == 0x09 && ((c9uReader.BaseStream.Position + 12) < c9uReader.BaseStream.Length))
                {
                        if (mode == 0) {
                            c9uReader.ReadBytes(3);
                        } else {
                            c9uWriter.Write(c9uReader.ReadBytes(3));
                        }
                        Int64 baseFont = c9uReader.ReadInt64();
                    
                        if (mode != 0) {
                            c9uWriter.Write(baseFont);
                        }


                        if (baseFont == 8389765503978266946)
                        {
                            if (mode == 0)
                            {
                                c9uReader.ReadByte();
                                textSize = c9uReader.ReadInt32();


                                if (textSize > 0)
                                {
                                    //c9uReader.ReadChar();
                                    String text = new String(c9uReader.ReadChars(textSize));
                                    //c9uReader.ReadChar();


                                    tWriter.Write(text.ToCharArray());
                                    tWriter.Write('\n');
                                }
                            }
                            else
                            {
                                c9uWriter.Write(c9uReader.ReadByte());


                                textSize = c9uReader.ReadInt32();


                                if (textSize > 0)
                                {
                                    c9uReader.ReadChars(textSize);


                                    String newText = lineReadFile.ReadLine();


                                    c9uWriter.Write(newText.Length + 1);


                                    c9uWriter.Write(newText.ToCharArray());
                                    c9uWriter.Write('\0');
                                }
                            }
                        }
                        else
                        {
                            if (mode != 0)
                            {
                                c9uWriter.BaseStream.Seek(-11, SeekOrigin.Current);
                            }
                            c9uReader.BaseStream.Seek(-11, SeekOrigin.Current);
                        }
                }
                if (testByte == 0x0c && ((c9uReader.BaseStream.Position + 15) < c9uReader.BaseStream.Length))
                {
                    if (mode == 0)
                    {
                        c9uReader.ReadBytes(3);
                    }
                    else
                    {
                        c9uWriter.Write(c9uReader.ReadBytes(3));
                    }
                    String baseFont = new String(c9uReader.ReadChars(12));


                    if (mode != 0)
                    {
                        c9uWriter.Write(baseFont.ToCharArray());
                    }


                    if (baseFont.Equals("BaseFontS12", StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (mode == 0)
                        {
                            textSize = c9uReader.ReadInt32();


                            if (textSize > 0)
                            {
                                //c9uReader.ReadChar();
                                String text = new String(c9uReader.ReadChars(textSize));
                                //c9uReader.ReadChar();


                                tWriter.Write(text.ToCharArray());
                                tWriter.Write('\n');
                            }
                        }
                        else
                        {
                            c9uWriter.Write('\0');


                            textSize = c9uReader.ReadInt32();


                            if (textSize > 0)
                            {
                                c9uReader.ReadChars(textSize);


                                String newText = lineReadFile.ReadLine();


                                c9uWriter.Write(newText.Length + 1);


                                c9uWriter.Write(newText.ToCharArray());
                                c9uWriter.Write('\0');
                            }
                        }
                    }
                    else
                    {
                        if (mode != 0)
                        {
                            c9uWriter.BaseStream.Seek(-14, SeekOrigin.Current);
                        }
                        c9uReader.BaseStream.Seek(-14, SeekOrigin.Current);
                    }
                }
            }


            c9uReader.Close();
        }
    }
}
 

Attachments

You must be registered for see attachments list
Joined
Jun 3, 2009
Messages
975
Reaction score
283
I'm trying to run .exe with command
always run as administrator your cmd and then go to the path where your decoder and files

example: cd c:\c9udecoder\c9udecode.exe 0 c:\c9udecoder\filenamehere hope that helps
also dont forget

NOTE: When encoding, you need to have the _translate_file.txt document for the file in that same location as well as the .new.c9u file.
 
Last edited:
Junior Spellweaver
Joined
Oct 27, 2015
Messages
164
Reaction score
33
fallenfate - [Release] Source - C9U Text String Decompiler/Compiler - RaGEZONE Forums

Help Please
 
Experienced Elementalist
Joined
Sep 13, 2014
Messages
232
Reaction score
86
How to use : start c9udecode.exe 0 filename

save as bat file.
 
Put Community First
Loyal Member
Joined
Oct 2, 2014
Messages
1,115
Reaction score
833
@fallenfate please attach a translated c9u to english if possible
Any particular c9u? As long as it isn't like 10000 lines long, I have time to translate one file for you, sure :). Unfortunately I cannot test anything massive, not yet. My main PC is having issues but I have tools on my laptop, it just won't run things well enough without me ripping hair out, and I'm running out of it already.

@Stunn Sorry for the delay, will try to test what you PMed this week.
 
Experienced Elementalist
Joined
Dec 19, 2015
Messages
247
Reaction score
69
@fallenfate ok, if it gives any error, just use CHSFILEMANAGER, to update c9cfsinfo.dat to the folders that were changed.
 
Back
Top