forked from Stichting-MINIX-Research-Foundation/minix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyscalls.c
More file actions
85 lines (67 loc) · 1.4 KB
/
Copy pathsyscalls.c
File metadata and controls
85 lines (67 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* syscall.c for mdb
*/
#include "mdb.h"
#ifdef SYSCALLS_SUPPORT
#include <stdio.h>
#include <stdlib.h>
#include <sys/ptrace.h>
#include "proto.h"
#define SYSCALL_NAME "__sendrec"
#ifdef __i386
#define SYSCALL_OFFSET 0xF
#define SYSCALL_OLD 0x21CD
#else
#define SYSCALL_OFFSET 0xE
#define SYSCALL_OLD 0x20CD
#endif
PRIVATE long intaddr;
PUBLIC void start_syscall(addr)
long addr;
{
long old;
syscalls = FALSE;
if ( addr == 0 ) {
intaddr = symbolvalue( SYSCALL_NAME, TRUE );
if ( intaddr == 0 )
return;
intaddr += SYSCALL_OFFSET;
}
else {
intaddr = addr;
Printf("Using %lx as syscall address\n",addr);
}
old = breakpt(intaddr,"\n");
/* Check instruction */
if ( (old & 0xFFFF) == SYSCALL_OLD)
syscalls = TRUE;
}
PUBLIC void do_syscall(addr)
long addr;
{
unsigned reg_ax,reg_bx;
if ( addr != intaddr ) return;
Printf("syscall to ");
reg_ax = get_reg(curpid,reg_addr("AX"));
switch (reg_ax) {
case 0: Printf(" MM ");
break;
case 1: Printf(" FS ");
break;
case 2: Printf(" INET ");
break;
default: Printf("Invalid dest = %d", reg_ax);
exit(0);
}
reg_bx = get_reg(curpid,reg_addr("BX"));
decode_message(reg_bx);
/* Single step */
tstart(T_STEP, 0, 0, 1);
/* Check return code */
reg_ax = get_reg(curpid,reg_addr("AX"));
if ( reg_ax != 0 )
Printf("syscall failed AX=%d\n",reg_ax);
else
decode_result();
}
#endif /* SYSCALLS_SUPPORT */