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

[ValueError@switch_variable_detection.py:117] ValueError: No switch variable candidate found. #284

Closed github-actions[bot] closed 10 months ago

github-actions[bot] commented 11 months ago

closes #279

ebehner commented 11 months ago

After taking a closer look at the sample, I am not sure if we fix it at the right place. The MLIL CFG in BinaryNinja looks as follows: image

Since this is not really a switch, we do this monkey-patch in the parser:

return {edge.target.source_block.start: [Constant(i)] for i, edge in enumerate(block.outgoing_edges)}

(https://github.com/fkie-cad/dewolf/blob/2cd08b60c3b83ffd772812a950f7fa36d3da2721/decompiler/frontend/binaryninja/parser.py#L67C12-L67C12)

Thus, the switch-edge becomes the constant 0. We ignore this during the restructuring, because the graph has only one leave and we assume that its reaching-condition is True. In this case, it seems more that the jump statement simply jumps to the next statement, i.e., from line 24 to 25. Perhaps, we have to adopt something in the parser here instead of the switch-variable-detection.