bmax121 / KernelPatch

Patching and hooking the Linux kernel with only a stripped Linux kernel image.
GNU General Public License v2.0
572 stars 89 forks source link

How to export header files to a kernel module from source code of a kernel or other means to get a structure object #100

Open ArmanAirapetov opened 1 month ago

ArmanAirapetov commented 1 month ago

Hello. My module requires some structure to function, for example, the timer_list structure of the linux/timer.h . How can I import it in my project? Detail information about subject

I have added linux source to KernelPatch/kernel/. I have changed the Makefile. Before:

INCLUDE_DIRS := . include patch/include linux/include linux/arch/arm64/include linux/tools/arch/arm64/include

After:

INCLUDE_DIRS := . include patch/include linux-4.14.156/include linux-4.14.156/arch/arm64/include linux-4.14.156/tools/arch/arm64/include

I got this error message:

make 
/home/user/Downloads/aarch64-none-elf-gcc-xpack-13.2.1-1.1/xpacks/.bin/aarch64-none-elf-gcc  -I../../kernel/. -I../../kernel/include -I../../kernel/patch/include -I../../kernel/linux-4.14.156/include -I../../kernel/linux-4.14.156/arch/arm64/include -I../../kernel/linux-4.14.156/tools/arch/arm64/include -c -O2 -o secure.o secure.c
In file included from secure.c:4:
../../kernel/linux-4.14.156/include/uapi/asm-generic/unistd.h:2:10: fatal error: asm/bitsperlong.h: No such file or directory
    2 | #include <asm/bitsperlong.h>
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:26: secure.o] Error 1
ArmanAirapetov commented 1 month ago

I replaced the INCLUDE_DIRS again:

INCLUDE_DIRS := . include patch/include linux-4.14.156/include linux-4.14.156/arch/arm64/include linux-4.14.156/tools/arch/arm64/include linux-4.14.156/include/uapi linux-4.14.156/arch/arm64/include/uapi linux-4.14.156/arch/arm64/include/generated/uapi linux-4.14.156/arch/arm64/include/generated

I get this error log when executing make err.log