internal static IntPtr GetThunk(MethodInfo method) { Type dt = Interop.GetPrototype(method.Name); if (dt != null) { IntPtr tmp = Marshal.AllocHGlobal(IntPtr.Size); Delegate d = Delegate.CreateDelegate(dt, method); Thunk cb = new Thunk(d); Marshal.StructureToPtr(cb, tmp, false); IntPtr fp = Marshal.ReadIntPtr(tmp, 0); Marshal.FreeHGlobal(tmp); keepAlive.Add(d); return(fp); } return(IntPtr.Zero); }
internal static IntPtr GetThunk(MethodInfo method) { Type dt = Interop.GetPrototype(method.Name); if (dt != null) { IntPtr tmp = Marshal.AllocHGlobal(IntPtr.Size); Delegate d = Delegate.CreateDelegate(dt, method); Thunk cb = new Thunk(d); Marshal.StructureToPtr(cb, tmp, false); IntPtr fp = Marshal.ReadIntPtr(tmp, 0); Marshal.FreeHGlobal(tmp); keepAlive.Add(d); return fp; } return IntPtr.Zero; }