Extract DDS game images from TDB (Texture Database) files

Results 1 to 17 of 17
  1. #1
    Goodbye chrissdegrece is offline
    MemberRank
    Oct 2009 Join Date
    GreeceLocation
    1,015Posts

    Extract DDS game images from TDB (Texture Database) files

    Credits for this program go to xadet3!

    http://forum.ragezone.com/f144/filef...a-file-577133/

    I DID NOT WRITE THIS, I just added command line arguments support.

    With this little prog you can extract the DDS images used by the game and are stored in TDB files. Maybe it would be interesting to build a TDB builder too so that we can change some DDS files and rebuild the TDB, hmmmm.

    You need .Net to run this.

    Code:
    USAGE:
    TDBextract <filename> <outputfolder> 
    
    TDBextract gui.tdb c:\temp\ddsextra\  (mind the last backslash)
    Original code:

    Code:
    using System;
    using System.IO;
    using System.Text;
    
    namespace TDB
    {
        /// <summary>
        /// Extractor for the TDB file package
        /// </summary>
        class Program
        {
            /// <summary>
            /// Crypt table
            /// </summary>
            static readonly byte[] cryptTable = new byte[]
            {
                0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23, 0x23, 0x23, 0x23, 0x20, 0x46, 0x6F, 0x72, 0x20, 0x6F,
                0x75, 0x72, 0x20, 0x65, 0x76, 0x65, 0x72, 0x6C, 0x61, 0x73, 0x74, 0x69, 0x6E, 0x67, 0x20, 0x6C,
                0x6F, 0x76, 0x65, 0x2E, 0x20, 0x46, 0x72, 0x6F, 0x6D, 0x20, 0x*** 0x34, 0x20, 0x44, 0x65, 0x63,
                0x2C, 0x20, 0x31, 0x39, 0x39, 0x34, 0x2E, 0x20, 0x23, 0x23, 0x23, 0x23, 0x20, 0x20, 0x20, 0x20,
                0x20, 0x20, 0x20, 0x20, 0x4F, 0x6F, 0x6F, 0x70, 0x73, 0x2E, 0x20, 0x57, 0x68, 0x6F, 0x20, 0x61,
                0x72, 0x65, 0x20, 0x79, 0x6F, 0x75, 0x3F, 0x20, 0x59, 0x6F, 0x75, 0x20, 0x61, 0x72, 0x65, 0x20,
                0x6E, 0x6F, 0x74, 0x20, 0x73, 0x75, 0x70, 0x70, 0x6F, 0x73, 0x65, 0x64, 0x20, 0x74, 0x6F, 0x20,
                0x72, 0x65, 0x61, 0x64, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x6D, 0x65, 0x73, 0x73, 0x61, 0x67,
                0x65, 0x2E, 0x20, 0x50, 0x6C, 0x65, 0x61, 0x73, 0x65, 0x20, 0x63, 0x6C, 0x6F, 0x73, 0x65, 0x20,
                0x74, 0x68, 0x69, 0x73, 0x2C, 0x20, 0x45, 0x6E, 0x6A, 0x6F, 0x79, 0x20, 0x6F, 0x75, 0x72, 0x20,
                0x67, 0x61, 0x6D, 0x65, 0x20, 0x41, 0x33, 0x2C, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x61, 0x6C, 0x77,
                0x61, 0x79, 0x73, 0x20, 0x62, 0x65, 0x20, 0x68, 0x61, 0x70, 0x70, 0x79, 0x7E, 0x21, 0x20, 0x20,
                0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2D, 0x20, 0x54, 0x68, 0x65, 0x20, 0x45, 0x78, 0x74,
                0x72, 0x61, 0x2D, 0x54, 0x65, 0x72, 0x72, 0x65, 0x73, 0x74, 0x72, 0x69, 0x61, 0x6C, 0x20, 0x2D,
                0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
                0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
            };
    
            /// <summary>
            /// File name of the file to extract
            /// </summary>
            const string FILE_NAME = @"C:\Program Files\A3 Game\Data\00.TDB";
    
            /// <summary>
            /// Folder to extract the files into
            /// </summary>
            const string OUTPUT_FOLDER = @"C:\Output\";
    
            /// <summary>
            /// Opens the TDB file and extracts all textures
            /// </summary>
            /// <param name="args"></param>
            static void Main(string[] args)
            {
                BinaryReader fh = new BinaryReader(File.OpenRead(FILE_NAME));
    
                byte[] version = fh.ReadBytes(32);
                int fileCount = fh.ReadInt32();
    
                for (int i = 0; i < fileCount; i++)
                {
                    int fileSize = fh.ReadInt32();
                    byte[] fileNameBuffer = fh.ReadBytes(128);
                    fh.ReadInt64();
                    fh.ReadInt32();
    
                    sub_80DAF9(ref fileNameBuffer, 128);
    
                    string fileName = Encoding.Default.GetString(fileNameBuffer).Trim('\0');
                    byte[] fileBuffer = fh.ReadBytes(fileSize);
    
                    Console.WriteLine("File Name: {0}; File Size: {1}", fileName, fileSize);
    
                    sub_80DAF9(ref fileBuffer, 128);
                    sub_80DAF9(ref fileBuffer, 32);
    
                    File.WriteAllBytes(string.Format(@"{0}\{1}", OUTPUT_FOLDER, fileName), fileBuffer);
                }
    
                fh.Close();
    
                Console.Read();
            }
    
            /// <summary>
            /// Deobfuscates an integer
            /// </summary>
            /// <param name="value">Value</param>
            /// <param name="key">Key</param>
            /// <returns></returns>
            static int sub_80D772(int value, int key)
            {
                return (int)(((key &amp; 0xFFFF0000) >> 16) | (key << 16)) ^ value;
            }
    
            /// <summary>
            /// Deobfuscates an integer
            /// </summary>
            /// <param name="value">Value</param>
            /// <returns>Deobfuscated value</returns>
            static int sub_80D939(int value)
            {
                value += ~(value << 15);
                value ^= value >> 10;
                value *= 9;
                value ^= value >> 6;
                value += ~(value << 11);
                value ^= value >> 16;
    
                return value;
            }
    
            /// <summary>
            /// Absolutely no idea what this does generally
            /// Used in the decryption process
            /// </summary>
            /// <param name="buffer">Buffer</param>
            /// <param name="size">Size</param>
            /// <returns>Some type of key?</returns>
            static int sub_80D7FD(byte[] buffer, int size)
            {
                if (size == 0)
                    size = buffer.Length - 1;
    
                int keyValue = 0;
    
                for (int i = 0; i < size; i++)
                    keyValue = (keyValue << 16) + (keyValue << 6) + buffer[i] - keyValue;
    
                return keyValue;
            }
    
            /// <summary>
            /// Seems to be the main decrypter
            /// </summary>
            /// <param name="buffer">Buffer</param>
            /// <param name="size">Size to decrypt</param>
            static void sub_80DAF9(ref byte[] buffer, int size)
            {
                for (int i = 1, j = size - 1; i < size; i++, j--)
                    buffer[j] = (byte)(i ^ (size ^ (cryptTable[buffer[j - 1]] ^ buffer[j])));
            }
        }
    }
    Attached Files Attached Files
    Last edited by chrissdegrece; 11-02-10 at 09:53 AM.


  2. #2
    Ŋ cvrdheeraj is offline
    MemberRank
    Jul 2006 Join Date
    IndiaLocation
    1,210Posts

    Re: Extract DDS game images from TDB (Texture Database) files

    Just extracting is of no use. You should be able to rebuild.

  3. #3
    Goodbye chrissdegrece is offline
    MemberRank
    Oct 2009 Join Date
    GreeceLocation
    1,015Posts

    Re: Extract DDS game images from TDB (Texture Database) files

    It's possible to rebuild, you Mania guys are a big team, I suppose you can do it. Though I am not sure if it's useful.

    It is useful to extract them, you can use images in your website.

    I was looking for those images to include them in GM Tool but unfortunately I have to make a reference table for each item because the filename doesn't include the item code.

    ---------- Post added at 04:08 PM ---------- Previous post was at 03:56 PM ----------

    If anyone extracts and labels each image with its corresponding item code then I will gladly code it to include it in Gm tool
    Last edited by chrissdegrece; 11-02-10 at 03:06 PM.

  4. #4
    Account Upgraded | Title Enabled! Mrgentle is offline
    MemberRank
    Oct 2007 Join Date
    IndiaLocation
    593Posts

    Re: Extract DDS game images from TDB (Texture Database) files

    i am working on rebuilding the dds files to tdb file..but i need to original code by xadet ..if anyone has it..please provide me...i guess the one above here is EDITED

  5. #5
    Goodbye chrissdegrece is offline
    MemberRank
    Oct 2009 Join Date
    GreeceLocation
    1,015Posts

    Re: Extract DDS game images from TDB (Texture Database) files

    no I didn't edit anything, it's a copy paste

  6. #6
    Account Upgraded | Title Enabled! Mrgentle is offline
    MemberRank
    Oct 2007 Join Date
    IndiaLocation
    593Posts

    Re: Extract DDS game images from TDB (Texture Database) files

    Quote Originally Posted by chrissdegrece View Post
    no I didn't edit anything, it's a copy paste
    okay


    Btw..glad to see you around :)
    Last edited by Mrgentle; 22-06-11 at 07:56 PM.

  7. #7
    Account Upgraded | Title Enabled! Mrgentle is offline
    MemberRank
    Oct 2007 Join Date
    IndiaLocation
    593Posts

    Re: Extract DDS game images from TDB (Texture Database) files

    Hmm..It took a while for me to brush up my ASM, because i was trying after long ofcourse..but got it perfect at the end.

    The Hashes Of same GUI files Extracted and then again Encoded back again without changes, doesnt match i guess its due to the wrong file sort reading .DDS from the folder , and encoding..doesnt matter anyway the client accepts Mmm...its..fun with all those file modification using the mipster to modify the mipmaps..need to see how all those dds are spreaded out

    Someone wanna try? I would do that for you

    Attached Thumbnails Attached Thumbnails untitled.png  
    Last edited by Mrgentle; 02-07-11 at 02:07 PM.

  8. #8
    Member ast009 is offline
    MemberRank
    Apr 2011 Join Date
    65Posts

    Re: Extract DDS game images from TDB (Texture Database) files

    i am not good in coding as u all ppl but
    anyway great work Mrgentle it will be helpfull tool.

    my suggestion is that u may check while the file(.dds) are un-packed back its the unpacked that maybe changing its extension.

    i means that may that u have to change .dds to any other extension before images are packed.
    as in 15 mb clients files WL.ull file name has changed to bs.TDB

    just a suggestion :) :P :|

  9. #9
    0% Interested Chaitanya is offline
    MemberRank
    Apr 2011 Join Date
    Planet EarthLocation
    330Posts

    Re: Extract DDS game images from TDB (Texture Database) files

    Can U modify the logo above the rapaka on the login ID pass entering window for me ??

  10. #10
    Account Upgraded | Title Enabled! Mrgentle is offline
    MemberRank
    Oct 2007 Join Date
    IndiaLocation
    593Posts

    Re: Extract DDS game images from TDB (Texture Database) files

    Quote Originally Posted by ast009 View Post
    i am not good in coding as u all ppl but
    anyway great work Mrgentle it will be helpfull tool.

    my suggestion is that u may check while the file(.dds) are un-packed back its the unpacked that maybe changing its extension.

    i means that may that u have to change .dds to any other extension before images are packed.
    as in 15 mb clients files WL.ull file name has changed to bs.TDB

    just a suggestion :) :P :|

    Each and Everything you said is just crap..just flush it out dude !! your thinking is on the wrong path


    Quote Originally Posted by Magixxx View Post
    Can U modify the logo above the rapaka on the login ID pass entering window for me ??
    ya give me the logo of the size 256x128 any format and also the GUI.tdb file i dont know which file you guys use i have all edited
    Last edited by Mrgentle; 03-07-11 at 09:57 AM.

  11. #11
    0% Interested Chaitanya is offline
    MemberRank
    Apr 2011 Join Date
    Planet EarthLocation
    330Posts

    Re: Extract DDS game images from TDB (Texture Database) files


  12. #12
    Account Upgraded | Title Enabled! Mrgentle is offline
    MemberRank
    Oct 2007 Join Date
    IndiaLocation
    593Posts

    Re: Extract DDS game images from TDB (Texture Database) files


  13. #13
    0% Interested Chaitanya is offline
    MemberRank
    Apr 2011 Join Date
    Planet EarthLocation
    330Posts

    Re: Extract DDS game images from TDB (Texture Database) files

    OMG.. Its really nice man..

    Are u going to share to that tool ?

  14. #14
    Apprentice khajin is offline
    MemberRank
    Apr 2011 Join Date
    18Posts

    Re: Extract DDS game images from TDB (Texture Database) files

    no, he wont share

  15. #15
    @work onyourrisk is offline
    MemberRank
    Jan 2008 Join Date
    IndiaLocation
    706Posts

    Re: Extract DDS game images from TDB (Texture Database) files

    Quote Originally Posted by Magixxx View Post
    OMG.. Its really nice man..

    Are u going to share to that tool ?
    Want Spoon Feeding ...... HA ?


  16. #16
    0% Interested Chaitanya is offline
    MemberRank
    Apr 2011 Join Date
    Planet EarthLocation
    330Posts

    Re: Extract DDS game images from TDB (Texture Database) files

    LOL..
    U guys are now showing oversmartness..
    I am asking him that is he going to share or not ?

    Is this a spoon feeding. ?
    Then from the first time u started server development, U Used to use other ppls released server files.
    U also used to get spoon feed.
    And dnt disagree.
    U are also grown up from spoon feeding !

  17. #17
    Account Upgraded | Title Enabled! holy003 is offline
    MemberRank
    Jan 2011 Join Date
    Mumbai, MaharasLocation
    306Posts

    Re: Extract DDS game images from TDB (Texture Database) files

    Quote Originally Posted by Magixxx View Post
    LOL..
    U guys are now showing oversmartness..
    I am asking him that is he going to share or not ?

    Is this a spoon feeding. ?
    Then from the first time u started server development, U Used to use other ppls released server files.
    U also used to get spoon feed.
    And dnt disagree.
    U are also grown up from spoon feeding !
    ==== 100% Right ====



Advertisement