예제 #1
0
        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);
        }
예제 #2
0
 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;
 }