LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-29-2007, 09:27 AM   #1
captaint
LQ Newbie
 
Registered: Jun 2007
Posts: 2

Rep: Reputation: 0
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
 
Old 06-29-2007, 10:33 AM   #2
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
look at function pointers for how to use that information.

example:

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

Last edited by SciYro; 06-29-2007 at 10:35 AM.
 
Old 06-29-2007, 12:06 PM   #3
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
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.
 
Old 06-29-2007, 12:15 PM   #4
captaint
LQ Newbie
 
Registered: Jun 2007
Posts: 2

Original Poster
Rep: Reputation: 0
@ 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
 
Old 06-30-2007, 04:44 AM   #5
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
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/
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
warning undefined functions.....doing kernel module programing swift_a2002 Programming 10 05-24-2007 11:50 AM
linking freeradius functions to an external auth module kky Programming 0 09-26-2006 09:16 AM
Not Finding pcibios_* functions in RHEL4 (2.6.9)..module compilation problem kumarnine Programming 1 04-13-2006 08:23 AM
time functions in a c program mbacke Programming 3 04-18-2005 02:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration