In BBS, I have issued a question shown in the question. The result is not a reply, hey, it is really shameless ~~~ The function in the module (even if you have a self-hanging module - actually it is also a kernel module), there is only some specific system functions (such as user_to_kernel) between user space and kernel space (such as USER_TO_KERNEL), and absolute It is not possible to communicate in the form of "function in the module". So how can the function in the module written can be executed? Who is called? In fact, the answer is very simple, they are called by the core, pay attention, is called by the core. For example, the init_module () and cleanup_module () functions are in the mount module (INSMOD) and uninstall module (RMMOD), the kernel calls the two functions according to the command parameters, which are responsible for the initialization and post processing of the module. Naturally, the next question follows, how is the other functions in the module called? For example, in addition to the init_module () and cleanup_module () functions, I also wrote a Hello_World () function, a simple output "Hello World" to the console, good, next is the key to this analysis, before we Emphasizing the function in the module is called by the core, there is no other opportunity to perform it. That if our hello_world () function cannot be called by the kernel, this does not mean that it will never be executed? It is indeed this, in other words, in this case it is a spam code, never seeing day. How can we make our hello_world () function to be executed? Obviously, the key is to let the kernel know it, ie the kernel can find it. So how can I make the kernel find this function? Further problem is, why is the kernel to find this function? The first question is that the kernel finds a function through a specific data structure in the system. Of course, this means that in your module program, only the code of the Hello_World () function is not enough, but also a few Step Work: A, first, the various data structures in the system are so much, which one is to use? This is determined by your module's registration nature, such as your module is a USB device driver module, then you need to fill in the data structure of the USB device driver (usually the data structure is in the form of structures) struct usb_driver { The first item; the second item; the third item; .......} Some of the strings is a string, some are a function pointer, and the details are reviewed. b, put the function pointer of the hello_world () into a data structure. Let's take an example of the USB device driver module. In its data structure USB_DRIVER {}, choose an item that happens to function pointer, put the pointer of the hello_world () function (through function name), then fill it Other parts of this data structure (if you don't want to fill it, it is empty: p, separated by a semicolon).