BASIC Developer & Support Resources > Interpreters

dynamically calling DLLs

<< < (2/8) > >>

Steve A.:
Hey Rick,


--- Quote from: rdc on October 07, 2010, 11:02:13 am ---Google LoadLibrary and GetProcAddress.

--- End quote ---

That's covered. I already use them.
The problem is an algorithm to plug the call parameters into the correct places for any given function being called.
Example:
let's say I call MyFunc in MyDLL.DLL,
now MyFunc needs one param:

  <call> "MyDLL.DLL", "MyFunc", (int)
-or-
  <call> "MyDLL.DLL", "MyFunc", (char)

It would be a bit tedious, but, I could build a template to handle this.
Now I want two (2) params:

  <call> "MyDLL.DLL", "MyFunc", (int, char)
-or-
  <call> "MyDLL.DLL", "MyFunc", (char, int)

2 params with (only) 2 types of vars equals 4 templates,
3 params with (only) 2 types of vars equals 8 templates,
............<snip>
by the time you get to 10 params you need 1024 templates.
And, there are possibly 5 to 10 different data types.

That's what I'm talking about.

Steve A.:

--- Quote from: Aurel on October 07, 2010, 12:24:23 pm ---Oups i totaly miss the point.

--- End quote ---

No problem.
It's not an easy problem for me to explain.
Else where, where I've posted, some people told me I was stupid for even wanting to do that.
And, explained in great detail why it was too much of a security risk and a ton of other reasons.
The DLLs and API are there, on every system.
Why not make them available to the user, I say ?

JRS:

--- Quote from: Steve A. ---Okay, what you are saying is, SB can take a previously undefined DLL and Function there-in and execute it, passing random parameters?
And, the source code for doing that is available ?

--- End quote ---

The DYC SB extension module source is available to use in any way you see fit. The dynacall code is the meat of the interface and should be simple to implement in BxBasic.

Here is an example of using the SB DYC extension module to call the Oxygen Basic JIT compiler.

rdc:

--- Quote from: Steve A. on October 07, 2010, 12:07:54 pm ---Hey Rick,


--- Quote from: rdc on October 07, 2010, 11:02:13 am ---Google LoadLibrary and GetProcAddress.

--- End quote ---

That's covered. I already use them.
The problem is an algorithm to plug the call parameters into the correct places for any given function being called.
--- End quote ---

You don't need to create templates. All you need to do is to have a declare statement that the user will write for the dll in question including its parameters. You would then parse the declare statement and treat it like a function call except that you would be calling the dll rather than an internal function. It would be up to the user to correctly Declare the DLL. If they don't it would simple generate a runtime error.

rdc:
Of course you can always just expose the LoadLibrary, et. all. functions in your interpreter and let the user handle the calling in their program. The only thing you need to supply would be the appropriate sized data types. For example, a null terminated string data type would be needed since many string functions use C-strings.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version