Files
linux-kernel-module-cheat/userland/virt_to_phys_user.c
Ciro Santilli 六四事件 法轮功 ca231b82f6 get rid of lkmc package, move userland and kernel-modules to top
Rationale: we already had a non buildroot build system,
maintaining both will be hard, and having short paths is more awesome.
2018-10-25 00:00:02 +00:00

27 lines
689 B
C

/* https://github.com/cirosantilli/linux-kernel-module-cheat#userland-physical-address-experiments */
#define _XOPEN_SOURCE 700
#include <stdio.h> /* printf */
#include <stdlib.h> /* EXIT_SUCCESS, EXIT_FAILURE, strtoull */
#include "common.h" /* virt_to_phys_user */
int main(int argc, char **argv)
{
pid_t pid;
uintptr_t vaddr, paddr = 0;
if (argc < 3) {
printf("Usage: %s pid vaddr\n", argv[0]);
return EXIT_FAILURE;
}
pid = strtoull(argv[1], NULL, 0);
vaddr = strtoull(argv[2], NULL, 0);
if (virt_to_phys_user(&paddr, pid, vaddr)) {
fprintf(stderr, "error: virt_to_phys_user\n");
return EXIT_FAILURE;
};
printf("0x%jx\n", (uintmax_t)paddr);
return EXIT_SUCCESS;
}