Old 9th August 2015, 23:10   #1
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
Dialogs v3 (unicode) nsis plugin

Updated and unicode version from this one.

Note that I will giving updates via github instead of this thread. Use this thread for support or questions.

Go to Github repository for latest versions.
Attached Files
File Type: 7z Dialogs-3.0.0.0.7z (36.0 KB, 598 views)


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 10th August 2015, 02:13   #2
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 881
Nice work.

One observation, when you are allocating memory for the buffer, the sizing appears to be wrong. string_size is the number of characters, for ansi this is fine as they are one byte each. Under unicode the size is two bytes, so the actual length allocated is half. So the 'correct' way is sizeof(TCHAR)*string_size.

I also see a mixing of unicode only functions and TCHAR strings, this would break the ansi build. Is this intentional or a mistake?

Also, to help remove connections to the CRT, change ZeroMemory() to SecureZeroMemory(). Oh, and swap _tsclen() for lstrlen(), and _sntprintf() for wnsprintf(), and _ttoi() for myatoi() (provided by the plugin api). Use Dependency Walker to confirm that MSVCRTx0.DLL isn't in the list.

Just as a side note, the callback functions return type is usually an LRESULT, but since INT_PTR is the same width I guess it doesn't make any difference.

Sorry for nitpicking, I just ported Afrow UK's PassDialog plugin from char only to unicode and 64 bit, and I still have a bit of a buzz from it.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 10th August 2015, 05:29   #3
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
Hi Jason.

1.- Thanks for the sizeof(TCHAR)*string_size tip.
2.- Is intentional, because I don't think there is sane machine running windows Me or lower. Either less, this plugin is for unicode machines (sorry ANSI users, you'll have to compile into ANSI if you want this char type support)
3.- Yup, I'll change the functions as you pointed.


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 10th August 2015, 09:00   #4
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 337
thanks mr Joel

my problem solve with new plugin:


PHP Code:

!include "LogicLib.nsh"

SetCompressor /SOLID lzma
Name 
"InputBox"
OutFile "InputBox.exe"
RequestExecutionLevel user
ShowInstDetails show
Unicode true
XPStyle on

!define Password "12345"

Page instfiles

# Just for testing
!addplugindir /x86-unicode "..\bin"

Function .onInit
InitPluginsDir

InputBox dialog
Type0=text,1=password
Dialog titlemax 64 chars
Secundary textmax 64 chars
label okmax 12 chars
label cancelmax 12 chars
; Return var for the button pressed0=cancel1=ok
; Return var with the inputed text

Loop1
:
Dialogs::Ver 9
Dialogs
::InputBox 1 "PasswordBox $9" "Please a enter Password..." "OK" "Close" 4 6


${if} $== 1
;----------------------------
Var /GLOBAL 
Len
StrLen $Len 
"$6"
${If} "$Len"25"
MessageBox MB_OK|MB_ICONINFORMATION "You entered $Len character,Maximum password length is limited to 25 character."
Goto Loop1
${EndIf}
;----------------------------
${If} 
"$6" == ""
MessageBox MB_OK|MB_ICONINFORMATION "Please enter a password to continue..."
Goto Loop1
${EndIf}
;----------------------------
${If} 
"$6" != "${Password}"
MessageBox MB_OK|MB_ICONSTOP "The password '$6' is correct!"
Goto Loop1
${EndIf}
;----------------------------
${If} 
"$6" == "${Password}"
MessageBox MB_OK|MB_ICONINFORMATION "Welcome To Application..."
${EndIf}
;----------------------------
${endif}



FunctionEnd



Section 
""
SectionEnd 
just a question:
is not possible change this unicode plugin to ansi?! Finally,we have two plug-ins (Unicode-Ansi)?
r2du-soft is offline   Reply With Quote
Old 10th August 2015, 10:51   #5
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 881
Wow, two plugin requests in two days, your on a roll.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 10th August 2015, 14:02   #6
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
It'll be just simple to remove the explicit unicode functions in the code and add the option to build unicode or ansi in cmake. In a few days you can visit github for updates.


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 11th August 2015, 03:29   #7
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 881
Looking good.

Another observation, wsnprintf() expects the number of characters, not the number of bytes. So it's enough to use string_size, provided that the allocation used sizeof(TCHAR)*string_size.

That's a common mistake to make, some require the size in bytes (sizeof(TCHAR)*string_size), others require the length in characters (string_size). Another way to get the character length is: sizeof(buff)/sizeof(buff[0]).

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 11th August 2015, 04:36   #8
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
Damn, win api

I'll change the wnsprintf parameter to string_size in the next release. -_-


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel 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