Hello JB,
First: Thansk for your quick reply.
I tried that and made a bit progress:
private static void ReplaceConstantsWithString(ILProcessor editor,
MethodDefinition MethodDef, string currentoffset, string decryptedstring)
{
List<Instruction> body = MethodDef.Body.Instructions.ToList();
body.Reverse();
Instruction[] newbody = body.ToArray();
Instruction previousinstr = null;
foreach (Instruction ins in MethodDef.Body.Instructions) //
Loop from first Instruction to the last instruction
{
if (string.Format("{0:X}", ins.Offset).ToString() ==
currentoffset) // Find my call (works!)
{
previousinstr = ins.Previous; // Save previous
instruction a instruction variable
editor.Replace(ins, Instruction.Create(OpCodes.Ldstr,
decryptedstring)); // replace with an ldstr Instruction (works!)
a:
if (previousinstr.Previous.OpCode != OpCodes.Call &&
previousinstr.Previous.OpCode != OpCodes.Callvirt)
{
Console.WriteLine("Nop");
editor.Replace(previousinstr.Previous,
Instruction.Create(OpCodes.Nop));
previousinstr = previousinstr.Previous;
goto a;
}
return;
}
}
}
Now sometimes everything is nop'ed as it should be:
<https://lh6.googleusercontent.com/-51IVAgBToVQ/VHnA7O3MdLI/AAAAAAAAAEc/i4EIN3WoJT4/s1600/good.PNG>
but sometimes its skipping one instruction that should normally getting
noped too :
<https://lh4.googleusercontent.com/-mDkb_1R8RWo/VHnBFiAY_2I/AAAAAAAAAEk/9cwkd-JIT_Y/s1600/bad.PNG>
How can I fix this problem?
--
--
--
mono-cecil
---
You received this message because you are subscribed to the Google Groups
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.