The DBEditor 1.6.1 has bug in saving patch.pack. When the user click the save menuitem, it throws an OutOfMemory exception.
The code location for the exception is in below:
Code:
...
//The value of numFiles will be a huge number,
//so it reaches the maximum size of array
fileList.Capacity = (int)numFiles;
...
The array overrun due to number of bytes mismatch in reading/writing the header of patch.pack file.
The reading method:
Code:
PackFile.cs
public void Open(string filepath)
{
......
char[] signature = reader.ReadChars(4); //4 chars
......
int packType = reader.ReadInt32(); //4 bytes
......
version = reader.ReadInt32(); //4 bytes
......
int mysteryInt = reader.ReadInt32(); //4 bytes
......
fileList.Capacity = (int)numFiles; //Throws an exception
......
}
Except the first 4 chars, The reading method has read 4+4+4=12 bytes totally.
The writing method:
Code:
PackFile.cs
private void writeToFile(string filepath)
{
......
writer.Write("PFH0".ToCharArray()); //4 chars
......
writer.Write((short)type); //2 bytes
......
writer.Write(version); //4 bytes,the type of version is Int32
......
writer.Write((long)0); //8 bytes
......
}
Except the first 4 chars, The writing method has write 2+4+8=14 bytes totally.
Got idea? The DBEditor read 12 bytes but write 14 bytes, it brokes the patch.pack file. When DBEditor reopen the patch.pack, it gots an incorrect number of files.
We can fix it easy:
Code:
PackFile.cs
private void writeToFile(string filepath)
{
......
writer.Write("PFH0".ToCharArray()); //4 chars
......
writer.Write((short)type); //2 bytes
......
writer.Write(version); //4 bytes
......
//writer.Write((long)0); //remove this line
writer.Write((int)0); // write 4 bytes first
writer.Write((short)0); //and write 2 bytes
......
}
It is works fine in saving patch.pack now.
ps: The DBEditor has a potential bug in writing method. After writing the first 4 chars, it writes the pack type [writer.Write((short)type);]. The type variable is a short numeric, 2 bytes. But the reading method reads 4 bytes for the pack type [writer.Write((short)type);].
The download link (updated for patch2.pack):
http://www.minehe.net/shares/files/D...MineHe_new.zip