Inline a few more instructions
This commit is contained in:
parent
192fd3b66c
commit
06bef669c5
|
@ -142,7 +142,9 @@ namespace de4dot.blocks.cflow {
|
||||||
if (instr == null || loadIndex != methodArgsCount - popLastArgs)
|
if (instr == null || loadIndex != methodArgsCount - popLastArgs)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (instr.OpCode.Code == Code.Call || instr.OpCode.Code == Code.Callvirt) {
|
switch (instr.OpCode.Code) {
|
||||||
|
case Code.Call:
|
||||||
|
case Code.Callvirt:
|
||||||
if (foundLdarga)
|
if (foundLdarga)
|
||||||
return null;
|
return null;
|
||||||
var callInstr = instr;
|
var callInstr = instr;
|
||||||
|
@ -160,8 +162,8 @@ namespace de4dot.blocks.cflow {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new InstructionPatcher(patchIndex, instrIndex, callInstr);
|
return new InstructionPatcher(patchIndex, instrIndex, callInstr);
|
||||||
}
|
|
||||||
else if (instr.OpCode.Code == Code.Newobj) {
|
case Code.Newobj:
|
||||||
if (foundLdarga)
|
if (foundLdarga)
|
||||||
return null;
|
return null;
|
||||||
var newobjInstr = instr;
|
var newobjInstr = instr;
|
||||||
|
@ -185,21 +187,31 @@ namespace de4dot.blocks.cflow {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new InstructionPatcher(patchIndex, instrIndex, newobjInstr);
|
return new InstructionPatcher(patchIndex, instrIndex, newobjInstr);
|
||||||
}
|
|
||||||
else if (instr.OpCode.Code == Code.Ldfld || instr.OpCode.Code == Code.Ldflda ||
|
case Code.Ldfld:
|
||||||
instr.OpCode.Code == Code.Ldftn || instr.OpCode.Code == Code.Ldvirtftn) {
|
case Code.Ldflda:
|
||||||
|
case Code.Ldftn:
|
||||||
|
case Code.Ldvirtftn:
|
||||||
|
case Code.Ldlen:
|
||||||
|
case Code.Initobj:
|
||||||
|
case Code.Isinst:
|
||||||
|
case Code.Castclass:
|
||||||
|
case Code.Newarr:
|
||||||
|
case Code.Ldtoken:
|
||||||
|
case Code.Unbox_Any:
|
||||||
var ldInstr = instr;
|
var ldInstr = instr;
|
||||||
if (methodArgsCount != 1)
|
if (methodArgsCount != 1)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (!HasAccessTo(instr.Operand))
|
if (instr.OpCode.OperandType != OperandType.InlineNone && !HasAccessTo(instr.Operand))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new InstructionPatcher(patchIndex, instrIndex, ldInstr);
|
return new InstructionPatcher(patchIndex, instrIndex, ldInstr);
|
||||||
}
|
|
||||||
|
|
||||||
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool HasAccessTo(object operand) {
|
bool HasAccessTo(object operand) {
|
||||||
if (operand == null)
|
if (operand == null)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user