![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Apache on Solaris10 configured with loadable module support? | kavera | SUN Solaris | 2 | 10-17-2007 11:15 PM |
| Script doesn't work, but commands inside work | cheongww | UNIX for Dummies Questions & Answers | 2 | 11-14-2006 06:52 PM |
| Custom pam module | mhm4 | SUN Solaris | 1 | 10-02-2006 03:33 PM |
| LWP module ? | Beto | UNIX for Dummies Questions & Answers | 4 | 07-12-2001 05:17 AM |
| PHP Module | ComTec | UNIX for Dummies Questions & Answers | 10 | 02-13-2001 11:41 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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! |
| Forum Sponsor | ||
|
|
|
|||
|
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...
|
|
|||
|
Quote:
|
|
|||
|
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. |
|||
| Google UNIX.COM |