-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
66 lines (62 loc) · 1.24 KB
/
test.c
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
#include <stdio.h>
#include <unistd.h>
#define NR_set_hidden 351
int main (void)
{
int choice;
pid_t pid;
printf("Enter (1) to fork current process or (2) to change a specific process' hidden flag. (0) to exit. ");
scanf("%d",&choice);
switch (choice)
{
case 0:
{
printf("Good bye...\n");
return 0;
}
break;
case 1:
{
pid = getpid();
int frk = fork();
if(frk == -1)
{
printf("Process couldn't fork succesfully. You have no permission to do this operation.\n");
return -1;
}
else if (frk == 0)
{
printf("I'm the child process and my pid is %d\n",getpid());
return 0;
}
else
{
printf("I'm the parent process and my pid is %d\n",pid);
return 0;
}
}
break;
case 2:
{
int flag;
printf("Please enter pid of process you want to change its flag: ");
scanf("%d",&pid);
printf("Please enter 'hidden' flag value: ");
scanf("%d",&flag);
long ret = syscall(NR_set_hidden, pid,flag);
if (ret != 0)
{
printf("Hidden flag couldn't changed succesfully, error code is %ld.\n",ret);
return -1;
}
else
{
printf("Hidden flag has been changed succesfully.\n");
return 0;
}
}
break;
default:
return 0 ;
}
}