Skip to content

Instantly share code, notes, and snippets.

@nicholasmckinney
Created May 8, 2017 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nicholasmckinney/59fc990c10c0af4e8fab84e5655ecd97 to your computer and use it in GitHub Desktop.
Save nicholasmckinney/59fc990c10c0af4e8fab84e5655ecd97 to your computer and use it in GitHub Desktop.
Basic Example of Binary Patching With MPatch.exe and APatch.exe
#Build Your Binaries
c:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe a.cs
c:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe b.cs
c:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe c.cs
# Create Your Patch
# You need Windows 7 SDK
"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\mpatch.exe" a.exe b.exe dbi_patch
#Apply Your Patch
#Patch c.exe so it looks like b.exe
"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\apatch.exe" dbi_patch a.exe c.exe
#Compare
fc b.exe c.exe
using System;
public class Program
{
public static void Main()
{
Console.WriteLine("Hello World");
}
}
using System;
public class Program
{
public static void Main()
{
Console.WriteLine("Bye World");
}
}
using System;
public class Program
{
public static void Main()
{
Console.WriteLine("");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment