cecil:Instruction.OpCode.Code值对应的Instruction.Operand类型
是否有任何文档或 cecil 源代码的一部分可供我参考,以全面了解 cecil 将用于给定 Code
值的 Operand
类型?例如:我可以从 MethodBodyRocks
中得知 Ldloc
采用 VariableDefinition
类型的 Operand
,但我还没有能够追踪到其他一些指令代码。
Is there any documentation or is there a part of the cecil source code that I can consult to get a comprehensive view of which Operand
types cecil will use for a given Code
value? Eg: I can glean from MethodBodyRocks
that Ldloc
takes an Operand
of type VariableDefinition
, but I haven't been able to track down this down for some of the other instruction codes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要添加到poupou的答案, OpCodes.cs显示为每个指令代码分配哪个
OperandType
。使用此OperandType
您可以参考 CodeReader.ReadOperand 查看如何使用这些OperandType
来确定构造哪种具体对象类型。另请注意,CodeReader.ReadCode
在返回之前使用CodeReader.ResolveBranches
将某些操作数从指令偏移量转换为Instruction
对象。我创建了这个表,这比每次都挖掘源代码要方便得多(该表中未涵盖的任何内容都应该有一个 InlineNone OperandType):
To add to poupou's answer, OpCodes.cs shows which
OperandType
gets assigned for each instruction Code. Using thisOperandType
you can consult CodeReader.ReadOperand to see how theseOperandType
s are used to determine which concrete object type is constructed. Also note thatCodeReader.ReadCode
usesCodeReader.ResolveBranches
to transform some operands from instruction offsets intoInstruction
objects before returning.I created this table which was a lot more convenient then digging through the source every time (anything not covered in this table should have an InlineNone OperandType):
您可以在 OpCodes 中查看每个 OpCode 的定义。 cs 文件。
例如,对于Ldloc,您会看到OperandType.InlineVar
You can look at the definition of every OpCode in the OpCodes.cs file.
E.g. for Ldloc you would see OperandType.InlineVar