use module functions in own C program?
hello everybody
i have a kernel module called for example xyz.ko (only the binary file). when the module is loaded and i look at /proc/kallsyms i can see functions from the module like "c0161080 t XYZ_Write_Chars [xyz_driver]". is there any way to use this funtion in my own C program? if yes, can you give me a short example please? thanks in advance captaint |
look at function pointers for how to use that information.
example: void somefunc (void (*funcpoint) (void*)) { void* data = somedata; funcpoint (somedata); } |
Are you attempting to call these from a C program in userspace? If so... you probably want to investigate the use of character/block devices to communicate with a kernel module and/or syscalls. Being able to call kernel functions directly at will from userspace would be a massive security risk.
For your example I would implement a character devices as a part of my module and have people use the write system call to interact with it. |
@ SciYro
thank you much, i have tried but i'm not able to get some working code ( C noob :( ) @ jtshaw yes i'm trying to call this from userspace. i will explain what i want to do: i have a binary lcd/vfd kernel module where i can't get the source code. the module creates a device (/dev/vfd) but i don't know how to "talk" to this device, so i thought i could perhaps call the functions directly in the module (for example VFD_Write_Chars, where i guess it will write to the lcd/vfd). do you know a better way? i have another binary which outputs something on lcd/vfd - is there a way to sniff this? thank you a lot for help captaint |
If you dont have a good grasp on C, kernel level programing should be avoided. That said, find some good tutorial to read, i like this one: http://www.cs.cf.ac.uk/Dave/C/
|
All times are GMT -5. The time now is 04:24 AM. |