WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > CustomLicense plug-in
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
JasonFriday13
Senior Member

Registered: May 2005
From: Hawera, New Zealand

CustomLicense plug-in

Introducing my new plugin. It loads a text file into a static buffer, then can set that text into a text or label control that has a HWND. I have already made a wiki page, the link is below.

http://nsis.sourceforge.net/CustomLicense_plug-in

__________________
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
Wiki Profile

Quick Link | Report this post to a moderator | IP: Logged

JasonFriday13 is offline Old Post 07-16-2006 11:06 PM
Click Here to See the Profile for JasonFriday13 Click here to Send JasonFriday13 a Private Message Find more posts by JasonFriday13 Add JasonFriday13 to your buddy list Edit/Delete Message Reply w/Quote
JasonFriday13
Senior Member

Registered: May 2005
From: Hawera, New Zealand

Found out last week I have 3 weeks holiday, not 2 . So now I have released a new version. This loads the contents of the file into a dynamically created
buffer. Max file size 305 666 bytes (298KB). See the wiki page above.

__________________
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
Wiki Profile

Quick Link | Report this post to a moderator | IP: Logged

JasonFriday13 is offline Old Post 07-23-2006 10:43 PM
Click Here to See the Profile for JasonFriday13 Click here to Send JasonFriday13 a Private Message Find more posts by JasonFriday13 Add JasonFriday13 to your buddy list Edit/Delete Message Reply w/Quote
Joel
Debian user
(Forum King)

Registered: Jan 2003
From: Ubuntu land

Why not use EM_STREAMIN and void that malloc and free stuff

__________________

* Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM.
* Ubuntu 9.10 64-bits.
* Firefox (Namoroka) 3.6.2.
* lighttpd, php5, perl, eruby, python.
* geany, XHTML & CSS & JavaScript, Gtk+, QT4, bindings.

Quick Link | Report this post to a moderator | IP: Logged

Joel is offline Old Post 07-24-2006 12:55 AM
Click Here to See the Profile for Joel Click here to Send Joel a Private Message Click Here to Email Joel Visit Joel's homepage! Find more posts by Joel Add Joel to your buddy list Edit/Delete Message Reply w/Quote
JasonFriday13
Senior Member

Registered: May 2005
From: Hawera, New Zealand

I will take a look at it. I used the first method I found which was malloc and free, because that what the system plugin uses.

__________________
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
Wiki Profile

Quick Link | Report this post to a moderator | IP: Logged

JasonFriday13 is offline Old Post 07-24-2006 10:06 PM
Click Here to See the Profile for JasonFriday13 Click here to Send JasonFriday13 a Private Message Find more posts by JasonFriday13 Add JasonFriday13 to your buddy list Edit/Delete Message Reply w/Quote
SuperPat
Senior Member

Registered: Mar 2006
From: France

Very Good.

I use an other technique:
I use the file open/write/close function to append the ini file with a large text.

__________________

Quick Link | Report this post to a moderator | IP: Logged

SuperPat is offline Old Post 07-25-2006 12:16 AM
Click Here to See the Profile for SuperPat Click here to Send SuperPat a Private Message Click Here to Email SuperPat Visit SuperPat's homepage! Find more posts by SuperPat Add SuperPat to your buddy list Edit/Delete Message Reply w/Quote
Joel
Debian user
(Forum King)

Registered: Jan 2003
From: Ubuntu land

Well... I saw your source code. Is nice and clean, but I found some things that you might want to check:

PHP:

