LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   use module functions in own C program? (https://www.linuxquestions.org/questions/programming-9/use-module-functions-in-own-c-program-565372/)

captaint 06-29-2007 09:27 AM

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

SciYro 06-29-2007 10:33 AM

look at function pointers for how to use that information.

example:

void somefunc (void (*funcpoint) (void*)) {
void* data = somedata;
funcpoint (somedata);
}

jtshaw 06-29-2007 12:06 PM

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.

captaint 06-29-2007 12:15 PM

@ 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

SciYro 06-30-2007 04:44 AM

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.