- NSIS Discussion
- Problem with System::Call
Archive: Problem with System::Call
smoura
27th October 2006 14:36 UTC
Problem with System::Call
Hi all...
I'm having a problem with System::Call that in some machines works ok but in other computer's it fails the call returning 'error'. Is there some kind of requisite for using this function?
The code looks like this:
Function wndSerial_ValidateCustom
; Serial number reading
ReadINIStr $R1 "$PLUGINSDIR\wndSerial.ini" "Field 2" "State"
ReadINIStr $R2 "$PLUGINSDIR\wndSerial.ini" "Field 3" "State"
ReadINIStr $R3 "$PLUGINSDIR\wndSerial.ini" "Field 4" "State"
ReadINIStr $R4 "$PLUGINSDIR\wndSerial.ini" "Field 5" "State"
; Call the function to validate the serial number
SetPluginUnload alwaysoff
System::Call "$PLUGINSDIR\ValidateSN::ValidateSN(t r11, t r12,t r13,t r14)i .r1"
MessageBox MB_OK "$1"
IntCmp $1 1 serial_ok serial_wrong
serial_wrong:
System::Free $1
MessageBox MB_OK|MB_ICONEXCLAMATION $(WNDSERIAL_INVALIDSN)
Abort
serial_ok:
; Continue installation
System::Free $1
SetPluginUnload manual
FunctionEnd
Now I've tested this on a cleaned machine installed with the first version of Windows XP and though I set a correct serial number there is no validation (the value in $1 is always 'error'), then I gradually updated it, when finally installed Service Pack 2 the serial validation occured correctly.
Does the System::Call function need the Service Pack 2 installation (does it use some funcion that was only available through the SP2)? or am I missing something in my code.
If there's the need to install SP2 could there be another way of calling an external DLL function?
Thanks for your time, best regards,
Samuel Moura
kichik
27th October 2006 14:39 UTC
System::Call doesn't need SP2, but your validation DLL might. Check out its dependencies using Dependency Walker. Ideally, you should compile your DLL with static linking, so it won't depend on anything like msvcr71.dll or any other DLLs.
smoura
27th October 2006 14:45 UTC
Originally posted by kichik
System::Call doesn't need SP2, but your validation DLL might. Check out its dependencies using Dependency Walker. Ideally, you should compile your DLL with static linking, so it won't depend on anything like msvcr71.dll or any other DLLs.
Thanks for the fast reply! Dumb meee... but of course this is the problem!
Thanks very much! :o
smoura
27th October 2006 16:27 UTC
Hum... I've been cleaning my dll though I cant seem to put it to work in a computer without SP2! :confused:
I've used the Dependency walker to check the dependencies and my dll only depends on Kernel32 + NTdll (consequently).
The only functions I use beside the standard string functions are malloc, free and memset wich were already available before SP2.
Any help would be kindly appreciated!
kichik
27th October 2006 16:29 UTC
Are malloc, free and memset statically linked or dynamically linked to msvcr71.dll?
smoura
27th October 2006 16:34 UTC
Originally posted by kichik
Are malloc, free and memset statically linked or dynamically linked to msvcr71.dll?
How can I check this?
kichik
27th October 2006 16:41 UTC
Well, if you said you only see kernel32.dll in Dependency Walker, it's probably statically linked or else you'd have seen msvcr71.dll. Can you attach the DLL?
smoura
27th October 2006 16:46 UTC
Originally posted by kichik
Well, if you said you only see kernel32.dll in Dependency Walker, it's probably statically linked or else you'd have seen msvcr71.dll. Can you attach the DLL?
Sure here it goes. I just use the include directive on c++, I supose that it gets static linked through the corresponding .lib file.
kichik
27th October 2006 16:57 UTC
I can't see any used import that shouldn't exist on all versions of Windows XP. However, there are many imports that aren't available in Windows 9x. Namely, all of the Unicode enabled functions like LCMapStringW and GetEnvironmentStringsW.
Back to the point, run depends.exe on the file on Windows XP SP 0. It should paint imports it can't find in red.
Also, which System.dll are you using? You didn't recompile NSIS, right?
smoura
27th October 2006 17:01 UTC
Originally posted by kichik
I can't see any used import that shouldn't exist on all versions of Windows XP. However, there are many imports that aren't available in Windows 9x. Namely, all of the Unicode enabled functions like LCMapStringW and GetEnvironmentStringsW.
Back to the point, run depends.exe on the file on Windows XP SP 0. It should paint imports it can't find in red.
Also, which System.dll are you using? You didn't recompile NSIS, right?
I'm going to try the depends.exe on the other PC.
I'm using the one that comes with NSIS 2.21, installed it today, and no recompilation :D!
smoura
27th October 2006 17:06 UTC
:P meanwhile solved the problem
it seems that in systems prior to SP2 there's a need to specify the output directory to the plugins directory before using the plugin!
SetOutPath "$PLUGINSDIR"
System::Call "ValidateSN.dll::ValidateSN(t r11, t r12,t r13,t r14)i .r1"
Added the first line of this snippet and changed the second one! It now works!
Thanks very much for your time! ;)