Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / how to get function/sub addresses

Author
Message
Three Score
19
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 25th Feb 2007 16:04 Edited at: 25th Feb 2007 16:06
I was just now thinking...and I finally figured out how that one guy's scripting engine did it!
You can get the function or subroutine address by using the stack...
the layout of the stack in your dll function will be as so
(starting at the most recent value)
1: function address of the plugin function
2: arguments of plugin function
3: address of callling function(from dbp)
4: arguments of dbp function


This could be very useful in anywhere from making an interpretor, to making callbacks...

I may try to make an example a bit later, but for now wanted to get that brilliant idea out..

edit:
this is assuming that dbp follows the C++ calling method, if it doesn't then I'm not sure it's possible..

Open86 --My Emulator (now with it's first super alpha release
I'm addicted to placebo's...I would quit but it wouldn't mean anything! lol
Torrey
19
Years of Service
User Offline
Joined: 20th Aug 2004
Location: New Jersey
Posted: 25th Feb 2007 18:34
Pretty darn close, I'd suggest you walk through with a debugger sometime to see how the stack looks when it enters a dll function. Your list is wrong (but getting closer). Also if you manage to grab the returning address you'll mess up the stack later (causing a process crash) on if you try to use it because you have to know where to start.

Milkman
18
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 26th Feb 2007 21:04 Edited at: 26th Feb 2007 21:06
This is exactly what i need in order to implement polymorphism into oodbp. I searched the forums yesterday and found a few threads relating to this. It looks like IanM and empty did this years ago in a plugin, but IanM never released his dll, and empty's link in his wip thread no longer works. If you could get this working, or someone else could get a hold of empty's or IanM's dll, that would be excellent.

http://forum.thegamecreators.com/?m=forum_view&t=38083&b=8
http://forum.thegamecreators.com/?m=forum_view&t=37828&b=1

Who needs a signature?

Login to post a reply

Server time is: 2024-06-16 05:02:25
Your offset time is: 2024-06-16 05:02:25