[Help]MagicType.dat

02/28/2011 12:30 WarpGeorge#1
PHP Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace 
ConsoleApplication1
{
    class 
Program
    
{
        static 
string FilePath = @"C:/";

        static 
void Main()
        {
            
using (BinaryReader Reader = new BinaryReader(new FileStream(FilePath + @"MagicType.dat"FileMode.Open)))
            {
                
TextWriter TW = new StreamWriter(@"C:\MagicType.txt");
                
uint TotalSpells Reader.ReadUInt32();
                
TW.WriteLine("Total Spells: " TotalSpells);
                
TW.WriteLine();
                for (
int i 0TotalSpellsi++)
                {
                    
TW.WriteLine("ID: " Reader.ReadUInt16());
                    
TW.WriteLine("Type: " Reader.ReadByte());
                    
TW.WriteLine("Sort: " Reader.ReadUInt32());
                    
TW.WriteLine("Name: " Reader.ReadByte());
                    
TW.WriteLine();
                }
                
TW.Close();
                
Reader.Close();
            }
            
Console.WriteLine("Decryption Done!");
            
Console.ReadLine();
        }

    }

I have troubles reading the content of the MagicType.dat file. I think I don't know the column names (the one which defines the numbers/strings), so program can't read them. I tried looking in other sources just to get the names but I still failed. Can someone provide a little help?
Here's a part of the decrypted content:
Code:
Total Spells: 655

ID: 10000
Type: 0
Sort: 2560256
Name: 0

ID: 10002
Type: 0
Sort: 2560768
Name: 0

ID: 10004
Type: 0
Sort: 2562560
Name: 0

ID: 10011
Type: 0
Sort: 2563072
Name: 0

ID: 10013
Type: 0
Sort: 2565120
Name: 0

ID: 10021
Type: 0
Sort: 2565632
Name: 0

ID: 10023
Type: 0
Sort: 2572800
Name: 0

ID: 10051
Type: 0
Sort: 2573312
Name: 0

ID: 10053
Type: 0
Sort: 2573824
Name: 0

ID: 10100
Type: 0
Sort: 2598400
Name: 0
02/28/2011 17:18 CptSky#2
Quote:
Originally Posted by WarpGeorge View Post
PHP Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace 
ConsoleApplication1
{
    class 
Program
    
{
        static 
string FilePath = @"C:/";

        static 
void Main()
        {
            
using (BinaryReader Reader = new BinaryReader(new FileStream(FilePath + @"MagicType.dat"FileMode.Open)))
            {
                
TextWriter TW = new StreamWriter(@"C:\MagicType.txt");
                
uint TotalSpells Reader.ReadUInt32();
                
Reader.BaseStream.Seek(TotalSpells 4SeekOrigin.Current);

                
TW.WriteLine("Total Spells: " TotalSpells);
                
TW.WriteLine();
                for (
int i 0TotalSpellsi++)
                {
                    
TW.WriteLine("ID: " Reader.ReadUInt16());
                    
TW.WriteLine("Type: " Reader.ReadByte());
                    
TW.WriteLine("Sort: " Reader.ReadUInt32());
                    
TW.WriteLine("Name: " Encoding.Default.GetString(Reader.ReadBytes(16)));
                    
TW.WriteLine();
                }
                
TW.Close();
                
Reader.Close();
            }
            
Console.WriteLine("Decryption Done!");
            
Console.ReadLine();
        }

    }

[...]
My reader is somewhere on my hard drive, but it should works.
02/28/2011 19:43 George7293#3
Quote:
Originally Posted by CptSky View Post
My reader is somewhere on my hard drive, but it should works.
Do you mean that's your code or you'll gonna gimme a tip? If it matters, this code was not entirely done by me. It's based on Arco's GameMap.dat decoder...
02/28/2011 19:46 WarpGeorge#4
#Delete the upper reply. It was made accidentaly when I was browsing my old old account. You can even infract me for that, I'll take the responsability for...
Do you mean that's your code or you'll gonna gimme a tip? If it matters, this code was not entirely done by me. It's based on Arco's GameMap.dat decoder...
02/28/2011 23:09 nTL3fTy#5
What version is this being based on? TQ has changed the format of magictype.dat a few times..
03/01/2011 01:28 shitboi#6
try searching for datcryptor v2 by high6. It has a complete solution to latest .dat crypts.
03/01/2011 04:06 pro4never#7
Quote:
Originally Posted by shitboi View Post
try searching for datcryptor v2 by high6. It has a complete solution to latest .dat crypts.
He's talking about the old magictype.dat.


Your code looks reasonable. Does it work at all? Chances are there's just an extra column or two. Read a bit further into and you should be good.

There are a HELL of a lot more columns then that (take a peek at a current decrypted one... like 50 columns per entry lol!) so chances are you just need to read more offsets regardless of if you need them or not.

IE: throw in some ReadBytes(X);'s
03/01/2011 06:50 WarpGeorge#8
Quote:
Originally Posted by pro4never View Post
He's talking about the old magictype.dat.


Your code looks reasonable. Does it work at all? Chances are there's just an extra column or two. Read a bit further into and you should be good.

There are a HELL of a lot more columns then that (take a peek at a current decrypted one... like 50 columns per entry lol!) so chances are you just need to read more offsets regardless of if you need them or not.

IE: throw in some ReadBytes(X);'s
It does, anyway when I dump the file, in the ID field, the program's adding an extra 0 at the end of it like, 1045 (FB) it turns into 10450...
03/01/2011 06:55 DeathByMoogles#9
Quote:
Originally Posted by WarpGeorge View Post
It does, anyway when I dump the file, in the ID field, the program's adding an extra 0 at the end of it like, 1045 (FB) it turns into 10450...
I may not be a C# guru, but instead of worrying what in the code is causing that, sometimes it's better to just have it trim it off and go about your day.

Just my opinion, though.
03/01/2011 08:51 WarpGeorge#10
I' m worried just because after I manage to fully decrypt it, I'll need to revert it back to its original state (encrypted) in order to make it functional again.
03/01/2011 13:06 nTL3fTy#11
Quote:
Originally Posted by WarpGeorge View Post
It does, anyway when I dump the file, in the ID field, the program's adding an extra 0 at the end of it like, 1045 (FB) it turns into 10450...
In the later versions, TQ changed the Id field to reflect the level of the spell as well, so 10450 is 1045 level 0, 10451 is 1045 level 1, etc.
03/01/2011 14:30 WarpGeorge#12
Yes, I figured that out by myself but you know, this version it's the last version I think, when TQ kept the same way to encrypt the MagicType.dat. For example, for the v5095 version, higher than 5065 obviusly, you can decrypt the MagicType.dat using the decryptors available on this forum. Since I have no clue how to decrypt it or encrypt it back (well, decrypting may just work if someone's gonna help me) but ecrypting it's totally clueless for me.
03/01/2011 14:47 shitboi#13
Quote:
Originally Posted by pro4never View Post
He's talking about the old magictype.dat.


Your code looks reasonable. Does it work at all? Chances are there's just an extra column or two. Read a bit further into and you should be good.

There are a HELL of a lot more columns then that (take a peek at a current decrypted one... like 50 columns per entry lol!) so chances are you just need to read more offsets regardless of if you need them or not.

IE: throw in some ReadBytes(X);'s
yeah, i did realize that his code are for older versions of co. that makes me wonder if he doesn't know that he might be using the wrong algorithm; cuz he didn't specify which version is he working on. lol.
03/01/2011 15:08 WarpGeorge#14
My bad then. The version where i'm trying to get it decrypted it's 5065...
03/02/2011 01:56 nTL3fTy#15
Magictype.dat structure:
datatypename
intamount
uint[amount]id
MagicType[amount]magictypes

MagicType structure:

I believe this should be all you need to parse the file. The id mentioned in the beginning of the file is type*10+level. With that information, you can build a dictionary.