Archive: Looking for a smaller way for this...


Looking for a smaller way for this...
Is there a smaller way to create a NSIS plugin?
Ok. Since I'm learning C++ with Dev-C++, I'd like to try to
make some of them.
Thanks :)


What do you mean? Please give more details.


Try searching for ways to avoid inclusion of MSVCRT from MinGW's compiled DLL. I have searched Google a bit but couldn't find anything useful on the first result page ;)


Hey, a quick way to get started is to import the exdll project and modify it. Just make sure to change the project type to win32dll before compiling. Dev-cpp doesn't import the fact that its a dll.


not using the standard c functions helps as well - like with most of the example dlls by including your own atoi functions, etc and that (usually saves around 30k from what i remember).

other options are eliminating duplicate strings (not sure how/if Dev-C++ has that option - know how to with vc++ 6 and borland c++ 5)

if you were using vc++ 6 i would also say to try this which kicks in certain optimisations to help cut compiled sizes down (if the code and all that allows for it ;))

-daz


Here is an example project. Simply extra and drop into the NSIS Contrib folder (so it can find the ExDll.h). I hope this helps.

Don


Thanks to everyone :).
@KichiK: According to Dev-C++'s site, the MSVCRT dependecy come with Windows 95 or higher... since NSIS run only in Win95 and up, I'll be don't problem, right?


Well, in VC-land, I use ATL/WTL.

ATL (Active Template Library) was created to build *small* DLL/COM objects which could be downloaded on the net (even using dialup)... it has wizard project support under VC, and once you have created the empty DLL, you just don't add any COM interfaces/objects. :)

WTL (Windows Template Library) is more of an [unofficial] statement of what MFC could (should?) have been... template-based class wrappers around many of the Windows controls and objects actually handle a great deal of what most people use MFC for - without the incredible bloat!

With care, either or both may be used to construct *small* (4k-8k) libraries/executables without runtime library (or exception handling) support.

The downside (for some) is probably that these are Microsoft-based tools... ATL comes with VC, while WTL is available as a free download (with very little documentation).


ok, with the fuction that come with the above zip:


void __declspec(dllexport) myFunction(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
{
EXDLL_INIT();
{
char buf[1024];
popstring(buf);
MessageBox(hwndParent,buf,0,MB_OK);
}
}

How can I input or output values?

With popstring and pushstring. They work on the NSIS stack which is controlled by Push, Pop and Exch in the script.


Thanks I'll give it a try :)


Ok. I almost got it. I have this:


char buf[1024];
char buf2[1024];
popstring(buf);
popstring(buf2);
MessageBox(hwndParent,buf,0,MB_OK);
MessageBox(hwndParent,buf2,0,MB_OK);

Works great. It display the Two MessageBoxes with MB_YESNO and the MB_ICONINFORMATION.
These are my questions:
1. How can I input numeric (int or double) values, since the popstring is char?
2. How can I output values? Since Button "Yes" is 6 and Button "No" is 7.
Thanks. :)

Here is an example:


static buf[1024];
int num;
popstring(buf); //get number string
num = my_atoi(buf); //convert to number
wsprintf(buf,"%d",num); //convert number back to string
pushstring; //output number string


The my_atoi function is available from the nsexec plugin.

Ok. One more time. :) I have this:


int num1;
int num2;
int ret;
char *ok;
int decimal, sign;

/* .... */

char buf1[1024];
char buf2[1024];
num1 = atoi(buf1);
num2 = atoi(buf2);
ret = num1 + num2;
ok = fcvt(ret,1, &decimal, &sign);
popstring(ok);
MessageBox(hwndParent,ok,"Hola",64);

If I put:

MyDLL::Test "5" "3"

In the MessageBox ok is equal to "5", when is suppose to be "8". Why doesn't make the op. "5+3"

use wsprintf(ok,"%d",ret); and change char* ok to char ok[8].

that should work

-daz

[edit] you don't need the fcvt(..) part with the change [/edit]


Thanks DrO. :) With this:


char buf1[1024];
char buf2[1024];
popstring(buf1);
popstring(buf2);
num1 = atoi(buf1);
num2 = atoi(buf2);
ret = num1 + num2;
wsprintf(ok,"%d",ret);
MessageBox(hwndParent,ok,"Hola",64);

