Merge branch 'master' into confuser

This commit is contained in:
de4dot 2012-07-29 13:21:03 +02:00
commit 7c4994f624
3 changed files with 20 additions and 9 deletions

View File

@ -144,7 +144,7 @@ namespace de4dot.code {
abstract class MethodReturnValueInliner { abstract class MethodReturnValueInliner {
protected List<CallResult> callResults; protected List<CallResult> callResults;
List<Block> allBlocks; List<Block> allBlocks;
Blocks blocks; MethodDefinition theMethod;
VariableValues variableValues; VariableValues variableValues;
int errors = 0; int errors = 0;
bool useUnknownArgs = false; bool useUnknownArgs = false;
@ -178,7 +178,7 @@ namespace de4dot.code {
public abstract bool HasHandlers { get; } public abstract bool HasHandlers { get; }
protected MethodDefinition Method { protected MethodDefinition Method {
get { return blocks.Method; } get { return theMethod; }
} }
protected abstract void inlineAllCalls(); protected abstract void inlineAllCalls();
@ -186,13 +186,19 @@ namespace de4dot.code {
// Returns null if method is not a method we should inline // Returns null if method is not a method we should inline
protected abstract CallResult createCallResult(MethodReference method, GenericInstanceMethod gim, Block block, int callInstrIndex); protected abstract CallResult createCallResult(MethodReference method, GenericInstanceMethod gim, Block block, int callInstrIndex);
public int decrypt(Blocks theBlocks) { public int decrypt(Blocks blocks) {
if (!HasHandlers)
return 0;
return decrypt(blocks.Method, blocks.MethodBlocks.getAllBlocks());
}
public int decrypt(MethodDefinition method, List<Block> allBlocks) {
if (!HasHandlers) if (!HasHandlers)
return 0; return 0;
try { try {
blocks = theBlocks; theMethod = method;
callResults = new List<CallResult>(); callResults = new List<CallResult>();
allBlocks = blocks.MethodBlocks.getAllBlocks(); this.allBlocks = allBlocks;
findAllCallResults(); findAllCallResults();
inlineAllCalls(); inlineAllCalls();
@ -200,16 +206,16 @@ namespace de4dot.code {
return callResults.Count; return callResults.Count;
} }
finally { finally {
blocks = null; theMethod = null;
callResults = null; callResults = null;
allBlocks = null; this.allBlocks = null;
variableValues = null; variableValues = null;
} }
} }
bool getLocalVariableValue(VariableDefinition variable, out object value) { bool getLocalVariableValue(VariableDefinition variable, out object value) {
if (variableValues == null) if (variableValues == null)
variableValues = new VariableValues(blocks.Locals, allBlocks); variableValues = new VariableValues(theMethod.Body.Variables, allBlocks);
var val = variableValues.getValue(variable); var val = variableValues.getValue(variable);
if (!val.isValid()) { if (!val.isValid()) {
value = null; value = null;
@ -333,7 +339,7 @@ namespace de4dot.code {
case Code.Ldloc_1: case Code.Ldloc_1:
case Code.Ldloc_2: case Code.Ldloc_2:
case Code.Ldloc_3: case Code.Ldloc_3:
getLocalVariableValue(Instr.getLocalVar(blocks.Locals, instr), out arg); getLocalVariableValue(Instr.getLocalVar(theMethod.Body.Variables, instr), out arg);
break; break;
case Code.Ldfld: case Code.Ldfld:

View File

@ -771,5 +771,9 @@ namespace de4dot.code {
void IDeobfuscatedFile.stringDecryptersAdded() { void IDeobfuscatedFile.stringDecryptersAdded() {
updateDynamicStringInliner(); updateDynamicStringInliner();
} }
void IDeobfuscatedFile.setDeobfuscator(IDeobfuscator deob) {
this.deob = deob;
}
} }
} }

View File

@ -22,5 +22,6 @@ namespace de4dot.code.deobfuscators {
IDeobfuscatorContext DeobfuscatorContext { get; } IDeobfuscatorContext DeobfuscatorContext { get; }
void createAssemblyFile(byte[] data, string assemblyName, string extension); void createAssemblyFile(byte[] data, string assemblyName, string extension);
void stringDecryptersAdded(); void stringDecryptersAdded();
void setDeobfuscator(IDeobfuscator deob);
} }
} }