Skip to content

A simple linux kernel module template running under WSL

License

Notifications You must be signed in to change notification settings

AnnsAnns/wsl-kernel-module-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wsl-kernel-module

A simple WSL kernel module meant as a demonstration on how to develop linux kernel modules under WSL.

Version

This was developed for WSL2 Kernel 5.15.19.X but should work on all versions as long as you up/downgrade the submodule.

How to use

Please note that you might have to change the WSL submodule branch depending on your WSL instance. It should match whatever is returned when typing:

uname -r

Compile / Configure Kernel

Copy your config over:

zcat /proc/config.gz > .config

Compile the kernel:

make -j $(nproc)

Install:

sudo make -j $(nproc) modules_install

Compile Module

cd kernel_module
make

Congratulations, you should now have a working kernel module called main.ko. Try loading it via:

sudo insmod main.ko

and look at what it prints via:

dmesg