Archive: Unable to correctly call a dll using system.dll


Unable to correctly call a dll using system.dll
Hello,

During my installation flow, I need to check if a cd-key entered by end-user is valid (cd-key is get by a custom page into an ini file). I do it by using a dll.

The dll prototype is:
prototype cdecl BOOL MiscHelper.IsValid(BYVAL STRING, BYREF STRING);

the C prototype is:
typedef DWORD (__cdelc *IsValid) (const char*, const char*);

So the dll name is "MiscHelp.dll" and the exported function to call is "IsValid"

Here is my NSIS code to call the dll (within the main section)

SetOutPath "$PLUGINSDIR"
File "MiscHelper.dll"
ReadINIStr $0 "$PLUGINSDIR\MPkeysRetrieveTest.ini" "Field 1" "State"
StrCpy $1 "timeshift"
System::call "MiscHelper::IsValid(*t, *t) i(r1, r0).r8 ?e"

$1 is a seed name
$0 stores the key to check (and work)

My issue is that the return ($8) is always "0", whatsoever the key is valid or not. If I choose "b" or "t" for return type, I got no return at all.
Notice I've tested the dll with an Installshield script and it does work... but I really need to use NSIS and not IS.


What happens if you don't use pointers (t instead of *t)?
Also what is the error code that you get? (Pop it to, say, $9)

...
System::call "MiscHelper::IsValid(t r1, t r2)i.r8 ?e"
Pop $9
...

CF

First of all, if it's cdecl, you need to tell System. The default is stdcall. Use ?c.

Next is what CancerFace said. It's not a pointer to a string, it's a string.


Well!

Many thanks for your answers as it solved my issue!

Best regards to both of you!
zepitou