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 Discussion / dll parameter limit break :)

Author
Message
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 27th Oct 2009 01:59
I have created this dll so that you can call dll functions with more then 9 parameters. it can actually call functions with less then 9 parameters, but that's not what it's for lol.

you can load up to 100 dll's and then you call the dll functions just like you would in dbc. The call dll functions are as follows:

CallDll1
CallDll2
CallDll3

and so on up to 13. i am going to get to 15 or 20 parameters and i think that that should be plenty. of course those numbers cooraspond to how many parameters there are.

after looking at the dba file you might be thinking "How do i pass strings if all the parameters are integers" well i have provided a function in the dll called "GetCharPtr" it takes one parameter. the string you want the pointer to. it couldn't be included as a dbc function because if you did that it would return the functions string. so you will have to use the dbc command call dll to get the pointer. then simply pass the pointer instead of the string(it's the same thing. when you pass a string to a dll, dbc passes the pointer)

i have included a example of creating a window using the functions. there isn't a way to get dbc user defined function pointers so i couldn't create a custom window, but it's just a overlapped text box.

a zip is included with the dll and a dba file with the example and functions.

New Site! Check it out \/

Attachments

Login to view attachments
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 27th Oct 2009 02:37
Very clever! I remember working on something like this a while ago. One approach I tried was using command line switch type of parameters. Each parameter that was sent to the dll would have a prefix of the type:

"i-" for integer
"f-" for float
"s-" for string
"d-" for dword
etc.

So an integer value of 10 might look like "i-10". The parameters would be sent as a single string (string pointer) to the custom dll that would parse out the types and apply them to the real DLL that I would want called. The limit to this is the length of the string - 255 characters - in DBC. But with modification, multiple strings could be used. Also I hadn't addressed posting a literal string that may contain a type identifyer like "s-s-" or "s-f-" . The advantage to this was I only needed a single DBC function.

I never timed it so I don't know if the parsing of the text in the dll was slow down or not. You've got me interested in maybe taking another look at this...

Enjoy your day.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 27th Oct 2009 04:30 Edited at: 27th Oct 2009 04:30
While your idea might have worked, there's a easier way i just used memblocks(if the number parameters is greater then 7, 7 because it adds 2 parameters for dll number and function name) i just put all the values in a dword. and the function takes one DWORD ptr.

I just used LoadLibrary, FreeLibrary, and GetProcAddress functions(they are WinAPI functions) then define function pointer types using typedef like this:

typedef LPVOID (*functionType)(LPVOID);

then because you use LPVOID then it will work with any function. and on the dll's functions it takes integer and converts to LPVOID. that's why to pass a string, you need the GetCharPtr function.

edit:

i just realized. as of speed, your string idea might work better. i will test that out!

New Site! Check it out \/

Login to post a reply

Server time is: 2024-05-09 07:17:03
Your offset time is: 2024-05-09 07:17:03