How to extract Worms W.M.D Language file (bin...etc)

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
monako
Posts: 5
Joined: Thu Feb 21, 2019 4:22 pm

How to extract Worms W.M.D Language file (bin...etc)

Post by monako »

Hi guys.
I'd like to decompress the language file and change it to my native language.
So I looked in DataPC\Language folder, I found these files.
AllTextEng.bin and AllTextEng64.bin file.

How do I decompress these files?
and How can I compress it?
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: How to extract Worms W.M.D Language file (bin...etc)

Post by LokiReborn »

monako wrote:Hi guys.
I'd like to decompress the language file and change it to my native language.
So I looked in DataPC\Language folder, I found these files.
AllTextEng.bin and AllTextEng64.bin file.

How do I decompress these files?
and How can I compress it?


Looking at the 32-bit one quickly the format is pretty simple. The layout is
Long (Value is always 1)
Long (File Length)
Long (Record Count)
Long (Size of Entry?)
-- Start Entry Blocks
-- String Data null terminated

For the Entry block
Long ID
Long Offset

This is an example to do the extract with C#, there are around 3.2k entries however only 2.7k unique entries. You'll need to decide how you want to manage all of the text and work with it.

Code: Select all

        private void extractBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog OD = new OpenFileDialog();
            if(OD.ShowDialog() == DialogResult.OK)
            {
                byte[] fileIn = File.ReadAllBytes(OD.FileName);
                MemoryStream ms = new MemoryStream(fileIn);
                BinaryReader br = new BinaryReader(ms);
                List<Entry> entries = new List<Entry>();
                List<string> output = new List<string>();

                br.ReadInt32(); // Version 1?
                br.ReadInt32(); //File length
                int count = br.ReadInt32();
                int blockSize = br.ReadInt32();

                for (int i = 0; i < count; i++)
                {
                    entries.Add(new Entry(br.ReadUInt32(), br.ReadInt32()));
                }

                foreach(Entry en in entries)
                {
                    br.BaseStream.Position = en.offset + 8;
                    output.Add(String.Format("{0}\t{1}",en.id, getString(br)));
                }

                File.WriteAllLines(OD.FileName + ".txt", output);
                MessageBox.Show("Done.");
            }
        }

        private string getString(BinaryReader br)
        {
            MemoryStream ms = new MemoryStream();

            byte b = 0xFF;
            while (b != 0)
            {
                b = br.ReadByte();

                if (b != 0)
                    ms.WriteByte(b);
            }

            return Encoding.UTF8.GetString(ms.ToArray());
        }

        class Entry
        {
            public uint id;
            public int offset;

            public Entry(uint id, int offset)
            {
                this.id = id;
                this.offset = offset;
            }
        }
monako
Posts: 5
Joined: Thu Feb 21, 2019 4:22 pm

Re: How to extract Worms W.M.D Language file (bin...etc)

Post by monako »

LokiReborn wrote:
monako wrote:Hi guys.
I'd like to decompress the language file and change it to my native language.
So I looked in DataPC\Language folder, I found these files.
AllTextEng.bin and AllTextEng64.bin file.

How do I decompress these files?
and How can I compress it?


Looking at the 32-bit one quickly the format is pretty simple. The layout is
Long (Value is always 1)
Long (File Length)
Long (Record Count)
Long (Size of Entry?)
-- Start Entry Blocks
-- String Data null terminated

For the Entry block
Long ID
Long Offset

This is an example to do the extract with C#, there are around 3.2k entries however only 2.7k unique entries. You'll need to decide how you want to manage all of the text and work with it.

Code: Select all

        private void extractBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog OD = new OpenFileDialog();
            if(OD.ShowDialog() == DialogResult.OK)
            {
                byte[] fileIn = File.ReadAllBytes(OD.FileName);
                MemoryStream ms = new MemoryStream(fileIn);
                BinaryReader br = new BinaryReader(ms);
                List<Entry> entries = new List<Entry>();
                List<string> output = new List<string>();

                br.ReadInt32(); // Version 1?
                br.ReadInt32(); //File length
                int count = br.ReadInt32();
                int blockSize = br.ReadInt32();

                for (int i = 0; i < count; i++)
                {
                    entries.Add(new Entry(br.ReadUInt32(), br.ReadInt32()));
                }

                foreach(Entry en in entries)
                {
                    br.BaseStream.Position = en.offset + 8;
                    output.Add(String.Format("{0}\t{1}",en.id, getString(br)));
                }

                File.WriteAllLines(OD.FileName + ".txt", output);
                MessageBox.Show("Done.");
            }
        }

        private string getString(BinaryReader br)
        {
            MemoryStream ms = new MemoryStream();

            byte b = 0xFF;
            while (b != 0)
            {
                b = br.ReadByte();

                if (b != 0)
                    ms.WriteByte(b);
            }

            return Encoding.UTF8.GetString(ms.ToArray());
        }

        class Entry
        {
            public uint id;
            public int offset;

            public Entry(uint id, int offset)
            {
                this.id = id;
                this.offset = offset;
            }
        }

Thank you for your reply. But I'm not a programmer.
so I can't use c# programming.
Can you make me an extractor and input tool? :o
krdrt5367
Posts: 1
Joined: Mon Sep 16, 2019 4:02 pm

Re: How to extract Worms W.M.D Language file (bin...etc)

Post by krdrt5367 »

Please can download the .exe application with the file. :(
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: How to extract Worms W.M.D Language file (bin...etc)

Post by aluigi »