r2dec-js
r2dec-js copied to clipboard
Handle for loops
for loops are easy to detect:
do {
ops
ops
ops
[...]
// can be here an if or a label, if there's one
// then there could be a for loop.
add // incrementer
sub // decrementer
} while(cond);
Edits goes only under controlflow.js
. Probably is possible to only edit the while
detection code in order to enhance it to support for
logic.
the algorithm should be like for the while:
[...]
type is do-while
if jumps into do-while loop then type is while;
if between previous jump-label and while-jump there are math or calls ops that (no compare ops) then type is for-loop (with or without iterators, e.g. c++ iterators)