lancelot
lancelot copied to clipboard
switch detection
samples:
- cc688ff3a525bac5e1241d13fae8d97a:10001EA1
32-bit added in 3e378a4b218e60efe8bf6f771543354ca5cd78e5
in mimi64, function 0x140056250 has a massive switch jmp at 0x1400562BF
some programs will place the jump tables contiguously, so need to be able to detect if the targets are already part of a prior jump table. if this is the case, then we need to remove the existing references. likewise, we should stop reading a jump table when encountering entries that already have references.
for example, given the following:
jtable_1:
j1
j2
j3
j4
jtable_2:
j5
j6
j7
j8
the cases:
- consider that
jtable_1
is already defined, and we want to now addjtable_2
. need to remove the entriesj5
-j8
fromjtable_1
and add them tojtable_2
. - consider that
jtable_2
is already defined and we want to now addjtable_1
. need to add only up toj4
and not continue acrossj5
and above.
note: we could probably have these two cases happening at the same time (a sandwich). so, we probably want to find the end of the logical array first, then find any prior tables, and finally update/add the xrefs.
external refs:
- https://github.com/vivisect/vivisect/pull/251
- https://github.com/vivisect/vivisect/pull/247#issuecomment-527244982