Skip to content

Commit 48390ff

Browse files
mbabinski-at-googleMaciej Babinski
authored andcommitted
Gracefully handle unknown system calls.
1 parent d691e98 commit 48390ff

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

plasma/lib/arch/x86/int80.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
#
1919

20+
from collections import defaultdict
21+
2022
from capstone.x86 import (X86_REG_EBX, X86_REG_ECX, X86_REG_EDX, X86_REG_ESI,
2123
X86_INS_INT, X86_OP_IMM, X86_REG_AL, X86_REG_AX, X86_REG_EAX,
2224
X86_REG_RAX, X86_REG_BL, X86_REG_CL, X86_REG_DL, X86_REG_BX,
@@ -57,7 +59,7 @@
5759

5860
# http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html
5961

60-
SYSCALL = {
62+
SYSCALL_DATA = {
6163
1: {"name": "exit", "args_type": [ARG_INT]},
6264
# 2: {"name": "fork", "args_type": ['struct pt_regs']},
6365
2: {"name": "fork", "args_type": []},
@@ -241,6 +243,10 @@
241243
190: {"name": "vfork", "args_type": ['struct pt_regs']},
242244
}
243245

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]
244250

245251

246252
def reg_write(inst, reg_id):
@@ -292,11 +298,11 @@ def read_block(ctx, blk):
292298
inline_comm[inst.address] = "?"
293299
continue
294300

295-
inline_comm[inst.address] = SYSCALL[sysnum]["name"] + "("
301+
inline_comm[inst.address] = SYSCALL(sysnum)["name"] + "("
296302

297303
# Search values for each args, otherwise print the register
298304

299-
args_type = SYSCALL[sysnum]["args_type"]
305+
args_type = SYSCALL(sysnum)["args_type"]
300306
for j in range(len(args_type)):
301307
idx_wr_reg = search_backward(blk, i, ARGS_ORDER[j])
302308

0 commit comments

Comments
 (0)