mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-26 11:41:35 +01:00
rename kernel_module to kernel_modules, start README mass factorings
This commit is contained in:
26
packages/kernel_modules/user/virt_to_phys_user.c
Normal file
26
packages/kernel_modules/user/virt_to_phys_user.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* 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;
|
||||
}
|
||||
Reference in New Issue
Block a user