Update code since dot10 was updated

This commit is contained in:
de4dot 2012-11-02 07:36:02 +01:00
parent 24c43d5a66
commit 70916173f3
10 changed files with 25 additions and 25 deletions

View File

@ -134,7 +134,7 @@ namespace AssemblyData.methodsrewriter {
if (ex.FilterStart == instr) { if (ex.FilterStart == instr) {
} }
if (ex.HandlerStart == instr) { if (ex.HandlerStart == instr) {
if (ex.HandlerType == ExceptionClause.Finally) if (ex.HandlerType == ExceptionHandlerType.Finally)
ilg.BeginFinallyBlock(); ilg.BeginFinallyBlock();
else else
ilg.BeginCatchBlock(Resolver.getRtType(ex.CatchType)); ilg.BeginCatchBlock(Resolver.getRtType(ex.CatchType));
@ -317,11 +317,11 @@ namespace AssemblyData.methodsrewriter {
break; break;
case OperandType.InlineVar: case OperandType.InlineVar:
ilg.Emit(opcode, checked((short)((IVariable)instr.Operand).Number)); ilg.Emit(opcode, checked((short)((IVariable)instr.Operand).Index));
break; break;
case OperandType.ShortInlineVar: case OperandType.ShortInlineVar:
ilg.Emit(opcode, checked((byte)((IVariable)instr.Operand).Number)); ilg.Emit(opcode, checked((byte)((IVariable)instr.Operand).Index));
break; break;
case OperandType.InlineSig: //TODO: case OperandType.InlineSig: //TODO:

View File

@ -332,8 +332,8 @@ namespace AssemblyData.methodsrewriter {
} }
static IList<TypeSig> getParameters(MethodDef method) { static IList<TypeSig> getParameters(MethodDef method) {
var list = new List<TypeSig>(method.Parameters.Length + 1); var list = new List<TypeSig>(method.Parameters.Count + 1);
for (int i = 0; i < method.Parameters.Length; i++) for (int i = 0; i < method.Parameters.Count; i++)
list.Add(method.Parameters[i].Type); list.Add(method.Parameters[i].Type);
return list; return list;
} }

View File

@ -46,10 +46,10 @@ namespace de4dot.blocks {
public int handlerStart; public int handlerStart;
public int handlerEnd; public int handlerEnd;
public ITypeDefOrRef catchType; public ITypeDefOrRef catchType;
public ExceptionClause handlerType; public ExceptionHandlerType handlerType;
public ExceptionInfo(int tryStart, int tryEnd, int filterStart, public ExceptionInfo(int tryStart, int tryEnd, int filterStart,
int handlerStart, int handlerEnd, ITypeDefOrRef catchType, int handlerStart, int handlerEnd, ITypeDefOrRef catchType,
ExceptionClause handlerType) { ExceptionHandlerType handlerType) {
if (tryStart > tryEnd || filterStart > handlerStart || if (tryStart > tryEnd || filterStart > handlerStart ||
tryStart < 0 || tryEnd < 0 || filterStart < 0 || handlerStart < 0 || handlerEnd < 0) tryStart < 0 || tryEnd < 0 || filterStart < 0 || handlerStart < 0 || handlerEnd < 0)
throw new ApplicationException("Invalid start/end/filter/handler indexes"); throw new ApplicationException("Invalid start/end/filter/handler indexes");

View File

@ -28,13 +28,13 @@ namespace de4dot.blocks {
// State for an ExceptionHandler instance // State for an ExceptionHandler instance
ITypeDefOrRef catchType; ITypeDefOrRef catchType;
ExceptionClause handlerType; ExceptionHandlerType handlerType;
public ITypeDefOrRef CatchType { public ITypeDefOrRef CatchType {
get { return catchType; } get { return catchType; }
} }
public ExceptionClause HandlerType { public ExceptionHandlerType HandlerType {
get { return handlerType; } get { return handlerType; }
} }

View File

@ -163,7 +163,7 @@ namespace de4dot.blocks.cflow {
} }
public Value getArg(Parameter arg) { public Value getArg(Parameter arg) {
return getArg(arg.Number); return getArg(arg.Index);
} }
TypeSig getArgType(int index) { TypeSig getArgType(int index) {
@ -173,11 +173,11 @@ namespace de4dot.blocks.cflow {
} }
public void setArg(Parameter arg, Value value) { public void setArg(Parameter arg, Value value) {
setArg(arg.Number, value); setArg(arg.Index, value);
} }
public void makeArgUnknown(Parameter arg) { public void makeArgUnknown(Parameter arg) {
setArg(arg, getUnknownArg(arg.Number)); setArg(arg, getUnknownArg(arg.Index));
} }
void setArg(int index, Value value) { void setArg(int index, Value value) {
@ -194,15 +194,15 @@ namespace de4dot.blocks.cflow {
} }
public Value getLocal(Local local) { public Value getLocal(Local local) {
return getLocal(local.Number); return getLocal(local.Index);
} }
public void setLocal(Local local, Value value) { public void setLocal(Local local, Value value) {
setLocal(local.Number, value); setLocal(local.Index, value);
} }
public void makeLocalUnknown(Local local) { public void makeLocalUnknown(Local local) {
setLocal(local.Number, getUnknownLocal(local.Number)); setLocal(local.Index, getUnknownLocal(local.Index));
} }
void setLocal(int index, Value value) { void setLocal(int index, Value value) {
@ -247,7 +247,7 @@ namespace de4dot.blocks.cflow {
case Code.Starg: case Code.Starg:
case Code.Starg_S: emulate_Starg((Parameter)instr.Operand); break; case Code.Starg_S: emulate_Starg((Parameter)instr.Operand); break;
case Code.Stloc: case Code.Stloc:
case Code.Stloc_S: emulate_Stloc(((Local)instr.Operand).Number); break; case Code.Stloc_S: emulate_Stloc(((Local)instr.Operand).Index); break;
case Code.Stloc_0: emulate_Stloc(0); break; case Code.Stloc_0: emulate_Stloc(0); break;
case Code.Stloc_1: emulate_Stloc(1); break; case Code.Stloc_1: emulate_Stloc(1); break;
case Code.Stloc_2: emulate_Stloc(2); break; case Code.Stloc_2: emulate_Stloc(2); break;
@ -269,7 +269,7 @@ namespace de4dot.blocks.cflow {
case Code.Ldarga: case Code.Ldarga:
case Code.Ldarga_S: emulate_Ldarga((Parameter)instr.Operand); break; case Code.Ldarga_S: emulate_Ldarga((Parameter)instr.Operand); break;
case Code.Ldloca: case Code.Ldloca:
case Code.Ldloca_S: emulate_Ldloca(((Local)instr.Operand).Number); break; case Code.Ldloca_S: emulate_Ldloca(((Local)instr.Operand).Index); break;
case Code.Dup: valueStack.copyTop(); break; case Code.Dup: valueStack.copyTop(); break;
@ -837,7 +837,7 @@ namespace de4dot.blocks.cflow {
} }
void emulate_Starg(Parameter arg) { void emulate_Starg(Parameter arg) {
setArg(arg.Number, valueStack.pop()); setArg(arg.Index, valueStack.pop());
} }
void emulate_Stloc(int index) { void emulate_Stloc(int index) {

View File

@ -165,7 +165,7 @@ namespace de4dot.blocks.cflow {
var methodArgs = methodToInline.Parameters; var methodArgs = methodToInline.Parameters;
var calledMethodArgs = DotNetUtils.getArgs(ctor); var calledMethodArgs = DotNetUtils.getArgs(ctor);
if (methodArgs.Length + 1 - popLastArgs != calledMethodArgs.Count) if (methodArgs.Count + 1 - popLastArgs != calledMethodArgs.Count)
return null; return null;
for (int i = 1; i < calledMethodArgs.Count; i++) { for (int i = 1; i < calledMethodArgs.Count; i++) {
if (!isCompatibleType(i, calledMethodArgs[i], methodArgs[i - 1].Type)) if (!isCompatibleType(i, calledMethodArgs[i], methodArgs[i - 1].Type))
@ -199,7 +199,7 @@ namespace de4dot.blocks.cflow {
var methodToInlineArgs = methodToInline.Parameters; var methodToInlineArgs = methodToInline.Parameters;
var methodArgs = DotNetUtils.getArgs(method); var methodArgs = DotNetUtils.getArgs(method);
bool hasImplicitThis = method.MethodSig.ImplicitThis; bool hasImplicitThis = method.MethodSig.ImplicitThis;
if (methodToInlineArgs.Length - ignoreLastMethodToInlineArgs != methodArgs.Count) if (methodToInlineArgs.Count - ignoreLastMethodToInlineArgs != methodArgs.Count)
return false; return false;
for (int i = 0; i < methodArgs.Count; i++) { for (int i = 0; i < methodArgs.Count; i++) {
var methodArg = methodArgs[i]; var methodArg = methodArgs[i];

View File

@ -440,11 +440,11 @@ namespace de4dot.code {
continue; continue;
if (argsStrings == null) { if (argsStrings == null) {
if (method.Parameters.Length == 0) if (method.Parameters.Count == 0)
continue; continue;
} }
else { else {
if (argsStrings.Length != method.Parameters.Length) if (argsStrings.Length != method.Parameters.Count)
continue; continue;
for (int i = 0; i < argsStrings.Length; i++) { for (int i = 0; i < argsStrings.Length; i++) {
if (argsStrings[i] != method.Parameters[i].Type.FullName) if (argsStrings[i] != method.Parameters[i].Type.FullName)

View File

@ -562,7 +562,7 @@ namespace de4dot.code.deobfuscators {
var body = method.CilBody; var body = method.CilBody;
if (body.InitLocals || body.MaxStack > 8) if (body.InitLocals || body.MaxStack > 8)
return true; return true;
if (body.LocalList.Length > 0) if (body.LocalList.Count > 0)
return true; return true;
if (body.ExceptionHandlers.Count > 0) if (body.ExceptionHandlers.Count > 0)
return true; return true;

View File

@ -42,7 +42,7 @@ namespace de4dot.code.deobfuscators {
if (tryBlock.TryHandlerBlocks.Count != 1) if (tryBlock.TryHandlerBlocks.Count != 1)
continue; continue;
var catchBlock = tryBlock.TryHandlerBlocks[0]; var catchBlock = tryBlock.TryHandlerBlocks[0];
if (catchBlock.HandlerType != ExceptionClause.Catch || if (catchBlock.HandlerType != ExceptionHandlerType.Catch ||
catchBlock.CatchType.FullName != "System.Exception") { catchBlock.CatchType.FullName != "System.Exception") {
continue; continue;
} }

2
dot10

@ -1 +1 @@
Subproject commit 4030f90eb8d1a71793dfd1772efc7b5e5513dff4 Subproject commit 8ca97147ac3d379b023e0fc65c6ba997287a5f77