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 / Passing DBP function (pointers) to a dll ??

Author
Message
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 11th Mar 2006 18:03 Edited at: 11th Mar 2006 18:04
Hi,

I wondered if it is possible to pass the address of DBPro functions to a dll?
How is this done? I have seen alot of "spareFunctions" in the globstruct header, but I am not sure whether this has somethin to do with it...

anyone knows that one?? thx!!


edit: I want to call DBP functions from the dll...

greets,
Barnski.
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 11th Mar 2006 18:08
There's no way to get the pointer to DBP functions safely; atleast not in my experience.

Perhaps if they added an Address symbol (which is wanted anyway).. that said Arrays and Typed data is Read Only; so god knows how well functions would work.

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 11th Mar 2006 18:52 Edited at: 11th Mar 2006 18:53
wellthen...

I could think of doing something like the following:

function foo()
register function "foo"
`foo function code
endfunction

where register function is a command of the dll, which uses assembly to find out its return address, which you could then use as function pointer and register it with the passed name...

but; I don't know right away how to include asm in a c++ source code,

and, it would need some dbp function layout analysis...


anyone's up for the task?

greets,
Barnski.
Torrey
20
Years of Service
User Offline
Joined: 20th Aug 2004
Location: New Jersey
Posted: 11th Mar 2006 18:54 Edited at: 11th Mar 2006 18:59
I'm assuming you're talking using dbpro functions from their DLLs, in that case you'll want to use LoadLibrary and GetProcAddress so that you'll have the functions address.

If you're talking about using dbpro user functions you'll need to know assembler. This feature is used with my scripting plugin, but it's closed source (link in sig).

[edit]

Quote: "where register function is a command of the dll, which uses assembly to find out its return address, which you could then use as function pointer and register it with the passed name..."


If you registered the dbpro function the way you did above the return address is the instruction right after your dll call. Future calls to that address will screw up the stack, and the program will crash when the RET instruction is executed. User functions in dbpro create a proc when compiled.

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 11th Mar 2006 18:56 Edited at: 11th Mar 2006 19:02
I know assembler... just never used it in conjunction with VS and C++

EDIT:
Quote: "If you registered the dbpro function the way you did above the return address is the instruction right after your dll call. Future calls to that address will screw up the stack, and the program will crash when the RET instruction is executed. User functions in dbpro create a proc when compiled."


There are two ways to avoid this: the first, I already mentioned: analyse the DBPro function layout to know how many bytes youhave to subtract from the return adress to get to the start of the function.

the other is to manually set up the stack fram of the function before jumping

greets,
Barnski.
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 11th Mar 2006 19:07
I (kind of) successfully used a similar "register" approach, where you had to call the function once to register it and get the pointer (and exit from it immediately after that). Like I said, it works quite well. Another approach is to get that information from the _virtual.dat file. Apperantly there's also a way to get the addresses of variables from there.

Torrey
20
Years of Service
User Offline
Joined: 20th Aug 2004
Location: New Jersey
Posted: 11th Mar 2006 19:11
Finally someone on this forum that knows what they're talking about.

You'll probably want to use Ollydbg to crack at the function code so that you can step through the instructions after your DLL call, and see what the stack looks like at that point for the return address location. Changes in your plugin and dbpro can affect the stack, so you may want to set up SEH to handle any memory exceptions that can occur during your dbpro user function call.

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 11th Mar 2006 19:32
Thanks for sharing your knowledge

Most of this stuff is new for me, since I only wrote assembly under linux, so I will have quite a bit to chew off now!

Anyways, when I release my new plugin in the next days, I will include a link to your DarkScript

greets,
Barnski.

Login to post a reply

Server time is: 2024-11-21 23:57:58
Your offset time is: 2024-11-21 23:57:58