1

I have a CreateDelegate method, and I use

Marshal.GetDelegateForFunctionPointer(func_addr, CreateDelegate())

It works very well, but now I need to Marshal as ThisCall. So func_addr is a "CallingConvention.ThisCall". Statically, this is working :

[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
delegate int d_Add(IntPtr _this, int x, int y);
...
var value = Marshal.GetDelegateForFunctionPointer<d_Add>(Addfunc_addr)(_this, 50, 100);
// return 150;

I would like to do add the UnmanagedFunctionPointerAttribute at runtime to my fresh delegate from CreateDelegate, or any way to marshal my delegate as ThisCall, is this possible ?

I found this thread : Add Custom Attribute at Runtime but in my case it is not a custom attribute.

EäsyHäx
  • 11
  • 1

0 Answers0