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
| #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <ctype.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/mman.h>
#define MAP_SIZE 4096UL
#define MAP_MASK (MAP_SIZE - 1)
int main(void) {
int fd;
int *map_base_c,*map_base_d, *map_base_p, *virt_addr;
off_t target,control,data,pullup;
control=0x56000050;
if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) FATAL;
map_base_d = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd,data & ~MAP_MASK);
printf("Memory mapped at address %p.\n", map_base_d);
virt_addr = map_base_d; //+ (data & MAP_MASK)
*virt_addr = 0x00; //This is where it goes off. find out why!!!
printf("Value at address 0x%X (%p): 0x%X\n", data, virt_addr,(*virt_addr));
close(fd);
return 0;
} |