Remove "castclass System.String" if present

This commit is contained in:
de4dot 2012-01-05 17:16:38 +01:00
parent 42ff75c7ff
commit d6f3ff64b9

View File

@ -34,6 +34,13 @@ namespace de4dot.code {
int ldstrIndex = callResult.callStartIndex;
block.replace(ldstrIndex, num, Instruction.Create(OpCodes.Ldstr, (string)callResult.returnValue));
// If it's followed by castclass string, remove it
if (ldstrIndex + 1 < block.Instructions.Count) {
var instr = block.Instructions[ldstrIndex + 1];
if (instr.OpCode.Code == Code.Castclass && instr.Operand.ToString() == "System.String")
block.remove(ldstrIndex + 1, 1);
}
// If it's followed by String.Intern(), then nop out that call
if (ldstrIndex + 1 < block.Instructions.Count) {
var instr = block.Instructions[ldstrIndex + 1];