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.

DarkBASIC Professional Discussion / Getting the address of local variables/parameters - DLL included

Author
Message
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 16th May 2007 21:30 Edited at: 17th May 2007 07:28
Today I have been experimenting with DBP and the function stack, through use of C++ and inline assembly. I've managed to work out how to access the address of local variables of a function, as well as parameters. I'd imagine this will be very useful to some as it means you can now pass the address of variables into functions, essentially allowing you to return multiple values. Of course, this doesn't work in the global scope, but one thing at a time.

There are two functions: get local variable ptr which gets the address of a specified local variable, and get parameter variable ptr which gets the address of a specified function parameter. Variable numbers start at zero.

One of the uses of this is when you want to return multiple variables from a function. You simply pass the pointers, and in the function you write to these pointers using the * symbol.

Example:



The DLL is attached.

Quote: "Notes
When declaring variables, the following syntax will mess up pointers:

local myVar as integer : myVar = 1
local myVar2 as integer : myVar2 = 2

You must not put any instructions in between declarations as above. If you want to assign values to variables straight away, you can do it like this:

local myVar as integer = 1
local myVar2 as integer = 2
"


Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)

Attachments

Login to view attachments
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 16th May 2007 23:09
Let me see ur dll file. U dont have it.

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 17th May 2007 02:48
@Mnemonix
What are you talking about? Its there on the post. And even in the RAR, I can see it.

@Benjamin
Good job. Is this a finished plugin? Or are you still adding support for more functionality?

Cheers,

-db

Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 17th May 2007 06:48
Quote: "Good job. Is this a finished plugin? Or are you still adding support for more functionality?"

Thanks. I'd say it's more of a WIP, I want to experiment with different things, such as function pointers and the like.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 17th May 2007 07:17
Cool. This has far reaching potential. I'll definitely keep an eye on it


Come see the WIP!

Login to post a reply

Server time is: 2024-05-07 22:10:43
Your offset time is: 2024-05-07 22:10:43