FileHandle
= CreateFile(FileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (!
FileHandle) ...


According to msdn, when CreateFile fails, it returns INVALID_HANDLE_VALUE and as I remember is not zero.
PHP:

TempVar
== "/UNLOAD"


I don't think that's possible, you loose data and always will be true , maybe lstrcmp.

__________________

* Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM.
* Ubuntu 9.10 64-bits.
* Firefox (Namoroka) 3.6.2.
* lighttpd, php5, perl, eruby, python.
* geany, XHTML & CSS & JavaScript, Gtk+, QT4, bindings.

Quick Link | Report this post to a moderator | IP: Logged

Joel is offline Old Post 07-25-2006 12:54 AM
Click Here to See the Profile for Joel Click here to Send Joel a Private Message Click Here to Email Joel Visit Joel's homepage! Find more posts by Joel Add Joel to your buddy list Edit/Delete Message Reply w/Quote
JasonFriday13
Senior Member

Registered: May 2005
From: Hawera, New Zealand

Yeah, I will change it to say:
if (!FileHandle || FileHandle == INVALID_HANDLE_VALUE)

Don't know about the 'Temp == "/UNLOAD"' expression, but it seems to work just fine in my tests.

__________________
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
Wiki Profile

Quick Link | Report this post to a moderator | IP: Logged

JasonFriday13 is offline Old Post 07-25-2006 02:45 AM
Click Here to See the Profile for JasonFriday13 Click here to Send JasonFriday13 a Private Message Find more posts by JasonFriday13 Add JasonFriday13 to your buddy list Edit/Delete Message Reply w/Quote
JasonFriday13
Senior Member

Registered: May 2005
From: Hawera, New Zealand

I have modified the plugin again, and now it has just one function called 'LoadFile'. Usage:

CustomLicense::LoadFile "C:\path\filetoload.txt" "hwndofcontrol"

The first parameter is obvious, the second is the hwnd of the control to load the text into. Example:

code:
Function Pre installoptions::init "$PLUGINSDIR\inipage.ini" Pop $0 ; See the installoptions readme for info on how ; to get the field number. ; Put the code between here... ;FindWindow $0 "#32770" "" $HWNDPARENT GetDlgItem $0 $0 1201 CustomLicense::LoadFile "$PLUGINSDIR\license.txt" "$0" Pop $0 StrCmp $0 0 0 next MessageBox MB_OK "Error with CustomLicense plug-in." next: ; ...and here in the show function if you want to ; use this plugin with standard nsis pages. installoptions::show FunctionEnd

The actual plugin will probably be out on Monday next week.

@Joel: I had a go at the EM_STREAMIN, but I had no idea on how it is supposed to work. I kept getting errors when I ran the test installer, and it is because it can't understand '->'. I first tried '.', but it gave me an error and told me to use '->'. It crashed at (example): struct->structmember = FileName. So I stayed with my current configuration.

__________________
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
Wiki Profile

Quick Link | Report this post to a moderator | IP: Logged

JasonFriday13 is offline Old Post 08-01-2006 10:26 PM
Click Here to See the Profile for JasonFriday13 Click here to Send JasonFriday13 a Private Message Find more posts by JasonFriday13 Add JasonFriday13 to your buddy list Edit/Delete Message Reply w/Quote
Afrow UK
Moderator

Registered: Nov 2002
From: Shropshire, England

Shouldn't:
installoptions::init
Be:
InstallOptions:InitDialog

-Stu

__________________
afrowuk.co.uk

Quick Link | Report this post to a moderator | IP: Logged

Afrow UK is offline Old Post 08-01-2006 10:57 PM
Click Here to See the Profile for Afrow UK Click here to Send Afrow UK a Private Message Click Here to Email Afrow UK Visit Afrow UK's homepage! Find more posts by Afrow UK Add Afrow UK to your buddy list Edit/Delete Message Reply w/Quote
JasonFriday13
Senior Member

Registered: May 2005
From: Hawera, New Zealand

True. I just have used installoptions passively with MUI and ISUI. Updated version is out. Go to the wiki page above to download.

[edit] fixed typo [/edit]

__________________
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
Wiki Profile

Quick Link | Report this post to a moderator | IP: Logged

JasonFriday13 is offline Old Post 08-06-2006 09:36 PM
Click Here to See the Profile for JasonFriday13 Click here to Send JasonFriday13 a Private Message Find more posts by JasonFriday13 Add JasonFriday13 to your buddy list Edit/Delete Message Reply w/Quote
Takhir
Major Dude

Registered: Feb 2004
From: Moscow, Russia

Your dll still depends on msvcrt.dll. You can easy change malloc-free to kernel.dll GloballAlloc-GlobalFree (Requires Windows 95 or later).

Quick Link | Report this post to a moderator | IP: Logged

Takhir is offline Old Post 08-07-2006 05:54 AM
Click Here to See the Profile for Takhir Click here to Send Takhir a Private Message Visit Takhir's homepage! Find more posts by Takhir Add Takhir to your buddy list Edit/Delete Message Reply w/Quote
JasonFriday13
Senior Member

Registered: May 2005
From: Hawera, New Zealand

I suppose that is an innocent change to make. I will change it tonight. New version out tomorrow.

__________________
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
Wiki Profile

Quick Link | Report this post to a moderator | IP: Logged

JasonFriday13 is offline Old Post 08-07-2006 10:59 PM
Click Here to See the Profile for JasonFriday13 Click here to Send JasonFriday13 a Private Message Find more posts by JasonFriday13 Add JasonFriday13 to your buddy list Edit/Delete Message Reply w/Quote
JasonFriday13
Senior Member

Registered: May 2005
From: Hawera, New Zealand

Well, I shouldn't get ahead of myself. I now have a small problem. There are now four weird characters at the end of the string after the text has been set in the control. If I take one byte off the number of bytes to read, it gets rid of the weird characters and chops off one byte off the string (a fullstop in my case).

One workaround is to put an extra character at the end of the license file (eg a fullstop), but I don't want to have to tell users to do this before using my plugin. Any ideas?

[edit] I could manually add a terminating NULL character to the string. Would that work?[/edit]

__________________
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
Wiki Profile

Quick Link | Report this post to a moderator | IP: Logged

JasonFriday13 is offline Old Post 08-08-2006 11:14 PM
Click Here to See the Profile for JasonFriday13 Click here to Send JasonFriday13 a Private Message Find more posts by JasonFriday13 Add JasonFriday13 to your buddy list Edit/Delete Message Reply w/Quote
Afrow UK
Moderator

Registered: Nov 2002
From: Shropshire, England

Yep, always make sure you put one on yourself: \0
I missed this in early versions of my array plugin and it caused a few issues.

Edit: Or make sure that you allocate an extra byte to allow for the null character on the end.

-Stu

__________________
afrowuk.co.uk

Quick Link | Report this post to a moderator | IP: Logged

Afrow UK is offline Old Post 08-08-2006 11:26 PM
Click Here to See the Profile for Afrow UK Click here to Send Afrow UK a Private Message Click Here to Email Afrow UK Visit Afrow UK's homepage! Find more posts by Afrow UK Add Afrow UK to your buddy list Edit/Delete Message Reply w/Quote
JasonFriday13
Senior Member

Registered: May 2005
From: Hawera, New Zealand

OK, will do. New version due out on Monday (really).

__________________
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
Wiki Profile

Quick Link | Report this post to a moderator | IP: Logged

JasonFriday13 is offline Old Post 08-08-2006 11:39 PM
Click Here to See the Profile for JasonFriday13 Click here to Send JasonFriday13 a Private Message Find more posts by JasonFriday13 Add JasonFriday13 to your buddy list Edit/Delete Message Reply w/Quote
Takhir
Major Dude

Registered: Feb 2004
From: Moscow, Russia

The only comment in the script sample I wrote long ago is about terminating zero http://nsis.sourceforge.net/External_License_file

Quick Link | Report this post to a moderator | IP: Logged

Takhir is offline Old Post 08-09-2006 05:34 AM
Click Here to See the Profile for Takhir Click here to Send Takhir a Private Message Visit Takhir's homepage! Find more posts by Takhir Add Takhir to your buddy list Edit/Delete Message Reply w/Quote
JasonFriday13
Senior Member

Registered: May 2005
From: Hawera, New Zealand

Surprisingly, that example is almost exactly the same as the internals of my plugin .

There is a new version out today. In the last version, I forgot to free the allocated memory, which is now fixed. Now uses GlobalAlloc and GlobalFree for memory allocation.

My initial test to see how big a file I can load went very well. I managed to load a 483KB file with no errors on the first go . Please tell me how big a file you have managed to load with this plugin without a crash (this is a good way to test my plugin).

When I was going to add the terminating zero, I relised I was not allocating enough memory for the whole file. I was always truncating the terminating zero, thus getting weird characters and some crashes from large files. Now I am allocating enough memory for the file and the terminating zero.

Go to wiki to download (probably the last version for a while).

__________________
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
Wiki Profile

Quick Link | Report this post to a moderator | IP: Logged

JasonFriday13 is offline Old Post 08-13-2006 09:59 PM
Click Here to See the Profile for JasonFriday13 Click here to Send JasonFriday13 a Private Message Find more posts by JasonFriday13 Add JasonFriday13 to your buddy list Edit/Delete Message Reply w/Quote
kfank
Junior Member

Registered: Jan 2008
From: Sherwood, OR

It appears that if the file path argument is >= 64 characters then the function does not work. Initial debugging of DLL seemed to show that the file argument was in fact getting passed in and parsed (the correct file was opened and read) but perhaps return from DLL is failing?

Quick Link | Report this post to a moderator | IP: Logged

kfank is offline Old Post 03-01-2008 08:12 AM
Click Here to See the Profile for kfank Click here to Send kfank a Private Message Find more posts by kfank Add kfank to your buddy list Edit/Delete Message Reply w/Quote
kfank
Junior Member

Registered: Jan 2008
From: Sherwood, OR

Well, it's quite obvious that the stack variables are only allocated 64 bytes in the DLL. This length is too short if the file passed in is in the $PLUGINSDIR. I will post a DLL with larger buffer unless JasonFriday13 wants to.

Quick Link | Report this post to a moderator | IP: Logged

kfank is offline Old Post 03-03-2008 01:45 AM
Click Here to See the Profile for kfank Click here to Send kfank a Private Message Find more posts by kfank Add kfank to your buddy list Edit/Delete Message Reply w/Quote
Afrow UK
Moderator

Registered: Nov 2002
From: Shropshire, England

You are given the buffer length as one of the NSIS plug-in function arguments which you can use to allocate memory with LocalAlloc or GlobalAlloc.

Stu

__________________
afrowuk.co.uk

Quick Link | Report this post to a moderator | IP: Logged

Afrow UK is offline Old Post 03-03-2008 10:39 AM
Click Here to See the Profile for Afrow UK Click here to Send Afrow UK a Private Message Click Here to Email Afrow UK Visit Afrow UK's homepage! Find more posts by Afrow UK Add Afrow UK to your buddy list Edit/Delete Message Reply w/Quote
paolo.salvan
Junior Member

Registered: Jan 2010
From:

Hi all,

...I've tried the last plug-in version and I've found the described bug (buffer overflow) still not solved (and I'm having random problems under Vista/7);

I think that in CustomLicense.c the line:
unsigned int LoadFileContents(char FileName[64], unsigned int hwnd)
^^^^
...should be changed to:
unsigned int LoadFileContents(char FileName[256], unsigned int hwnd)
^^^^^

...but I've no build environment to compile the fix and public the fixed plugin, can someone fix it?

Quick Link | Report this post to a moderator | IP: Logged

paolo.salvan is offline Old Post 01-15-2010 10:06 AM
Click Here to See the Profile for paolo.salvan Click here to Send paolo.salvan a Private Message Find more posts by paolo.salvan Add paolo.salvan to your buddy list Edit/Delete Message Reply w/Quote
kfank
Junior Member

Registered: Jan 2008
From: Sherwood, OR

I have followed Afrow's advice to take the buffer size from the arguments and have built both Ansi and Unicode versions. I've uploaded the build to:

URL submitted by user.

Quick Link | Report this post to a moderator | IP: Logged

kfank is offline Old Post 01-26-2010 12:03 AM
Click Here to See the Profile for kfank Click here to Send kfank a Private Message Find more posts by kfank Add kfank to your buddy list Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 09:09 PM. Post New Thread    Post A Reply
  Last Thread   Next Thread
WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > CustomLicense plug-in
Show Printable Version
 | 
Email this Page
 | 
Subscribe to this Thread

Forum Jump:
 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is off
vB code is ON
Smilies are ON
[IMG] code is ON