akeit0
akeit0
CC#
Created by akeit0 on 2/15/2025 in #help
How to get the direct function pointer of virtual struct method?
This works.
public static IntPtr GetMethodPointer(MethodInfo methodInfo)
{
var dynamicMethod = new DynamicMethod("GetFunctionPointer", typeof(IntPtr), [], typeof(MdInternal).Module);
var il = dynamicMethod.GetILGenerator();
il.Emit(OpCodes.Ldftn, methodInfo);
il.Emit(OpCodes.Ret);
return (IntPtr)dynamicMethod.Invoke(null, null)!;
}
public static IntPtr GetMethodPointer(MethodInfo methodInfo)
{
var dynamicMethod = new DynamicMethod("GetFunctionPointer", typeof(IntPtr), [], typeof(MdInternal).Module);
var il = dynamicMethod.GetILGenerator();
il.Emit(OpCodes.Ldftn, methodInfo);
il.Emit(OpCodes.Ret);
return (IntPtr)dynamicMethod.Invoke(null, null)!;
}
14 replies
CC#
Created by akeit0 on 2/15/2025 in #help
How to get the direct function pointer of virtual struct method?
It uses Delegate._methodPtrAux, but it is not the one I need.
14 replies
CC#
Created by akeit0 on 2/15/2025 in #help
How to get the direct function pointer of virtual struct method?
But writing IL is not good. I wish there was an even better way...
14 replies
CC#
Created by akeit0 on 2/15/2025 in #help
How to get the direct function pointer of virtual struct method?
typo
14 replies
CC#
Created by akeit0 on 2/15/2025 in #help
How to get the direct function pointer of virtual struct method?
I need this due to an issue of clrmd. https://github.com/microsoft/clrmd/issues/1306
14 replies
CC#
Created by akeit0 on 2/15/2025 in #help
How to get the direct function pointer of virtual struct method?
Thanks!! This seems to work.
ldftn instance void Foo::Foo()
ldftn instance void Foo::Foo()
14 replies