I need to learn C# for work, and what better way to do that than to fix NXPatcher?
Currently I'm working on NXPatcher Advanced. Here are the following features I'm adding:
- Complete rewrite in a different language.
- Patching DLL created in C# to allow others to do whatever they want to with patch files.
- NXPatcher logic and patch logic are now separate.
- No more running out of realloc space. The C# garbage collector will use swap space instead of running out of RAM.
I do not plan on rewriting NXPatcher Lite because it already does everything I need it to do.
Here's an example of the code I'm working with to apply a patch file to a directory.
Code:
namespace NXPatcherCS
{
class Program
{
static void Main(string[] args)
{
var accessor = new PatchAccessor(@"H:\Maplestory\GMS\00155to00159.patch");
accessor.ValidateCRC();
// DumpDeflateStream returns an emitter, which is a dumb, low level accessor for the unpacked patch file. It only fetches the bytes and doesn't do any interpretation.
var dumpPatchEmitter = accessor.DumpDeflateStream();
// Setup where the dump file is, where all of the original files are, and where all of the new files will go.
var dirName = Path.GetDirectoryName(dumpPath);
var outDir = Path.Combine(dirName, "patcher");
// Let's patch, baby!
var dpa = new DumpPatchApplier(dumpPatchEmitter, dirName, outDir);
dpa.ApplyPatch();
}
}
}
I tested this code on a 600 MB patch file. While there was a performance penalty for using C# instead of C/C++, at least it will patch now. For some reason, my algorithm soaks up RAM worse than Chrome when patching sound.wz. I will need to profile my code to figure out what's taking up gobs of RAM.
Already written features:
- Access patches, check CRCs/headers, and dump the patch file
- Read the dumped patch files
- Apply the dumped patch files
- Accessor for patch EXE files
- Writer for patch EXE files
Still need to write:
- NXPatcher Advanced logic
- WZ version checking