Last active
August 17, 2025 04:35
-
-
Save vasi/94173f68b4caa93100a9b192086b02cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <sys/mman.h> | |
| #include <fcntl.h> | |
| #include <stdio.h> | |
| int main(int argc, char *argv[]) { | |
| // Run: sudo ./test /sys/bus/pci/devices/*:00:10.0/resource2 | |
| char *file = argv[1]; | |
| fprintf(stderr, "file = %s\n", file); | |
| int fd = open(file, O_RDWR | O_CLOEXEC); | |
| fprintf(stderr, "fd = %d\n", fd); | |
| void *addr = mmap(NULL, 0x4000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); | |
| fprintf(stderr, "addr = %p\n", addr); | |
| perror("error"); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment