Old 27th October 2006, 13:36   #1
smoura
Junior Member
 
Join Date: May 2006
Posts: 17
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:

code:

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
smoura is offline   Reply With Quote
Old 27th October 2006, 13:39   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 27th October 2006, 13:45   #3
smoura
Junior Member
 
Join Date: May 2006
Posts: 17
Quote:
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!
smoura is offline   Reply With Quote
Old 27th October 2006, 15:27   #4
smoura
Junior Member
 
Join Date: May 2006
Posts: 17
Hum... I've been cleaning my dll though I cant seem to put it to work in a computer without SP2!

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!
smoura is offline   Reply With Quote
Old 27th October 2006, 15:29   #5
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Are malloc, free and memset statically linked or dynamically linked to msvcr71.dll?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 27th October 2006, 15:34   #6
smoura
Junior Member
 
Join Date: May 2006
Posts: 17
Quote:
Originally posted by kichik
Are malloc, free and memset statically linked or dynamically linked to msvcr71.dll?
How can I check this?
smoura is offline   Reply With Quote
Old 27th October 2006, 15:41   #7
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 27th October 2006, 15:46   #8
smoura
Junior Member
 
Join Date: May 2006
Posts: 17
Quote:
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.
Attached Files
File Type: zip validatesn.zip (17.8 KB, 131 views)
smoura is offline   Reply With Quote
Old 27th October 2006, 15:57   #9
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 27th October 2006, 16:01   #10
smoura
Junior Member
 
Join Date: May 2006
Posts: 17
Quote:
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 !
smoura is offline   Reply With Quote
Old 27th October 2006, 16:06   #11
smoura
Junior Member
 
Join Date: May 2006
Posts: 17
: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!

code:

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!
smoura is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump