mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-27 12:04:27 +01:00
myinsmod takes params
This commit is contained in:
@@ -10,22 +10,28 @@
|
|||||||
#define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts)
|
#define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts)
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
size_t image_size;
|
const char *params;
|
||||||
void *image;
|
|
||||||
int fd;
|
int fd;
|
||||||
|
size_t image_size;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
void *image;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc < 2) {
|
||||||
puts("Usage ./prog mymodule.ko");
|
puts("Usage ./prog mymodule.ko [args]");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
if (argc < 3) {
|
||||||
|
params = "";
|
||||||
|
} else {
|
||||||
|
params = argv[2];
|
||||||
|
}
|
||||||
fd = open(argv[1], O_RDONLY);
|
fd = open(argv[1], O_RDONLY);
|
||||||
fstat(fd, &st);
|
fstat(fd, &st);
|
||||||
image_size = st.st_size;
|
image_size = st.st_size;
|
||||||
image = malloc(image_size);
|
image = malloc(image_size);
|
||||||
read(fd, image, image_size);
|
read(fd, image, image_size);
|
||||||
close(fd);
|
close(fd);
|
||||||
if (init_module(image, image_size, "") != 0) {
|
if (init_module(image, image_size, params) != 0) {
|
||||||
perror("init_module");
|
perror("init_module");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user