You are reading an archived copy of my old blog. Please visit for fresh stuff!


bspatch c# port

November 22nd, 2008

For osu! updates, I use an algorithm called bsdiff (bytewise subtraction) designed by Colin Percival.  Up until now it has been an external dependency that causes problems with Vista (UAC issues) and occasional instability in the process handling, so I got around to porting it over to .NET last night.  I thought for once I’d share this publicly because I think it may be helpful for others out there wanting to do a similar thing.

I only ported the bspatch part over, so you’ll need to create the diff files using the original code (also available as a native windows c++ port here. The sharpziplib library is used for bzip2 stream handling, and only minimal files are included.  This makes for a very small binary (19,968 bytes).

Binary available here (pruned to smallest possible size).
Source code here.

While I haven’t benchmarked performance seriously, it should be near-equal to the native code.  There is no unsafe code used (although it can be employed very easily for a performance boost).

5 comments to “bspatch c# port”

  1. Excellent work. I am glad somebody converted this to win32 in which the environment arguments can actually be read correctly. Saves me the trouble of rewriting it.

  2. also have a bsdiff port avilable – might publish that later but contact me if you need it for now.

  3. can you send me the port you have of bsdiff? thanks in advance.

  4. please send me the port you have done for bsdiff, very thanks.

  5. I also ported bsdiff to C#; a minor change I made to my implementation is that it uses “Stream” (not byte[]) when applying the patch, so it doesn’t load the entire input file into memory nor buffer the entire output file in memory.

    More info is at and the code is at

Leave a Comment