fkie-cad / dewolf

A research decompiler implemented as a Binary Ninja plugin.
GNU Lesser General Public License v2.1
162 stars 9 forks source link

[Switch Missing Case Finder] Finding cases in if-else conditions #282

Closed ebehner closed 11 months ago

ebehner commented 11 months ago

Proposal

If a switch-node is a branch of a condition node, whose other branch has a possible case-condition, then we add it as a case-node if the switch-node has no reaching-condition (or a simple if-cond before). However, if this condition is always fulfilled if the new case-condition is fulfilled, we could still add the case node.

Consider the following AST for an illustration: image Here, node 4 is a case-node of the switch node, but we do not add it because the switch-node has a reaching-condition. However, the reaching-condition var_0 !=2 is always true, if the case condition var_0 == 1 is fulfilled. Thus we could add it.

Approach

Update the missing-case finder for conditions such that it also handles this for switch-nodes with a reaching condition or a simple if-before. Add the missing-case node only if the case-condtion implies the reaching-condition.

ebehner commented 11 months ago

/cib

github-actions[bot] commented 11 months ago

Branch issue-282-_Switch_Missing_Case_Finder_Finding_cases_in_if-else_conditions created!