Page 1 of 1
How do I call a function in an external file???
Posted: Fri Jan 30, 2009 4:01 pm
by LordMage
I hope this isn't a stupid easy question, but I am planning to load a ram disk and some custom libraries for HAL, Keyboard, Video...etc. I will have standard interfaces for these "drivers" and I really just want to know how I make use of the functions in the files. before my kernel loads I am going to load the files in a RAMDisk I have functions to read and write to the RAMDisk but I don't know how to make use of the information inside it.
It might be as easy as declareing a function external and prototypeing it somewhere in my code but then how do I redirect the execution to the actual function when I need it?
Thank you for any answers and I will elaborate if need be. just let me know what information is lacking.
Re: How do I call a function in an external file???
Posted: Fri Jan 30, 2009 4:07 pm
by Love4Boobies
Since it's already in RAM, it's just a matter of CALLing your library functions. All you need is their entry points.
EDIT: seems berkus beat me to it

Re: How do I call a function in an external file???
Posted: Fri Jan 30, 2009 4:10 pm
by LordMage
Berkus, is there a tutorial or sample code that explains that plugin abstraction process in detail? That sounds like the ticket, I just need to see how to properly implement it.
Re: How do I call a function in an external file???
Posted: Sat Jan 31, 2009 1:01 pm
by JohnnyTheDon
If you are using ELF files you may want to implement a dlsym() like function that will take a symbol name (as a string) and return it's address. It is slightly more flexible (since it doesn't require a special entry function) but not strictly necessary.
Re: How do I call a function in an external file???
Posted: Tue Feb 03, 2009 10:45 am
by LordMage
okay, sorry for the long wait. I don't have internet right now. I live in Ky where the ice storms hit. I found a bunch of dlsym code examples and looked at that qtplugin that berkus mentioned. I like the idea but this is a linux type implementation isn't it. is there a straighht forward non GPL way of doing this. do I simply load the file and search through the file for the string output by the linker to signify the funciton? I could use a dlsym type implementation that way, I would just need to read up on how the MSVC linker outputs the function names. I have that information somewhere. let me know if I am on the right track. I could use the function pointer method that dlsym and my idt use.
Thanks for the help already recieved and any more given.
Re: How do I call a function in an external file???
Posted: Tue Feb 03, 2009 4:30 pm
by JohnnyTheDon
If you're compiling with MSVC, then its a PE file. The PE specs will show you how to find the exported symbol table.