得到“ldftn” C# 中的函数指针
在cil代码中,ldftn用于获取函数指针地址来调用委托构造函数(即.ctor(object, native int))。
在C#中如何获取用于构造委托的函数指针?
in cil code, ldftn is used to get the function pointer address to call the delegate constructor(i.e. .ctor(object, native int)).
How to get the function pointer used to construct delegate in C#?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你的问题的措辞方式让人很难理解你实际上想要做什么。我想也许你想要的是这样的:
Your question is phrased in a way that makes it hard to understand what you're actually trying to do. I think that perhaps what you want is something like this:
如果您正在寻找 Reflection.Emit 代码的外观,那么如下所示:
第一行将函数指针加载到堆栈上。第二行将其“传递”给委托的构造函数。
yourDelegateType
应该类似于typeof(Func)
等。If you're looking for how the Reflection.Emit code should look, then something like this:
The first line loads the function pointer onto the stack. The second line "passes" it to the constructor of the delegate.
yourDelegateType
should be something liketypeof(Func<string>)
, etc.ldftn 在 C# 9 .NET 5 中可用
https://learn.microsoft.com/dotnet/core/dotnet- Five
函数指针:公开以下中间语言 (IL) 操作码的语言构造:ldftn 和 calli。
ldftn available in C# 9 .NET 5
https://learn.microsoft.com/dotnet/core/dotnet-five
Function pointers: Language constructs that expose the following intermediate language (IL) opcodes: ldftn and calli.