-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmp.c
More file actions
53 lines (44 loc) · 1.24 KB
/
Copy pathtmp.c
File metadata and controls
53 lines (44 loc) · 1.24 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
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <fcntl.h>
#include <string.h>
#include <xenctrl.h>
#include <xen/sys/privcmd.h>
#include <unistd.h>
#include <libvmi/libvmi.h>
#include <string.h>
#include <sys/mman.h>
#define DOMAIN "Web"
#define PID 2
#define VADDR 0x400574
int main(int argc, char *argv[])
{
int fd, ret, i;
unsigned long cr3;
vmi_instance_t vmi;
unsigned long offset = 0;
unsigned long addr = (addr_t) strtoul(argv[2], NULL, 16);
privcmd_hypercall_t hyper0 = {
__HYPERVISOR_change_ept_content,
//int domID, unsigned long gfn, unsigned long mfn, int flag, void buff
{ atoi(argv[1]), addr, 0, 6, 0}
};
privcmd_hypercall_t hyper1 = {
__HYPERVISOR_change_ept_content,
//int domID, unsigned long gfn, unsigned long mfn, int flag, void buff
{ atoi(argv[1]), 0, 0, 13, 0}
};
fd = open("/proc/xen/privcmd", O_RDWR);
if (fd < 0) {
perror("open");
exit(1);
}
if( atoi(argv[3]) == 1 )
ret = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, &hyper1);
else
ret = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, &hyper0);
return 0;
}