9/26/2023 0 Comments Writing kernel modules linux c![]() ![]() This is how Linux enforces what code is considered to be a derivative work of Linux. GPL is the General Public License and if you do not have MODULE_LICENSE("GPL") then symbols that are exported via EXPORT_SYMBOL_GPL() will not be visible to your module. Defining the license macro is important as without it, the kernel will complain while loading the module. Next we define the macros MODULE_LICENSE and MODULE_AUTHOR. Firstly we have few #include statements that include some macros that we have used in the program. We will walk through the above code line by line. As always let’s start with writing Hello World!. It is advised to build these modules in a virtual machine to prevent corruption and to revert back to previous states of the operating system without much trouble. ![]() It is literally adding your code to the kernel which implies that these modules run with kernel privileges (ring 0) (In later posts we will write some rootkits as well :) ). The examples provided mostly focus on device drivers but we can do pretty much anything with kernel modules. you plug in a printer whose driver was not already present). But what if we need some functionality that is not already built-in? This is where loading new modules without rebooting the system comes in handy (loadable modules) (eg. Many modules are already loaded into the kernel by default (built-in modules) (eg. Modules extend the functionality of the kernel. Kernel Modules are pieces of code that can be loaded into the kernel while the kernel is already running. In this post, we will introduce the reader to writing Kernel Modules for Linux. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |