2
我在.NET中編寫應用程序來編輯任何方法的說明。我想將ldstr放入OpCode並在Operand中放入一個字符串。 Mono.Cecil允許我設置操作數,但問題是OpCode是ReadOnly屬性。有什麼方法可以編輯OpCode? 爲此,我用這個代碼: 如何編輯指令的操作碼?
Dim assembly1 As AssemblyDefinition
assembly1 = AssemblyDefinition.ReadAssembly(rute)
For Each modDef In assembly1.Modules
For Each typeDef In modDef.Types
For Each mDef In typeDef.Methods
For i = 0 To mDef.Body.Instructions.Count - 1
mDef.Body.Instructions(i).OpCode.Code = Mono.Cecil.Cil.Code.ldstr
mDef.Body.Instructions(i).Operand = "Text"
Next
Next
Next
Next
非常感謝!