Results 1 to 9 of 9
  1. #1
    faceofdevil's Avatar
    Join Date
    Jul 2009
    Gender
    female
    Posts
    77
    Reputation
    9
    Thanks
    6

    [help] Decoding file formats

    Hello, I'm working on decoding some .dat files that this game client runs. And I cant seem to find many tuts on decoding file formats. The only suggestion I can come up with is debugging the client and programming the data like the client does to read the .dat files.

    this is the only thing i came up with off the top of my head but i believe it wont work..

    Code:
    unsigned char GetCharVal( char mychar )
    {
    	switch( mychar )
    	{
    		case '0':	return 0;
    		case '1':	return 1;
    		case '2':	return 2;
    		case '3':	return 3;
    		case '4':	return 4;
    		case '5':	return 5;
    		case '6':	return 6;
    		case '7':	return 7;
    		case '8':	return 8;
    		case '9':	return 9;
    		case 'a':	return 10;
    		case 'b':	return 11;
    		case 'c':	return 12;
    		case 'd':	return 13;
    		case 'e':	return 14;
    		case 'f':	return 15;
    		case 'A':	return 10;
    		case 'B':	return 11;
    		case 'C':	return 12;
    		case 'D':	return 13;
    		case 'E':	return 14;
    		case 'F':	return 15;
    	}
    	return 0;
    }
    // MY Decoded class...
    void DecodeBinary( char* encoded, unsigned char* data )
    {
    	unsigned curbit = 0;
    	for( unsigned i = 0; i < (unsigned)strlen(encoded); i+=2 )
    	{
    		data[curbit] = GetCharVal( encoded[i] ) << 4;
    		data[curbit] += GetCharVal( encoded[i+1] );
    		curbit++;
    	}
    }
    Of course i still need to add in the function that would convert this to a txt file or whatever file format I want.

    So what suggestions do you have on reverse engineering file formats. (DECODE and ENCODE)....

  2. #2
    VvITylerIvV's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    The streets
    Posts
    668
    Reputation
    5
    Thanks
    61
    My Mood
    In Love
    decrypt > right click > open with notepad


    you can view the code in notepad but the file is encrypted, so unlock? the encryption and open with notepad
    Favourite quotes:

    Code:
    I don't need easy, I just need possible. ~ Me 
    
    There are three birds on a fence. Two decide to fly away, how many are left? Three, just because you decide to do something doesn't mean you've done it. ~ Don't know who said this
    
    Do not go where the path may lead, go instead where there is no path and leave a trail. ~ Ralph Waldo Emerson
    Quote Originally Posted by VirtualSia View Post
    You both have a very weird and awkward view on Computer science.
    Computer science is about computing, which is programming.
    Definition of computing: The use or operation of computers.
    Turning on my computer = computing = programming
    LAWLFAIL

  3. #3
    faceofdevil's Avatar
    Join Date
    Jul 2009
    Gender
    female
    Posts
    77
    Reputation
    9
    Thanks
    6
    I'm guessing you've never worked with file formats yet. Opening with notepad wont solve the issue with being able to read the data thats inside. Some data once decrypted has to be converted to say jpeg or whatever else format it is.

  4. #4
    VvITylerIvV's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    The streets
    Posts
    668
    Reputation
    5
    Thanks
    61
    My Mood
    In Love
    Quote Originally Posted by faceofdevil View Post
    I'm guessing you've never worked with file formats yet. Opening with notepad wont solve the issue with being able to read the data thats inside. Some data once decrypted has to be converted to say jpeg or whatever else format it is.
    o, well my friend has made JPEG pictures via notepad, I'm not sure how but he says he has. Anyways, I understand that now and no, I haven't worked with file formats...
    Favourite quotes:

    Code:
    I don't need easy, I just need possible. ~ Me 
    
    There are three birds on a fence. Two decide to fly away, how many are left? Three, just because you decide to do something doesn't mean you've done it. ~ Don't know who said this
    
    Do not go where the path may lead, go instead where there is no path and leave a trail. ~ Ralph Waldo Emerson
    Quote Originally Posted by VirtualSia View Post
    You both have a very weird and awkward view on Computer science.
    Computer science is about computing, which is programming.
    Definition of computing: The use or operation of computers.
    Turning on my computer = computing = programming
    LAWLFAIL

  5. #5
    Kallisti's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,019
    Reputation
    52
    Thanks
    376
    My Mood
    In Love
    Im pretty sure nobody opened dat files

    未来が見えなくて怖いから
    未来が見えてしまって悲しいから
    目を閉じて優しい思い出に浸ってしまう




  6. #6
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    why not use atoi or whatever the function was to convert from text to int?
    Ah we-a blaze the fyah, make it bun dem!

  7. #7
    faceofdevil's Avatar
    Join Date
    Jul 2009
    Gender
    female
    Posts
    77
    Reputation
    9
    Thanks
    6
    Not really what I was asking for. More of the question how does one proceed to reverse engineer a file type. That is encrypted so that data can be read from it. The only few ways i know is with a hex editor or by debugging the calls in the (.exe) and reverse them that way.

    Any suggestions one might have?

  8. #8
    -Raz0r-'s Avatar
    Join Date
    Aug 2010
    Gender
    male
    Location
    Australia
    Posts
    117
    Reputation
    15
    Thanks
    38
    My Mood
    Lurking
    The first thing I'd do is try and identify the file 'header', and then search for a pattern within the file.

    If I were to export, say, some path-finding data from my file, I'd want to know how to read it back in.
    I'd write out the header, containing how many nodes there are in the level, etc, then the data would come straight after it.
    This way I could safely read it back in without having to hack in checks for how many nodes were written out. (A good reference for file headers in games is maybe the Q3 BSP file format)
    Then for the pattern, I'd assuming it would write out an array (node table) of type T (node data), so it might look like 'float float float unsigned int unsigned char' per node.

    Hopefully this helps. I can't really do more without the file and game in question.
    Good luck!

    EDIT: And of-course using a disassembler/debugger on the function that reads in/writes out the file could give you some useful information
    It also might be worth practising on your own file reading/writing test application so you know what to look for (This way you'll have source code to compare to)
    Last edited by -Raz0r-; 08-06-2010 at 05:43 PM.

  9. #9
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    You need to know the file format architecture, in order to create an algorithm that uses the algorithm (aka. rule) to encode or decode the your data.

    For example, the BMP (bitmap image) file format is as follows:


    Code:
    Byte	Nr	Value
    1-2	 66 77	Always BM
    3-6	 X X X X	Filesize
    7-10	 0 0 0 0	Always 0
    11-14	 X X X X	Offset to pixeldata
    15-18	 40 0 0 0	Always 40
    19-22	 X X X X	Image width in pixels
    23-26	 X X X X	Image height in pixels
    27-28	 1 0	Always 1
    29-32	 24 0 0 0	Bits per pixel
    33-36	 0 0 0 0	Compression, usually 0
    37-53	 4x(0 0 0 0)	No longer used
    Last edited by freedompeace; 08-08-2010 at 09:25 PM.

Similar Threads

  1. File Format Help
    By noleash in forum Combat Arms EU Mods & Rez Modding Help
    Replies: 3
    Last Post: 08-14-2010, 12:23 AM
  2. [Request] please help need file
    By elletheking in forum Battlefield 2 Hacks & Cheats
    Replies: 6
    Last Post: 01-09-2010, 08:26 PM
  3. Help me [file name]
    By cebolinha1 in forum Combat Arms Mod Discussion
    Replies: 5
    Last Post: 12-12-2009, 07:26 PM
  4. [Help] CA File Extension Deleter
    By LetItRock in forum Visual Basic Programming
    Replies: 8
    Last Post: 11-02-2009, 04:15 PM
  5. ICO (Windows Icon) file format plugin for Photoshop
    By MrVader in forum Art & Graphic Design
    Replies: 7
    Last Post: 10-21-2008, 03:15 AM