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 / Using DBP Commands In DLL To Retreive Information?

Author
Message
The Lone Programmer
22
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 4th Apr 2006 18:00
Hey,

Say I was making a DLL that needed an objects X, Y, and Z coordinates, but I didn't want to have a function like this:
myFunction(X, Y, Z)

How could I make a DLL that in result would look like this:
myFunction(Object_Number)


What I mean is how do I find the coordinates by just passing my object number in as the parameter? I don't need to alter the object or return any DBP information. I just want to call the coordinates without actually passing them.

If anyone knows how, please let me know. I am using Delphi, but if you made it simple enough I could probably translate C++ or another language.

Thanks,
The Lone Programmer

"Is The Juice Worth The Squeeze"
-The Girl Next Door
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 4th Apr 2006 22:22 Edited at: 5th Apr 2006 23:33
You need a GlubStruct translation for Delphi (mine is somewhere around these boards, but I'll post an updated version next week). This record will contain handles to the instances of the DLLs that DBpro uses- in this case we need the handle of DBproBasic3Debug (g_pGlob.g_Basic3D). To find out the address of the function we also need its name. If in doubt consult the string table of the DLL and look at what function name the command in question points at. For example to get the x position:

So the function name is ?GetXPositionEx@@YAKH@Z

Now we can get the function address with the WinAPI function GetProcAddress.

That Delphi function would return the object's XPos.

The Lone Programmer
22
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 5th Apr 2006 18:29
How might I find the string table of a compiled DLL?

I know when I make DLLs I have to create a string table, but when I place them in the DBPro folder I only need the compiled DLL.

How do I extract a string table from a compiled DLL? If I have the wrong idea, what should I be doing in order to find the string table for DBPro commands?

You said your going to post the updated GlobStruct. Is this the updated header for Delphi or just C++? I thought you told me you weren't going to update the Delphi one? Change of mind?

I appreciate the help.


Thanks,
The Lone Programmer

"Is The Juice Worth The Squeeze"
-The Girl Next Door
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 5th Apr 2006 23:31
Quote: "How do I extract a string table from a compiled DLL?"

You can view the resources (including string tables) of executables and dlls with a tool like "Reshack" (google).


Quote: "Is this the updated header for Delphi or just C++? I thought you told me you weren't going to update the Delphi one? Change of mind?"

For Delphi. I needed to modify/correct/extend it for my upcoming plugin.

Sergey K
21
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 6th Apr 2006 16:44
use ResHack application for that

and why you not askign me dude? you know that i know how to do that, and you always talking with me on msn. so why wont u just ask me.. lol

MyNewSite:http://gogetax.com
Forums(About BLO and more):http://gogetax.com/forum
The Lone Programmer
22
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 6th Apr 2006 18:29 Edited at: 6th Apr 2006 18:37
How did we know that DBproBasic3Debug = (g_pGlob.g_Basic3D)?
The rest seems very self explanitory easy, but I am just a little confused how we decided what the DLL equaled.

Lol I would, but at the time when I have the question you are never on. Besides Empty is the programming master

I think that covers it, but I will return to this post if I have more problems.


Thanks,
The Lone Programmer

"Is The Juice Worth The Squeeze"
-The Girl Next Door
The Lone Programmer
22
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 6th Apr 2006 19:46
Ya I think I found where you got those values, but new problem.

I pasted this code into my code:


And I get an error right here:
GetObjectXPos := GetProcAddress(g_pGlob.g_Basic3D, '?GetXPositionEx@@YAKH@Z');

Its saying g_pGlob is undefined. Did I miss a step? I added the Globstruct properly cause I use it all the time, and I added the Windows use to the list.

What step did I do wrong?


Thanks,
The Lone Programmer

"Is The Juice Worth The Squeeze"
-The Girl Next Door
Sergey K
21
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 6th Apr 2006 20:16 Edited at: 6th Apr 2006 20:22
try that way:


i havent tryed to use dbp command that also got result (like result of object position) but it should work

MyNewSite:http://gogetax.com
Forums(About BLO and more):http://gogetax.com/forum
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 7th Apr 2006 13:25
Quote: "Its saying g_pGlob is undefined. Did I miss a step? I added the Globstruct properly cause I use it all the time, and I added the Windows use to the list.

What step did I do wrong?"


You need to declare a global variable
var g_pGlob: PGlobStruct;

and assign the structure to it in your ReceiveCorePtr procedure (see my tutorial for details).

GogetaX's way will work too but is slower.

As for returning floats from DBP Dll function usually you'll get away with the method GogetaX and me showed, however to be absolutely sure you'd have to do something like this:



This is because DBpro expects single precision floating point results in the EAX register rather than on the FPU stack.

keithml
19
Years of Service
User Offline
Joined: 25th Jul 2005
Location: Florida
Posted: 17th Apr 2006 23:41
Hi. I too use Delphi for plugins. I would love to be able to call the DarkBasic functions from a plugin, so far I have only attempted providing independent functions in plugins. I see that a lot of advice is given below, could somebody put up a quick (but complete) delphi project with say the new globstruct (delphi-ized) and a simple example of calling a function or two from inside Delphi. I think this would really help!

Thanks,
Keith

Login to post a reply

Server time is: 2025-05-19 08:20:09
Your offset time is: 2025-05-19 08:20:09