fix: 修复SplitBasicBlockGroup计算带filter的异常handler时,先计算整个异常块再计算filter和handler块的顺序bug,正确方式为先计算filter和handler,再计算整体

pull/30/head
walon 2025-10-16 22:28:05 +08:00
parent b582c1f24b
commit c9ea564544
1 changed files with 9 additions and 8 deletions

View File

@ -774,13 +774,13 @@ namespace Obfuz.ObfusPasses.ControlFlowObfus
private class ExceptionHandlerWithFilterGroup : BlockGroup private class ExceptionHandlerWithFilterGroup : BlockGroup
{ {
public readonly ExceptionHandler exceptionHandler; public readonly ExceptionHandler exceptionHandler;
//public readonly ExceptionFilterGroup filterGroup; public readonly ExceptionFilterGroup filterGroup;
//public readonly ExceptionHandlerGroup handlerGroup; public readonly ExceptionHandlerGroup handlerGroup;
public ExceptionHandlerWithFilterGroup(ExceptionHandler exceptionHandler, List<Instruction> filterInstructions, List<Instruction> handlerInstructions, List<Instruction> allInstructions, Dictionary<Instruction, BlockGroup> inst2group) : base(allInstructions, inst2group) public ExceptionHandlerWithFilterGroup(ExceptionHandler exceptionHandler, ExceptionFilterGroup filterGroup, ExceptionHandlerGroup handlerGroup, List<Instruction> instructions, Dictionary<Instruction, BlockGroup> inst2group) : base(instructions, inst2group)
{ {
this.exceptionHandler = exceptionHandler; this.exceptionHandler = exceptionHandler;
var filterGroup = new ExceptionFilterGroup(exceptionHandler, filterInstructions, inst2group); this.filterGroup = filterGroup;
var handlerGroup = new ExceptionHandlerGroup(exceptionHandler, handlerInstructions, inst2group); this.handlerGroup = handlerGroup;
} }
} }
@ -833,9 +833,10 @@ namespace Obfuz.ObfusPasses.ControlFlowObfus
int filterEndIndex = ex.HandlerStart != null ? inst2Index[ex.HandlerStart] : inst2Index.Count; int filterEndIndex = ex.HandlerStart != null ? inst2Index[ex.HandlerStart] : inst2Index.Count;
int handlerStartIndex = filterEndIndex; int handlerStartIndex = filterEndIndex;
int handlerEndIndex = ex.HandlerEnd != null ? inst2Index[ex.HandlerEnd] : inst2Index.Count; int handlerEndIndex = ex.HandlerEnd != null ? inst2Index[ex.HandlerEnd] : inst2Index.Count;
var filterHandlerGroup = new ExceptionHandlerWithFilterGroup(ex,
instructions.GetRange(filterStartIndex, filterEndIndex - filterStartIndex), var filterGroup = new ExceptionFilterGroup(ex, instructions.GetRange(filterStartIndex, filterEndIndex - filterStartIndex), inst2blockGroup);
instructions.GetRange(handlerStartIndex, handlerEndIndex - handlerStartIndex), var handlerGroup = new ExceptionHandlerGroup(ex, instructions.GetRange(handlerStartIndex, handlerEndIndex - handlerStartIndex), inst2blockGroup);
var filterHandlerGroup = new ExceptionHandlerWithFilterGroup(ex, filterGroup, handlerGroup,
instructions.GetRange(filterStartIndex, handlerEndIndex - filterStartIndex), inst2blockGroup); instructions.GetRange(filterStartIndex, handlerEndIndex - filterStartIndex), inst2blockGroup);
} }
else else