Skip to content

Instantly share code, notes, and snippets.

/answer.cs Secret

Created February 16, 2013 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4911b6f1a65a328983a6 to your computer and use it in GitHub Desktop.
Save anonymous/4911b6f1a65a328983a6 to your computer and use it in GitHub Desktop.
var buffer = new JIT.ExecutableBuffer(new byte[] {
0xB8, 0x2A, 0x00, 0x00, 0x00, // mov eax, 0x2A
0xC3, // ret
});
unsafe {
var f = (F)Marshal.GetDelegateForFunctionPointer(new IntPtr(buffer.Pointer), typeof(F));
Console.WriteLine("{0}", f());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment