|
17 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 | # |
19 | 19 |
|
| 20 | +from collections import defaultdict |
| 21 | + |
20 | 22 | from capstone.x86 import (X86_REG_EBX, X86_REG_ECX, X86_REG_EDX, X86_REG_ESI, |
21 | 23 | X86_INS_INT, X86_OP_IMM, X86_REG_AL, X86_REG_AX, X86_REG_EAX, |
22 | 24 | X86_REG_RAX, X86_REG_BL, X86_REG_CL, X86_REG_DL, X86_REG_BX, |
|
57 | 59 |
|
58 | 60 | # http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html |
59 | 61 |
|
60 | | -SYSCALL = { |
| 62 | +SYSCALL_DATA = { |
61 | 63 | 1: {"name": "exit", "args_type": [ARG_INT]}, |
62 | 64 | # 2: {"name": "fork", "args_type": ['struct pt_regs']}, |
63 | 65 | 2: {"name": "fork", "args_type": []}, |
|
241 | 243 | 190: {"name": "vfork", "args_type": ['struct pt_regs']}, |
242 | 244 | } |
243 | 245 |
|
| 246 | +def SYSCALL(no): |
| 247 | + if no not in SYSCALL_DATA: |
| 248 | + SYSCALL_DATA[no] = {"name": "SYS%d" % no, "args_type": []} |
| 249 | + return SYSCALL_DATA[no] |
244 | 250 |
|
245 | 251 |
|
246 | 252 | def reg_write(inst, reg_id): |
@@ -292,11 +298,11 @@ def read_block(ctx, blk): |
292 | 298 | inline_comm[inst.address] = "?" |
293 | 299 | continue |
294 | 300 |
|
295 | | - inline_comm[inst.address] = SYSCALL[sysnum]["name"] + "(" |
| 301 | + inline_comm[inst.address] = SYSCALL(sysnum)["name"] + "(" |
296 | 302 |
|
297 | 303 | # Search values for each args, otherwise print the register |
298 | 304 |
|
299 | | - args_type = SYSCALL[sysnum]["args_type"] |
| 305 | + args_type = SYSCALL(sysnum)["args_type"] |
300 | 306 | for j in range(len(args_type)): |
301 | 307 | idx_wr_reg = search_backward(blk, i, ARGS_ORDER[j]) |
302 | 308 |
|
|
0 commit comments