-
Notifications
You must be signed in to change notification settings - Fork 9
/
syscall_interpret.h
49 lines (45 loc) · 1.15 KB
/
syscall_interpret.h
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
/* Syscall_Interpret.h
*
* This Header file contains the functions to interpret arguments of
* supported System calls.
*/
#define MAX_STRING_LEN 30
#define MAX_OUT_STRING_LEN 250
void interpret_write(long *reg_array, pid_t child, char *buf,
unsigned int len)
{
long ebx, ecx, edx;
ebx = reg_array[1];
ecx = reg_array[2];
edx = reg_array[3];
snprintf(buf ,len ,"write( %u, %u, %d)",(unsigned int) ebx,
(unsigned int) ecx, (int) edx);
}
void interpret_read(long *reg_array, pid_t child, char *buf,
unsigned int len)
{
long ebx, ecx, edx;
ebx = reg_array[1];
ecx = reg_array[2];
edx = reg_array[3];
snprintf(buf ,len ,"read( %u, %u, %d)",(unsigned int) ebx,
(unsigned int) ecx, (int) edx);
}
void interpret_open(long *reg_array, pid_t child, char *buf,
unsigned int len)
{
long ebx, ecx, edx;
int err;
char *fname = (char *) malloc(sizeof(char)*(MAX_STRING_LEN+1));
ebx = reg_array[1];
ecx = reg_array[2];
edx = reg_array[3];
err = get_string_data_unbounded(child, ebx, fname,
MAX_STRING_LEN);
if (err)
fname[0] = '\0';
snprintf(buf ,len ,"open( %s, %d, %d)",fname,
(int) ecx, (int) edx);
/*CLEANUP*/
if(fname) free(fname);
}