December 03, 2020, 04:54:17 AM

Author Topic: Programming A Diablo 2 File (Character+Item) Editor Part 1  (Read 2841 times)

sunjester

  • New Member
  • *
  • Posts: 1
    • View Profile
Programming A Diablo 2 File (Character+Item) Editor Part 1
« on: April 27, 2010, 12:42:30 AM »
--- 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: [Select]
        /// <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]++;
                }
            }
        }

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: [Select]
        /// <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();
            }
        }

load character name
Code: [Select]
        /// <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();
            }
        }

download milkman project files
« Last Edit: April 27, 2010, 12:46:34 AM by sunjester »