Now I'm going to output the value of the press messagebox button, for example: OK=1; YES=6; NO=7. The return value must be in a $(0..9), any ideas? :)

try this:

char buf1[1024];
char buf2[1024];
int ret;
popstring(buf1);
popstring(buf2);
wsprintf(ok,"%d",atoi(buf1)+atoi(buf2));
ret = MessageBox(hwndParent,ok,"Hola",64);
wsprintf(buf1,"%d",ret);
pushstring(buf1); // should put the return value into $0

-daz


Thanks dude :) :up:
Now I think that I can take it from here :confused: --> :p


no problem ;)

-daz


Well, one more :rolleyes:
Since is

pushstring(buf1); // should put the return value into $0
How can I change the value of the stack, I mean in this example is $0 is the default, how can change it... mmm, let's say to $5

I thought that pushstring will not replace anything on the stack, just add an item to the stack, so the user will have to pop multiple times to get all the stack strings.

Wouldn't the user just have to Pop $5

Edit: But then again, I don't know any C++/Delphi, so I'm probably wrong.

-Stu


think it's setuservariable (or something to that name) in exdll.h and from what i understand it will allow you to set $5 based on the id from the enum list you use.

can't check this for sure at the moment but think that's the push in the right direction.

I thought that pushstring will not replace anything on the stack, just add an item to the stack, so the user will have to pop multiple times to get all the stack strings.
that's how i'd take it as well

-daz

I'm stuck in here:


float myret;
float num1;
float num2;
char ok[1024];

void __declspec(dllexport) Add(HWND hWnd, int string_size, char *variables, stack_t **stacktop)
{
EXDLL_INIT();
{
char n1[1024];
char n2[1024];
popstring(n1);
popstring(n2);
num1 = atof(n1);
num2 = atof(n2);
myret = num1 + num2;
//gcvt(myret,3,ok);
sprintf(ok,"%g",myret);
MessageBox (hWnd, ok, "AtenciĆ³n", 0 + MB_ICONASTERISK);
}
}

if I used this:

MyDLL::Add "5" "2"

the ok returns this: 2.48085e+006 :igor:
I'm trying to read "float numbers" like "5" and "5.6" to make the op. like 5+5.56.
Any ideas?

What's %g? Don't you mean %f? printf also has options you can put between % and f. See printf's readme for more information about setting the output precision.


Ok. I'm trying again. Thanks :)


Well... This could be "it".
I have this now:


char n1[1024];
char n2[1024];
char ret[1024];
popstring(n1);
popstring(n2);
num1 = atof(n1);
num2 = atof(n2);
myret = num1 + num2;
gcvt (myret,10,ok);
MessageBox (hWnd, ok, "AtenciĆ³n", 0 + MB_ICONASTERISK);
popstring(ret);
if (ret == "Yes") MessageBox (hWnd, "Esta es para $0" , "Hola!", 0);
if (ret == "No") MessageBox (hWnd, "Esta es para $1" , "Hola", 0);

With this Nsis code:

MyDLL::Add "3.150" "-1.134" "No"
Quit

The plugin successfully do the operation. :up:
But it doesn't show the second Messagebox, anyone know why?

You can't compare strings like that. Use strcmp or anyone of its varients.


Thanks Kichik, that was it :D


Just to say thanks to all the people who help me creating a plugin.
It's almost done. It's based in the concept of Math.dll, with a spanish style :p ;).
Thanks to all the people of this thread and brainsucker :).
It's more like a doubt. When the compiler (makensisw.exe) reads the script, it has something like this in the log:


Processing plugin dlls: "C:\lobolunar\dev\nsis\plugins\*.dll"
- Banner::destroy
- Banner::show
- LangDLL::LangDialog
...

In my plugin I have some functions that I don't wanna show in the log... so...how do you do that....

Functions that should not be accessible to the user shouldn't be of the following format:

void __declspec(dllexport) functionName(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)


mmm...Yes I think of that, but still...
Look, I'm attaching the source code of my first version.
In MathOpH.h has the function that I don't wanna show.


Remove the functions you don't want exported from dll.def.


mmmmm, how? :rolleyes:
/edit... I discovered :D Thanks :up: /