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.

Work in Progress / Callbacks in Styx v1.10

Author
Message
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 11th Jan 2007 22:35
With the STYX plug-in (version 1.10- to be released soon), you can create Callback functions in DBPro.

What are Callback functions? As the name suggests, these are functions that are called by other functions. However, the calling functions are not part of your program but live in external DLLs. This can be quite useful for a plugin system, for example. Also some of the WinAPI functions require a callback function.

This snippet shows the WinAPI function named "EnumWindows", which calls the DBPro function "EnumWindowsProc" once for each window that is currently active.




Torrey
20
Years of Service
User Offline
Joined: 20th Aug 2004
Location: New Jersey
Posted: 12th Jan 2007 03:08 Edited at: 12th Jan 2007 03:09
Empty, sometimes I feel we might be clones of one another. I worked on custom callbacks for v1.1 of my scripting plugin's print command, and also the error handler. While taking a look at the dbpro source code you used I noticed the use of "CALLBACK ARG(1)" which basically grabs the pushed value off the stack. Couldn't you have wrote the function this way:



There are really two values that are pushed on the stack for this callback, but really you need only one for the example. Also, since you are returning a value of 1 placing it after endfunction should put the return in the EAX register like it should be. That's what it always did in my tests.

Either way I love the work you've been doing!

empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 12th Jan 2007 03:30 Edited at: 12th Jan 2007 03:39
Actually in the case of callbacks in Styx, the pointer doesn't point to the actual routine but to an internal function that makes sure that the stack is cleaned-up after the call (since all WinAPI callbacks need to follow the stdcall convention).
For consistency reasons and to make the whole thing less error-prone this also applies to Styx' "Referenced Functions". While this is a bit cumbersome inside the function, it has the advantage that it allows to call referenced functions with variable numbers of parameters. Example:



Quote: "
Either way I love the work you've been doing!"

Thank you!

Login to post a reply

Server time is: 2024-09-29 18:29:40
Your offset time is: 2024-09-29 18:29:40