Linux内核:获取内核驱动程序的函数地址

时间:2022-01-08 16:56:01

Is it possible in a linux kernel module to get the pointer of a function exported by another kernel module (something like cat /proc/kallsyms) but with api calls. Also if it would be possbile to load the intended module into memory if it doesn't exist. Basically what i am trying to do is to introduce a soft dependency between 2 modules. so i can execute one with or without the other.

是否有可能在Linux内核模块中获取由另一个内核模块(类似cat / proc / kallsyms)导出的函数的指针,但是使用api调用。此外,如果不存在,可能会将目标模块加载到内存中。基本上我要做的是在两个模块之间引入一个软依赖。所以我可以使用或不使用另一个执行一个。

1 个解决方案

#1


1  

Yes, this is possible. Using following Linux Kernel APIs,

是的,这是可能的。使用以下Linux内核API,

  1. Using find_symbol API, you can search for desired symbol exists or not
  2. 使用find_symbol API,您可以搜索是否存在所需的符号

  3. If it fails to find symbol, then you can try to load desired module which exports symbol which you intended to use using APIs called find_module and request_module. Here is sample code for these APIs here
  4. 如果找不到符号,那么您可以尝试加载所需的模块,该模块使用名为find_module和request_module的API导出您要使用的符号。以下是这些API的示例代码

#1


1  

Yes, this is possible. Using following Linux Kernel APIs,

是的,这是可能的。使用以下Linux内核API,

  1. Using find_symbol API, you can search for desired symbol exists or not
  2. 使用find_symbol API,您可以搜索是否存在所需的符号

  3. If it fails to find symbol, then you can try to load desired module which exports symbol which you intended to use using APIs called find_module and request_module. Here is sample code for these APIs here
  4. 如果找不到符号,那么您可以尝试加载所需的模块,该模块使用名为find_module和request_module的API导出您要使用的符号。以下是这些API的示例代码