Skip to content

Commit

Permalink
Increase difficulty
Browse files Browse the repository at this point in the history
  • Loading branch information
nnjun committed Dec 20, 2021
1 parent c23cb8f commit fb03812
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,24 @@ private RebuildIfResult reBuildIf(IrMethod ir, IfStmt ifStmt, List<Stmt> origStm

LBlock defaultTarget = generateLBlock();

Map<Integer, LabelStmt> switchBlock = new HashMap<>();
Map<Integer, LabelStmt> switchBlock = new LinkedHashMap<>();
Map<Integer, LabelStmt> newSwitchBlock = new LinkedHashMap<>();
switchBlock.put(mapping.get(MAPPING_GOTO).hashCode() ^ obfIndexI, targetBlock.getLabelStmt());
switchBlock.put(mapping.get(MAPPING_ELSE).hashCode() ^ obfIndexI, elseBlock.getLabelStmt());
switchBlock.put(mapping.get(MAPPING_ENTER).hashCode() ^ obfIndexI, enterBlock.getLabelStmt());
switchBlock.put(mapping.get(MAPPING_NEXT).hashCode() ^ obfIndexI, nextBlock.getLabelStmt());
switchBlock.put(mapping.get(MAPPING_FAKE).hashCode() ^ obfIndexI, fake.getLabelStmt());
List<Integer> sortList = new ArrayList<>(switchBlock.keySet());
Collections.shuffle(sortList);
for (Integer integer : sortList) {
newSwitchBlock.put(integer, switchBlock.get(integer));
}


// switch(obfIndex)
LookupSwitchStmt lookupSwitchStmt = Stmts.nLookupSwitch(obfIndex,
switchBlock.keySet().stream().mapToInt(integer -> integer).toArray(),
switchBlock.values().toArray(new LabelStmt[]{}),
newSwitchBlock.keySet().stream().mapToInt(integer -> integer).toArray(),
newSwitchBlock.values().toArray(new LabelStmt[]{}),
defaultTarget.getLabelStmt());

newStmts.add(lookupSwitchStmt);
Expand Down

0 comments on commit fb03812

Please sign in to comment.