Code
using System;
using System.Reflection;
class Proggy
{
public delegate uint Ret1ArgDelegate(uint args);
static uint PlaceHolder(uint args) { return 0; }
public static byte[] asmByt = new byte[]
{
0x89,0xD0,
0xD1,0xC8,
0xC3
};
unsafe static void Main()
{
fixed(byte* startAddy = &asmByt[0])
{
Type delType = typeof(Delegate);
FieldInfo _methodPtr = delType.GetField("_methodPtr", BindingFlags.NonPublic | BindingFlags.Instance);
Ret1ArgDelegate del = new Ret1ArgDelegate(PlaceHolder);
_methodPtr.SetValue(del, (IntPtr)startAddy);
uint ncd = (uint)0xFFFFFFFC;
ncd = del(ncd);
Console.WriteLine("{0:x}", ncd);
}
}
}
I posted this on another forum, just sharing it here.