Battle.net R&D > Development

Programming A Diablo 2 File (Character+Item) Editor Part 1

(1/1)

sunjester:
--- This guide will help get you started in making your own tools to manipulate game files to tip the stakes in your favor. We don't want you to run out and start hacking into places you don't belong. These guides and tutorials are for "hackers" that love to tinker and create. We work locally and do not violate any TOS agreements in our findings or information we present here. We are simply programmers having fun. ---

by sunjester
@http://fusecurity.com/
op: http://fusecurity.com/forum/programming-a-diablo-2-file-character-item-editor-part-1-t58.html

(you should pretty much be a programmer if you are reading this. Your need to know what bytes are, reading files in binary mode, writing files in binary mode. you should be familiar with c# and using the .NET framework. however, information is presented here that could be used in other programming languages that support reading and writing binary files.)

To read the character files you have to read them in binary mode. It's not like reading a regular file. Reading binary byte positions is the key to retrieving and setting data in the character files. Before this tutorial I have had no experience in reading the Diablo 2 character files. I will be referencing several external sources and will provide them in files at the end or wherever in this article.

I found something online that showed the location to the binary positions to read the data we want. here is the link to it, http://diablo2.my-spot.info/109fileformat.html. take a look at that, that is where we will begin. Let's read the character's name from the file. It says the byte position is 20 and the length is 16 bytes.


--- Code: ---        /// <summary>
        /// this will load a character name from the currently selected character
        /// file in the combo box. the pInfo int array is as follows:
        ///     0   stream length
        ///     1   byte position to start reading at
        ///     2   how many bytes to read
        ///     3   counter
        /// </summary>
        /// <author>sunjester</author>
        /// <website>fusecurity.com</website>
        private void loadCharName()
        {
            txtCharName.Clear();

            using (BinaryReader b = new BinaryReader(File.Open(cmbCharacters.SelectedItem.ToString(), FileMode.Open)))
            {
                int[] pInfo = { (int)b.BaseStream.Length, 20, 16, 0 };
                b.BaseStream.Seek(pInfo[1], SeekOrigin.Begin);
                while (pInfo[1] < pInfo[0] && pInfo[3] < pInfo[2])
                {
                    byte y = b.ReadByte();
                    txtCharName.Text += char.ConvertFromUtf32(y);
                    pInfo[1]++;
                    pInfo[3]++;
                }
            }
        }
--- End code ---

and indeed, it does. Since I won't be threading anything here today, maybe some other time, but since we are not worried about threading I am going to sloppily just add the bytes to the textbox.

load character level

--- Code: ---        /// <summary>
        /// loads the characters level to a textbox
        /// </summary>
        private void loadCharLvl()
        {
            txtCharLvl.Clear();

            using (BinaryReader b = new BinaryReader(File.Open(cmbCharacters.SelectedItem.ToString(), FileMode.Open)))
            {
                int[] pInfo = { (int)b.BaseStream.Length, 43, 1, 0 };
                b.BaseStream.Seek(pInfo[1], SeekOrigin.Begin);
                while (pInfo[1] < pInfo[0] && pInfo[3] < pInfo[2])
                {
                    byte y = b.ReadByte();
                    txtCharLvl.Text += y;
                    pInfo[1]++;
                    pInfo[3]++;
                }
                b.Close();
            }
        }
--- End code ---

load character name

--- Code: ---        /// <summary>
        /// this will load a character name from the currently selected character
        /// file in the combo box. the pInfo int array is as follows:
        ///     0   stream length
        ///     1   byte position to start reading at
        ///     2   how many bytes to read
        ///     3   counter
        /// </summary>
        /// <author>sunjester</author>
        /// <website>fusecurity.com</website>
        private void loadCharName()
        {
            txtCharName.Clear();

            using (BinaryReader b = new BinaryReader(File.Open(cmbCharacters.SelectedItem.ToString(), FileMode.Open)))
            {
                int[] pInfo = { (int)b.BaseStream.Length, 20, 16, 0 };
                b.BaseStream.Seek(pInfo[1], SeekOrigin.Begin);
                while (pInfo[1] < pInfo[0] && pInfo[3] < pInfo[2])
                {
                    byte y = b.ReadByte();
                    txtCharName.Text += char.ConvertFromUtf32(y);
                    pInfo[1]++;
                    pInfo[3]++;
                }
                b.Close();
            }
        }
--- End code ---

download milkman project files

Navigation

[0] Message Index

It appears that you have not registered with DarkBlizz - Making Battle.net Magic -. To register, please click here...
Go to full version