Update ldelema type, and add unbox.any and ldobj
This commit is contained in:
parent
2949862614
commit
5511ab833b
|
@ -53,13 +53,13 @@ namespace de4dot.code.deobfuscators.CliSecure.vm {
|
|||
break;
|
||||
|
||||
case Code.Ldobj:
|
||||
operandType = MethodStack.getLoadedType(method, instrs, i, 0);
|
||||
operandType = getPtrElementType(MethodStack.getLoadedType(method, instrs, i, 0));
|
||||
break;
|
||||
|
||||
case Code.Stobj:
|
||||
operandType = MethodStack.getLoadedType(method, instrs, i, 1);
|
||||
if (operandType == null)
|
||||
operandType = MethodStack.getLoadedType(method, instrs, i, 0);
|
||||
if (!isValidType(operandType))
|
||||
operandType = getPtrElementType(MethodStack.getLoadedType(method, instrs, i, 1));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -76,6 +76,18 @@ namespace de4dot.code.deobfuscators.CliSecure.vm {
|
|||
return atLeastOneFailed;
|
||||
}
|
||||
|
||||
static TypeReference getPtrElementType(TypeReference type) {
|
||||
if (type == null)
|
||||
return null;
|
||||
var pt = type as PointerType;
|
||||
if (pt != null)
|
||||
return pt.ElementType;
|
||||
var bt = type as ByReferenceType;
|
||||
if (bt != null)
|
||||
return bt.ElementType;
|
||||
return null;
|
||||
}
|
||||
|
||||
bool isValidType(TypeReference type) {
|
||||
if (type == null)
|
||||
return false;
|
||||
|
|
|
@ -192,6 +192,7 @@ namespace de4dot.code.deobfuscators {
|
|||
|
||||
case Code.Castclass:
|
||||
case Code.Isinst:
|
||||
case Code.Unbox_Any:
|
||||
fieldType = pushInstr.Operand as TypeReference;
|
||||
break;
|
||||
|
||||
|
@ -225,6 +226,10 @@ namespace de4dot.code.deobfuscators {
|
|||
break;
|
||||
|
||||
case Code.Ldelema:
|
||||
fieldType = createByReferenceType(pushInstr.Operand as TypeReference);
|
||||
break;
|
||||
|
||||
case Code.Ldobj:
|
||||
fieldType = pushInstr.Operand as TypeReference;
|
||||
break;
|
||||
|
||||
|
@ -235,6 +240,12 @@ namespace de4dot.code.deobfuscators {
|
|||
return fieldType;
|
||||
}
|
||||
|
||||
static ByReferenceType createByReferenceType(TypeReference elementType) {
|
||||
if (elementType == null)
|
||||
return null;
|
||||
return new ByReferenceType(elementType);
|
||||
}
|
||||
|
||||
static Instruction getPreviousInstruction(IList<Instruction> instructions, ref int instrIndex) {
|
||||
while (true) {
|
||||
instrIndex--;
|
||||
|
|
Loading…
Reference in New Issue
Block a user