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.

Code Snippets / [DBP-Matrix1utils]:returning dll string functions using CALL DLL e.g. Matrix1Util_16.dll (strings library)

Author
Message
Bored of the Rings
User Banned
Posted: 31st Jan 2019 10:05 Edited at: 9th Feb 2019 19:03
So this wee code snippet example uses the strings dll library (Ian M's matrix1 utils plugin) and gets an input string i.e. "test" and converts it to upper case using the plugin function "FastUpper". You can use Dependency Walker program to get the function names (undecorated). Have a play around with the code and try other functions. The main thing is for string returns , memory needs to be allocated (for some scenarios) and has to return a DWORD pointer to the string. I used Resource Hacker to look up the resource strings table for each command.



[recently added]

As in a previous post, here is how to return a string that uses the weird CreateDeleteString function used in the DBPRO globstruct.h.
Here, I've just added a dummy function with the ReverseString function. Which kind of defeats the object, but works as a quick workaround without having to do the whole pointer to globstruct stuff.
[recently added: meant to add that you can use any command from the dll to use in the dummy function and the dll needs to reside in the compiler plugin folder e,g, the user folder]



Here's the whole of Matruxutils 14 functions being called (dummy function not required here):

Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 11th Feb 2019 14:37
Currently making updates to some C code to remove the need for the dummy function so DBPro doesn't crash.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 13th Feb 2019 19:14 Edited at: 14th Feb 2019 06:24
DBPro program now updated as below, post C code update:
so what I did is remove (temporarily) all plugin-user dll's except IanM's Matrix1 #20 dll (to prevent any dll clashes e.g. functions with the same name). I then updated his Matrix1Utility C code to include the "Reverse String" function code but using Ian's Create, Delete and Emtpy string functions. Updated the .rc file using the decorated function name and then copied the compiled DLL to the plugin-user folder. Ran the code below which now no longer uses the dummy function and reverses the string without crashing. I'll update posts if I remember anything else. You must make sure that the "?ReceiveCoreDataPtr@@YAXPAX@Z" related lines are included or you get a crash. In addition, I no longer have any user dlls in the program app root folder just in the plugin-user folder. I'll be making further tests just to rule out anything I may have overlooked, but all seems to work well.




C code added to Matrix1Utility program found here:
http://www.matrix1.demon.co.uk/

Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 14th Feb 2019 06:34
if you want to obtain the Globstruct pointer, just add following code to your dll:

EXPORT DWORD GetGlobPtr(void)
{
return (DWORD)&Core;
}

and then add a string table to the resource file (.rc), for example:

IDS_STRING216 "GETGLOBPTR[%D%?GetGlobPtr@@YAKXZ"
copy the updated dll into the plugin-user folder again...

...and then in your db code just as a tester add:

globptr as dword
globptr = getglobptr()
print globptr
print *globptr

globptrstart=*globptr
print peek string(globptrstart+313)

all being well you should see a text string showing your appdata temp folder.


Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Login to post a reply

Server time is: 2024-11-21 15:51:38
Your offset time is: 2024-11-21 15:51:38