Module Support! How does it work?


 
Thread Tools Search this Thread
Top Forums Programming Module Support! How does it work?
# 1  
Old 05-30-2006
Module Support! How does it work?

ey everyone,

I have been working on an application for a while, and would like others to
be able to add modules for it. The problem is, I don't know how to implement
them.

I am using the dlopen() library set. I understand how to load modules into t
he program and how to execute the code. The problem is, I want these modules
to be able to modify ANY part of the program. For example, if there are 100
functions in my application, I want the program to be able to modify any si
ngle one of those functions to do something different. Is there a way to do
this, without having to make every single function in my code a function poi
nter?

Btw, im writing this on Unix :-)

Thanks a lot!
# 2  
Old 05-30-2006
u can do it by making object file separately for each function and bind them with main program.

say :

make a foo.so for function foo()

while building your application use foo.so
# 3  
Old 05-31-2006
I am not sure that i understand what you are talking about.
Your ptogram contains an array of functionpointers and you want to change it on run time ?

can you give an example why on earth someone would do it ?
# 4  
Old 06-03-2006
I don't think you can do that with dlopen. You'll have to do this hardcore -- libelf to parse the so files, and mmap to map executable pages into memory from it. If you figure it out let me know, since that's one secret I haven't yet managed to penetrate, libelf has got to be among the most important and least documented libraries on earth...
# 5  
Old 06-03-2006
Quote:
Originally Posted by grumpf
Your program contains an array of functionpointers and you want to change it on run time ?

can you give an example why on earth someone would do it ?
Plugins work this way. That way, things like codecs don't have to be hardcoded -- or even linked -- into the program, they can be loaded on command. it's usually blocks of functions that get loaded though.
# 6  
Old 06-05-2006
First you'd have to define an interface to which the module writers would conform. My guess is that "modify every function in my program" does not really explain what and how to modify it. You are at the incorrect level of abstraction to make this work if you're going to have everything be function pointers.

Basically, you first want to define a concrete set of functionality that module writers should be able to hook into. Then you have to specify an interface agreement that the module writers can conform to.

One of the first things I think you may want to define is a procedure to initialize the module. Part of this could be that the module passes you back a set of function pointers (into itself) that you can call. You define the datastructure that gets passed and the module conforms and uses it to tell you want it wants to overload or hook into and passes you the callback or overload routine it wants you to call.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. IP Networking

Discussion at work, would a router work pluging a cable in wan1 and lan1?

hi all. and sorry for the random question, but this sparkled a raging flame-war at work and i want more points of view situation a router, with linux of some sort, dhcp client requesting for ip in wan1 (as usual with wan ports) dhcp server listening in lan1, and assigning ip (as usual... (9 Replies)
Discussion started by: broli
9 Replies

2. Red Hat

Does the pam_pwdfile module support clear text passwords?

I need to utilize pam_pwdfile in order to authenticate virtual users in vsftpd. I know I can utilize htpasswd2 -m to create a password file however it is vital since I am administrating several machines in our organization that the password generated be in clear text. Does anyone on here know if... (10 Replies)
Discussion started by: colbyshores
10 Replies

3. Shell Programming and Scripting

My script work on Linux but not work in sunos.

My script work on Linux but not work in sun os. my script. logFiles="sentLog1.log sentLog2.log" intial_time="0 0" logLocation="/usr/local/tomcat/logs/" sleepTime=600 failMessage=":: $(tput bold)Log not update$(tput rmso) = " successMessage="OK" arr=($logFiles)... (7 Replies)
Discussion started by: ooilinlove
7 Replies

4. Red Hat

PAM module pam_passwdqc module

Hello friends Today i have changed my passwd policy for strong password Everything is working correctly but when i changed my password , it did not ask me my old password my /etc/pam.d/system-auth file is (only passwdqc.so module line) password required pam_passwdqc.so retry=3... (0 Replies)
Discussion started by: rink
0 Replies

5. Shell Programming and Scripting

Perl variables inside Net::Telnet::Cisco Module doesn't work

I am writing perl script to configure Cisco device but Variables inside Net::Telnet::Cisco Module doesn't work and passed to device without resolving. Please advise. here is a sample of script: use Net::Telnet::Cisco; $device = "10.14.199.1"; ($o1, $o2, $o3, $o4) = split(/\./,$device);... (5 Replies)
Discussion started by: ahmed_zaher
5 Replies

6. Solaris

Config reader module in Sun MC Agent not work in E2900

Hi men, Have you ever meet this error ? I install full Sun MC 4.0 packages (+ Add ons) exception of Sun Midrange Platform Administration because i don't know how to configure it Then all other servers are ok, only E2900 servers have Config reader module error: Data Acquisition error I... (12 Replies)
Discussion started by: tien86
12 Replies

7. Linux

How to convert Linux Kernel built-in module into a loadable module

Hi all, I am working on USB data monitoring on Fedora Core 9. Kernel 2.6.25 has a built-in module (the one that isn't loadable, but compiles and links statically with the kernel during compilation) to snoop USB data. It is in <kernel_source_code>/drivers/usb/mon/. I need to know if I can... (0 Replies)
Discussion started by: anitemp
0 Replies

8. Solaris

Apache on Solaris10 configured with loadable module support?

I have Apache 2 webserver as delivered with the Solaris 10 installation. How to verify if Apache is configured with loadable module support? Or if needs to be recompiled with loadable module support. (2 Replies)
Discussion started by: kavera
2 Replies

9. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script RemoveFiles.sh Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies
Login or Register to Ask a Question