A simple WSL kernel module meant as a demonstration on how to develop linux kernel modules under WSL.
This was developed for WSL2 Kernel 5.15.19.X but should work on all versions as long as you up/downgrade the submodule.
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
Copy your config over:
zcat /proc/config.gz > .config
Compile the kernel:
make -j $(nproc)
Install:
sudo make -j $(nproc) modules_install
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