diff --git a/2_MemoryLoading/2.0_no_arguments/Makefile b/2_MemoryLoading/2.0_no_arguments/Makefile index 32c22ba..0cab874 100644 --- a/2_MemoryLoading/2.0_no_arguments/Makefile +++ b/2_MemoryLoading/2.0_no_arguments/Makefile @@ -1,2 +1,12 @@ +kmod_name = example + all: + echo "#include " > load.c + echo "#include " >> load.c + echo "#include " >> load.c + echo "" >> load.c + xxd -i $(kmod_name).ko >> load.c + echo "const char args[] = \"\\\0\";" >> load.c + echo "" >> load.c + cat stub.c >> load.c gcc -o load load.c diff --git a/2_MemoryLoading/2.0_no_arguments/README.md b/2_MemoryLoading/2.0_no_arguments/README.md index 64a64e5..1011830 100644 --- a/2_MemoryLoading/2.0_no_arguments/README.md +++ b/2_MemoryLoading/2.0_no_arguments/README.md @@ -12,4 +12,4 @@ * Unload with `rmmod example` * Check the second output in the kernel buffer with `dmesg` -> NOTE: If you aren't running kernel `5.4.0-33-generic` (Ubuntu 20.04 currently), then you will need to recompile [`example.ko`](../../0_Basic_LKMs/0.0_Basic/), and replace the `example_ko` and `example_ko_len` lines with the output of `xxd -i example.ko`. +> NOTE: This assumes that `example.ko` is in the current directory. If your LKM is named something else, change the first line in the [`Makefile`](./Makefile). diff --git a/2_MemoryLoading/2.0_no_arguments/stub.c b/2_MemoryLoading/2.0_no_arguments/stub.c new file mode 100644 index 0000000..e70313a --- /dev/null +++ b/2_MemoryLoading/2.0_no_arguments/stub.c @@ -0,0 +1,14 @@ +int main(void) +{ + int result; + + result = init_module(example_ko, example_ko_len, args); + + if( result != 0 ) + { + printf("Error: %d\n", result); + return(-1); + } + + return(0); +}