tigereye
8th November 2007 20:10 UTC
Help with System::call
Trying to figure out system::call to get to an external .dll that I've written.
The DLL's function declaration is pretty simple. It takes a string to search for, and returns a boolean whether it's installed:
__declspec(dllexport) int __cdecl CheckProductInstalled(LPTSTR)
I've tried various versions of the system::call string, but I think this is correct, based on what I can get from the readme.
System::Call 'EnumProductsDLL.dll::CheckProductInstalled(t r0) i.r2?e'
Where $0 contains the string to search for.
However, I keep getting 'error' back in $2. If I pop the stack to get the lastdllerror I always get 0.
I don't think I'm actually getting to the .dll because there is some debug logic in the .dll that doesn't appear to be happening.
Anything obvious where I might have messed up?
Thanks,
Mike
Afrow UK
8th November 2007 20:52 UTC
You are using cdecl. The default is stdcall. Use ?c.
Stu
kichik
8th November 2007 23:05 UTC
Seems to me like System can't find the DLL. Have you extracted it somewhere it can be found?
tigereye
9th November 2007 19:46 UTC
Thanks for the help.
Afrow,
I tried with both ?c and removing the cdecl from the declaration, same results.
Kickik
I am extracting the file immediately before this call. The logic from my test program is below:
INSTDIR is set to C:\temp
SetOutPath $INSTDIR
file "enumproductsdll.dll"
strcpy $0 'Symantec Antivirus'
System::Call 'EnumProductsDLL.dll::CheckProductInstalled(t r0) i.r2?e'
messagebox mb_ok $2
pop $5
messagebox mb_ok $5
Thanks,
Mike
kichik
9th November 2007 19:50 UTC
Are you sure all of its dependencies can also be loaded? Open it from that directory with Dependency Walker to make sure.
tigereye
9th November 2007 20:32 UTC
Originally posted by kichik
Are you sure all of its dependencies can also be loaded? Open it from that directory with Dependency Walker to make sure.
Hmmm... well, that was at least part of the problem (hadn't statically linked it to msvcrt8). However, after doing that, am still having issues.
kichik
9th November 2007 20:41 UTC
Well, that's about it. Either the DLL can not be found due to a typo or wrong search path or it can't be loaded due to missing dependencies. Unless you're trying to load x86 DLL on x64, which is quite impossible considering NSIS doesn't build on x64, it's those two.