//-------- static void TestNonStaticMethodHook() { SampleClass cls = new SampleClass(); object o = cHook.Hook(typeof(SampleClass), "Call", new Type[] { typeof(string), typeof(string) }, typeof(MySampleClass), "Call", new Type[] { typeof(string), typeof(string) }); cls.Call("Non-Static Method Hook\r\rThis should be hooked", "HookTest"); cHook.Unhook(o); cls.Call("Non-Static Method Hook\r\rThis should NOT be hooked", "HookTest"); //find the method we want to hook //replace with our method. REMEMBER THAT FUNCTION SIGNATURE MUST MATCH!! }
public DialogResult Call(string text, string caption) { SampleClass _this = (object)this as SampleClass; return(_this.Call(text, "HOOKED!!!")); }