Archive: Serial Checking Using Own .DLL


Serial Checking Using Own .DLL
Hey all,

We are currenly building an installer which can install one of our own tailor-made products. We would like to do serial checking during installation.
The idea was that we make our own dll, and start this with parameters trough NSIS (by making a custom dialog) the dll gives a response[return?] but is NSIS able to catch up this responses or reactions from an external program/libary?

Is this possible ? Or do you have some other bright ideas ?
Thanks in advance.


2 possibilities:
you will need to build your dll as a nsis-plugin dll, or call it by system-plugin.
example-code for plugin-dlls to interact with nsis stack and variables is delievered in every nsis build, more on that in the documentation, as i'm not familiar with plugin programming :)
maybe lobo lunar, deguix, or the nsis devs may help.

calling your own dll with the system plugin doesn't require you to rewrite it, so have a look at the system plugin readme to see how to use it.
code would look like that:

syntax of your serial-check function, provided by serial.dll:
bool CheckSerial(LPSTR serial);

correct usage of system-plugin:
; --- insert code to get the users input (the serial) here
; --- as you need to use installoptions for a serial-page, no need to init pluginsdir anymore :)
; --- after user input, lets say you stored the serial in $SERIAL (user var defined by 'Var SERIAL')
; --- then extract your dll:
File /oname=$PLUGINSDIR\Serial.dll .\Serial.dll
; --- call it, output will be stored on top of stack
System:Call '$PLUGINSDIR\serial.dll::CheckSerial (t $SERIAL)i .s'
; --- get output
Pop $0
; --- if return is "1" (=true), serial is ok
StrCmp $0 "1" serial_ok serial_wrong
serial_ok:
; --- insert code to execute if serial is ok here
; --- e.g. enable next-button (disable it on prefunction of serial page)
Goto done
serial_wrong:
; --- insert code to execute if serial is wrong here
; --- e.g. messagebox
done:
; --- continue installation


code will be the same if you redesign your dll as nsis-plugin, except of this change:
except of
File /oname=$PLUGINSDIR\Serial.dll .\Serial.dll
System:Call '$PLUGINSDIR\serial.dll::CheckSerial (t $SERIAL)i .s'

u'd use
Serial::CheckSerial $SERIAL

Hi Comm@nder21,

first of all thanks for your reply (Mike and I are building the installer together and I will take the plugin building into my account).

The code certainly clears some blanks for me.

However, the real difference between an NSIS plugin and the system DLL is still a bit unclear to me.

Basically they look the same in your code but I am a bit confused on how to write the DLL (or what differentiates them from eachother). I have already started writing a simple plugin but I think I can get it to work just as you did in your example.

Do you also have any idea on how to extract the input from a custom dialog and put it in a variable to pass to the serial checking function?

Background:

In total, the serial checking function passes these values:

Username, Address, Zip code, City, Expiration date, Licensetype (true license (1) or demo license (0)) and of
course the serial number to check. Later on I also want to add modules to it (eg. the client buys one module, so he cannot use the other modules, just the one he bought).

The code in the DLL then performs some calculations on the input and calculates the serial. Then it compares the serial to the one supplied by the user. Return values should be indeed something like true or false, just like you pointed out in your example.

Thanks again,
Martin


the system dll is a plugin for nsis delievered with any nsis distribution.
it is used to interact between "normal" dlls and nsis.
if you code your own plugin you'll have to use special code to interact with nsis. (variables, stack)
system dll already has this code and interacts with your dll like every other program, but also it can interact with nsis using nsis specific features.
so it is the easiest way.