Archive: Plugin Creation


Plugin Creation
Hello,

I'm trying to create a new nsis plugin to check a serial number and return a true or false value, I have made the DLL as a pluging, copied to the plugin dir, the function is being executed, but the parameters passed are not arriving to the dll.

I'm not using VC++ or even c++, so I guess that I need to access the stack in some other way, but I can't find any info about this.

Thanks


There is an example of how to create NSIS plugins including functions for accessing the stack in the NSIS distribution, see ExDLL folder.

If the language you are using is not found there you should still have a look at the functions there and try to convert them to your programming language.

Vytautas ;)


What language are you working on? Did you try using system plugin for this?


Lobo Lunar, System plugin can do much but we (people from forums) don't know every trick inside it. Its readme has information but not as clear as it should be to be totally understood. I think brainsucker HAS to make a new readme for it. This request has been made since System plugin has been created, however he didn't work on it until now.


I'm using a language called Clarion, is a 4gl language. The main problem is how should I access the stack, somebody at the IRC told me to read about System::Store, that's what I should use? And if that is ok, once I have a result on my dll, where do I store that result? On which stack?

Another question is, I want to use that DLL to validate a Serial Number, If NSIS is using the assembler stack is pretty easy for any programmer to run a debugger on the installer and check for the return value (no matter how complicated is the algorithm for the serial number) and return the correct number, is there any one out there how has solved this in a very secure way?

Thank you all for your answers


As specified in ExDLL.c and ExDLL.h, the fourth and last parameter for the plug-in function, on the stack, is a pointer to the NSIS stack head. The NSIS stack head is a pointer to stack_t structure which is defined in ExDLL.h. Translate that into your programming language and you'll be able to play with the NSIS stack.


Ok, just one question, I can't fully understand the following structure:

typedef struct _stack_t {
struct _stack_t *next;
char text[1]; // this should be the length of string_size
} stack_t;

the char part is ok, but I don't know what is the _stack_t, what is *next?

It is a pointer to something else? It is a pointer to another structure?

Thank you very much


next is a pointer to another stack_t. _stack_t is the name of the structure. See the popstring and pushstring functions for examples of how to use this structure.


I think I have it know, it is a pointer to the same structure to get the following value, right?

thx, I will post my code when I finish to everyone else in case is helpfull to others in the same situation.


thx man, your help and the rest of the people here is tremendous, I thougth that our community (clarion news groups) was the only one with helping people ;)

again, thx


Well, I have the plugin working now, do you want me to post the use of the stack an all the necessary stuff directly here? Or should I put the files on other places?

The generated plugin with all the runtimes linked in is, at least 270Kb, I know, it is big but there is no way to make it smaller

Just le me know what do you want me to do.


Well... is a DLL; you can try UPX :)


very good! it is 112kb now, not so small as the ones made with vc++ but... :)


You can get rid of Debug stuff, and you can include LIBCTINY.LIB in your project (you can search for it on the net).