Ignore invalid metadata tokens in code
This commit is contained in:
parent
9c253e7864
commit
61b1f7a06a
|
@ -183,8 +183,16 @@ namespace de4dot.blocks {
|
|||
}
|
||||
|
||||
public void repartitionBlocks() {
|
||||
foreach (var scopeBlock in getAllScopeBlocks(methodBlocks))
|
||||
foreach (var scopeBlock in getAllScopeBlocks(methodBlocks)) {
|
||||
try {
|
||||
scopeBlock.repartitionBlocks();
|
||||
}
|
||||
catch (NullReferenceException) {
|
||||
//TODO: Send this message to the log
|
||||
Console.WriteLine("Null ref exception! Invalid metadata token in code? Method: {0:X8}: {1}", method.MetadataToken.ToUInt32(), method.FullName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,10 +38,16 @@ namespace de4dot.blocks.cflow {
|
|||
var instructions = block.Instructions;
|
||||
if (instructions.Count == 0)
|
||||
return false;
|
||||
try {
|
||||
for (int i = 0; i < instructions.Count - 1; i++) {
|
||||
var instr = instructions[i].Instruction;
|
||||
instructionEmulator.emulate(instr);
|
||||
}
|
||||
}
|
||||
catch (System.NullReferenceException) {
|
||||
// Here if eg. invalid metadata token in a call instruction (operand is null)
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (block.LastInstr.OpCode.Code) {
|
||||
case Code.Beq:
|
||||
|
|
|
@ -35,8 +35,14 @@ namespace de4dot.blocks.cflow {
|
|||
public bool remove() {
|
||||
bool changed = false;
|
||||
|
||||
foreach (var block in allBlocks)
|
||||
foreach (var block in allBlocks) {
|
||||
try {
|
||||
changed |= remove(block);
|
||||
}
|
||||
catch (System.NullReferenceException) {
|
||||
// Here if eg. invalid metadata token in a call instruction (operand is null)
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user