new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/SConscript
@@ -0,0 +1,25 @@
+# FIXME: install assembly and pascal includes into the correct locations
+
+c_devel = Split("""
+ exdll.h
+""")
+
+example = Split("""
+ exdll.c
+ exdll.dpr
+ exdll.dsp
+ exdll.dsw
+ exdll_with_unit.dpr
+ nsis.pas
+ extdll.inc
+""")
+
+Import('defenv')
+
+if defenv['PLATFORM'] == 'win32':
+ example += c_devel
+else:
+ defenv.DistributeIncC(c_devel)
+
+defenv.DistributeExamples(example, path='Plugin')
+
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdll.c
@@ -0,0 +1,44 @@
+// Unicode support by Jim Park -- 08/02/2007
+
+#include <windows.h>
+#include "tchar.h"
+#include "exdll.h"
+
+HINSTANCE g_hInstance;
+
+HWND g_hwndParent;
+
+// To work with Unicode version of NSIS, please use TCHAR-type
+// functions for accessing the variables and the stack.
+
+void __declspec(dllexport) myFunction(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop,
+ extra_parameters *extra)
+{
+ g_hwndParent=hwndParent;
+
+ EXDLL_INIT();
+
+
+ // note if you want parameters from the stack, pop them off in order.
+ // i.e. if you are called via exdll::myFunction file.dat poop.dat
+ // calling popstring() the first time would give you file.dat,
+ // and the second time would give you poop.dat.
+ // you should empty the stack of your parameters, and ONLY your
+ // parameters.
+
+ // do your stuff here
+ {
+ TCHAR buf[1024];
+ wsprintf(buf,_T("$0=%s\n"),getuservariable(INST_0));
+ MessageBox(g_hwndParent,buf,0,MB_OK);
+ }
+}
+
+
+
+BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
+{
+ g_hInstance=hInst;
+ return TRUE;
+}
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdll.dpr
@@ -0,0 +1,118 @@
+{
+ NSIS ExDLL example
+ (C) 2001 - Peter Windridge
+
+ Fixed and formatted by Brett Dever
+ http://editor.nfscheats.com/
+
+ Tested in Delphi 7.0
+}
+
+library exdll;
+
+uses Windows;
+
+type
+ VarConstants = (
+ INST_0,
+ INST_1, // $1
+ INST_2, // $2
+ INST_3, // $3
+ INST_4, // $4
+ INST_5, // $5
+ INST_6, // $6
+ INST_7, // $7
+ INST_8, // $8
+ INST_9, // $9
+ INST_R0, // $R0
+ INST_R1, // $R1
+ INST_R2, // $R2
+ INST_R3, // $R3
+ INST_R4, // $R4
+ INST_R5, // $R5
+ INST_R6, // $R6
+ INST_R7, // $R7
+ INST_R8, // $R8
+ INST_R9, // $R9
+ INST_CMDLINE, // $CMDLINE
+ INST_INSTDIR, // $INSTDIR
+ INST_OUTDIR, // $OUTDIR
+ INST_EXEDIR, // $EXEDIR
+ INST_LANG, // $LANGUAGE
+ __INST_LAST
+ );
+ TVariableList = INST_0..__INST_LAST;
+ pstack_t = ^stack_t;
+ stack_t = record
+ next: pstack_t;
+ text: PChar;
+ end;
+
+var
+ g_stringsize: integer;
+ g_stacktop: ^pstack_t;
+ g_variables: PChar;
+ g_hwndParent: HWND;
+
+function PopString(): string;
+var
+ th: pstack_t;
+begin
+ if integer(g_stacktop^) <> 0 then begin
+ th := g_stacktop^;
+ Result := PChar(@th.text);
+ g_stacktop^ := th.next;
+ GlobalFree(HGLOBAL(th));
+ end;
+end;
+
+procedure PushString(const str: string='');
+var
+ th: pstack_t;
+begin
+ if integer(g_stacktop) <> 0 then begin
+ th := pstack_t(GlobalAlloc(GPTR, SizeOf(stack_t) + g_stringsize));
+ lstrcpyn(@th.text, PChar(str), g_stringsize);
+ th.next := g_stacktop^;
+ g_stacktop^ := th;
+ end;
+end;
+
+function GetUserVariable(const varnum: TVariableList): string;
+begin
+ if (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then
+ Result := g_variables + integer(varnum) * g_stringsize
+ else
+ Result := '';
+end;
+
+procedure SetUserVariable(const varnum: TVariableList; const value: string);
+begin
+ if (value <> '') and (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then
+ lstrcpy(g_variables + integer(varnum) * g_stringsize, PChar(value))
+end;
+
+procedure NSISDialog(const text, caption: string; const buttons: integer);
+begin
+ MessageBox(g_hwndParent, PChar(text), PChar(caption), buttons);
+end;
+
+procedure ex_dll(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer); cdecl;
+begin
+ // setup global variables
+ g_stringsize := string_size;
+ g_hwndParent := hwndParent;
+ g_stacktop := stacktop;
+ g_variables := variables;
+ // end global variable setup
+
+ NSISDialog(GetUserVariable(INST_0), 'The value of $0', MB_OK);
+ NSISDialog(PopString, 'pop', MB_OK);
+ PushString('Hello, this is a push');
+ SetUserVariable(INST_0, 'This is user var $0');
+end;
+
+exports ex_dll;
+
+begin
+end.
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdll.dsp
@@ -0,0 +1,111 @@
+# Microsoft Developer Studio Project File - Name="exdll" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=exdll - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "exdll.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "exdll.mak" CFG="exdll - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "exdll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "exdll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "exdll - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXDLL_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXDLL_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /entry:"DllMain" /dll /machine:I386 /nodefaultlib /out:"../../Plugins/exdll.dll" /opt:nowin98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "exdll - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXDLL_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXDLL_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "exdll - Win32 Release"
+# Name "exdll - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\exdll.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\exdll.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdll.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "exdll"=.\exdll.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdll.h
@@ -0,0 +1,234 @@
+// Unicode support added by Jim Park -- 07/27/2007
+// Unicode support requires that all plugins take TCHARs instead as well. This
+// means existing plugins will not work for the Unicode version of NSIS unless
+// recompiled. You have been warned.
+
+#ifndef _EXDLL_H_
+#define _EXDLL_H_
+
+#include <windows.h>
+#include "tchar.h"
+
+#if defined(__GNUC__)
+#define UNUSED __attribute__((unused))
+#else
+#define UNUSED
+#endif
+
+// only include this file from one place in your DLL.
+// (it is all static, if you use it in two places it will fail)
+
+#define EXDLL_INIT() { \
+ g_stringsize=string_size; \
+ g_stacktop=stacktop; \
+ g_variables=variables; }
+
+// For page showing plug-ins
+#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8)
+#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd)
+
+/* Jim Park: This char is compared as an int value and therefore
+ it's fine as an ASCII. Do not need to change to wchar_t since
+ it will get the same integer value. */
+#define NOTIFY_BYE_BYE _T('x')
+
+typedef struct _stack_t {
+ struct _stack_t *next;
+ TCHAR text[1]; // this should be the length of string_size
+} stack_t;
+
+
+static unsigned int g_stringsize;
+static stack_t **g_stacktop;
+static TCHAR *g_variables;
+
+static int __stdcall popstring(TCHAR *str) UNUSED; // 0 on success, 1 on empty stack
+static void __stdcall pushstring(const TCHAR *str) UNUSED;
+static TCHAR * __stdcall getuservariable(const int varnum) UNUSED;
+static void __stdcall setuservariable(const int varnum, const TCHAR *var) UNUSED;
+
+enum
+{
+INST_0, // $0
+INST_1, // $1
+INST_2, // $2
+INST_3, // $3
+INST_4, // $4
+INST_5, // $5
+INST_6, // $6
+INST_7, // $7
+INST_8, // $8
+INST_9, // $9
+INST_R0, // $R0
+INST_R1, // $R1
+INST_R2, // $R2
+INST_R3, // $R3
+INST_R4, // $R4
+INST_R5, // $R5
+INST_R6, // $R6
+INST_R7, // $R7
+INST_R8, // $R8
+INST_R9, // $R9
+INST_CMDLINE, // $CMDLINE
+INST_INSTDIR, // $INSTDIR
+INST_OUTDIR, // $OUTDIR
+INST_EXEDIR, // $EXEDIR
+INST_LANG, // $LANGUAGE
+__INST_LAST
+};
+
+typedef struct {
+ int autoclose;
+ int all_user_var;
+ int exec_error;
+ int abort;
+ int exec_reboot;
+ int reboot_called;
+ int XXX_cur_insttype; // deprecated
+ int XXX_insttype_changed; // deprecated
+ int silent;
+ int instdir_error;
+ int rtl;
+ int errlvl;
+ int alter_reg_view;
+ int status_update;
+} exec_flags_type;
+
+typedef struct {
+ exec_flags_type *exec_flags;
+ int (__stdcall *ExecuteCodeSegment)(int, HWND);
+ void (__stdcall *validate_filename)(TCHAR *);
+} extra_parameters;
+
+// utility functions (not required but often useful)
+static int __stdcall popstring(TCHAR *str)
+{
+ stack_t *th;
+ if (!g_stacktop || !*g_stacktop) return 1;
+ th=(*g_stacktop);
+ lstrcpy(str,th->text);
+ *g_stacktop = th->next;
+ GlobalFree((HGLOBAL)th);
+ return 0;
+}
+
+static void __stdcall pushstring(const TCHAR *str)
+{
+ stack_t *th;
+ if (!g_stacktop) return;
+ th=(stack_t*)GlobalAlloc(GPTR,(sizeof(stack_t)+(g_stringsize)*sizeof(TCHAR)));
+ lstrcpyn(th->text,str,g_stringsize);
+ th->next=*g_stacktop;
+ *g_stacktop=th;
+}
+
+static TCHAR * __stdcall getuservariable(const int varnum)
+{
+ if (varnum < 0 || varnum >= __INST_LAST) return NULL;
+ return g_variables+varnum*g_stringsize;
+}
+
+static void __stdcall setuservariable(const int varnum, const TCHAR *var)
+{
+ if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
+ lstrcpy(g_variables + varnum*g_stringsize, var);
+}
+
+#ifdef _UNICODE
+#define PopStringW(x) popstring(x)
+#define PushStringW(x) pushstring(x)
+#define SetUserVariableW(x,y) setuservariable(x,y)
+
+static int __stdcall PopStringA(char* ansiStr)
+{
+ wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, g_stringsize*sizeof(wchar_t));
+ int rval = popstring(wideStr);
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+ GlobalFree((HGLOBAL)wideStr);
+ return rval;
+}
+
+static void __stdcall PushStringA(const char* ansiStr)
+{
+ wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, g_stringsize*sizeof(wchar_t));
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+ pushstring(wideStr);
+ GlobalFree((HGLOBAL)wideStr);
+ return;
+}
+
+static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr)
+{
+ lstrcpyW(wideStr, getuservariable(varnum));
+}
+
+static void __stdcall GetUserVariableA(const int varnum, char* ansiStr)
+{
+ wchar_t* wideStr = getuservariable(varnum);
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+}
+
+static void __stdcall SetUserVariableA(const int varnum, const char* ansiStr)
+{
+ if (ansiStr != NULL && varnum >= 0 && varnum < __INST_LAST)
+ {
+ wchar_t* wideStr = g_variables + varnum * g_stringsize;
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+ }
+}
+
+#else
+// ANSI defs
+
+#define PopStringA(x) popstring(x)
+#define PushStringA(x) pushstring(x)
+#define SetUserVariableA(x,y) setuservariable(x,y)
+
+static int __stdcall PopStringW(wchar_t* wideStr)
+{
+ char* ansiStr = (char*) GlobalAlloc(GPTR, g_stringsize);
+ int rval = popstring(ansiStr);
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+ GlobalFree((HGLOBAL)ansiStr);
+ return rval;
+}
+
+static void __stdcall PushStringW(wchar_t* wideStr)
+{
+ char* ansiStr = (char*) GlobalAlloc(GPTR, g_stringsize);
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+ pushstring(ansiStr);
+ GlobalFree((HGLOBAL)ansiStr);
+}
+
+static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr)
+{
+ char* ansiStr = getuservariable(varnum);
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+}
+
+static void __stdcall GetUserVariableA(const int varnum, char* ansiStr)
+{
+ lstrcpyA(ansiStr, getuservariable(varnum));
+}
+
+static void __stdcall SetUserVariableW(const int varnum, const wchar_t* wideStr)
+{
+ if (wideStr != NULL && varnum >= 0 && varnum < __INST_LAST)
+ {
+ char* ansiStr = g_variables + varnum * g_stringsize;
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+ }
+}
+#endif
+
+static BOOL __stdcall IsUnicode(void)
+{
+#ifdef _UNICODE
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+#endif//_EXDLL_H_
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdll_with_unit.dpr
@@ -0,0 +1,31 @@
+{
+ NSIS ExDLL2 example
+ Original is ExDLL
+ (C) 2001 - Peter Windridge
+
+ Changed with delphi unit nsis.pas
+ by bernhard mayer
+
+ Tested in Delphi 7.0
+}
+
+library exdll;
+
+uses
+ nsis, windows;
+
+procedure ex_dll(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer); cdecl;
+begin
+ // set up global variables
+ Init(hwndParent, string_size, variables, stacktop);
+
+ NSISDialog(GetUserVariable(INST_0), 'The value of $0', MB_OK);
+ NSISDialog(PopString, 'pop', MB_OK);
+ PushString('Hello, this is a push');
+ SetUserVariable(INST_0, 'This is user var $0');
+end;
+
+exports ex_dll;
+
+begin
+end.
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdllutil.cpp
@@ -0,0 +1,131 @@
+// Unicode support by Jim Park -- 08/23/2007
+
+#include <windows.h>
+#include "exdllutil.h"
+
+// utility functions (not required but often useful)
+static int __stdcall popstring(TCHAR *str)
+{
+ stack_t *th;
+ if (!g_stacktop || !*g_stacktop) return 1;
+ th=(*g_stacktop);
+ lstrcpy(str,th->text);
+ *g_stacktop = th->next;
+ GlobalFree((HGLOBAL)th);
+ return 0;
+}
+
+static void __stdcall pushstring(const TCHAR *str)
+{
+ stack_t *th;
+ if (!g_stacktop) return;
+ th=(stack_t*)GlobalAlloc(GPTR,(sizeof(stack_t)+(g_stringsize)*sizeof(TCHAR)));
+ lstrcpyn(th->text,str,g_stringsize);
+ th->next=*g_stacktop;
+ *g_stacktop=th;
+}
+
+static TCHAR * __stdcall getuservariable(const int varnum)
+{
+ if (varnum < 0 || varnum >= __INST_LAST) return NULL;
+ return g_variables+varnum*g_stringsize;
+}
+
+static void __stdcall setuservariable(const int varnum, const TCHAR *var)
+{
+ if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
+ lstrcpy(g_variables + varnum*g_stringsize, var);
+}
+
+#ifdef _UNICODE
+static int __stdcall PopStringA(char* ansiStr)
+{
+ wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, g_stringsize*sizeof(wchar_t));
+ int rval = popstring(wideStr);
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+ GlobalFree((HGLOBAL)wideStr);
+ return rval;
+}
+
+static void __stdcall PushStringA(const char* ansiStr)
+{
+ wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, g_stringsize*sizeof(wchar_t));
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+ pushtring(wideStr);
+ GlobalFree((HGLOBAL)wideStr);
+ return;
+}
+
+static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr)
+{
+ lstrcpyW(wideStr, getuservariable(varnum));
+}
+
+static void __stdcall GetUserVariableA(const int varnum, char* ansiStr)
+{
+ wchar_t* wideStr = getuservariable(varnum);
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+}
+
+static void __stdcall SetUserVariableA(const int varnum, const char* ansiStr)
+{
+ if (ansiStr != NULL && varnum >= 0 && varnum < __INST_LAST)
+ {
+ wchar_t* wideStr = g_variables + varnum * g_stringsize;
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+ }
+}
+
+#else
+// ANSI defs
+static int __stdcall PopStringW(wchar_t* wideStr)
+{
+ char* ansiStr = (char*) GlobalAlloc(GPTR, g_stringsize);
+ int rval = popstring(ansiStr);
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+ GlobalFree((HGLOBAL)ansiStr);
+ return rval;
+}
+
+static void __stdcall PushStringW(wchar_t* wideStr)
+{
+ char* ansiStr = (char*) GlobalAlloc(GPTR, g_stringsize);
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+ pushstring(ansiStr);
+ GlobalFree((HGLOBAL)ansiStr);
+}
+
+static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr)
+{
+ char* ansiStr = getuservariable(varnum);
+ MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
+}
+
+static void __stdcall GetUserVariableA(const int varnum, char* ansiStr)
+{
+ lstrcpyA(ansiStr, getuservariable(varnum));
+}
+
+static void __stdcall SetUserVariableW(const int varnum, const wchar_t* wideStr)
+{
+ if (wideStr != NULL && varnum >= 0 && varnum < __INST_LAST)
+ {
+ char* ansiStr = g_variables + varnum * g_stringsize;
+ WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
+ }
+}
+#endif
+
+static BOOL __stdcall IsUnicode(void)
+{
+#ifdef _UNICODE
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+static TCHAR* __stdcall AllocString()
+{
+ return (TCHAR*) GlobalAlloc(GPTR, g_stringsize*sizeof(TCHAR));
+}
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/exdllutil.h
@@ -0,0 +1,119 @@
+// Unicode support by Jim Park -- 08/23/2007
+// Jim Park: Should probably turn this into a nice class for C++ programs.
+
+#pragma once
+#include <windows.h>
+#include <tchar.h>
+// only include this file from one place in your DLL.
+// (it is all static, if you use it in two places it will fail)
+
+#define EXDLL_INIT() { \
+ g_stringsize=string_size; \
+ g_stacktop=stacktop; \
+ g_variables=variables; }
+
+// For page showing plug-ins
+#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8)
+#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd)
+
+/* Jim Park: This char is compared as an int value and therefore
+ it's fine as an ASCII. Do not need to change to wchar_t since
+ it will get the same integer value. */
+#define NOTIFY_BYE_BYE _T('x')
+
+typedef struct _stack_t {
+ struct _stack_t *next;
+ TCHAR text[1]; // this should be the length of string_size
+} stack_t;
+
+static unsigned int g_stringsize;
+static stack_t **g_stacktop;
+static TCHAR *g_variables;
+
+
+enum
+{
+INST_0, // $0
+INST_1, // $1
+INST_2, // $2
+INST_3, // $3
+INST_4, // $4
+INST_5, // $5
+INST_6, // $6
+INST_7, // $7
+INST_8, // $8
+INST_9, // $9
+INST_R0, // $R0
+INST_R1, // $R1
+INST_R2, // $R2
+INST_R3, // $R3
+INST_R4, // $R4
+INST_R5, // $R5
+INST_R6, // $R6
+INST_R7, // $R7
+INST_R8, // $R8
+INST_R9, // $R9
+INST_CMDLINE, // $CMDLINE
+INST_INSTDIR, // $INSTDIR
+INST_OUTDIR, // $OUTDIR
+INST_EXEDIR, // $EXEDIR
+INST_LANG, // $LANGUAGE
+__INST_LAST
+};
+
+typedef struct {
+ int autoclose;
+ int all_user_var;
+ int exec_error;
+ int abort;
+ int exec_reboot;
+ int reboot_called;
+ int XXX_cur_insttype; // deprecated
+ int XXX_insttype_changed; // deprecated
+ int silent;
+ int instdir_error;
+ int rtl;
+ int errlvl;
+ int alter_reg_view;
+} exec_flags_type;
+
+typedef struct {
+ exec_flags_type *exec_flags;
+ int (__stdcall *ExecuteCodeSegment)(int, HWND);
+ void (__stdcall *validate_filename)(TCHAR *);
+} extra_parameters;
+
+static int __stdcall popstring(TCHAR *str); // 0 on success, 1 on empty stack
+static void __stdcall pushstring(const TCHAR *str);
+static char * __stdcall getuservariable(const int varnum);
+static void __stdcall setuservariable(const int varnum, const TCHAR *var);
+
+#ifdef _UNICODE
+#define PopStringW(x) popstring(x)
+#define PushStringW(x) pushstring(x)
+#define SetUserVariableW(x,y) setuservariable(x,y)
+
+static int __stdcall PopStringA(char* ansiStr);
+static void __stdcall PushStringA(const char* ansiStr);
+static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr);
+static void __stdcall GetUserVariableA(const int varnum, char* ansiStr);
+static void __stdcall SetUserVariableA(const int varnum, const char* ansiStr);
+
+#else
+// ANSI defs
+
+#define PopStringA(x) popstring(x)
+#define PushStringA(x) pushstring(x)
+#define SetUserVariableA(x,y) setuservariable(x,y)
+
+static int __stdcall PopStringW(wchar_t* wideStr);
+static void __stdcall PushStringW(wchar_t* wideStr);
+static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr);
+static void __stdcall GetUserVariableA(const int varnum, char* ansiStr);
+static void __stdcall SetUserVariableW(const int varnum, const wchar_t* wideStr);
+
+#endif
+
+static BOOL __stdcall IsUnicode(void)
+static TCHAR* __stdcall AllocString();
+
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/extdll.inc
@@ -0,0 +1,145 @@
+;################################################################
+; ExtDLL header for MASM32
+;
+; Author: Ramon
+;
+; Obs: This header must be included after windows.inc and kernel32.inc
+; because it need the prototypes for lstrcpy, lstrcpyn,
+; GlobalAlloc and GlobalFree
+;
+;################################################################
+stack_t struct
+ next dd ?
+ text dd ? ; 1 DUP(?) ; this should be the length of string_size
+stack_t ends
+
+.const
+; For page showing plug-ins
+WM_NOTIFY_OUTER_NEXT equ (WM_USER+0x8)
+WM_NOTIFY_CUSTOM_READY equ (WM_USER+0xd)
+NOTIFY_BYE_BYE equ 'x'
+
+INST_0 EQU 0 ; $0
+INST_1 EQU 1 ; $1
+INST_2 EQU 2 ; $2
+INST_3 EQU 3 ; $3
+INST_4 EQU 4 ; $4
+INST_5 EQU 5 ; $5
+INST_6 EQU 6 ; $6
+INST_7 EQU 7 ; $7
+INST_8 EQU 8 ; $8
+INST_9 EQU 9 ; $9
+INST_R0 EQU 10 ; $R0
+INST_R1 EQU 11 ; $R1
+INST_R2 EQU 12 ; $R2
+INST_R3 EQU 13 ; $R3
+INST_R4 EQU 14 ; $R4
+INST_R5 EQU 15 ; $R5
+INST_R6 EQU 16 ; $R6
+INST_R7 EQU 17 ; $R7
+INST_R8 EQU 18 ; $R8
+INST_R9 EQU 19 ; $R9
+INST_CMDLINE EQU 20 ; $CMDLINE
+INST_INSTDIR EQU 21 ; $INSTDIR
+INST_OUTDIR EQU 22 ; $OUTDIR
+INST_EXEDIR EQU 23 ; $EXEDIR
+INST_LANG EQU 24 ; $LANGUAGE
+__INST_LAST EQU 25
+
+.data?
+g_stringsize dd ?
+g_stacktop dd ?
+g_variables dd ?
+
+m2m MACRO M1, M2
+ push M2
+ pop M1
+ENDM
+
+EXDLL_INIT MACRO
+ m2m g_stringsize, string_size
+ m2m g_stacktop, stacktop
+ m2m g_variables, variables
+ENDM
+
+.code
+
+; utility functions (not required but often useful)
+popstring proc uses edi pStr:DWORD
+
+ LOCAL th:DWORD
+
+ mov edi, g_stacktop
+ cmp edi, 0
+ jz STACK_ERR
+ mov edi, [edi]
+ cmp edi, 0
+ jz STACK_ERR
+
+ ASSUME edi:PTR stack_t
+ invoke lstrcpy, pStr, ADDR [edi].text
+ mov th , edi
+ mov edi, [edi].next
+ mov eax, g_stacktop
+ mov [eax], edi
+ invoke GlobalFree, th
+ ASSUME edi:PTR NOTHING
+ mov eax, 0
+ ret
+
+STACK_ERR:
+ mov eax, 1
+ ret
+
+popstring endp
+
+pushstring proc uses edi pStr:DWORD
+
+ cmp g_stacktop, 0
+ jz STACK_ERR
+
+ mov eax, sizeof stack_t
+ add eax, g_stringsize
+ invoke GlobalAlloc, GPTR, eax
+
+ mov edi, eax
+ assume edi:PTR stack_t
+
+ invoke lstrcpyn, ADDR [edi].text, pStr, g_stringsize
+ mov eax, g_stacktop
+ push DWORD PTR[eax]
+ mov [eax], edi
+ pop eax
+ ;lea edi, [edi].next ; Not needed [edi].next == edi
+ mov DWORD PTR[edi], eax
+ ASSUME edi:PTR NOTHING
+
+STACK_ERR:
+ ret
+
+pushstring endp
+
+getuservariable proc varnum:DWORD
+
+ .if varnum < 0 || varnum >= __INST_LAST
+ xor eax, eax
+ .else
+ mov eax, varnum
+ imul eax, g_stringsize
+ add eax, g_variables
+ .endif
+ ret
+
+getuservariable endp
+
+setuservariable proc varnum:DWORD, var:DWORD
+
+ .if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
+ mov eax, varnum
+ imul eax, g_stringsize
+ add eax, g_variables
+ invoke lstrcpy, eax, var
+ .endif
+ ret
+
+setuservariable endp
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/nsis.pas
@@ -0,0 +1,126 @@
+{
+ Original Code from
+ (C) 2001 - Peter Windridge
+
+ Code in seperate unit and some changes
+ 2003 by Bernhard Mayer
+
+ Fixed and formatted by Brett Dever
+ http://editor.nfscheats.com/
+
+ simply include this unit in your plugin project and export
+ functions as needed
+}
+
+
+unit nsis;
+
+interface
+
+uses
+ windows;
+
+type
+ VarConstants = (
+ INST_0, // $0
+ INST_1, // $1
+ INST_2, // $2
+ INST_3, // $3
+ INST_4, // $4
+ INST_5, // $5
+ INST_6, // $6
+ INST_7, // $7
+ INST_8, // $8
+ INST_9, // $9
+ INST_R0, // $R0
+ INST_R1, // $R1
+ INST_R2, // $R2
+ INST_R3, // $R3
+ INST_R4, // $R4
+ INST_R5, // $R5
+ INST_R6, // $R6
+ INST_R7, // $R7
+ INST_R8, // $R8
+ INST_R9, // $R9
+ INST_CMDLINE, // $CMDLINE
+ INST_INSTDIR, // $INSTDIR
+ INST_OUTDIR, // $OUTDIR
+ INST_EXEDIR, // $EXEDIR
+ INST_LANG, // $LANGUAGE
+ __INST_LAST
+ );
+ TVariableList = INST_0..__INST_LAST;
+ pstack_t = ^stack_t;
+ stack_t = record
+ next: pstack_t;
+ text: PChar;
+ end;
+
+var
+ g_stringsize: integer;
+ g_stacktop: ^pstack_t;
+ g_variables: PChar;
+ g_hwndParent: HWND;
+
+procedure Init(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer);
+function PopString(): string;
+procedure PushString(const str: string='');
+function GetUserVariable(const varnum: TVariableList): string;
+procedure SetUserVariable(const varnum: TVariableList; const value: string);
+procedure NSISDialog(const text, caption: string; const buttons: integer);
+
+implementation
+
+procedure Init(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer);
+begin
+ g_stringsize := string_size;
+ g_hwndParent := hwndParent;
+ g_stacktop := stacktop;
+ g_variables := variables;
+end;
+
+function PopString(): string;
+var
+ th: pstack_t;
+begin
+ if integer(g_stacktop^) <> 0 then begin
+ th := g_stacktop^;
+ Result := PChar(@th.text);
+ g_stacktop^ := th.next;
+ GlobalFree(HGLOBAL(th));
+ end;
+end;
+
+procedure PushString(const str: string='');
+var
+ th: pstack_t;
+begin
+ if integer(g_stacktop) <> 0 then begin
+ th := pstack_t(GlobalAlloc(GPTR, SizeOf(stack_t) + g_stringsize));
+ lstrcpyn(@th.text, PChar(str), g_stringsize);
+ th.next := g_stacktop^;
+ g_stacktop^ := th;
+ end;
+end;
+
+function GetUserVariable(const varnum: TVariableList): string;
+begin
+ if (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then
+ Result := g_variables + integer(varnum) * g_stringsize
+ else
+ Result := '';
+end;
+
+procedure SetUserVariable(const varnum: TVariableList; const value: string);
+begin
+ if (value <> '') and (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then
+ lstrcpy(g_variables + integer(varnum) * g_stringsize, PChar(value))
+end;
+
+procedure NSISDialog(const text, caption: string; const buttons: integer);
+begin
+ MessageBox(g_hwndParent, PChar(text), PChar(caption), buttons);
+end;
+
+begin
+end.
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ExDLL/tchar.h
@@ -0,0 +1,210 @@
+/*
+ * tchar.h
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ *
+ * For Unicode support by Jim Park -- 08/30/2007
+ */
+
+// Jim Park: Only those we use are listed here.
+
+#pragma once
+
+#ifdef _UNICODE
+
+#ifndef _T
+#define __T(x) L ## x
+#define _T(x) __T(x)
+#define _TEXT(x) __T(x)
+#endif
+typedef wchar_t TCHAR;
+typedef wchar_t _TUCHAR;
+
+// program
+#define _tmain wmain
+#define _tWinMain wWinMain
+#define _tenviron _wenviron
+#define __targv __wargv
+
+// printfs
+#define _ftprintf fwprintf
+#define _sntprintf _snwprintf
+#define _stprintf _swprintf
+#define _tprintf wprintf
+#define _vftprintf vfwprintf
+#define _vsntprintf _vsnwprintf
+#define _vstprintf _vswprintf
+
+// scanfs
+#define _tscanf wscanf
+#define _stscanf swscanf
+
+// string manipulations
+#define _tcscat wcscat
+#define _tcschr wcschr
+#define _tcsclen wcslen
+#define _tcscpy wcscpy
+#define _tcsdup _wcsdup
+#define _tcslen wcslen
+#define _tcsnccpy wcsncpy
+#define _tcsncpy wcsncpy
+#define _tcsrchr wcsrchr
+#define _tcsstr wcsstr
+#define _tcstok wcstok
+
+// string comparisons
+#define _tcscmp wcscmp
+#define _tcsicmp _wcsicmp
+#define _tcsncicmp _wcsnicmp
+#define _tcsncmp wcsncmp
+#define _tcsnicmp _wcsnicmp
+
+// upper / lower
+#define _tcslwr _wcslwr
+#define _tcsupr _wcsupr
+#define _totlower towlower
+#define _totupper towupper
+
+// conversions to numbers
+#define _tcstoi64 _wcstoi64
+#define _tcstol wcstol
+#define _tcstoul wcstoul
+#define _tstof _wtof
+#define _tstoi _wtoi
+#define _tstoi64 _wtoi64
+#define _ttoi _wtoi
+#define _ttoi64 _wtoi64
+#define _ttol _wtol
+
+// conversion from numbers to strings
+#define _itot _itow
+#define _ltot _ltow
+#define _i64tot _i64tow
+#define _ui64tot _ui64tow
+
+// file manipulations
+#define _tfopen _wfopen
+#define _topen _wopen
+#define _tremove _wremove
+#define _tunlink _wunlink
+
+// reading and writing to i/o
+#define _fgettc fgetwc
+#define _fgetts fgetws
+#define _fputts fputws
+#define _gettchar getwchar
+
+// directory
+#define _tchdir _wchdir
+
+// environment
+#define _tgetenv _wgetenv
+#define _tsystem _wsystem
+
+// time
+#define _tcsftime wcsftime
+
+#else // ANSI
+
+#ifndef _T
+#define _T(x) x
+#define _TEXT(x) x
+#endif
+typedef char TCHAR;
+typedef unsigned char _TUCHAR;
+
+// program
+#define _tmain main
+#define _tWinMain WinMain
+#define _tenviron environ
+#define __targv __argv
+
+// printfs
+#define _ftprintf fprintf
+#define _sntprintf _snprintf
+#define _stprintf sprintf
+#define _tprintf printf
+#define _vftprintf vfprintf
+#define _vsntprintf _vsnprintf
+#define _vstprintf vsprintf
+
+// scanfs
+#define _tscanf scanf
+#define _stscanf sscanf
+
+// string manipulations
+#define _tcscat strcat
+#define _tcschr strchr
+#define _tcsclen strlen
+#define _tcscnlen strnlen
+#define _tcscpy strcpy
+#define _tcsdup _strdup
+#define _tcslen strlen
+#define _tcsnccpy strncpy
+#define _tcsrchr strrchr
+#define _tcsstr strstr
+#define _tcstok strtok
+
+// string comparisons
+#define _tcscmp strcmp
+#define _tcsicmp _stricmp
+#define _tcsncmp strncmp
+#define _tcsncicmp _strnicmp
+#define _tcsnicmp _strnicmp
+
+// upper / lower
+#define _tcslwr _strlwr
+#define _tcsupr _strupr
+
+#define _totupper toupper
+#define _totlower tolower
+
+// conversions to numbers
+#define _tcstol strtol
+#define _tcstoul strtoul
+#define _tstof atof
+#define _tstoi atoi
+#define _tstoi64 _atoi64
+#define _tstoi64 _atoi64
+#define _ttoi atoi
+#define _ttoi64 _atoi64
+#define _ttol atol
+
+// conversion from numbers to strings
+#define _i64tot _i64toa
+#define _itot _itoa
+#define _ltot _ltoa
+#define _ui64tot _ui64toa
+
+// file manipulations
+#define _tfopen fopen
+#define _topen _open
+#define _tremove remove
+#define _tunlink _unlink
+
+// reading and writing to i/o
+#define _fgettc fgetc
+#define _fgetts fgets
+#define _fputts fputs
+#define _gettchar getchar
+
+// directory
+#define _tchdir _chdir
+
+// environment
+#define _tgetenv getenv
+#define _tsystem system
+
+// time
+#define _tcsftime strftime
+
+#endif
+
+// is functions (the same in Unicode / ANSI)
+#define _istgraph isgraph
+#define _istascii __isascii
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/README
@@ -0,0 +1,56 @@
+These directories contain modified source code to the NSIS Plugins used by the
+Windows installers. All of these plugin dll's have been compiled with VC6.
+
+NSIS project page: http://nsis.sourceforge.net/
+NSIS Unicode port project page: http://www.scratchpaper.com/
+
+APPLICABLE LICENSES
+-------------------
+* All NSIS source code, plug-ins, documentation, examples, header files and
+ graphics, with the exception of the compression modules and where otherwise
+ noted, are licensed under the zlib/libpng license.
+
+* The zlib compression module for NSIS is licensed under the zlib/libpng
+ license.
+
+* The bzip2 compression module for NSIS is licensed under the bzip2 license.
+
+* The LZMA compression module for NSIS is licensed under the Common Public
+ License version 1.0.
+
+-------------------------------------------------------------------------------
+
+ExDLL NSIS Unicode source 2.38.1 for plugin projects
+http://www.scratchpaper.com/
+These files are required to compile the nsProcess and ShellLink plugins. No
+changes were made to these files.
+
+-------------------------------------------------------------------------------
+
+nsProcess NSIS plugin v1.5
+http://nsis.sourceforge.net/NsProcess_plugin
+Unicode support was added for this plugin. A diff of the changes to the source
+are available at:
+https://bugzilla.mozilla.org/show_bug.cgi?id=473348
+https://bugzilla.mozilla.org/attachment.cgi?id=357012
+
+-------------------------------------------------------------------------------
+
+ShellLink NSIS plugin v1.1
+http://nsis.sourceforge.net/ShellLink_plug-in
+Unicode support was added for this plugin. A diff of the changes to the source
+are available at:
+https://bugzilla.mozilla.org/show_bug.cgi?id=473348
+https://bugzilla.mozilla.org/attachment.cgi?id=357058
+
+-------------------------------------------------------------------------------
+
+UAC NSIS plugin v0.0.10a
+http://nsis.sourceforge.net/UAC_plug-in
+The source files already support Unicode but there is no Unicode distribution
+so the plugin had to be compiled with Unicode support. A diff of the changes to
+the source are available at:
+https://bugzilla.mozilla.org/show_bug.cgi?id=473348
+https://bugzilla.mozilla.org/attachment.cgi?id=357014
+
+-------------------------------------------------------------------------------
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ShellLink/ConvFunc.h
@@ -0,0 +1,242 @@
+/*****************************************************************
+ * Conversion functions header v1.2 *
+ * *
+ * 2005 Shengalts Aleksander aka Instructor (Shengalts@mail.ru) *
+ * *
+ * *
+ *Functions: *
+ * xatoi, xitoa, hex2dec, dec2hex, str2hex, hex2str *
+ * *
+ *Usage: *
+ *#define xatoi //insert xatoi function *
+ *#define xitoa //insert xitoa function *
+ *#include "ConvFunc.h" *
+ *****************************************************************/
+
+#ifndef _CONVFUNC_
+#define _CONVFUNC_
+
+
+/********************************************************************
+ *
+ * xatoi
+ *
+ *Converts char to int.
+ *
+ *[in] char *str -string number
+ *
+ *Returns: integer
+ *
+ *Examples:
+ * xatoi("45") == 45;
+ * xatoi(" -0045:value") == -45;
+ ********************************************************************/
+#ifdef xatoi
+#define xatoi_INCLUDED
+#undef xatoi
+int xatoi(TCHAR *str)
+{
+ BOOL bMinus=FALSE;
+ int nNumber=0;
+
+ while (*str == TEXT(' '))
+ ++str;
+ if (*str == TEXT('-'))
+ {
+ bMinus=TRUE;
+ ++str;
+ }
+ for (; (*str != TEXT('\0')) && (*str >= TEXT('0')) && (*str <= TEXT('9')); ++str)
+ nNumber=(nNumber * 10) + (*str - 48);
+ if (bMinus == TRUE)
+ nNumber=0 - nNumber;
+ return nNumber;
+}
+#endif
+
+/********************************************************************
+ *
+ * xitoa [API: wsprintf(szResult, "%d", 45)]
+ *
+ *Converts int to char.
+ *
+ *[out] char *str -string number
+ *[in] int number -integer
+ *
+ *Examples:
+ * xitoa(szResult, 45); //szResult == "45"
+ * xitoa(szResult, -45); //szResult == "-45"
+ ********************************************************************/
+#ifdef xitoa
+#define xitoa_INCLUDED
+#undef xitoa
+void xitoa(char *str, int number)
+{
+ int nCapacity=0;
+ int nTmp=number;
+
+ if (number == 0)
+ {
+ str[0]='0';
+ str[1]='\0';
+ return;
+ }
+ if (number < 0)
+ {
+ str[0]='-';
+ number=0 - number;
+ ++nCapacity;
+ }
+ for (; (nTmp != 0); ++nCapacity)
+ nTmp=nTmp/10;
+ for (str[nCapacity--]='\0'; (number != 0); --nCapacity)
+ {
+ str[nCapacity]=(number % 10) + 48;
+ number=number/10;
+ }
+}
+#endif
+
+/********************************************************************
+ *
+ * hex2dec
+ *
+ *Converts hex value to decimal.
+ *
+ *[in] char *hex -hex value
+ *
+ *Returns: integer
+ *
+ *Examples:
+ * hex2dec("A1F") == 2591;
+ ********************************************************************/
+#if defined hex2dec || defined hex2str
+#define hex2dec_INCLUDED
+#undef hex2dec
+unsigned hex2dec(char *hex)
+{
+ int a;
+ int b=0;
+
+ while (1)
+ {
+ a=*hex++;
+ if (a >= '0' && a <= '9') a-='0';
+ else if (a >= 'a' && a <= 'f') a-='a'-10;
+ else if (a >= 'A' && a <= 'F') a-='A'-10;
+ else return b;
+
+ if (*hex) b=(b + a) * 16;
+ else return (b + a);
+ }
+}
+#endif
+
+/********************************************************************
+ *
+ * dec2hex [API: wsprintf(szResult, "%02x", 2591)]
+ *
+ *Converts decimal to hex value.
+ *
+ *[in] DWORD dec -positive integer
+ *[out] char *hex -hex value (output)
+ *[in] BOOL lowercase -if TRUE hexadecimal value in lowercase
+ * if FALSE in uppercase.
+ *[in] DWORD width -minimum number of characters to the output
+ *
+ *Examples:
+ * dec2hex(2591, szResult, FALSE, 2); //szResult == "A1F"
+ * dec2hex(10, szResult, TRUE, 2); //szResult == "0a"
+ ********************************************************************/
+#if defined dec2hex || defined str2hex
+#define dec2hex_INCLUDED
+#undef dec2hex
+void dec2hex(unsigned int dec, char *hex, BOOL lowercase, unsigned int width)
+{
+ unsigned int a=dec;
+ unsigned int b=0;
+ unsigned int c=0;
+ char d='1';
+ if (a == 0) d='0';
+
+ while (a)
+ {
+ b=a % 16;
+ a=a / 16;
+ if (b < 10) hex[c++]=b + '0';
+ else if (lowercase == TRUE) hex[c++]=b + 'a' - 10;
+ else hex[c++]=b + 'A' - 10;
+ }
+ while (width > c) hex[c++]='0';
+ hex[c]='\0';
+
+ if (d == '1')
+ for (b=0, --c; b < c; d=hex[b], hex[b++]=hex[c], hex[c--]=d);
+}
+#endif
+
+/********************************************************************
+ *
+ * str2hex
+ *
+ *Converts string to hex values.
+ *
+ *[in] unsigned char *str -string
+ *[out] char *hex -hex string
+ *[in] BOOL lowercase -if TRUE hexadecimal value in lowercase
+ * if FALSE in uppercase.
+ *[in] unsigned int bytes -number of characters in string
+ *
+ *Examples:
+ * str2hex((unsigned char *)"Some Text", szResult, TRUE, lstrlen("Some Text")); //szResult == "536f6d652054657874"
+ ********************************************************************/
+#if defined str2hex && defined dec2hex_INCLUDED
+#define str2hex_INCLUDED
+#undef str2hex
+void str2hex(unsigned char *str, char *hex, BOOL lowercase, unsigned int bytes)
+{
+ char a[16];
+ unsigned int b=0;
+
+ for (hex[0]='\0'; b < bytes; ++b)
+ {
+ //wsprintf(a, "%02x", (unsigned int)str[b]);
+ dec2hex((unsigned int)str[b], a, lowercase, 2);
+ lstrcat(hex, a);
+ }
+}
+#endif
+
+/********************************************************************
+ *
+ * hex2str
+ *
+ *Converts hex values to string.
+ *
+ *[in] char *hex -hex string
+ *[out] char *str -string
+ *
+ *Examples:
+ * hex2str("536f6d652054657874", szResult); //szResult == "Some Text"
+ ********************************************************************/
+#if defined hex2str && defined hex2dec_INCLUDED
+#define hex2str_INCLUDED
+#undef hex2str
+void hex2str(char *hex, char *str)
+{
+ char a[4];
+
+ while (*hex)
+ {
+ a[0]=*hex;
+ a[1]=*++hex;
+ a[2]='\0';
+
+ if (*hex++) *str++=hex2dec(a);
+ else break;
+ }
+ *str='\0';
+}
+#endif
+
+#endif //_CONVFUNC_
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ShellLink/Readme.html
@@ -0,0 +1,229 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
+<HTML><HEAD><TITLE>ShellLink</TITLE>
+<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
+<STYLE type=text/css>
+BODY {
+ PADDING-RIGHT: 10px; PADDING-LEFT: 10px; FONT-WEIGHT: normal; FONT-SIZE: 10pt; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; BACKGROUND-COLOR: #f0f0f0
+}
+CENTER {
+ TEXT-ALIGN: center
+}
+TABLE {
+ MARGIN: auto; BACKGROUND-COLOR: #ffffff; TEXT-ALIGN: left
+}
+.maintable {
+ BORDER-RIGHT: #376eab 2px solid; BORDER-TOP: #376eab 2px solid; BORDER-LEFT: #376eab 2px solid; BORDER-BOTTOM: #376eab 2px solid
+}
+.margin {
+ MARGIN: 20px
+}
+.text {
+ MARGIN: 20px
+}
+.bold {
+ FONT-WEIGHT: bold
+}
+.italic {
+ FONT-STYLE: italic
+}
+.bigheader {
+ FONT-SIZE: 24pt; MARGIN: 10px; COLOR: #333333; TEXT-ALIGN: center
+}
+.header {
+ FONT-SIZE: 14pt; COLOR: #7a7272
+}
+.subheader {
+ FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030
+}
+.footer {
+ FONT-SIZE: 8pt; MARGIN: 5px; COLOR: #909090; TEXT-ALIGN: right
+}
+A:link {
+ COLOR: #294f75; TEXT-DECORATION: none
+}
+A:visited {
+ COLOR: #294f75; TEXT-DECORATION: none
+}
+A:active {
+ COLOR: #294f75; TEXT-DECORATION: none
+}
+A:hover {
+ COLOR: #182634; TEXT-DECORATION: none
+}
+</STYLE>
+
+<META content="MSHTML 6.00.2800.1264" name=GENERATOR></HEAD>
+<BODY>
+<DIV class=center>
+<TABLE class=maintable cellSpacing=0 cellPadding=0 width=750>
+ <TBODY>
+ <TR>
+ <TD>
+ <TABLE cellSpacing=0 cellPadding=0>
+ <TBODY>
+ <TR>
+ <TD>
+ <P class=bigheader>ShellLink </P></TD></TR>
+ <TR>
+ <TD>
+<DIV style="MARGIN: 20px">
+<P style="FONT-SIZE: 14pt; COLOR: #7a7272">Introduction</P>
+<P style="MARGIN: 20px">ShellLink is a NSIS plugin that allows you to read and write shell link (.lnk) files.</P>
+<P style="FONT-SIZE: 14pt; COLOR: #7a7272">How to use</P>
+<P style="MARGIN: 20px">Make sure you have a valid path (link.lnk) to the shell link file.</P>
+
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Get Shortcut Working Directory</P>
+<PRE style="MARGIN: 20px">ShellLink::GetShortCutWorkingDirectory link.lnk
+Pop $0
+
+$0=C:\Program Files\MyProgram
+</PRE>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Get Shortcut Target</P>
+<PRE style="MARGIN: 20px">ShellLink::GetShortCutTarget link.lnk
+Pop $0
+
+$0=C:\Program Files\MyProgram\run.exe
+</PRE>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Get Shortcut Arguments </P>
+<PRE style="MARGIN: 20px">ShellLink::GetShortCutArgs link.lnk
+Pop $0
+
+$0=/s /d=1
+</PRE>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Get Shortcut Icon Location </P>
+<PRE style="MARGIN: 20px">ShellLink::GetShortCutIconLocation link.lnk
+Pop $0
+
+$0=C:\Program Files\MyProgram\run.dll
+</PRE>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Get Shortcut Icon Index </P>
+<PRE style="MARGIN: 20px">ShellLink::GetShortCutIconIndex link.lnk
+Pop $0
+
+$0=3
+</PRE>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Get Shortcut Show Mode </P>
+<PRE style="MARGIN: 20px">ShellLink::GetShortCutShowMode link.lnk
+Pop $0
+
+$0=0 (SW_HIDE)
+$0=1 (SW_SHOWNORMAL or SW_NORMAL)
+$0=2 (SW_SHOWMINIMIZED)
+$0=3 (SW_SHOWMAXIMIZED or SW_MAXIMIZE)
+$0=4 (SW_SHOWNOACTIVATE)
+$0=5 (SW_SHOW)
+$0=6 (SW_MINIMIZE)
+$0=7 (SW_SHOWMINNOACTIVE)
+$0=8 (SW_SHOWNA)
+$0=9 (SW_RESTORE)
+$0=10 (SW_SHOWDEFAULT)
+$0=11 (SW_FORCEMINIMIZE or SW_MAX)
+</PRE>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Get Shortcut Hot Keys</P>
+<PRE style="MARGIN: 20px">ShellLink::GetShortCutHotkey link.lnk
+Pop $0
+
+$0=634
+</PRE>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Get Shortcut Description</P>
+<PRE style="MARGIN: 20px">ShellLink::GetShortCutDescription link.lnk
+Pop $0
+
+$0=My Shortcut Description
+</PRE>
+
+<BR>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Set Shortcut Working Directory</P>
+<PRE style="MARGIN: 20px">ShellLink::SetShortCutWorkingDirectory link.lnk directory
+Pop $0
+
+$0=0 -no errors
+$0=-1 -error
+</PRE>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Set Shortcut Target</P>
+<PRE style="MARGIN: 20px">ShellLink::SetShortCutTarget link.lnk target.file
+Pop $0
+
+$0=0 -no errors
+$0=-1 -error
+</PRE>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Set Shortcut Arguments</P>
+<PRE style="MARGIN: 20px">ShellLink::SetShortCutArgs link.lnk parameters
+Pop $0
+
+$0=0 -no errors
+$0=-1 -error
+</PRE>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Set Shortcut Icon Location</P>
+<PRE style="MARGIN: 20px">ShellLink::SetShortCutIconLocation link.lnk icon.file
+Pop $0
+
+$0=0 -no errors
+$0=-1 -error
+</PRE>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Set Shortcut Icon Index</P>
+<PRE style="MARGIN: 20px">ShellLink::SetShortCutIconIndex link.lnk icon_index_number
+Pop $0
+
+$0=0 -no errors
+$0=-1 -error
+</PRE>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Set Shortcut Show Mode</P>
+<PRE style="MARGIN: 20px">ShellLink::SetShortCutShowMode link.lnk start_options
+Pop $0
+
+$0=0 -no errors
+$0=-1 -error
+</PRE>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Set Shortcut Hot Keys</P>
+<PRE style="MARGIN: 20px">ShellLink::SetShortCutHotkey link.lnk keyboard_shortcut
+Pop $0
+
+$0=0 -no errors
+$0=-1 -error
+</PRE>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">Set Shortcut Description</P>
+<PRE style="MARGIN: 20px">ShellLink::SetShortCutDescription link.lnk description
+Pop $0
+
+$0=0 -no errors
+$0=-1 -error
+</PRE>
+
+<P style="FONT-SIZE: 14pt; COLOR: #7a7272">Source code</P>
+<P style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN: 20px; COLOR: #303030">NSIS plug-in (C++)</P>
+<P style="MARGIN: 20px">A download link to the source and DLL of this NSIS plug-in
+can be found below.</P>
+<P style="FONT-SIZE: 14pt; COLOR: #7a7272">Version history</P>
+<UL>
+ <LI>1.1 by Shengalts Aleksander aka Instructor (Shengalts@mail.ru)
+ <BR> -code has been rewritten
+ <BR> -added functions to change shell link information
+ <BR> -reduced dll size 44Kb -> 4Kb
+ <BR> -documentation updated
+ <LI>1.0 first release of ShellLink.
+</UL>
+<P style="FONT-SIZE: 14pt; COLOR: #7a7272">Credits</P>
+<P style="MARGIN: 20px">Written and documented by Angelo Mandato </P>
+<P style="FONT-SIZE: 14pt; COLOR: #7a7272">License</P>
+<PRE style="MARGIN: 20px">© 2004 Angelo Mandato
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute
+it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented;
+ you must not claim that you wrote the original software.
+ If you use this software in a product, an acknowledgment in the
+ product documentation would be appreciated but is not required.
+2. Altered versions must be plainly marked as such,
+ and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any distribution.
+</PRE>
+<P style="FONT-SIZE: 14pt; COLOR: #7a7272">Download</P>
+<P style="MARGIN: 20px"><a href="http://www.spaceblue.com/downloads/shelllink.zip">http://www.spaceblue.com/downloads/shelllink.zip</a></P>
+ </DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></BODY></HTML>
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ShellLink/ShellLink.cpp
@@ -0,0 +1,350 @@
+/*
+Module : ShellLink.cpp
+Purpose: NSIS Plug-in for retriving shell link information
+Created: 12/16/2003
+Last Update: 01/14/2004
+
+Copyright (c) 2004 Angelo Mandato.
+See ShellLink.html for more information
+
+
+Modified: 21/09/2005
+Author: Shengalts Aleksander aka Instructor (Shengalts@mail.ru)
+Changes: -code has been rewritten
+ -added functions to change shell link information
+ -reduced dll size 44Kb -> 4Kb
+*/
+
+#define UNICODE
+#define _UNICODE
+
+// Uncomment for debugging message boxes
+//#define SHELLLINK_DEBUG
+
+#include <windows.h>
+#include <shlobj.h>
+
+#define xatoi
+#include "ConvFunc.h"
+
+#define MAX_STRLEN 1024
+#define SHELLLINKTYPE_GETARGS 1
+#define SHELLLINKTYPE_GETDESC 2
+#define SHELLLINKTYPE_GETHOTKEY 3
+#define SHELLLINKTYPE_GETICONLOC 4
+#define SHELLLINKTYPE_GETICONINDEX 5
+#define SHELLLINKTYPE_GETPATH 6
+#define SHELLLINKTYPE_GETSHOWMODE 7
+#define SHELLLINKTYPE_GETWORKINGDIR 8
+#define SHELLLINKTYPE_SETARGS 9
+#define SHELLLINKTYPE_SETDESC 10
+#define SHELLLINKTYPE_SETHOTKEY 11
+#define SHELLLINKTYPE_SETICONLOC 12
+#define SHELLLINKTYPE_SETICONINDEX 13
+#define SHELLLINKTYPE_SETPATH 14
+#define SHELLLINKTYPE_SETSHOWMODE 15
+#define SHELLLINKTYPE_SETWORKINGDIR 16
+
+typedef struct _stack_t {
+ struct _stack_t *next;
+ TCHAR text[MAX_STRLEN];
+} stack_t;
+
+stack_t **g_stacktop;
+unsigned int g_stringsize;
+TCHAR *g_variables;
+TCHAR szBuf[MAX_STRLEN]=TEXT("");
+TCHAR szBuf2[MAX_STRLEN]=TEXT("");
+int nBuf;
+WORD wHotkey;
+
+void ShortCutData(int nType, HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop);
+int popstring(TCHAR *str);
+void pushstring(TCHAR *str);
+
+//Get
+extern "C" void __declspec(dllexport) GetShortCutArgs(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_GETARGS, hwndParent, string_size, variables, stacktop);
+}
+
+extern "C" void __declspec(dllexport) GetShortCutDescription(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_GETDESC, hwndParent, string_size, variables, stacktop);
+}
+
+extern "C" void __declspec(dllexport) GetShortCutHotkey(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_GETHOTKEY, hwndParent, string_size, variables, stacktop);
+}
+
+extern "C" void __declspec(dllexport) GetShortCutIconLocation(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_GETICONLOC, hwndParent, string_size, variables, stacktop);
+}
+
+extern "C" void __declspec(dllexport) GetShortCutIconIndex(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_GETICONINDEX, hwndParent, string_size, variables, stacktop);
+}
+
+extern "C" void __declspec(dllexport) GetShortCutTarget(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_GETPATH, hwndParent, string_size, variables, stacktop);
+}
+
+extern "C" void __declspec(dllexport) GetShortCutShowMode(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_GETSHOWMODE, hwndParent, string_size, variables, stacktop);
+}
+
+extern "C" void __declspec(dllexport) GetShortCutWorkingDirectory(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_GETWORKINGDIR, hwndParent, string_size, variables, stacktop);
+}
+
+//Set
+extern "C" void __declspec(dllexport) SetShortCutArgs(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_SETARGS, hwndParent, string_size, variables, stacktop);
+}
+
+extern "C" void __declspec(dllexport) SetShortCutDescription(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_SETDESC, hwndParent, string_size, variables, stacktop);
+}
+
+extern "C" void __declspec(dllexport) SetShortCutHotkey(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_SETHOTKEY, hwndParent, string_size, variables, stacktop);
+}
+
+extern "C" void __declspec(dllexport) SetShortCutIconLocation(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_SETICONLOC, hwndParent, string_size, variables, stacktop);
+}
+
+extern "C" void __declspec(dllexport) SetShortCutIconIndex(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_SETICONINDEX, hwndParent, string_size, variables, stacktop);
+}
+
+extern "C" void __declspec(dllexport) SetShortCutTarget(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_SETPATH, hwndParent, string_size, variables, stacktop);
+}
+
+extern "C" void __declspec(dllexport) SetShortCutShowMode(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+
+ ShortCutData(SHELLLINKTYPE_SETSHOWMODE, hwndParent, string_size, variables, stacktop);
+}
+
+extern "C" void __declspec(dllexport) SetShortCutWorkingDirectory(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ ShortCutData(SHELLLINKTYPE_SETWORKINGDIR, hwndParent, string_size, variables, stacktop);
+}
+
+void ShortCutData(int nType, HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
+{
+ g_stringsize=string_size;
+ g_stacktop=stacktop;
+ g_variables=variables;
+ {
+ HRESULT hRes;
+ IShellLink* m_psl;
+ IPersistFile* m_ppf;
+
+ popstring(szBuf);
+ if (nType > SHELLLINKTYPE_GETWORKINGDIR) popstring(szBuf2);
+
+ hRes=CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*) &m_psl);
+ if (hRes == S_OK)
+ {
+ hRes=m_psl->QueryInterface(IID_IPersistFile, (LPVOID*) &m_ppf);
+ if (hRes == S_OK)
+ {
+#ifdef UNICODE
+ hRes=m_ppf->Load(szBuf, STGM_READWRITE);
+#else
+ WCHAR wszPath[MAX_PATH];
+ MultiByteToWideChar(CP_ACP, 0, szBuf, -1, wszPath, MAX_PATH);
+
+ hRes=m_ppf->Load(wszPath, STGM_READWRITE);
+#endif
+ if (hRes == S_OK)
+ {
+ if (nType <= SHELLLINKTYPE_GETWORKINGDIR)
+ {
+ //Get
+ switch(nType)
+ {
+ case SHELLLINKTYPE_GETARGS:
+ {
+ hRes=m_psl->GetArguments(szBuf, MAX_PATH);
+ if (hRes != S_OK) szBuf[0]=TEXT('\0');
+ }; break;
+ case SHELLLINKTYPE_GETDESC:
+ {
+ hRes=m_psl->GetDescription(szBuf, MAX_PATH);
+ if (hRes != S_OK) szBuf[0]=TEXT('\0');
+ }; break;
+ case SHELLLINKTYPE_GETHOTKEY:
+ {
+ hRes=m_psl->GetHotkey(&wHotkey);
+ if (hRes == S_OK) wsprintf(szBuf, TEXT("%d"), wHotkey);
+ else szBuf[0]=TEXT('\0');
+ }; break;
+ case SHELLLINKTYPE_GETICONLOC:
+ {
+ hRes=m_psl->GetIconLocation(szBuf, MAX_PATH, &nBuf);
+ if (hRes != S_OK) szBuf[0]=TEXT('\0');
+ }; break;
+ case SHELLLINKTYPE_GETICONINDEX:
+ {
+ hRes=m_psl->GetIconLocation(szBuf, MAX_PATH, &nBuf);
+ if (hRes == S_OK) wsprintf(szBuf, TEXT("%d"), nBuf);
+ else szBuf[0]=TEXT('\0');
+ }; break;
+ case SHELLLINKTYPE_GETPATH:
+ {
+ WIN32_FIND_DATA fd;
+
+ hRes=m_psl->GetPath(szBuf, MAX_PATH, &fd, SLGP_UNCPRIORITY);
+ if (hRes != S_OK) szBuf[0]=TEXT('\0');
+ }; break;
+ case SHELLLINKTYPE_GETSHOWMODE:
+ {
+ hRes=m_psl->GetShowCmd(&nBuf);
+ if (hRes == S_OK) wsprintf(szBuf, TEXT("%d"), nBuf);
+ else szBuf[0]=TEXT('\0');
+ }; break;
+ case SHELLLINKTYPE_GETWORKINGDIR:
+ {
+ hRes=m_psl->GetWorkingDirectory(szBuf, MAX_PATH);
+ if (hRes != S_OK) szBuf[0]=TEXT('\0');
+ }; break;
+ }
+ }
+ else
+ {
+ //Set
+ switch(nType)
+ {
+ case SHELLLINKTYPE_SETARGS:
+ {
+ hRes=m_psl->SetArguments(szBuf2);
+ }; break;
+ case SHELLLINKTYPE_SETDESC:
+ {
+ hRes=m_psl->SetDescription(szBuf2);
+ }; break;
+ case SHELLLINKTYPE_SETHOTKEY:
+ {
+ wHotkey=(unsigned short)xatoi(szBuf2);
+ hRes=m_psl->SetHotkey(wHotkey);
+ }; break;
+ case SHELLLINKTYPE_SETICONLOC:
+ {
+ hRes=m_psl->GetIconLocation(szBuf, MAX_PATH, &nBuf);
+ if (hRes == S_OK)
+ hRes=m_psl->SetIconLocation(szBuf2, nBuf);
+ }; break;
+ case SHELLLINKTYPE_SETICONINDEX:
+ {
+ int nBuf2;
+ nBuf=xatoi(szBuf2);
+ hRes=m_psl->GetIconLocation(szBuf, MAX_PATH, &nBuf2);
+ if (hRes == S_OK)
+ hRes=m_psl->SetIconLocation(szBuf, nBuf);
+ }; break;
+ case SHELLLINKTYPE_SETPATH:
+ {
+ hRes=m_psl->SetPath(szBuf2);
+ }; break;
+ case SHELLLINKTYPE_SETSHOWMODE:
+ {
+ nBuf=xatoi(szBuf2);
+ hRes=m_psl->SetShowCmd(nBuf);
+ }; break;
+ case SHELLLINKTYPE_SETWORKINGDIR:
+ {
+ hRes=m_psl->SetWorkingDirectory(szBuf2);
+ }; break;
+ }
+ if (hRes == S_OK) hRes=m_ppf->Save(NULL, FALSE);
+ #ifdef SHELLLINK_DEBUG
+ else MessageBox(hwndParent, "ERROR: Save()", "ShellLink", MB_OK);
+ #endif
+ }
+ }
+ #ifdef SHELLLINK_DEBUG
+ else MessageBox(hwndParent, "ERROR: Load()", "ShellLink", MB_OK);
+ #endif
+ }
+ #ifdef SHELLLINK_DEBUG
+ else MessageBox(hwndParent, "CShellLink::Initialise, Failed in call to QueryInterface for IPersistFile, HRESULT was %x\n", "ShellLink", MB_OK);
+ #endif
+
+ // Cleanup:
+ if (m_ppf) m_ppf->Release();
+ if (m_psl) m_psl->Release();
+ }
+ #ifdef SHELLLINK_DEBUG
+ else MessageBox(hwndParent, "ERROR: CoCreateInstance()", "ShellLink", MB_OK);
+ #endif
+
+ if (hRes == S_OK)
+ {
+ if (nType <= SHELLLINKTYPE_GETWORKINGDIR) pushstring(szBuf);
+ else pushstring(TEXT("0"));
+ }
+ else
+ {
+ if (nType <= SHELLLINKTYPE_GETWORKINGDIR) pushstring(TEXT(""));
+ else pushstring(TEXT("-1"));
+ }
+ }
+}
+
+BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
+{
+ return TRUE;
+}
+
+int popstring(TCHAR *str)
+{
+ stack_t *th;
+ if (!g_stacktop || !*g_stacktop) return 1;
+ th=(*g_stacktop);
+ lstrcpy(str,th->text);
+ *g_stacktop=th->next;
+ GlobalFree((HGLOBAL)th);
+ return 0;
+}
+
+void pushstring(TCHAR *str)
+{
+ stack_t *th;
+ if (!g_stacktop) return;
+ th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize);
+ lstrcpyn(th->text,str,g_stringsize);
+ th->next=*g_stacktop;
+ *g_stacktop=th;
+}
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ShellLink/ShellLink.dsp
@@ -0,0 +1,108 @@
+# Microsoft Developer Studio Project File - Name="ShellLink" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=ShellLink - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "ShellLink.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "ShellLink.mak" CFG="ShellLink - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ShellLink - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "ShellLink - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "ShellLink - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ShellLink_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ShellLink_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib uuid.lib ole32.lib /nologo /entry:"DllMain" /dll /machine:I386 /nodefaultlib /out:"ShellLink.dll" /opt:nowin98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "ShellLink - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ShellLink_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ShellLink_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "ShellLink - Win32 Release"
+# Name "ShellLink - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\ShellLink.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/ShellLink/ShellLink.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "ShellLink"=.\ShellLink.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/UAC/History.txt
@@ -0,0 +1,89 @@
+History:
+--------
+v0.0.10a - 20081004 (AndersK)
+ *Added SEE_MASK_NOZONECHECKS flag (experimental)
+
+v0.0.10 - 20080812 (AndersK)
+ *Added ugly hook hack to the shells run-as dialog on xp, defaults to other user
+
+v0.0.9 - 20080721 (AndersK)
+ *Fixed UAC_RealWorldFullyLoadedDualModeExample.nsi related bug (Thanks Case)
+
+v0.0.8 - 20080310 (AndersK)
+ +HTML Readme
+ +Added UAC::GetOuterHwnd (used by UAC_RealWorldFullyLoadedDualModeExample.nsi)
+ *Fixed UAC_RealWorldFullyLoadedDualModeExample.nsi
+ *Major code cleanup in UAC.cpp
+ -Removed UAC::RunElevatedAndProcessMessages (UAC::RunElevated now supports non NULL $HWNDParent)
+ -Removed several useless sample scripts
+
+v0.0.7e - 20080229 (AndersK)
+ *Added ugly hack for hackwnd to find correct title and give us a proper taskbar so the elevation dialog does not get lost (2000,XP (This also fixed Alt-Tab icon on Vista))
+ *Should compile with MSVC2005 now (Thanks Case)
+ *More unicode fixes, this time even tested with NSIS Unicode (Only RunElevated and Exec tested)
+
+v0.0.7d - 20080226 (AndersK)
+ *Fixed a couple of unicode version bugs (Unicode version still untested)
+ *Fixed weird XP string length bug (Thanks kfank)
+
+v0.0.7c - 20080218 (AndersK)
+ *Fixed SyncVars string length bug
+
+v0.0.7b - 20080205 (AndersK)
+ *Fixed DelayLoadDlls() problem on NT4
+
+v0.0.7 - 20080120 (AndersK)
+ +Added UAC::StackPush (For use with ExecCodeSegment)
+
+v0.0.6d - 20071108 (AndersK)
+ +Now syncs basic registers/variables before calling UAC::*Exec* and UAC::ExecCodeSegment (r0-r9,R0-R9,$CMDLINE,$INSTDIR,$OUTDIR,$EXEDIR,$LANGUAGE)
+ +Added UAC::RunElevatedAndProcessMessages, this can be called after .onInit (Very experimental, DO NOT USE)
+ +New include file with helper macros: UAC.nsh
+ *Replazed Clammerz hack with a better version
+
+v0.0.6c - 20071014 (AndersK)
+ +Check for and split up "domain\user" style input in RunAs.cpp for CreateProcessWithLogonW
+ *Added a ugly hack to trick messagebox'es in .OnInit to appear correctly on Vista (Thanks Clammerz)
+
+v0.0.6b - 20070523 (AndersK)
+ *Fixed showwindow flag (Thanks for the help kichik)
+
+v0.0.6 - 20070512 (AndersK)
+ +Added basic language support for MyRunAs dialog.
+
+v0.0.5e - 20070509 (AndersK)
+ *Fixed detection of UAC mode?
+ +IPC window is visible (but offscreen) during elevation to help with SetForegroundWindow/Focus problems
+
+v0.0.5d - 20070324 (AndersK)
+ *Fixed stupid IsAdmin bug
+
+v0.0.5c - 20070304 (AndersK)
+ *_IsAdmin now uses CheckTokenMembership if it exists ( MSKB:Q118626 / http://blogs.msdn.com/larryosterman/archive/2007/03/14/why-does-kb-118626-use-accesscheck-to-check-if-you-re-a-member-of-the-administrators-group.aspx )
+
+v0.0.5b - 20070301 (AndersK)
+ *Fixed ExecCodeSegment (Thread now calls CoInitialize)
+
+v0.0.5 - 20070228 (AndersK)
+ +Added ExecCodeSegment (You can now call ANY code in the context of the original user)
+
+v0.0.4b - 20070226 (AndersK)
+ *Fixed (My)RunAs font (http://blogs.msdn.com/oldnewthing/archive/2005/02/04/366987.aspx)
+
+v0.0.4 - 20070225 (AndersK)
+ +Added (My)RunAs dialog, used on Vista when running as LUA with UAC off
+ +Always uses /NCRC for elevated instance
+ *Now compiles as UNICODE (Untested, no UnicodeNSIS to test on)
+
+v0.0.3 - 20070224 (AndersK)
+ +Added Exec/ExecWait
+ +Added Verb & ShowWindow support for ShellExec[Wait]
+
+v0.0.2 - 20070219 (AndersK)
+ +Added ShellExecWait
+ *IPC srv wnd now has its own thread and msg loop
+ *Removed CRT dependency
+ *Hopefully loads on Win95 now
+
+v0.0.1 - 20070215 (AndersK)
+ *Initial release
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/UAC/License.txt
@@ -0,0 +1,14 @@
+This software is provided 'as-is', without any express or implied warranty.
+
+ZLIB/LIBPNG LICENSE
+-------------------
+
+This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+
+ 3. This notice may not be removed or altered from any source distribution.
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/UAC/NSISUtil.h
@@ -0,0 +1,149 @@
+/*
+Alternative to ExDll.h
+
+v0.0.1 - 20060811 (AndersK)
+*/
+
+#pragma once
+#include <TChar.h>
+
+
+typedef TCHAR NSISCH;
+#define NSISCALL __stdcall
+
+namespace NSIS {
+
+__forceinline void* NSISCALL MemAlloc(SIZE_T cb) {return GlobalAlloc(LPTR,cb);}
+__forceinline void NSISCALL MemFree(void* p) {GlobalFree(p);}
+
+enum {
+INST_0, // $0
+INST_1, // $1
+INST_2, // $2
+INST_3, // $3
+INST_4, // $4
+INST_5, // $5
+INST_6, // $6
+INST_7, // $7
+INST_8, // $8
+INST_9, // $9
+INST_R0, // $R0
+INST_R1, // $R1
+INST_R2, // $R2
+INST_R3, // $R3
+INST_R4, // $R4
+INST_R5, // $R5
+INST_R6, // $R6
+INST_R7, // $R7
+INST_R8, // $R8
+INST_R9, // $R9
+INST_CMDLINE, // $CMDLINE
+INST_INSTDIR, // $INSTDIR
+INST_OUTDIR, // $OUTDIR
+INST_EXEDIR, // $EXEDIR
+INST_LANG, // $LANGUAGE
+__INST_LAST,
+
+VIDX_TEMP=(INST_LANG+1), //#define state_temp_dir g_usrvars[25]
+VIDX_PLUGINSDIR,//# define state_plugins_dir g_usrvars[26]
+VIDX_EXEPATH,//#define state_exe_path g_usrvars[27]
+VIDX_EXEFILENAME,//#define state_exe_file g_usrvars[28]
+VIDX_STATECLICKNEXT,//#define state_click_next g_usrvars[30]
+__VIDX_UNDOCLAST
+};
+
+
+
+typedef struct _stack_t {
+ struct _stack_t *next;
+ NSISCH text[ANYSIZE_ARRAY];
+} stack_t;
+
+typedef struct {
+ int autoclose;
+ int all_user_var;
+ int exec_error;
+ int abort;
+ int exec_reboot;
+ int reboot_called;
+ int XXX_cur_insttype; // deprecated
+ int XXX_insttype_changed; // deprecated
+ int silent;
+ int instdir_error;
+ int rtl;
+ int errlvl;
+//NSIS v2.3x ?
+ int alter_reg_view;
+ int status_update;
+} exec_flags_type;
+
+typedef struct {
+ exec_flags_type *exec_flags;
+ int (NSISCALL *ExecuteCodeSegment)(int, HWND);
+ void (NSISCALL *validate_filename)(char *);
+} extra_parameters;
+
+extern UINT StrSize;
+extern stack_t **StackTop;
+extern NSISCH*Vars;
+
+inline bool NSISCALL SetErrLvl(extra_parameters*pExtraParams,int ErrLevel) {return pExtraParams? ((pExtraParams->exec_flags->errlvl=ErrLevel)||true):false;}
+inline bool NSISCALL SetErrorFlag(extra_parameters*pExtraParams) {return pExtraParams? ((pExtraParams->exec_flags->exec_error=1)||true):false;}
+inline bool NSISCALL ClearErrorFlag(extra_parameters*pExtraParams) {return pExtraParams?((pExtraParams->exec_flags->exec_error=0)||true):false;}
+
+__forceinline int NSISCALL ExecuteCodeSegment(extra_parameters*pExtraParams,int pos,HWND hwndProgress=NULL) {
+ return pExtraParams?pExtraParams->ExecuteCodeSegment(pos,hwndProgress):(/*EXEC_ERROR*/0x7FFFFFFF);
+}
+
+static NSISCH* __fastcall GetVar(const int varnum)
+{
+ //ASSERT(NSIS::Vars && NSIS::StrSize);
+ if (varnum < 0 || varnum >= __VIDX_UNDOCLAST) return NULL;
+ return NSIS::Vars+(varnum*NSIS::StrSize);
+}
+
+inline void NSISCALL SetVarUINT(const int varnum,UINT Value) {
+ wsprintf(GetVar(varnum),_T("%u"),Value);
+}
+
+static stack_t* NSISCALL StackPop() {
+ if (NSIS::StackTop && *NSIS::StackTop) {
+ stack_t*s=(*NSIS::StackTop);
+ *NSIS::StackTop=(*NSIS::StackTop)->next;
+ return s;
+ }
+ return 0;
+}
+__forceinline void NSISCALL StackFreeItem(stack_t*pStackItem) {NSIS::MemFree(pStackItem);}
+
+static DWORD NSISCALL StackPush(NSISCH*InStr,UINT StackStrSize=NSIS::StrSize) {
+ if (!NSIS::StackTop)return ERROR_INVALID_PARAMETER;
+ stack_t*sNew=(stack_t*)NSIS::MemAlloc(sizeof(stack_t)+(StackStrSize*sizeof(NSISCH)));
+ if (!sNew)return ERROR_OUTOFMEMORY;
+ lstrcpyn(sNew->text,InStr,StackStrSize);
+ sNew->next=*NSIS::StackTop;
+ *NSIS::StackTop=sNew;
+ return NO_ERROR;
+}
+
+}; /* namespace */
+
+#define NSISUTIL_INIT() namespace NSIS {static UINT StrSize;static stack_t **StackTop;static NSISCH*Vars;}//Call in only ONE source file
+#define NSISUTIL_INITEXPORT(_v,_strsize,_stackt) NSIS::Vars=_v;NSIS::StrSize=_strsize;NSIS::StackTop=_stackt
+
+//#define NSISEXPORT4(_func,_h,_strsize,_v,_stackt) extern "C" void __declspec(dllexport) __cdecl \
+// _func (HWND _h,int _strsize,NSISCH*_v,NSIS::stack_t **_stackt) { NSISUTIL_INITEXPORT(_v,_strsize,_stackt); TRACE("EXPORT::" #_func "\n");
+//#define NSISEXPORT5(_func,_h,_strsize,_v,_stackt,_eparams) extern "C" void __declspec(dllexport) __cdecl \
+// _func (HWND _h,int _strsize,NSISCH*_v,NSIS::stack_t **_stackt,NSIS::extra_parameters* _eparams) { NSISUTIL_INITEXPORT(_v,_strsize,_stackt); TRACE("EXPORT::" #_func "\n");
+//#define NSISEXPORT NSISEXPORT5
+
+#ifdef _MSC_VER
+# define EXPORTNSISFUNC extern "C" void __declspec(dllexport) __cdecl
+# else
+# error EXPORTNSISFUNC needs compiler goo, you are on your own!
+# endif
+#define NSISFUNCSTART4(_h,_strsize,_v,_stackt) {NSISUTIL_INITEXPORT(_v,_strsize,_stackt);
+#define NSISFUNCSTART5(_h,_strsize,_v,_stackt,_eparams) NSISFUNCSTART4(_h,_strsize,_v,_stackt)
+#define NSISFUNCSTART NSISFUNCSTART5
+#define NSISFUNCEND() }
+
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/UAC/RunAs.cpp
@@ -0,0 +1,276 @@
+//Copyright (C) 2007 Anders Kjersem. Licensed under the zlib/libpng license, see License.txt for details.
+/*
+If UAC is disabled, the runas verb is broken (Vista RTM) so when running as LUA there is no way to elevate so
+we provide our own dialog.
+*/
+
+#include "UAC.h"
+#ifdef FEAT_CUSTOMRUNASDLG
+#include <Lmcons.h>//UNLEN && GNLEN && PWLEN
+#include <WindowsX.h>
+#include "resource.h"
+#include "NSISUtil.h"
+using namespace NSIS;
+#define ERRAPP_TRYAGAIN (0x20000000|1)
+#define MYMAX_DOMAIN (2+max(GNLEN,MAX_COMPUTERNAME_LENGTH)+1)
+
+
+static LPCTSTR g_RunAsDlgTitle=_T("Run as");
+static LPCTSTR g_RunAsHelpText=_T("You may not have the necessary permissions to use all the features of the program you are about to run. You may run this program as a different user or continue to run the program as the current user.");
+static LPCTSTR g_RunAsCurrUsrFmt=_T("&Current user (%s)");//Max 50 chars!
+static LPCTSTR g_RunAsSpecHelp=_T("Run the program as the &following user:");
+
+FORCEINLINE bool MySetDlgItemText(HWND hDlg,int id,LPCTSTR s) {return MySndDlgItemMsg(hDlg,id,WM_SETTEXT,0,(LPARAM)s)!=0;}
+
+typedef struct {
+ SHELLEXECUTEINFO*pSEI;
+ bool AsSelf;
+} RUNASDLGDATA;
+
+void MyRunAsFmtCurrUserRadio(HWND hDlg,LPCTSTR Fmt) {
+ TCHAR bufFullName[MYMAX_DOMAIN+UNLEN+1];
+ TCHAR buf[50+MYMAX_DOMAIN+UNLEN+1];
+ *bufFullName=0;
+ ULONG cch;
+ if ((!_GetUserNameEx || !_GetUserNameEx(NameSamCompatible,bufFullName,&(cch=COUNTOF(bufFullName)))) &&
+ !_GetUserName(bufFullName,&(cch=COUNTOF(bufFullName))) ) {
+ *bufFullName=0;
+ }
+ wsprintf(buf,Fmt,*bufFullName?bufFullName:_T("?"));
+ MySetDlgItemText(hDlg,IDC_RUNASCURR,buf);
+
+ // default the "User name:" to Administrator from shell32
+ if (LoadString(GetModuleHandle(_T("SHELL32.dll")),21763, bufFullName, COUNTOF(bufFullName)) > 0) {
+ MySetDlgItemText(hDlg,IDC_USERNAME,bufFullName);
+ }
+}
+
+#ifdef FEAT_CUSTOMRUNASDLG_TRANSLATE
+void MyRunAsTranslateDlgString(LPCTSTR StrID,LPTSTR Ini,HWND hDlg,INT_PTR DlgItemId,int special=0) {
+ TCHAR buf[MAX_PATH*2];
+ DWORD len=GetPrivateProfileString(_T("MyRunAsStrings"),StrID,0,buf,ARRAYSIZE(buf),Ini);
+ if (len) {
+ if (IDC_RUNASCURR==special)
+ MyRunAsFmtCurrUserRadio(hDlg,buf);
+ else
+ (DlgItemId==-1) ? SetWindowText(hDlg,buf) : MySetDlgItemText(hDlg,DlgItemId,buf);
+ }
+}
+
+void MyRunAsTranslateDlg(HWND hDlg) {
+ DWORD len;
+ TCHAR buf[MAX_PATH*2];
+ HMODULE hDll=GetWindowInstance(hDlg);ASSERT(hDll);
+ if ( (len=GetModuleFileName(hDll,buf,ARRAYSIZE(buf))) <1)return;
+ buf[len-3]=0;
+ lstrcat(buf,_T("lng"));
+ MyRunAsTranslateDlgString(_T("DlgTitle"),buf,hDlg,-1);
+ MyRunAsTranslateDlgString(_T("HelpText"),buf,hDlg,IDC_HELPTEXT);
+ MyRunAsTranslateDlgString(_T("OptCurrUser"),buf,hDlg,IDC_RUNASCURR,IDC_RUNASCURR);
+ MyRunAsTranslateDlgString(_T("OptOtherUser"),buf,hDlg,IDC_RUNASSPEC);
+ MyRunAsTranslateDlgString(_T("Username"),buf,hDlg,IDC_LBLUSER);
+ MyRunAsTranslateDlgString(_T("Pwd"),buf,hDlg,IDC_LBLPWD);
+ MyRunAsTranslateDlgString(_T("OK"),buf,hDlg,IDOK);
+ MyRunAsTranslateDlgString(_T("Cancel"),buf,hDlg,IDCANCEL);
+ HWND h=GetDlgItem(hDlg,IDC_RUNASCURR);
+ if (GetPrivateProfileInt(_T("MyRunAsCfg"),_T("DisableCurrUserOpt"),false,buf))EnableWindow(h,false);
+ if (GetPrivateProfileInt(_T("MyRunAsCfg"),_T("HideCurrUserOpt"),false,buf))ShowWindow(h,false);
+}
+#endif
+
+bool ErrorIsLogonError(DWORD err) {
+ switch (err) {
+ case ERROR_LOGON_FAILURE:
+ case ERROR_ACCOUNT_RESTRICTION:
+ case ERROR_INVALID_LOGON_HOURS:
+ case ERROR_INVALID_WORKSTATION:
+ case ERROR_PASSWORD_EXPIRED:
+ case ERROR_ACCOUNT_DISABLED:
+ case ERROR_NONE_MAPPED:
+ case ERROR_NO_SUCH_USER:
+ case ERROR_INVALID_ACCOUNT_NAME:
+ return true;
+ }
+ return false;
+}
+
+
+
+void VerifyOKBtn(HWND hDlg,RUNASDLGDATA*pRADD) {
+ const bool HasText=pRADD?(pRADD->AsSelf?true:MySndDlgItemMsg(hDlg,IDC_USERNAME,WM_GETTEXTLENGTH)>0):false;
+ EnableWindow(GetDlgItem(hDlg,IDOK),HasText);
+}
+
+void SetDlgState(HWND hDlg,bool AsSelf,RUNASDLGDATA*pRADD) {
+ if (pRADD)pRADD->AsSelf=AsSelf;
+ MySndDlgItemMsg(hDlg,IDC_RUNASCURR,BM_SETCHECK,AsSelf?BST_CHECKED:BST_UNCHECKED);
+ MySndDlgItemMsg(hDlg,IDC_RUNASSPEC,BM_SETCHECK,!AsSelf?BST_CHECKED:BST_UNCHECKED);
+ int ids[]={IDC_USERNAME,IDC_PASSWORD,IDC_LBLUSER,IDC_LBLPWD};
+ for (int i=0; i<COUNTOF(ids);++i)EnableWindow(GetDlgItem(hDlg,ids[i]),!AsSelf);
+ VerifyOKBtn(hDlg,pRADD);
+}
+
+INT_PTR CALLBACK MyRunAsDlgProc(HWND hwnd,UINT uMsg,WPARAM wp,LPARAM lp) {
+ RUNASDLGDATA*pRADD=(RUNASDLGDATA*)GetWindowLongPtr(hwnd,GWLP_USERDATA);
+ switch(uMsg) {
+ //case WM_DESTROY:
+ // break;
+ case WM_CLOSE:
+ return DestroyWindow(hwnd);
+ case WM_INITDIALOG:
+ {
+ pRADD=(RUNASDLGDATA*)lp;ASSERT(pRADD);
+ SetWindowLongPtr(hwnd,GWLP_USERDATA,lp);
+ Edit_LimitText(GetDlgItem(hwnd,IDC_USERNAME),UNLEN+1+MYMAX_DOMAIN); //room for "foo@BAR" or "BAR\foo"
+ Edit_LimitText(GetDlgItem(hwnd,IDC_PASSWORD),PWLEN);
+ const HINSTANCE hSh32=GetModuleHandle(_T("SHELL32.dll"));
+ const HICON hIco=(HICON)LoadImage(hSh32,MAKEINTRESOURCE(194),IMAGE_ICON,32,32,LR_SHARED);
+ MySndDlgItemMsg(hwnd,IDC_SHICON,STM_SETICON,(WPARAM)hIco);
+ SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)g_RunAsDlgTitle);
+ MySetDlgItemText(hwnd,IDC_HELPTEXT,g_RunAsHelpText);
+ MyRunAsFmtCurrUserRadio(hwnd,g_RunAsCurrUsrFmt);
+ MySetDlgItemText(hwnd,IDC_RUNASSPEC,g_RunAsSpecHelp);
+#ifdef FEAT_CUSTOMRUNASDLG_TRANSLATE
+ MyRunAsTranslateDlg(hwnd);
+#endif
+ SetDlgState(hwnd,false,pRADD);
+
+#if defined(BUILD_DBG) && 0 //auto login used during testing ;)
+ SetDlgItemText(hwnd,IDC_USERNAME,_T("root"));
+ SetDlgItemText(hwnd,IDC_PASSWORD,_T("???"));
+ Sleep(1);PostMessage(hwnd,WM_COMMAND,IDOK,0);
+#endif
+ }
+ return true;
+ case WM_COMMAND:
+ {
+ switch(HIWORD(wp)) {
+ case EN_CHANGE:
+ VerifyOKBtn(hwnd,pRADD);
+ break;
+ case EN_SETFOCUS:
+ case BN_CLICKED:
+ if (LOWORD(wp)<=IDCANCEL)break;
+ SetDlgState(hwnd,LOWORD(wp)==IDC_RUNASCURR,pRADD);
+ return FALSE;
+ }
+ INT_PTR exitcode=!pRADD?-1:IDCANCEL;
+ switch(LOWORD(wp)) {
+ case IDOK:
+ if (pRADD) {
+ SHELLEXECUTEINFO&sei=*pRADD->pSEI;
+ PROCESS_INFORMATION pi={0};
+ DWORD ec=NO_ERROR;
+ WCHAR*wszExec;//Also used as TCHAR buffer in AsSelf mode
+ bool PerformTCharFmt=pRADD->AsSelf;
+ //const DWORD CommonStartupInfoFlags=STARTF_FORCEONFEEDBACK;
+#ifdef UNICODE
+ PerformTCharFmt=true;
+#endif
+ wszExec=(WCHAR*)NSIS::MemAlloc( (pRADD->AsSelf?sizeof(TCHAR):sizeof(WCHAR)) *(lstrlen(sei.lpFile)+1+lstrlen(sei.lpParameters)+1));
+ if (!wszExec)ec=ERROR_OUTOFMEMORY;
+ if (PerformTCharFmt)wsprintf((TCHAR*)wszExec,_T("%s%s%s"),sei.lpFile,((sei.lpParameters&&*sei.lpParameters)?_T(" "):_T("")),sei.lpParameters);
+ if (!ec) {
+ if (pRADD->AsSelf) {
+ STARTUPINFO si={sizeof(si)};
+ TRACEF("MyRunAs:CreateProcess:%s|\n",wszExec);
+ ec=(CreateProcess(0,(TCHAR*)wszExec,0,0,false,0,0,0,&si,&pi)?NO_ERROR:GetLastError());
+ }
+ else {
+ //All Wide strings!
+ WCHAR wszPwd[PWLEN+1];
+ WCHAR wszUName[UNLEN+1+MYMAX_DOMAIN+1];
+ STARTUPINFOW siw={sizeof(siw)};
+ WCHAR*p;
+#ifndef UNICODE
+ //Build unicode string, we already know the buffer is big enough so no error handling
+ p=wszExec;
+ MultiByteToWideChar(CP_THREAD_ACP,0,sei.lpFile,-1,p,0xFFFFFF);
+ if (sei.lpParameters && *sei.lpParameters) {
+ p+=lstrlen(sei.lpFile);*p++=L' ';*p=0;
+ MultiByteToWideChar(CP_THREAD_ACP,0,sei.lpParameters,-1,p,0xFFFFFF);
+ }
+#endif
+ SendMessageW(GetDlgItem(hwnd,IDC_USERNAME),WM_GETTEXT,COUNTOF(wszUName),(LPARAM)wszUName);
+ SendMessageW(GetDlgItem(hwnd,IDC_PASSWORD),WM_GETTEXT,COUNTOF(wszPwd),(LPARAM)wszPwd);
+
+ //Try to find [\\]domain\user and split into username and domain strings
+ WCHAR*pUName=wszUName,*pDomain=0;
+ p=wszUName;
+ //if (*p==p[1]=='\\')pUName=(p+=2);else \ //Should we still split things up if the string starts with \\ ? Is it possible to use \\machine\user at all?
+ ++p;//Don't parse "\something", require at least one char before backslash "?[*\]something"
+ while(*p && *p!='\\')++p;
+ if (*p=='\\') {
+ pDomain=pUName;
+ pUName=p+1;*p=0;
+ }
+
+ TRACEF("MyRunAs:CreateProcessWithLogonW:%ws|%ws|%ws|%ws|\n",pUName,pDomain?pDomain:L"NO?DOMAIN",wszPwd,wszExec);
+ ec=(_CreateProcessWithLogonW(pUName,pDomain?pDomain:0,wszPwd,LOGON_WITH_PROFILE,0,wszExec,0,0,0,&siw,&pi)?NO_ERROR:GetLastError());
+ TRACEF("MyRunAs:CreateProcessWithLogonW: ret=%u\n",ec);
+ SecureZeroMemory(wszPwd,sizeof(wszPwd));//if (wszPwd) {volatile WCHAR*_p=wszPwd;for(;_p&&*_p;++_p)*_p=1;if (_p)*wszPwd=0;}//Burn password (And attempt to prevent compiler from removing it)
+ if (ec && ErrorIsLogonError(ec)) {
+ LPTSTR szMsg;
+ DWORD ret=FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,0,ec,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),(LPTSTR)&szMsg,0,0);
+ if (ret) {
+ ec=ERRAPP_TRYAGAIN;
+ MessageBox(hwnd,szMsg,0,MB_ICONWARNING);
+ LocalFree(szMsg);
+ }
+ else ec=GetLastError();
+ }
+ }
+ }
+ NSIS::MemFree(wszExec);
+ if (pi.hThread)CloseHandle(pi.hThread);
+ if (ERRAPP_TRYAGAIN==ec)break;
+ if (ec) {
+ SetLastError(ec);
+ exitcode=-1;
+ }
+ else {
+ pRADD->pSEI->hProcess=pi.hProcess;
+ exitcode=IDOK;
+ }
+ }
+ case IDCANCEL:
+ EndDialog(hwnd,exitcode);
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+DWORD MyRunAs(HINSTANCE hInstDll,SHELLEXECUTEINFO&sei) {
+ INT_PTR ec;
+ ASSERT(sei.cbSize>=sizeof(SHELLEXECUTEINFO) && hInstDll);
+ if (ec=DelayLoadDlls())return ec;
+ ASSERT(_CreateProcessWithLogonW && _GetUserName);
+ RUNASDLGDATA radd={0};
+ radd.pSEI=&sei;
+ ec=DialogBoxParam(hInstDll,MAKEINTRESOURCE(IDD_MYRUNAS),sei.hwnd,MyRunAsDlgProc,(LPARAM)&radd);
+ TRACEF("MyRunAs returned %d (%s|%s)\n",ec,sei.lpFile,sei.lpParameters);
+ switch(ec) {
+ case 0:
+ return ERROR_INVALID_HANDLE;//DialogBoxParam returns 0 on bad hwnd
+ case IDOK:
+ return NO_ERROR;
+ case IDCANCEL:
+ return ERROR_CANCELLED;
+ }
+ return GetLastError();
+}
+
+
+#ifdef BUILD_DBG
+// RunDll exports are __stdcall, we dont care about that for this debug export, rundll32.exe is able to handle this mistake
+extern "C" void __declspec(dllexport) __cdecl DBGRDMyRunAs(HWND hwnd,HINSTANCE hinst,LPTSTR lpCmdLine,int nCmdShow) {
+ SHELLEXECUTEINFO sei={sizeof(sei)};
+ sei.lpFile=_T("Notepad.exe");//sei.lpParameters=_T("param1");
+ TRACEF("ec=%d\n",MyRunAs(GetModuleHandle(_T("UAC.dll")),sei));
+}
+#endif
+
+#endif /* FEAT_CUSTOMRUNASDLG */
+
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/UAC/UAC Readme.html
@@ -0,0 +1,222 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html><head>
+<title>UAC plug-in readme</title>
+<script type="text/javascript">
+function NavGL(q){window.open("http://www.google.com/search?hl=en&btnI=I&num=2&q="+escape(q));return 0;}
+</script>
+<style type="text/css">
+html,body {background-color:#FFF; color:#000;}
+a:link, a:visited, a:active {color:#00F;}
+h2 {border-bottom:0.1em solid #000;}
+#docHdrHdln{text-align:center;}
+.importanttxt {color:#e00;}
+.code {font-family:monospace;}
+.nsisvar {color:#C00;}
+.str {color:#390}
+.inifile {background-color:#EEE;border:1px solid #000;padding:0.2em;}
+.inicomment {background-color:#f5f5c5;color:#555;}
+table.piexport {text-align:left;margin-bottom:1em;}
+table.piexport td {vertical-align:top;}
+table.piexport table.ret {padding:0;margin:0;border:0;}
+</style>
+</head><body>
+<h1 id="docHdrHdln">UAC plug-in</h1>
+
+
+<code><pre>
+Interactive User (MediumIL) Admin user(HighIL)
++++[Setup.exe]++++++++++++++ +++[Setup.exe]++++++++++++++
++ + + +
++ ***[.OnInit]************ + + ***[.OnInit]************ +
++ * UAC::RunElevated >---+-+------>+ * * +
++ * NSIS.Quit() * + + * * +
++ ************************ + + ***********||*********** +
++ + + || +
++ + + \/ +
++ ***[Sections]*********** + + ***[Sections]*********** +
++ * * + /--+-+-< UAC::Exec * +
++ ************************ + | + ************************ +
++ + | + +
++ Win32.CreateProcess() <-+----/ + +
++ + + +
+++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++
+</pre></code>
+
+
+<h2>Contents</h2>
+<ul>
+<li><a href="#exports">Plugin Functions</a>
+<li><a href="#lang">Language support</a>
+<li><a href="#knownissues">Known Issues</a>
+<li><a href="#glossary">Glossary</a>
+</ul>
+
+
+
+
+
+
+<a name="exports"><h2>Plugin Functions</h2></a><div class="CntSec"><p>
+Every function will try to emulate the basic NSIS instruction (of similar name) when UAC::RunElevated has not "succeeded" or running on a system that does not support elevation (Win9x/NT4)</p>
+
+<table class="piexport"><tr><th colspan=2>UAC::RunElevated</th></tr>
+<tr><td>Parameters:</td><td></td></tr>
+<tr><td>Returns:</td><td>
+ <table class="ret">
+ <tr><td><span class="nsisvar">$0</span></td><td>Win32 error code (0 on success, 1223 if user aborted elevation dialog, anything else should be treated as a fatal error)</td></tr>
+ <tr><td><span class="nsisvar">$1</span></td><td><span class="code">If <span class="nsisvar">$0</span>==0</span>:
+ <table class="ret">
+ <tr><td>0</td><td>UAC is not supported by the OS</td></tr>
+ <tr><td>1</td><td>Started a elevated child process, the current process should act like a wrapper (Call Quit without any further processing)</td></tr>
+ <tr><td>2</td><td>The process is already running @ HighIL (Member of admin group)</td></tr>
+ <tr><td>3</td><td>You should call RunElevated again (This can happen if a user without admin priv. is used in the runas dialog)</td></tr>
+ </table>
+ </td></tr>
+ <tr><td><span class="nsisvar">$2</span></td><td><span class="code">If <span class="nsisvar">$0</span>==0 && <span class="nsisvar">$1</span>==1</span>: ExitCode of the elevated fork process (The NSIS errlvl is also set)</td></tr>
+ <tr><td><span class="nsisvar">$3</span></td><td><span class="code">If <span class="nsisvar">$0</span>==0</span>: 1 if the user is a member of the admin group or 0 otherwise</td></tr>
+ </table></td></tr>
+<tr><td>Description:</td><td>Allows non-admin/UAC.LUA users to re-spawn the installer as another user and UAC.Admin users to elevate.</td></tr>
+</table>
+<!--table class="piexport"><tr><th colspan=2>UAC::RunElevatedAndProcessMessages <i style="font-size:smaller;">(Experimental)</i></th></tr>
+<tr><td>Parameters:</td><td></td></tr>
+<tr><td>Returns:</td><td><i>See UAC::RunElevated</i></td></tr>
+<tr><td>Description:</td><td>Version of UAC::RunElevated that can be called from a page</td></tr>
+</table-->
+
+<table class="piexport"><tr><th colspan=2>UAC::Unload</th></tr>
+<tr><td>Parameters:</td><td></td></tr>
+<tr><td>Returns:</td><td></td></tr>
+<tr><td>Description:</td><td>Cleanup, you must call this function in .OnInstFailed, .onUserAbort and .OnInstSuccess</td></tr>
+</table>
+
+<table class="piexport"><tr>
+<th colspan=2>UAC::Exec</th></tr>
+<tr><td>Parameters:</td><td><INT:ShowWindow> <STR:App> <STR:Parameters> <STR:WorkingDir></td></tr>
+<tr><td>Returns:</td><td>
+ <table class="ret">
+ <tr><td><span class="nsisvar">$0</span></td><td>Win32 error code, 0 on success (ErrorFlag is also set on error)</td></tr>
+ </table></td></tr>
+</table>
+<table class="piexport"><tr>
+<th colspan=2>UAC::ExecWait</th></tr>
+<tr><td>Parameters:</td><td><INT:ShowWindow> <STR:App> <STR:Parameters> <STR:WorkingDir></td></tr>
+<tr><td>Returns:</td><td>
+ <table class="ret">
+ <tr><td><span class="nsisvar">$0</span></td><td>Win32 error code, 0 on success (ErrorFlag is also set on error)</td></tr>
+ <tr><td><span class="nsisvar">$1</span></td><td>Exitcode of new process</td></tr>
+ </table></td></tr>
+</table>
+<table class="piexport"><tr>
+<th colspan=2>UAC::ShellExec</th></tr>
+<tr><td>Parameters:</td><td><STR:Verb> <INT:ShowWindow> <STR:App> <STR:Parameters> <STR:WorkingDir></td></tr>
+<tr><td>Returns:</td><td>
+ <table class="ret">
+ <tr><td><span class="nsisvar">$0</span></td><td>Win32 error code, 0 on success (ErrorFlag is also set on error)</td></tr>
+ </table></td></tr>
+</table>
+<table class="piexport"><tr>
+<th colspan=2>UAC::ShellExecWait</th></tr>
+<tr><td>Parameters:</td><td><STR:Verb> <INT:ShowWindow> <STR:App> <STR:Parameters> <STR:WorkingDir></td></tr>
+<tr><td>Returns:</td><td>
+ <table class="ret">
+ <tr><td><span class="nsisvar">$0</span></td><td>Win32 error code, 0 on success (ErrorFlag is also set on error)</td></tr>
+ <tr><td><span class="nsisvar">$1</span></td><td>Exitcode of new process</td></tr>
+ </table></td></tr>
+</table>
+
+<table class="piexport"><tr><th colspan=2>UAC::IsAdmin</th></tr>
+<tr><td>Parameters:</td><td></td></tr>
+<tr><td>Returns:</td><td><span class="nsisvar">$0</span> (BOOL) result</td></tr>
+<tr><td>Description:</td><td>Check current thread/process token for a non-deny admin group SID entry</td></tr>
+</table>
+
+<table class="piexport"><tr><th colspan=2>UAC::ExecCodeSegment</th></tr>
+<tr><td>Parameters:</td><td><INT:NSISFunctionAddress></td></tr>
+<tr><td>Returns:</td><td>[None] (ErrorFlag is set on error)</td></tr>
+<tr><td>Description:</td><td>Calls NSIS function in LUA/outer instance (If you use instructions that alter the UI or the stack/variables in the code segment (StrCpy,Push/Pop/Exch,DetailPrint etc.) they will affect the hidden wrapper installer and not "your" installer instance)</td></tr>
+</table>
+
+<table class="piexport"><tr><th colspan=2>UAC::StackPush</th></tr>
+<tr><td>Parameters:</td><td><STR:String></td></tr>
+<tr><td>Returns:</td><td>[None] (ErrorFlag is set on error)</td></tr>
+<tr><td>Description:</td><td>Push to outer instance stack (For use with UAC::ExecCodeSegment)</td></tr>
+</table>
+
+<table class="piexport"><tr><th colspan=2>UAC::GetOuterHwnd</th></tr>
+<tr><td>Parameters:</td><td></td></tr>
+<tr><td>Returns:</td><td><span class="nsisvar">$0</span> HWNDPARENT of outer instance</td></tr>
+<tr><td>Description:</td><td>For use with ${UAC.RunElevatedAndProcessMessages}</td></tr>
+</table>
+
+<table class="piexport"><tr><th colspan=2>UAC::SupportsUAC</th></tr>
+<tr><td>Parameters:</td><td></td></tr>
+<tr><td>Returns:</td><td><span class="nsisvar">$0</span> !=0 if supported</td></tr>
+<tr><td>Description:</td><td>Check if the OS supports UAC (And the user has UAC turned on) <span class="importanttxt">This function only tests if UAC is active, will return 0 on NT5 even though runas is implemented on those platforms, will also return 0 on NT6+ if UAC is off. You should only call this function during testing, NOT to determine if you can call UAC::RunElevated</span></td></tr>
+</table>
+
+<table class="piexport"><tr><th colspan=2>UAC::GetElevationType</th></tr>
+<tr><td>Parameters:</td><td></td></tr>
+<tr><td>Returns:</td><td>
+ <table class="ret">
+ <tr><td><span class="nsisvar">$0</span></td><td><a href="#" OnClick="return NavGL('TOKEN_ELEVATION_TYPE Enumeration')">TOKEN_ELEVATION_TYPE</a>:
+ <table class="ret">
+ <tr><td>0</td><td>Unsupported/Failed (ErrorFlag is also set)</td></tr>
+ <tr><td>1</td><td>TokenElevationTypeDefault: User is not using a split token (UAC disabled)</td></tr>
+ <tr><td>2</td><td>TokenElevationTypeFull: UAC enabled, the (current) process is elevated</td></tr>
+ <tr><td>3</td><td>TokenElevationTypeLimited: UAC enabled, the process is not elevated</td></tr>
+ </table>
+ </td></tr>
+ </table></td></tr>
+</table>
+
+</div>
+
+
+
+
+
+<a name="lang"><h2>Language support</h2></a><div class="CntSec">
+<p>If the plugin is built with FEAT_CUSTOMRUNASDLG_TRANSLATE (Enabled by default),
+you can extract a file named <span class="str">UAC.LNG</span> to <span class="nsisvar">$pluginsdir</span>.
+It is a ini file with the following sections:
+</p><pre class="inifile">
+[MyRunAsCfg]
+<span class="inicomment">;Set to 1 to disable the radio button</span>
+DisableCurrUserOpt=
+<span class="inicomment">;Set to 1 to hide the radio button</span>
+HideCurrUserOpt=
+
+[MyRunAsStrings]
+DlgTitle=Hello There!
+HelpText=Just do your thing!
+<span class="inicomment">;Label for current user radio button, %s is replaced with result of GetUserNameEx(NameSamCompatible,...)</span>
+OptCurrUser=Self service (%s)
+OptOtherUser=Run as someone:
+UserName=Who:
+Pwd=PIN:
+OK=Okey!
+Cancel=No Way</pre>
+</div>
+
+<a name="knownissues"><h2>Known Issues</h2></a><div class="CntSec">
+<ul>
+<li>UACPI.KI#1: DetailPrint in outer process is ignored
+<li>UACPI.KI#2: Elevation can fail if the installer is located on a remote share that requires authentication
+</ul>
+</div>
+
+
+<a name="glossary"><h2>Glossary</h2></a><div class="CntSec">
+<ul>
+<li>AAM: Admin Approval Mode
+<li>IL: Integrity level (Part of the new MIC/WIC security levels added to NT6)
+<li>LUA: Limited/Least-privilege User Account
+<li>MIC: <a href="http://en.wikipedia.org/wiki/Mandatory_Integrity_Control">Mandatory Integrity Controls</a> (Now known as WIC)
+<li>UAC: User Account Control (Part of the UAP umbrella)
+<li>UAP: User Account Protection
+<li>WIC: <a href="http://www.securityfocus.com/infocus/1887">Windows Integrity Controls</a>
+<li>Win32 error code: Standard windows error codes, ERROR_???
+</ul>
+</div>
+
+</body></html>
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/UAC/UAC.dsp
@@ -0,0 +1,133 @@
+# Microsoft Developer Studio Project File - Name="UAC" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=UAC - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "UAC.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "UAC.mak" CFG="UAC - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "UAC - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "UAC - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "UAC - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UAC_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UAC_EXPORTS" /YX /FD /c
+# SUBTRACT CPP /Fr
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x414 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# SUBTRACT LINK32 /map
+
+!ELSEIF "$(CFG)" == "UAC - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UAC_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UAC_EXPORTS" /YX /FD /GZ /c
+# SUBTRACT CPP /Fr
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x414 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "UAC - Win32 Release"
+# Name "UAC - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\RunAs.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\uac.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\NSISUtil.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\uac.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\resource.rc
+# End Source File
+# End Group
+# Begin Group "Other"
+
+# PROP Default_Filter "txt"
+# Begin Source File
+
+SOURCE=.\History.txt
+# End Source File
+# End Group
+# End Target
+# End Project
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/UAC/UAC.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "UAC"=".\UAC.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/UAC/resource.h
@@ -0,0 +1,24 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by resource.rc
+//
+#define IDD_MYRUNAS 101
+#define IDC_RUNASCURR 1000
+#define IDC_RUNASSPEC 1001
+#define IDC_SHICON 1002
+#define IDC_HELPTEXT 1003
+#define IDC_USERNAME 1004
+#define IDC_PASSWORD 1005
+#define IDC_LBLUSER 1007
+#define IDC_LBLPWD 1008
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 102
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1009
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/UAC/resource.rc
@@ -0,0 +1,109 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+#include "uac.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_MYRUNAS DIALOG DISCARDABLE 0, 0, 250, 145
+STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_SETFOREGROUND | DS_FIXEDSYS |
+ DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+FONT 8, "MS Shell Dlg"
+BEGIN
+ DEFPUSHBUTTON "&OK",IDOK,132,122,50,14
+ PUSHBUTTON "Ca&ncel",IDCANCEL,188,122,50,14
+ ICON "",IDC_SHICON,7,7,20,20
+ LTEXT "",IDC_HELPTEXT,34,7,204,35
+ CONTROL "",IDC_RUNASCURR,"Button",BS_AUTORADIOBUTTON,20,49,218,
+ 10
+ CONTROL "",IDC_RUNASSPEC,"Button",BS_AUTORADIOBUTTON,20,65,218,
+ 10
+ LTEXT "&User name:",IDC_LBLUSER,20,84,42,16
+ EDITTEXT IDC_USERNAME,63,83,175,14,ES_AUTOHSCROLL
+ LTEXT "&Password:",IDC_LBLPWD,20,102,42,20
+ EDITTEXT IDC_PASSWORD,63,100,175,14,ES_PASSWORD | ES_AUTOHSCROLL
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+ IDD_MYRUNAS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 238
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 136
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "#include ""uac.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/UAC/uac.cpp
@@ -0,0 +1,1354 @@
+//Copyright (C) 2007 Anders Kjersem. Licensed under the zlib/libpng license, see License.txt for details.
+/*
+UAC plugin for NSIS
+===================
+Compiled with VC6+PlatformSDK (StdCall & MinimizeSize)
+
+
+Todo:
+-----
+¤GetCurrentDir in elevated parent and pass along to outer process for Exec* (or somekind of ipc to request it if workingdir param is empty)
+¤Check if secondary logon service is running in SysElevationPresent() on NT5
+¤Use IsUserAnAdmin? MAKEINTRESOURCE(680) export on 2k //http://forums.winamp.com/showthread.php?s=&threadid=195020
+¤AllowSetForegroundWindow
+¤Use RPC instead of WM_COPYDATA for IPC
+¤Autodetect "best" default admin user in MyRunAs
+¤Use ChangeWindowMessageFilter so we can get >WM_USER msg success feedback and possibly fill the log with detailprints
+¤Hide IPC window inside inner instance window? (Could this add unload problems?)
+¤CREATE_PRESERVE_CODE_AUTHZ_LEVEL? http://msdn2.microsoft.com/en-us/library/ms684863.aspx
+¤UpdateProcThreadAttribute?
+¤Consent UI on XP ?
+¤All langs in single file; [MyRunAsStrings]>LangSections != 0 then load strings from [langid] sections
+¤BroadcastSystemMessage to help with SetForeground
+¤UAC::StackPop
+
+
+Notes:
+------
+Primary integrity levels:
+Name SID RID
+Low Mandatory Level S-1-16-4096 0x1000
+Medium Mandatory Level S-1-16-8192 0x2000
+High Mandatory Level S-1-16-12288 0x3000
+System Mandatory Level S-1-16-16384 0x4000
+
+*/
+
+#define UAC_HACK_Clammerz //ugly messagebox focus hack for .onInit
+#define UAC_HACK_FGWND1 //super ugly fullscreen invisible window for focus tricks
+
+#define UAC_INITIMPORTS
+#include "UAC.h"
+#include <objbase.h>//CoInitialize
+#include "NSISUtil.h"
+using namespace NSIS;
+NSISUTIL_INIT();
+
+
+#define ERRAPP_BADIPCSRV (0x20000000|1)
+#define SW_INVALID ((WORD)-1)
+#define IPCTOUT_DEF (1000*3) //default timeout for IPC messages
+#define IPCTOUT_SHORT 1500
+#define IPCTOUT_LONG (IPCTOUT_DEF*2)
+
+enum _IPCSRVWNDMSG
+{
+ IPC_GETEXITCODE=WM_USER, //Get exit-code of the process spawned by the last call to ExecWait/ShellExecWait
+ IPC_ELEVATEAGAIN,
+ IPC_GETSRVPID, //Get PID of outer process
+ IPC_GETSRVHWND, //Get $HWNDParent of outer process
+ IPC_EXECCODESEGMENT, //wp:pos | lp:hwnd | returns ErrorCode+1
+
+#ifdef UAC_HACK_FGWND1
+ IPC_HACKFINDRUNAS,
+#endif
+};
+
+enum _COPYDATAID
+{
+ CDI_SHEXEC=666, //returns WindowsErrorCode+1
+ CDI_SYNCVAR,
+ CDI_STACKPUSH,
+};
+
+typedef struct
+{
+ UINT VarId;
+ NSISCH buf[ANYSIZE_ARRAY];
+} IPC_SYNCVAR;
+
+typedef struct
+{
+ HWND hwnd;
+ bool Wait;
+ bool UseCreateProcess;
+ WORD ShowMode;
+ NSISCH*strExec;
+ NSISCH*strParams;
+ NSISCH*strWorkDir;
+ NSISCH*strVerb;
+ NSISCH buf[ANYSIZE_ARRAY];
+} IPC_SHEXEC;
+
+
+typedef struct
+{
+ HINSTANCE hInstance;
+ HWND hSrvIPC;
+ BYTE DllRef;
+ bool UseIPC;
+ bool CheckedIPCParam;
+ UINT NSISStrLen;
+ //IPC Server stuff:
+ HANDLE threadIPC;
+ DWORD LastWaitExitCode;//Exit code of process started from last call to ExecWait/ShellExecWait
+ NSIS::extra_parameters*pXParams;
+ bool ElevateAgain;
+ //DelayLoadedModules:
+ HMODULE hModAdvAPI;
+} GLOBALS;
+
+
+GLOBALS g = {0};
+
+
+void StopIPCSrv();
+DWORD _GetElevationType(TOKEN_ELEVATION_TYPE* pTokenElevType);
+bool GetIPCSrvWndFromParams(HWND&hwndOut);
+
+
+
+#if _MSC_VER >= 1400 //MSVC 2005 wants to pull in the CRT, let's try to help it out
+void* __cdecl memset(void*mem,int c,size_t len)
+{
+ char *p=(char*)mem;
+ while (len-- > 0){*p++=c;}
+ return mem;
+}
+#endif
+
+
+
+FORCEINLINE NSISCH* GetIPCWndClass() { return _T("NSISUACIPC"); }
+FORCEINLINE bool StrCmpI(LPCTSTR s1,LPCTSTR s2) {return 0==lstrcmpi(s1,s2);}
+LPTSTR StrNextChar(LPCTSTR Str) { return CharNext(Str); }
+bool StrContainsWhiteSpace(LPCTSTR s) { if (s) {while(*s && *s>_T(' '))s=StrNextChar(s);if (*s)return true;}return false; }
+
+DWORD GetSysVer(bool Major=true)
+{
+ OSVERSIONINFO ovi = { sizeof(ovi) };
+ if ( !GetVersionEx(&ovi) ) return 0;
+ return Major ? ovi.dwMajorVersion : ovi.dwMinorVersion;
+}
+#define GetOSVerMaj() (GetSysVer(true))
+#define GetOSVerMin() (GetSysVer(false))
+
+UINT_PTR StrToUInt(LPTSTR s,bool ForceHEX=false,BOOL*pFoundBadChar=0)
+{
+ UINT_PTR v=0;
+ BYTE base=ForceHEX?16:10;
+ if (pFoundBadChar)*pFoundBadChar=false;
+ if ( !ForceHEX && *s=='0' && ((*(s=StrNextChar(s)))&~0x20)=='X' && (s=StrNextChar(s)) )base=16;
+ for (TCHAR c=*s; c; c=*(s=StrNextChar(s)) )
+ {
+ if (c >= _T('0') && c <= _T('9')) c-='0';
+ else if (base==16 && (c & ~0x20) >= 'A' && (c & ~0x20) <= 'F') c=(c & 7) +9;
+ else
+ {
+ if (pFoundBadChar /*&& c!=' '*/)*pFoundBadChar=true;
+ break;
+ }
+ v*=base;v+=c;
+ }
+ return v;
+}
+
+LPTSTR FindExePathEnd(LPTSTR p)
+{
+ if ( *p=='"' && *(++p) )
+ {
+ while( *p && *p!='"' )p=StrNextChar(p);
+ if (*p)
+ p=StrNextChar(p);
+ else
+ return 0;
+ }
+ else
+ if ( *p!='/' )while( *p && *p!=' ' )p=StrNextChar(p);
+ return p;
+}
+
+
+#ifdef FEAT_MSRUNASDLGMODHACK
+HHOOK g_MSRunAsHook;
+void MSRunAsDlgMod_Unload(void*hook)
+{
+ if (hook)
+ {
+ //ASSERT(g_MSRunAsHook==hook);
+ UnhookWindowsHookEx((HHOOK)hook);
+ //g_MSRunAsHook=0;
+ }
+}
+LRESULT CALLBACK MSRunAsDlgMod_ShellProc(int nCode,WPARAM wp,LPARAM lp)
+{
+ CWPRETSTRUCT*pCWPS;
+ if (nCode >= 0 && (pCWPS=(CWPRETSTRUCT*)lp) && WM_INITDIALOG==pCWPS->message)
+ {
+ TCHAR buf[30];
+ GetClassName(pCWPS->hwnd,buf,COUNTOF(buf));
+ if (!lstrcmpi(buf,_T("#32770")))
+ {
+ const UINT IDC_USRSAFER=0x106,IDC_OTHERUSER=0x104,IDC_SYSCRED=0x105;
+ GetClassName(GetDlgItem(pCWPS->hwnd,IDC_SYSCRED),buf,COUNTOF(buf));
+ if (!lstrcmpi(buf,_T("SysCredential"))) //make sure this is the run as dialog
+ {
+ MySndDlgItemMsg(pCWPS->hwnd,IDC_USRSAFER,BM_SETCHECK,BST_UNCHECKED);
+ MySndDlgItemMsg(pCWPS->hwnd,IDC_OTHERUSER,BM_CLICK);
+ }
+ }
+ }
+ return CallNextHookEx(g_MSRunAsHook,nCode,wp,lp);
+}
+void* MSRunAsDlgMod_Init()
+{
+ if(GetOSVerMaj()!=5 || GetOSVerMin()<1)return NULL;//only XP/2003
+ return g_MSRunAsHook=SetWindowsHookEx(WH_CALLWNDPROCRET,MSRunAsDlgMod_ShellProc,0,GetCurrentThreadId());
+}
+#endif
+
+DWORD DllSelfAddRef()
+{
+ NSISCH buf[MAX_PATH*5];//Lets hope $pluginsdir is shorter than this, only special builds could break this
+ DWORD len=GetModuleFileName(g.hInstance,buf,MAX_PATH*5);
+ if ( len && len<MAX_PATH*5 && LoadLibrary(buf) )
+ {
+ if (!g.DllRef)g.DllRef++;
+ return NO_ERROR;
+ }
+ ASSERT(!"DllSelfAddRef failed!");
+ return ERROR_BUFFER_OVERFLOW;
+}
+
+FORCEINLINE DWORD MaintainDllSelfRef() //Call this from every exported function to prevent NSIS from unloading our plugin
+{
+ if(!g.CheckedIPCParam && !g.DllRef)
+ {
+ HWND hSrv;
+ g.CheckedIPCParam=true;
+ g.UseIPC=GetIPCSrvWndFromParams(hSrv);
+ if(g.UseIPC)
+ {
+ g.DllRef++;
+ g.hSrvIPC=hSrv;
+ }
+ }
+ return (g.DllRef)?DllSelfAddRef():NO_ERROR;
+}
+
+
+DWORD SendIPCMsg(UINT Msg,WPARAM wp,LPARAM lp,DWORD_PTR&MsgRet,DWORD tout=IPCTOUT_DEF,const HWND hIPCSrv=g.hSrvIPC)
+{
+ if (tout==INFINITE) //BUGFIX: SendMessageTimeout(...,INFINITE,...) seems to be broken, SendMessageTimeout(...,SMTO_NORMAL,0,..) seems to work but why take the chance
+ {
+ MsgRet=SendMessage(hIPCSrv,Msg,wp,lp);
+ return NO_ERROR;
+ }
+ if ( SendMessageTimeout(hIPCSrv,Msg,wp,lp,SMTO_NORMAL,tout,&MsgRet) )return NO_ERROR;
+ return (tout=GetLastError()) ? tout : ERROR_TIMEOUT;
+}
+
+void _Unload()
+{
+ StopIPCSrv();
+ if (g.DllRef)
+ {
+ g.DllRef=0;
+ FreeLibrary(g.hInstance);
+ //Why bother?> FreeLibrary(g.hModAdvAPI);
+ }
+}
+
+DWORD DelayLoadGetProcAddr(void**ppProc,HMODULE hLib,LPCSTR Export)
+{
+ ASSERT(ppProc && hLib && Export);
+ if (!*ppProc)
+ {
+ *ppProc=GetProcAddress(hLib,Export);
+ if (!*ppProc)return GetLastError();
+ }
+ return NO_ERROR;
+}
+
+DWORD DelayLoadDlls()
+{
+
+#ifdef UNICODE
+# define __DLD_FUNCSUFFIX "W"
+# else
+# define __DLD_FUNCSUFFIX "A"
+# endif
+
+ if (!g.hModAdvAPI) //using g.hModAdvAPI to test if this is the first time we have been called
+ {
+ struct
+ {
+ HMODULE*pMod;
+ LPCSTR DllName;//NOTE: Always using ANSI strings to save a couple of bytes
+ }
+ dld[]=
+ {
+ {&g.hModAdvAPI,"AdvAPI32"},
+ {0}
+ };
+ DWORD ec;
+ UINT o;
+
+ for (o=0; dld[o].pMod; ++o)
+ if ( !(*dld[o].pMod=LoadLibraryA(dld[o].DllName)) )
+ return GetLastError();
+
+ struct
+ {
+ HMODULE hMod;
+ void**ppProc;
+ LPCSTR Export;
+ bool Optional;
+ }
+ dldprocs[]=
+ {
+ {GetModuleHandle(_T("USER32")),(void**)&_AllowSetForegroundWindow,"AllowSetForegroundWindow",true},
+ {g.hModAdvAPI,(void**)&_OpenProcessToken, "OpenProcessToken"},
+ {g.hModAdvAPI,(void**)&_OpenThreadToken, "OpenThreadToken"},
+ {g.hModAdvAPI,(void**)&_GetTokenInformation, "GetTokenInformation"},
+ {g.hModAdvAPI,(void**)&_AllocateAndInitializeSid, "AllocateAndInitializeSid"},
+ {g.hModAdvAPI,(void**)&_FreeSid, "FreeSid"},
+ {g.hModAdvAPI,(void**)&_EqualSid, "EqualSid"},
+ {g.hModAdvAPI,(void**)&_CheckTokenMembership, "CheckTokenMembership",true},
+ #ifdef FEAT_CUSTOMRUNASDLG
+ {g.hModAdvAPI,(void**)&_GetUserName, "GetUserName" __DLD_FUNCSUFFIX},
+ {g.hModAdvAPI,(void**)&_CreateProcessWithLogonW,"CreateProcessWithLogonW",true},
+ {LoadLibraryA("SECUR32"),(void**)&_GetUserNameEx,"GetUserNameEx" __DLD_FUNCSUFFIX,true},//We never free this library
+ #endif
+ {0}
+ };
+#undef __DLD_FUNCSUFFIX
+ for (o=0; dldprocs[o].hMod; ++o)
+ if (ec=DelayLoadGetProcAddr(dldprocs[o].ppProc,dldprocs[o].hMod,dldprocs[o].Export) && !dldprocs[o].Optional)
+ {
+ TRACEF("DelayLoadDlls failed to find %s in %X\n",dldprocs[o].Export,dldprocs[o].hMod);
+ return ec;
+ }
+ }
+ return NO_ERROR;
+}
+
+void AllowOuterInstanceWindowFocus()
+{
+ if (g.UseIPC)
+ {
+ DWORD_PTR MsgRet;
+ if (!SendIPCMsg(IPC_GETSRVPID,0,0,MsgRet,IPCTOUT_SHORT) && MsgRet && _AllowSetForegroundWindow)_AllowSetForegroundWindow(MsgRet);
+ }
+}
+
+DWORD SyncVars(HWND hwndNSIS)
+{
+ DWORD i,ec=NO_ERROR;
+ IPC_SYNCVAR*pSV=0;
+ if (!g.UseIPC)return NO_ERROR;
+ g.NSISStrLen=NSIS::StrSize;
+ TRACEF("SyncVars: g.NSISStrLen=%d\n",g.NSISStrLen);ASSERT(g.NSISStrLen>10);
+ DWORD cbStruct=FIELD_OFFSET(IPC_SYNCVAR,buf[g.NSISStrLen+1]);
+ pSV=(IPC_SYNCVAR*)MemAlloc(cbStruct);
+ if (!pSV)
+ goto die_GLE;
+ else
+ {
+ COPYDATASTRUCT cds={CDI_SYNCVAR,cbStruct,pSV};
+ for (i=0;i<__INST_LAST && !ec;++i)
+ {
+ pSV->VarId=i;
+ lstrcpyn(pSV->buf,GetVar(i),g.NSISStrLen);
+ DWORD MsgRet;//TRACEF("SyncVars: (%d)%s|\n",i,pSV->buf);
+ if (!(ec=SendIPCMsg(WM_COPYDATA,(WPARAM)hwndNSIS,(LPARAM)&cds,MsgRet,3000 )))ec=MsgRet-1;
+ }
+ }
+ return ec;
+die_GLE:
+ return GetLastError();
+}
+
+DWORD _Exec(HWND hwnd,NSISCH*Verb,NSISCH*Exec,NSISCH*Params,NSISCH*WorkDir,WORD ShowWnd,bool Wait,bool UseCreateProcess)
+{
+ DWORD ec;
+ NSISCH*buf=0;
+ SHELLEXECUTEINFO sei={sizeof(SHELLEXECUTEINFO)};
+ sei.hwnd =hwnd;
+ sei.nShow =(ShowWnd!=SW_INVALID)?ShowWnd:SW_NORMAL;
+ sei.fMask =SEE_MASK_FLAG_DDEWAIT;
+ sei.lpFile =(Exec&&*Exec) ?Exec:0;
+ sei.lpParameters=(Params&&*Params) ?Params:0;
+ sei.lpDirectory =(WorkDir&&*WorkDir) ?WorkDir:0;
+ sei.lpVerb =(Verb&&*Verb) ?Verb:0;
+ TRACEF("_Exec:%X|%s|%s|%s|wait=%d useCreateProc=%d ShowWnd=%d useShowWnd=%d\n",hwnd,Exec,Params,WorkDir,Wait,UseCreateProcess,ShowWnd,ShowWnd!=SW_INVALID);
+ if (UseCreateProcess)
+ {
+ STARTUPINFO si={sizeof(STARTUPINFO)};
+ if (ShowWnd != SW_INVALID)
+ {
+ si.dwFlags|=STARTF_USESHOWWINDOW;
+ si.wShowWindow=sei.nShow;
+ }
+ PROCESS_INFORMATION pi;
+ const NSISCH*Q=( (*Exec!='"') && (*Params) && StrContainsWhiteSpace(Exec)) ? _T("\"") : _T("");//Add extra quotes to program part of command-line?
+ const DWORD len= ((*Q)?2:0) + lstrlen(Exec) + 1 + lstrlen(Params) + 1;
+ buf=(NSISCH*)NSIS::MemAlloc(len*sizeof(NSISCH));
+ if (!buf)return ERROR_OUTOFMEMORY;
+ //Build string for CreateProcess, "[Q]<Exec>[Q][Space]<Params>"
+ wsprintf(buf,_T("%s%s%s%s%s"),Q,Exec,Q,((*Params)?_T(" "):_T("")),Params);
+ TRACEF("_Exec: calling CreateProcess>%s< in >%s< addedQ=%d show=%u\n",buf,sei.lpDirectory,*Q,sei.nShow);
+ if ( !CreateProcess(0,buf,0,0,false,0,0,sei.lpDirectory,&si,&pi) ) goto die_GLE;
+ CloseHandle(pi.hThread);
+ sei.hProcess=pi.hProcess;
+ }
+ else
+ {
+ sei.fMask|=SEE_MASK_NOCLOSEPROCESS;
+ TRACEF("_Exec: calling ShellExecuteEx...\n");
+ if ( !ShellExecuteEx(&sei) )goto die_GLE;
+ }
+ if (Wait)
+ {
+ WaitForSingleObject(sei.hProcess,INFINITE);
+ GetExitCodeProcess(sei.hProcess,&g.LastWaitExitCode);
+ }
+ else WaitForInputIdle(sei.hProcess,1500);//wait a little bit so the finish page window does not go away too fast and cause focus problems
+
+ CloseHandle(sei.hProcess);
+ ec=NO_ERROR;
+ret:
+ if (buf)NSIS::MemFree(buf);
+ return ec;
+die_GLE:
+ ec=GetLastError();
+ TRACEF("_Exec>%s failed with error %u (%s)\n",UseCreateProcess?"CreateProcess":"ShExec",ec,buf);
+ goto ret;
+}
+
+WORD GetShowWndCmdFromStr(NSISCH*s)
+{
+ //NOTE: Little used modes are still supported, just not with strings, you must use the actual number or ${SW_xx} defines from WinMessages.h
+ struct {NSISCH*id;WORD cmd;} swcm[] = {
+ {_T("SW_HIDE"), SW_HIDE},
+ {_T("SW_SHOW"), SW_SHOW},
+ {_T("SW_RESTORE"), SW_RESTORE},
+ {_T("SW_MAXIMIZE"), SW_MAXIMIZE},
+ {_T("SW_MINIMIZE"), SW_MINIMIZE},
+ // {_T("SW_MAX"), SW_MAXIMIZE},
+ // {_T("SW_MIN"), SW_MINIMIZE},
+ {_T("SW_SHOWNORMAL"), SW_SHOWNORMAL},
+ //{_T("SW_NORMAL"), SW_NORMAL},
+ //{_T("SW_SHOWMINIMIZED"), SW_SHOWMINIMIZED},
+ //{_T("SW_SHOWMAXIMIZED"), SW_SHOWMAXIMIZED},
+ //{_T("SW_SHOWNOACTIVATE"), SW_SHOWNOACTIVATE},
+ //{_T("SW_SHOWNA"), SW_SHOWNA},
+ //{_T("SW_SHOWMINNOACTIVE"), SW_SHOWMINNOACTIVE},
+ //{_T("SW_SHOWDEFAULT"), SW_SHOWDEFAULT},
+ //{_T("SW_FORCEMINIMIZE"), SW_FORCEMINIMIZE},
+ {0}
+ };
+ for (int i=0; swcm[i].id; ++i) if (StrCmpI(s,swcm[i].id)) return swcm[i].cmd;
+ return SW_INVALID;
+}
+
+void HandleExecExport(bool CreateProc,bool Wait,HWND&hwndNSIS,int&StrSize,NSISCH*&Vars,stack_t**&StackTop,NSIS::extra_parameters*pXParams)
+{
+ DWORD ec=NO_ERROR,ForkExitCode=ERROR_INVALID_FUNCTION;
+ UINT cch=0,cbStruct;
+ WORD ShowWnd;
+ IPC_SHEXEC*pISE=0;
+ stack_t* const pSIVerb=CreateProc?0:StackPop();//Only ShellExec supports verb's
+ stack_t* const pSIShowWnd =StackPop();
+ stack_t* const pSIExec =StackPop();
+ stack_t* const pSIParams =StackPop();
+ stack_t* const pSIWorkDir =StackPop();
+
+ if (ec=MaintainDllSelfRef())goto ret;
+ if (!pSIExec || !pSIParams || !pSIWorkDir || !pSIShowWnd || (!pSIVerb && !CreateProc))
+ {
+ TRACE("If you see this you probably forgot that all parameters are required!\n");
+ ec=ERROR_INVALID_PARAMETER;
+ goto ret;
+ }
+ ShowWnd=GetShowWndCmdFromStr(pSIShowWnd->text);
+ if (ShowWnd==SW_INVALID && *pSIShowWnd->text)
+ {
+ BOOL BadCh;
+ ShowWnd=StrToUInt(pSIShowWnd->text,false,&BadCh);
+ if (BadCh)ShowWnd=SW_INVALID;
+ }
+ TRACEF("HandleExecExport: ipc=%X (%X)\n",g.UseIPC,g.hSrvIPC);
+ SyncVars(hwndNSIS);
+ if (!g.UseIPC) //No IPC Server, we are not elevated with UAC
+ {
+ ec=_Exec(hwndNSIS,pSIVerb?pSIVerb->text:0,pSIExec->text,pSIParams->text,pSIWorkDir->text,ShowWnd,Wait,CreateProc);
+ if (Wait)ForkExitCode=g.LastWaitExitCode;
+ goto ret;
+ }
+ cch+=lstrlen(pSIExec->text)+1;
+ cch+=lstrlen(pSIParams->text)+1;
+ cch+=lstrlen(pSIWorkDir->text)+1;
+ if (pSIVerb)cch+=lstrlen(pSIVerb->text)+1;
+ cbStruct=FIELD_OFFSET( IPC_SHEXEC, buf[cch*sizeof(TCHAR)] );
+ pISE=(IPC_SHEXEC*)NSIS::MemAlloc(cbStruct);
+ if (!pISE)ec=GetLastError();
+ if (!ec)
+ {
+ DWORD_PTR MsgRet;
+ pISE->hwnd =hwndNSIS;
+ pISE->Wait =Wait;
+ pISE->ShowMode =ShowWnd;
+ pISE->UseCreateProcess=CreateProc;
+ //Just offsets at this point
+ pISE->strExec =(NSISCH*)0;
+ pISE->strParams =(NSISCH*)(lstrlen(pSIExec->text) +pISE->strExec+1);
+ pISE->strWorkDir=(NSISCH*)(lstrlen(pSIParams->text) +pISE->strParams+1);
+ pISE->strVerb= (NSISCH*)(lstrlen(pSIWorkDir->text)+pISE->strWorkDir+1);
+ lstrcpy(pISE->buf,pSIExec->text);
+ lstrcpy(&pISE->buf[(DWORD_PTR)pISE->strParams], pSIParams->text);
+ lstrcpy(&pISE->buf[(DWORD_PTR)pISE->strWorkDir],pSIWorkDir->text);
+ if (pSIVerb)lstrcpy(&pISE->buf[(DWORD_PTR)pISE->strVerb], pSIVerb->text);
+ COPYDATASTRUCT cds;
+ cds.dwData=CDI_SHEXEC;
+ cds.cbData=cbStruct;
+ cds.lpData=pISE;
+ AllowOuterInstanceWindowFocus();
+ if (!(ec=SendIPCMsg(WM_COPYDATA,(WPARAM)hwndNSIS,(LPARAM)&cds,MsgRet,Wait?(INFINITE):(IPCTOUT_LONG) )))ec=MsgRet-1;
+ TRACEF("HandleExecExport: IPC returned %X, ec=%d\n",MsgRet,ec);
+ if (Wait && NO_ERROR==ec)
+ {
+ ec=SendIPCMsg(IPC_GETEXITCODE,0,0,ForkExitCode);
+ TRACEF("HandleExecExport(Wait): Spawned process exit code=%d",ForkExitCode);
+ }
+ }
+ret:
+ NSIS::MemFree(pISE);
+ StackFreeItem(pSIShowWnd);
+ StackFreeItem(pSIExec);
+ StackFreeItem(pSIParams);
+ StackFreeItem(pSIWorkDir);
+ StackFreeItem(pSIVerb);
+ SetVarUINT(INST_0,ec);
+ if (ec)SetErrorFlag(pXParams);
+ if (Wait)SetVarUINT(INST_1,ForkExitCode);
+}
+
+
+bool _SupportsUAC(bool VersionTestOnly=false)
+{
+ TOKEN_ELEVATION_TYPE tet;
+ OSVERSIONINFO ovi={sizeof(ovi)};
+ if (!GetVersionEx(&ovi))
+ {
+ ASSERT(!"_SupportsUAC>GetVersionEx");
+ return false;
+ }
+ if (VersionTestOnly)return ovi.dwMajorVersion>=6;
+ if (ovi.dwMajorVersion>=6 && _GetElevationType(&tet)==NO_ERROR)
+ {
+ const bool ret=tet!=TokenElevationTypeDefault && tet!=NULL;
+ TRACEF("_SupportsUAC tet=%d, returning %d\n",tet,ret);
+ return ret;
+ }
+ DBGONLY(TRACEF("_SupportsUAC returning false! ver=%d _GetElevationType.ret=%u\n",ovi.dwMajorVersion,_GetElevationType(&tet)));
+ return false;
+}
+
+DWORD _GetElevationType(TOKEN_ELEVATION_TYPE*pTokenElevType)
+{
+ DWORD ec=ERROR_ACCESS_DENIED;
+ HANDLE hToken=0;
+ DWORD RetLen;
+ if (!pTokenElevType)return ERROR_INVALID_PARAMETER;
+ if (ec=DelayLoadDlls())return ec;
+ *pTokenElevType=(TOKEN_ELEVATION_TYPE)NULL;
+ if (!_SupportsUAC(true))return NO_ERROR;
+ if (!_OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY,&hToken))goto dieLastErr;
+ if (!_GetTokenInformation(hToken,(_TOKEN_INFORMATION_CLASS)TokenElevationType,pTokenElevType,sizeof(TOKEN_ELEVATION_TYPE),&RetLen))goto dieLastErr;
+ SetLastError(NO_ERROR);
+dieLastErr:
+ ec=GetLastError();
+ CloseHandle(hToken);
+ TRACEF("_GetElevationType ec=%u type=%d\n",ec,*pTokenElevType);
+ return ec;
+}
+
+
+bool _IsUACEnabled()
+{
+ HKEY hKey;
+ bool ret=false;
+ if (GetSysVer()>=6 && NO_ERROR==RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"),0,KEY_READ,&hKey))
+ {
+ DWORD val,type,size=sizeof(DWORD);
+ if (NO_ERROR==RegQueryValueEx(hKey,_T("EnableLUA"),0,&type,(LPBYTE)&val,&size) && type==REG_DWORD && val!=0) ret=true;
+ RegCloseKey(hKey);
+ }
+ return ret;
+}
+
+
+bool SysElevationPresent() //Will return false on Vista if UAC is off
+{
+ const DWORD vmaj=GetSysVer();
+ ASSERT(vmaj<=6 && vmaj>=4);
+ if (vmaj==5) return true; //TODO:Check if secondary logon service is running?
+ if (vmaj>=6) return _IsUACEnabled();
+ return false;
+}
+
+FORCEINLINE bool SysSupportsRunAs()
+{
+ return GetSysVer()>=5;
+}
+
+
+
+
+
+bool _IsAdmin()
+{
+
+#ifdef BUILD_XPTEST
+ static int _dbgOld=-1;
+ unsigned _dbg=(unsigned)FindExePathEnd(GetCommandLine());
+ if (_dbgOld==-1){_dbg=(_dbg && *((TCHAR*)_dbg))?MessageBoxA(0,"Debug: Pretend to be admin?",GetCommandLine(),MB_YESNOCANCEL):IDCANCEL;} else _dbg=_dbgOld;_dbgOld=_dbg;TRACEF("_IsAdmin=%d|%d\n",_dbg,_dbg==IDYES);
+ if (_dbg!=IDCANCEL){SetLastError(0);return _dbg==IDYES;}
+#endif
+
+ BOOL isAdmin=false;
+ DWORD ec;
+ OSVERSIONINFO ovi={sizeof(ovi)};
+ if (!GetVersionEx(&ovi))return false;
+ if (VER_PLATFORM_WIN32_NT != ovi.dwPlatformId) //Not NT
+ {
+ SetLastError(NO_ERROR);
+ return true;
+ }
+ if (ec=DelayLoadDlls())
+ {
+ TRACEF("DelayLoadDlls failed in _IsAdmin() with err x%X\n",ec);
+ SetLastError(ec);
+ return false;
+ }
+
+ ASSERT(_OpenThreadToken && _OpenProcessToken && _AllocateAndInitializeSid && _EqualSid && _FreeSid);
+ HANDLE hToken;
+ if (_OpenThreadToken(GetCurrentThread(),TOKEN_QUERY,FALSE,&hToken) || _OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY,&hToken))
+ {
+ SID_IDENTIFIER_AUTHORITY SystemSidAuthority = SECURITY_NT_AUTHORITY;
+ PSID psid=0;
+ if (_AllocateAndInitializeSid(&SystemSidAuthority,2,SECURITY_BUILTIN_DOMAIN_RID,DOMAIN_ALIAS_RID_ADMINS,0,0,0,0,0,0,&psid))
+ {
+ if (_CheckTokenMembership)
+ {
+ if (!_CheckTokenMembership(0,psid,&isAdmin))isAdmin=false;
+ }
+ else
+ {
+ DWORD cbTokenGrps;
+ if (!_GetTokenInformation(hToken,TokenGroups,0,0,&cbTokenGrps)&&GetLastError()==ERROR_INSUFFICIENT_BUFFER)
+ {
+ TOKEN_GROUPS*ptg=0;
+ if (ptg=(TOKEN_GROUPS*)NSIS::MemAlloc(cbTokenGrps))
+ {
+ if (_GetTokenInformation(hToken,TokenGroups,ptg,cbTokenGrps,&cbTokenGrps))
+ {
+ for (UINT i=0; i<ptg->GroupCount;i++)
+ {
+ if (_EqualSid(ptg->Groups[i].Sid,psid))isAdmin=true;
+ }
+ }
+ NSIS::MemFree(ptg);
+ }
+ }
+ }
+ _FreeSid(psid);
+ }
+ CloseHandle(hToken);
+ }
+ if (isAdmin) //UAC Admin with split token check
+ {
+ if (_SupportsUAC())
+ {
+ TOKEN_ELEVATION_TYPE tet;
+ if (_GetElevationType(&tet) || tet==TokenElevationTypeLimited)isAdmin=false;
+ }
+ else SetLastError(NO_ERROR);
+ }
+ return FALSE != isAdmin;
+}
+
+
+LRESULT CALLBACK IPCSrvWndProc(HWND hwnd,UINT uMsg,WPARAM wp,LPARAM lp)
+{
+ switch(uMsg)
+ {
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+ case WM_CLOSE:
+ return DestroyWindow(hwnd);
+ case WM_COPYDATA:
+ if (lp)
+ {
+ const COPYDATASTRUCT*pCDS=(COPYDATASTRUCT*)lp;
+ if (pCDS->dwData==CDI_SHEXEC && pCDS->lpData)
+ {
+ if ( pCDS->cbData < sizeof(IPC_SHEXEC) )break;
+ g.LastWaitExitCode=ERROR_INVALID_FUNCTION;
+ IPC_SHEXEC& ise=*((IPC_SHEXEC*)pCDS->lpData);
+ SetForegroundWindow(ise.hwnd);
+ DWORD ec=_Exec(
+ ise.hwnd,
+ &ise.buf[(DWORD_PTR)ise.strVerb],
+ &ise.buf[(DWORD_PTR)ise.strExec],
+ &ise.buf[(DWORD_PTR)ise.strParams],
+ &ise.buf[(DWORD_PTR)ise.strWorkDir],
+ ise.ShowMode,ise.Wait,ise.UseCreateProcess
+ );
+ TRACEF("IPCSrvWndProc>IPC_SHEXEC>_ShExec=%d\n",ec);
+ return ec+1;
+ }
+ else if (pCDS->dwData==CDI_SYNCVAR && pCDS->lpData && pCDS->cbData>1)
+ {
+ IPC_SYNCVAR*pSV=(IPC_SYNCVAR*)pCDS->lpData;
+ if (pSV->VarId>=__INST_LAST)return 1+ERROR_INVALID_PARAMETER;
+ TRACEF("WM_COPYDATA: CDI_SYNCVAR:%d=%s|\n",pSV->VarId,&pSV->buf[0]);
+ lstrcpy(GetVar(pSV->VarId),&pSV->buf[0]);
+ return NO_ERROR+1;
+ }
+ else if (pCDS->dwData==CDI_STACKPUSH && pCDS->lpData && pCDS->cbData>=1)
+ {
+ TRACEF("WM_COPYDATA: CDI_STACKPUSH:%s|\n",pCDS->lpData);
+ return StackPush((NSISCH*)pCDS->lpData)+1;
+ }
+ }
+ break;
+ case IPC_GETEXITCODE:
+ return g.LastWaitExitCode;
+ case IPC_ELEVATEAGAIN:
+ TRACE("IPCSrvWndProc>IPC_ELEVATEAGAIN\n");
+ return (g.ElevateAgain=true);
+ case IPC_GETSRVPID:
+ return GetCurrentProcessId();//FUCKO?
+ case IPC_GETSRVHWND:
+ return GetWindowLongPtr(hwnd,GWLP_USERDATA);
+ case IPC_EXECCODESEGMENT:
+ return 1+(g.pXParams ? ExecuteCodeSegment(g.pXParams,wp,(HWND)lp) : ERROR_INVALID_FUNCTION);
+#ifdef UAC_HACK_FGWND1
+ case IPC_HACKFINDRUNAS: //super ugly hack to get title of run as dialog
+ if (wp<200)
+ {
+ HWND hRA=GetLastActivePopup((HWND)lp);
+ TRACEF("IPC_HACKFINDRUNAS:%d %X %X\n",wp,lp,hRA);
+ if (hRA && hRA !=(HWND)lp ) return PostMessage((HWND)lp,WM_APP,0,(LONG_PTR)hRA);
+ Sleep(10);PostMessage(hwnd,uMsg,wp+1,lp);
+ }
+ break;
+#endif
+ }
+ return DefWindowProc(hwnd,uMsg,wp,lp);
+}
+
+
+DWORD WINAPI IPCSrvThread(LPVOID lpParameter)
+{
+ CoInitialize(0);
+ const DWORD WStyle=WS_VISIBLE DBGONLY(|(WS_CAPTION));
+ const int PosOffset=32700;
+ MSG msg;
+ WNDCLASS wc={0};
+ wc.lpszClassName=GetIPCWndClass();
+ wc.lpfnWndProc=IPCSrvWndProc;
+ wc.hInstance=g.hInstance;
+ if (!RegisterClass(&wc))goto dieLastErr;
+ if (!(g.hSrvIPC=CreateWindowEx(WS_EX_TOOLWINDOW DBGONLY(&~WS_EX_TOOLWINDOW),
+ GetIPCWndClass(),
+ DBGONLY(_T("Debug: NSIS.UAC")+)0,
+ WStyle,
+ -PosOffset DBGONLY(+PosOffset),-PosOffset DBGONLY(+PosOffset),DBGONLY(150+)1,DBGONLY(10+)1,
+ 0,0,wc.hInstance,0
+ )))goto dieLastErr;
+ SetWindowLongPtr(g.hSrvIPC,GWLP_USERDATA,(LONG_PTR)lpParameter);
+ TRACEF("IPCSrv=%X server created...\n",g.hSrvIPC);
+ while (GetMessage(&msg,0,0,0)>0)DispatchMessage(&msg);
+ SetLastError(NO_ERROR);
+dieLastErr:
+ CoUninitialize();
+ return g.LastWaitExitCode=GetLastError();
+}
+
+DWORD InitIPC(HWND hwndNSIS,NSIS::extra_parameters*pXParams,UINT NSISStrLen)
+{
+ if (g.threadIPC)return NO_ERROR;
+ TRACEF("InitIPC StrSize=%u vs %u\n",NSIS::StrSize,NSISStrLen);
+ DWORD tid;
+ ASSERT(!g.pXParams && pXParams);
+ ASSERT(NSISStrLen>0 && NSISStrLen==NSIS::StrSize);
+ g.NSISStrLen=NSISStrLen;
+ g.pXParams=pXParams;
+ g.threadIPC=CreateThread(0,0,IPCSrvThread,hwndNSIS,0,&tid);
+ if (g.threadIPC)
+ {
+ while(!g.hSrvIPC && !g.LastWaitExitCode)Sleep(20);
+ return g.hSrvIPC ? NO_ERROR : g.LastWaitExitCode;
+ }
+ return GetLastError();
+}
+
+void StopIPCSrv()
+{
+ if (g.threadIPC)
+ {
+ TRACEF("StopIPCSrv h=%X \n",g.hSrvIPC);
+#ifdef UAC_HACK_Clammerz
+ if ( GetSysVer()>=5 )
+ {
+ //WINBUGFIX: This ugly thing supposedly solves the problem of messagebox'es in .OnInit appearing behind other windows in Vista
+ HWND hack=CreateWindowEx(WS_EX_TRANSPARENT|WS_EX_LAYERED,_T("Button"),NULL,NULL,0,0,0,0,NULL,NULL,NULL,0);
+ ShowWindow(hack,SW_SHOW);
+ SetForegroundWindow(hack);
+ DestroyWindow(hack);
+ }
+#endif
+ PostMessage(g.hSrvIPC,WM_CLOSE,0,0);
+ WaitForSingleObject(g.threadIPC,INFINITE);
+ CloseHandle(g.threadIPC);
+ UnregisterClass(GetIPCWndClass(),g.hInstance);//DLL can be loaded more than once, so make sure RegisterClass doesn't fail
+ g.hSrvIPC=0;
+ g.threadIPC=0;
+ }
+}
+
+#ifdef UAC_HACK_FGWND1
+LRESULT CALLBACK HackWndSubProc(HWND hwnd,UINT Msg,WPARAM wp,LPARAM lp)
+{
+ switch(Msg)
+ {
+ case WM_APP:
+ GetWindowText((HWND)lp,GetVar(0),NSIS::StrSize);
+ if (*GetVar(0))SendMessage(hwnd,WM_SETTEXT,0,(LONG_PTR)GetVar(0));
+ break;
+ }
+ return DefWindowProc(hwnd,Msg,wp,lp);
+}
+#endif
+
+inline bool MustUseInternalRunAs()
+{
+#ifdef BUILD_DBGSELECTELVMODE
+ TCHAR dbgb[MAX_PATH*4];wsprintf(dbgb,_T("%s.ini"),GetVar(VIDX_EXEPATH));
+ static int dbg_answer=GetPrivateProfileInt(_T("UACDBG"),_T("MustUseInternalRunAs"),2,dbgb);
+ if (dbg_answer<2)return !!dbg_answer;WritePrivateProfileString(_T("UACDBG"),_T("MustUseInternalRunAs"),"",dbgb);
+ if (MessageBox(GetActiveWindow(),"MustUseInternalRunAs?",dbgb,MB_YESNO)==IDYES)return true;
+#endif
+ return GetSysVer()>=6 && !SysElevationPresent();
+}
+
+DWORD ForkSelf(HWND hParent,DWORD&ForkExitCode,NSIS::extra_parameters*pXParams,UINT NSISStrLen)
+{
+ DWORD ec=ERROR_ACCESS_DENIED;
+ SHELLEXECUTEINFO sei={sizeof(sei)};
+ STARTUPINFO startInfo={sizeof(STARTUPINFO)};
+ LPTSTR pszExePathBuf=0;
+ LPTSTR pszParamBuf=0;
+ LPTSTR p,pCL=GetCommandLine();
+ UINT len;
+#ifdef UAC_HACK_FGWND1
+ HWND hHack=0;
+#endif
+ ASSERT(pXParams);
+
+ GetStartupInfo(&startInfo);
+ if (ec=InitIPC(hParent,pXParams,NSISStrLen))goto ret;
+ ASSERT(IsWindow(g.hSrvIPC));
+ sei.hwnd=hParent;
+ sei.nShow=(startInfo.dwFlags&STARTF_USESHOWWINDOW) ? startInfo.wShowWindow : SW_SHOWNORMAL;
+ sei.fMask=SEE_MASK_NOCLOSEPROCESS|SEE_MASK_NOZONECHECKS;
+ sei.lpVerb=_T("runas");
+ p=FindExePathEnd(pCL);
+ len=p-pCL;
+ if (!p || !len)
+ {
+ ec=ERROR_FILE_NOT_FOUND;
+ goto ret;
+ }
+ for (;;)
+ {
+ NSIS::MemFree(pszExePathBuf);
+ if (!(pszExePathBuf=(LPTSTR)NSIS::MemAlloc((++len)*sizeof(TCHAR))))goto dieOOM;
+ if ( GetModuleFileName(0,pszExePathBuf,len) < len )break; //FUCKO: what if GetModuleFileName returns 0?
+ len+=MAX_PATH;
+ }
+ sei.lpFile=pszExePathBuf;
+ len=lstrlen(p);
+ len+=20;//space for "/UAC:xxxxxx /NCRC\0"
+ if (!(pszParamBuf=(LPTSTR)NSIS::MemAlloc(len*sizeof(TCHAR))))goto dieOOM;
+ wsprintf(pszParamBuf,_T("/UAC:%X /NCRC%s"),g.hSrvIPC,p);//NOTE: The argument parser depends on our special flag appearing first
+ sei.lpParameters=pszParamBuf;
+
+#ifdef UAC_HACK_FGWND1
+ if ( GetSysVer()>=5 && !sei.hwnd )
+ {
+ //sei.nShow=SW_SHOW;//forced, do we HAVE to do this?
+ hHack=CreateWindowEx(WS_EX_TRANSPARENT|WS_EX_LAYERED|WS_EX_TOOLWINDOW|WS_EX_APPWINDOW,_T("Button"),GetVar(VIDX_EXEFILENAME),0|WS_MAXIMIZE,0,0,0,0,NULL,NULL,NULL,0);
+
+ SetWindowLongPtr(hHack,GWLP_WNDPROC,(LONG_PTR)HackWndSubProc);
+ if (GetSysVer()<6 || MustUseInternalRunAs())
+ PostMessage(g.hSrvIPC,IPC_HACKFINDRUNAS,0,(LONG_PTR)hHack);
+ else
+ SetWindowLongPtr(hHack,GWL_EXSTYLE,GetWindowLongPtr(hHack,GWL_EXSTYLE)&~WS_EX_APPWINDOW);//kill taskbar btn on vista
+ HICON hIcon=(HICON)LoadImage(GetModuleHandle(0),MAKEINTRESOURCE(103),IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_SHARED);
+ SendMessage(hHack,WM_SETICON,ICON_BIG,(LONG_PTR)hIcon);
+ ShowWindow(hHack,SW_SHOW);
+ SetForegroundWindow(hHack);
+ sei.hwnd=hHack;
+ }
+#endif
+
+ if (hParent)SetForegroundWindow(hParent);//try to force taskbar button active (for RunElevatedAndProcessMessages, really important on Vista)
+
+#ifdef FEAT_CUSTOMRUNASDLG
+ if (MustUseInternalRunAs())
+ {
+ ec=MyRunAs(g.hInstance,sei);
+ }
+ else
+#endif
+ {
+ if (GetSysVer()>=6)
+ {
+ ////////sei.nShow=SW_SHOW;
+ //if ( _SupportsUAC() )sei.hwnd=0; //Vista does not like it when we provide a HWND
+ //if (_AllowSetForegroundWindow) _AllowSetForegroundWindow(ASFW_ANY);//TODO: is GrantClientWindowInput() enough?
+ }
+#ifdef FEAT_MSRUNASDLGMODHACK
+ void* hook=MSRunAsDlgMod_Init();
+#endif
+ TRACEF("ForkSelf:calling ShExec:app=%s|params=%s|vrb=%s|hwnd=%X\n",sei.lpFile,sei.lpParameters,sei.lpVerb,sei.hwnd);
+ ec=(ShellExecuteEx(&sei)?NO_ERROR:GetLastError());
+ TRACEF("ForkSelf: ShExec->Runas returned %d hInstApp=%d\n",ec,sei.hInstApp);
+#ifdef FEAT_MSRUNASDLGMODHACK
+ MSRunAsDlgMod_Unload(hook);
+#endif
+ }
+#ifdef UAC_HACK_FGWND1
+ DestroyWindow(hHack);
+#endif
+ if (ec)goto ret;
+ TRACEF("ForkSelf: waiting for process %X (%s|%s|%s)sei.hwnd=%X\n",(sei.hProcess),sei.lpFile,sei.lpParameters,sei.lpVerb,sei.hwnd);
+ ASSERT(sei.hProcess);
+ ASSERT(NO_ERROR==ec);
+ ShowWindow(g.hSrvIPC,SW_HIDE);
+
+ if (!IsWindow(sei.hwnd))
+ {
+ DWORD w=WaitForSingleObject(sei.hProcess,INFINITE);
+ if (w==WAIT_OBJECT_0)
+ VERIFY(GetExitCodeProcess(sei.hProcess,&ForkExitCode));
+ else
+ {
+ ec=GetLastError();
+ TRACEF("ForkSelf:WaitForSingleObject failed ec=%d w=%d\n",ec,w);ASSERT(!"ForkSelf:WaitForSingleObject");
+ }
+ }
+ else
+ {
+ bool abortWait=false;
+ const DWORD waitCount=1;
+ const HANDLE handles[waitCount]={sei.hProcess};
+ do
+ {
+ DWORD w=MsgWaitForMultipleObjects(waitCount,handles,false,INFINITE,QS_ALLEVENTS|QS_ALLINPUT);
+ switch(w)
+ {
+ case WAIT_OBJECT_0:
+ VERIFY(GetExitCodeProcess(sei.hProcess,&ForkExitCode));
+ abortWait=true;
+ break;
+ case WAIT_OBJECT_0+waitCount:
+ {
+ const HWND hwnd=sei.hwnd;
+ MSG msg;
+ while( !ec && PeekMessage(&msg,hwnd,0,0,PM_REMOVE) )
+ {
+ if (msg.message==WM_QUIT)
+ {
+ ASSERT(0);
+ ec=ERROR_CANCELLED;
+ break;
+ }
+ if (!IsDialogMessage(hwnd,&msg))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ }
+ break;
+ default:
+ abortWait=true;
+ ec=GetLastError();
+ TRACEF("ForkSelf:MsgWaitForMultipleObjects failed, ec=%u w=%u\n",ec,w);
+ }
+ } while( NO_ERROR==ec && !abortWait );
+ }
+
+ TRACEF("ForkSelf: wait complete, ec=%d forkexitcode=%u\n",ec,ForkExitCode);
+ goto ret;
+dieOOM:
+ ec=ERROR_OUTOFMEMORY;
+ret:
+ StopIPCSrv();
+ CloseHandle(sei.hProcess);
+ NSIS::MemFree(pszExePathBuf);
+ NSIS::MemFree(pszParamBuf);
+ return ec;
+}
+
+bool GetIPCSrvWndFromParams(HWND&hwndOut)
+{
+ LPTSTR p=FindExePathEnd(GetCommandLine());
+ while(p && *p==' ')p=CharNext(p);TRACEF("GetIPCSrvWndFromParams:%s|\n",p);
+ if (p && *p++=='/'&&*p++=='U'&&*p++=='A'&&*p++=='C'&&*p++==':')
+ {
+ hwndOut=(HWND)StrToUInt(p,true);
+ return !!IsWindow(hwndOut);
+ }
+ return false;
+}
+
+
+/*** RunElevated
+Return: r0: Windows error code (0 on success, 1223 if user aborted elevation dialog, anything else should be treated as a fatal error)
+ r1: If r0==0, r1 is:
+ 0 if UAC is not supported by the OS,
+ 1 if UAC was used to elevate and the current process should act like a wrapper (Call Quit in .OnInit without any further processing),
+ 2 if the process is (already?) running @ HighIL (Member of admin group on other systems),
+ 3 if you should call RunElevated again (This can happen if a user without admin priv. is used in the runas dialog),
+ r2: If r0==0 && r1==1: r2 is the ExitCode of the elevated fork process (The NSIS errlvl is also set to the ExitCode)
+ r3: If r0==0: r3 is 1 if the user is a member of the admin group or 0 otherwise
+*/
+EXPORTNSISFUNC RunElevated(HWND hwndNSIS,int StrSize,NSISCH*Vars,NSIS::stack_t **StackTop,NSIS::extra_parameters* XParams)
+{
+ NSISFUNCSTART(hwndNSIS,StrSize,Vars,StackTop,XParams);
+
+ BYTE UACMode=0;
+ bool UserIsAdmin=false;
+ DWORD ec=ERROR_ACCESS_DENIED,ForkExitCode;
+ TOKEN_ELEVATION_TYPE tet;
+
+ UserIsAdmin=_IsAdmin();
+ TRACEF("RunElevated:Init: IsAdmin=%d\n",UserIsAdmin);
+#ifdef BUILD_XPTEST
+ if (!UserIsAdmin)goto DbgXPAsUAC;//Skip UAC detection for special debug builds and force a call to runas on <NT6 systems
+#endif
+ if (!_SupportsUAC() && !SysSupportsRunAs())goto noUAC;
+ if ((ec=DelayLoadDlls()))goto ret;
+
+ if (GetIPCSrvWndFromParams(g.hSrvIPC))
+ {
+ if (ec=DllSelfAddRef())goto ret;
+ if (!IsWindow(g.hSrvIPC))ec=ERRAPP_BADIPCSRV;
+ UACMode=2;
+ g.UseIPC=true;
+ if (!UserIsAdmin) //Elevation used, but we are not Admin, let the wrapper know so it can try again...
+ {
+ UACMode=0xFF;//Special invalid mode
+ DWORD_PTR MsgRet;
+ if (SendIPCMsg(IPC_ELEVATEAGAIN,0,0,MsgRet) || !MsgRet)ec=ERRAPP_BADIPCSRV;//if we could not notify the need for re-elevation, the IPCSrv must be bad
+ }
+ goto ret;
+ }
+
+ if ( (ec=DllSelfAddRef()) || (ec=_GetElevationType(&tet)) )goto ret;
+ if ( tet==TokenElevationTypeFull || UserIsAdmin )
+ {
+ UserIsAdmin=true;
+ UACMode=2;
+ goto ret;
+ }
+
+ DBGONLY(DBG_RESETDBGVIEW());
+
+#ifdef BUILD_XPTEST
+DbgXPAsUAC:VERIFY(!DllSelfAddRef());
+#endif
+ //OS supports UAC and we need to elevate...
+ ASSERT(!UserIsAdmin);
+ UACMode=1;
+
+ ec=ForkSelf(hwndNSIS,ForkExitCode,XParams,StrSize);
+ if (!ec && !g.ElevateAgain)
+ {
+ SetVarUINT(INST_2,ForkExitCode);
+ SetErrLvl(XParams,ForkExitCode);
+ }
+ goto ret;
+noUAC:
+ ec=NO_ERROR;ASSERT(UACMode==0);
+ret:
+ if (ec==ERROR_CANCELLED)
+ {
+ if (UACMode!=1)ec=ERROR_INVALID_FUNCTION;
+ if (UACMode<2)g.UseIPC=false;
+ }
+ if (UACMode==0xFF && !ec) //We called IPC_ELEVATEAGAIN, so we need to quit so the wrapper gains control
+ {
+ ASSERT(g.UseIPC);
+ UACMode=1;//We pretend to be the wrapper so Quit gets called in .OnInit
+ SetErrLvl(XParams,0);
+ _Unload();
+ }
+ if (g.ElevateAgain)
+ {
+ ASSERT(!g.UseIPC);
+ UACMode=3;//Fork called IPC_ELEVATEAGAIN, we need to change our UACMode so the wrapper(our instance) can try to elevate again if it wants to
+ }
+ if (!g.UseIPC)
+ _Unload();//The wrapper can call quit in .OnInit without calling UAC::Unload, so we do it here
+
+ SetVarUINT(INST_0,ec);
+ SetVarUINT(INST_1,UACMode);
+ SetVarUINT(INST_3,UserIsAdmin);
+ TRACEF("RunElevated returning ec=%X UACMode=%d g.UseIPC=%d g.ElevateAgain=%d IsAdmin=%d\n",ec,UACMode,g.UseIPC,g.ElevateAgain,UserIsAdmin);
+
+ NSISFUNCEND();
+}
+
+
+
+/*** Exec
+Notes:
+ ¤ ErrorFlag is also set on error
+STACK: <ShowWindow> <File> <Parameters> <WorkingDir>
+Return: windows error code in r0, 0 on success
+*/
+EXPORTNSISFUNC Exec(HWND hwndNSIS,int StrSize,NSISCH*Vars,NSIS::stack_t **StackTop,NSIS::extra_parameters* XParams)
+{
+ NSISFUNCSTART(hwndNSIS,StrSize,Vars,StackTop,XParams);
+ HandleExecExport(true,false,hwndNSIS,StrSize,Vars,StackTop,XParams);
+ NSISFUNCEND();
+}
+
+/*** ExecWait
+Notes:
+ ¤ ErrorFlag is also set on error
+STACK: <ShowWindow> <File> <Parameters> <WorkingDir>
+Return:
+ r0: windows error code, 0 on success
+ r1: exitcode of new process
+*/
+EXPORTNSISFUNC ExecWait(HWND hwndNSIS,int StrSize,NSISCH*Vars,NSIS::stack_t **StackTop,NSIS::extra_parameters* XParams)
+{
+ NSISFUNCSTART(hwndNSIS,StrSize,Vars,StackTop,XParams);
+ HandleExecExport(true,true,hwndNSIS,StrSize,Vars,StackTop,XParams);
+ NSISFUNCEND();
+}
+
+/*** ShellExec
+Notes:
+ ¤ ErrorFlag is also set on error
+STACK: <Verb> <ShowWindow> <File> <Parameters> <WorkingDir>
+Return: windows error code in r0, 0 on success
+*/
+EXPORTNSISFUNC ShellExec(HWND hwndNSIS,int StrSize,NSISCH*Vars,NSIS::stack_t **StackTop,NSIS::extra_parameters* XParams)
+{
+ NSISFUNCSTART(hwndNSIS,StrSize,Vars,StackTop,XParams);
+ HandleExecExport(false,false,hwndNSIS,StrSize,Vars,StackTop,XParams);
+ NSISFUNCEND();
+}
+
+/*** ShellExecWait
+Notes:
+ ¤ ErrorFlag is also set on error
+STACK: <Verb> <ShowWindow> <File> <Parameters> <WorkingDir>
+Return:
+ r0: windows error code, 0 on success
+ r1: exitcode of new process
+*/
+EXPORTNSISFUNC ShellExecWait(HWND hwndNSIS,int StrSize,NSISCH*Vars,NSIS::stack_t **StackTop,NSIS::extra_parameters* XParams)
+{
+ NSISFUNCSTART(hwndNSIS,StrSize,Vars,StackTop,XParams);
+ HandleExecExport(false,true,hwndNSIS,StrSize,Vars,StackTop,XParams);
+ NSISFUNCEND();
+}
+
+
+/*** GetElevationType
+Notes:
+ TokenElevationTypeDefault=1 :User is not using a split token (UAC disabled)
+ TokenElevationTypeFull=2 :UAC enabled, the process is elevated
+ TokenElevationTypeLimited=3 :UAC enabled, the process is not elevated
+Return: r0: (TOKEN_ELEVATION_TYPE)TokenType, The error flag is set if the function fails and r0==0
+*/
+EXPORTNSISFUNC GetElevationType(HWND hwndNSIS,int StrSize,NSISCH*Vars,NSIS::stack_t **StackTop,NSIS::extra_parameters* XParams)
+{
+ NSISFUNCSTART(hwndNSIS,StrSize,Vars,StackTop,XParams);
+ TOKEN_ELEVATION_TYPE tet=(TOKEN_ELEVATION_TYPE)NULL; //Default to invalid value
+ if (MaintainDllSelfRef() || /*!_SupportsUAC() ||*/ _GetElevationType(&tet)) SetErrorFlag(XParams);
+ SetVarUINT(INST_0,tet);
+ NSISFUNCEND();
+}
+
+
+
+/*** SupportsUAC
+Notes: Check if the OS supports UAC (And the user has UAC turned on)
+Return: r0: (BOOL)Result
+*/
+EXPORTNSISFUNC SupportsUAC(HWND hwndNSIS,int StrSize,NSISCH*Vars,NSIS::stack_t **StackTop,NSIS::extra_parameters* XParams)
+{
+ NSISFUNCSTART(hwndNSIS,StrSize,Vars,StackTop,XParams);
+ BOOL present=false;
+ MaintainDllSelfRef();
+ if (_SupportsUAC())present=true;
+ SetVarUINT(INST_0,present);
+ NSISFUNCEND();
+}
+
+
+/*** IsAdmin
+Return: r0: (BOOL)Result
+*/
+EXPORTNSISFUNC IsAdmin(HWND hwndNSIS,int StrSize,NSISCH*Vars,NSIS::stack_t **StackTop,NSIS::extra_parameters* XParams)
+{
+ NSISFUNCSTART(hwndNSIS,StrSize,Vars,StackTop,XParams);
+ bool Admin=false;
+ DWORD ec;
+ if ( !(ec=MaintainDllSelfRef()) )
+ {
+ Admin=_IsAdmin();
+ if ( ec=GetLastError() )
+ {
+ TRACEF("IsAdmin failed with %d\n",ec);
+ SetErrorFlag(XParams);
+ Admin=false;
+ }
+ }
+ SetVarUINT(INST_0,Admin);
+ NSISFUNCEND();
+}
+
+
+
+/*** ExecCodeSegment
+Notes: Sets error flag on error
+ There is currently no way to transfer state to/from the executed code segment!
+ If you use instructions that alter the UI or the stack/variables in the code segment (StrCpy,Push/Pop/Exch,DetailPrint,HideWindow etc.) they will affect the hidden wrapper installer and not "your" installer instance!
+*/
+EXPORTNSISFUNC ExecCodeSegment(HWND hwndNSIS,int StrSize,NSISCH*Vars,NSIS::stack_t **StackTop,NSIS::extra_parameters* XParams)
+{
+ NSISFUNCSTART(hwndNSIS,StrSize,Vars,StackTop,XParams);
+
+ DWORD ec;
+ if (!(ec=DllSelfAddRef())) //force AddRef since our plugin could be called inside the executed code segment!
+ {
+ ec=ERROR_INVALID_PARAMETER;
+ stack_t* pSI=StackPop();
+ if (pSI)
+ {
+ BOOL badCh;
+ UINT pos=StrToUInt(pSI->text,false,&badCh);
+ TRACEF("ExecCodeSegment %d (%s) badinput=%d\n",pos-1,pSI->text,badCh);
+ if (!badCh && pos--)
+ {
+ if (!g.UseIPC)
+ ec=NSIS::ExecuteCodeSegment(XParams,pos);
+ else
+ {
+ SyncVars(hwndNSIS);
+ DWORD_PTR MsgRet;
+ AllowOuterInstanceWindowFocus();
+ if (!(ec=SendIPCMsg(IPC_EXECCODESEGMENT,pos,0,MsgRet,INFINITE)))ec=MsgRet-1;
+ }
+ }
+ StackFreeItem(pSI);
+ }
+ }
+ if (ec)SetErrorFlag(XParams);
+
+ NSISFUNCEND();
+}
+
+
+
+/*** StackPush */
+EXPORTNSISFUNC StackPush(HWND hwndNSIS,int StrSize,NSISCH*Vars,NSIS::stack_t **StackTop,NSIS::extra_parameters* XParams)
+{
+ NSISFUNCSTART(hwndNSIS,StrSize,Vars,StackTop,XParams);
+
+ DWORD ec;
+ if (!(ec=DllSelfAddRef()) && g.UseIPC)
+ {
+ stack_t* pSI=StackPop();
+ ec=ERROR_INVALID_PARAMETER;
+ if (pSI)
+ {
+ DWORD_PTR MsgRet;
+ COPYDATASTRUCT cds={CDI_STACKPUSH,(lstrlen(pSI->text)+1)*sizeof(NSISCH),pSI->text};
+ if (!(ec=SendIPCMsg(WM_COPYDATA,(WPARAM)hwndNSIS,(LPARAM)&cds,MsgRet,5000 )))ec=MsgRet-1;
+ StackFreeItem(pSI);
+ }
+ }
+ if (ec)SetErrorFlag(XParams);
+
+ NSISFUNCEND();
+}
+
+
+
+/*** GetOuterHwnd */
+EXPORTNSISFUNC GetOuterHwnd(HWND hwndNSIS,int StrSize,NSISCH*Vars,NSIS::stack_t **StackTop,NSIS::extra_parameters* XParams)
+{
+ NSISFUNCSTART(hwndNSIS,StrSize,Vars,StackTop,XParams);
+ MaintainDllSelfRef();
+ DWORD_PTR MsgRet;HWND hSrvIPC;
+ if (!GetIPCSrvWndFromParams(hSrvIPC)||!IsWindow(hSrvIPC)||SendIPCMsg(IPC_GETSRVHWND,0,0,MsgRet,IPCTOUT_DEF,hSrvIPC))MsgRet=0;
+ SetVarUINT(INST_0,MsgRet);
+ NSISFUNCEND();
+}
+
+
+
+/*** Unload
+Notes: Call in .OnInstFailed AND .OnInstSuccess !
+*/
+EXPORTNSISFUNC Unload(HWND hwndNSIS,int StrSize,NSISCH*Vars,NSIS::stack_t **StackTop)
+{
+ NSISFUNCSTART4(hwndNSIS,StrSize,Vars,StackTop);
+ if (!MaintainDllSelfRef())_Unload(); else ASSERT(!"MaintainDllSelfRef failed in Unload!");
+ NSISFUNCEND();
+}
+
+
+
+#ifdef _DEBUG
+BOOL WINAPI DllMain(HINSTANCE hInst,DWORD Event,LPVOID lpReserved)
+#else
+extern "C" BOOL WINAPI _DllMainCRTStartup(HINSTANCE hInst,ULONG Event,LPVOID lpReserved)
+#endif
+{
+ if (Event==DLL_PROCESS_ATTACH)
+ {
+ TRACEF("************************************ DllMain %u\n",GetCurrentProcessId());
+ ASSERT(!_OpenProcessToken && !_EqualSid);
+ g.hInstance=hInst;
+ }
+ DBGONLY( if (Event==DLL_PROCESS_DETACH){ASSERT(g.DllRef==0);}TRACE("DLL_PROCESS_DETACH\n"); );//Make sure we unloaded so we don't lock $pluginsdir
+ return TRUE;
+}
+
+
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/UAC/uac.h
@@ -0,0 +1,141 @@
+//Copyright (C) 2007 Anders Kjersem. Licensed under the zlib/libpng license, see License.txt for details.
+#pragma once
+/** /#define BUILD_DBGRELEASE // Include simple debug output in release version */
+/** /#define BUILD_DBGSELECTELVMODE //Test MyRunAs in release builds*/
+
+/**/#define UNICODE // Unicode build */
+/**/#define FEAT_CUSTOMRUNASDLG // Include custom runas dialog */
+/**/#define FEAT_CUSTOMRUNASDLG_TRANSLATE //*/
+/**/#define FEAT_MSRUNASDLGMODHACK // Default to other user radio button */
+
+
+#if !defined(APSTUDIO_INVOKED) && !defined(RC_INVOKED)
+
+#if (defined(_MSC_VER) && !defined(_DEBUG))
+ #pragma comment(linker,"/opt:nowin98")
+ #pragma comment(linker,"/ignore:4078")
+ #pragma comment(linker,"/merge:.rdata=.text")
+
+ //#pragma intrinsic(memset) //http://www.codeguru.com/forum/showthread.php?t=371491&page=2&pp=15 | http://www.ddj.com/windows/184416623
+#endif
+
+#if defined(UNICODE) && !defined(_UNICODE)
+#define _UNICODE
+#endif
+
+#define _WIN32_WINNT 0x0501
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <ShellAPI.h>
+#include <TChar.h>
+#include "NSISUtil.h"
+
+#ifndef SEE_MASK_NOZONECHECKS
+#define SEE_MASK_NOZONECHECKS 0x00800000
+#endif
+
+#define COUNTOF(___c) ( sizeof(___c)/sizeof(___c[0]) )
+#ifndef ARRAYSIZE
+#define ARRAYSIZE COUNTOF
+#endif
+#define FORCEINLINE __forceinline
+
+#if _MSC_VER >= 1400
+extern void* __cdecl memset(void*mem,int c,size_t len);
+#endif
+
+FORCEINLINE LRESULT MySndDlgItemMsg(HWND hDlg,int id,UINT Msg,WPARAM wp=0,LPARAM lp=0) {return SendMessage(GetDlgItem(hDlg,id),Msg,wp,lp);}
+
+
+//DelayLoaded functions:
+typedef BOOL (WINAPI*ALLOWSETFOREGROUNDWINDOW)(DWORD dwProcessId);
+typedef BOOL (WINAPI*OPENPROCESSTOKEN)(HANDLE ProcessHandle,DWORD DesiredAccess,PHANDLE TokenHandle);
+typedef BOOL (WINAPI*OPENTHREADTOKEN)(HANDLE ThreadHandle,DWORD DesiredAccess,BOOL OpenAsSelf,PHANDLE TokenHandle);
+typedef BOOL (WINAPI*GETTOKENINFORMATION)(HANDLE hToken,TOKEN_INFORMATION_CLASS TokInfoClass,LPVOID TokInfo,DWORD TokInfoLenh,PDWORD RetLen);
+typedef BOOL (WINAPI*ALLOCATEANDINITIALIZESID)(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,BYTE nSubAuthorityCount,DWORD sa0,DWORD sa1,DWORD sa2,DWORD sa3,DWORD sa4,DWORD sa5,DWORD sa6,DWORD sa7,PSID*pSid);
+typedef PVOID (WINAPI*FREESID)(PSID pSid);
+typedef BOOL (WINAPI*EQUALSID)(PSID pSid1,PSID pSid2);
+typedef BOOL (WINAPI*CHECKTOKENMEMBERSHIP)(HANDLE TokenHandle,PSID SidToCheck,PBOOL IsMember);
+#ifdef FEAT_CUSTOMRUNASDLG
+typedef BOOL (WINAPI*GETUSERNAME)(LPTSTR lpBuffer,LPDWORD nSize);
+typedef BOOL (WINAPI*CREATEPROCESSWITHLOGONW)(LPCWSTR lpUsername,LPCWSTR lpDomain,LPCWSTR lpPassword,DWORD dwLogonFlags,LPCWSTR lpApplicationName,LPWSTR lpCommandLine,DWORD dwCreationFlags,LPVOID pEnv,LPCWSTR WorkDir,LPSTARTUPINFOW pSI,LPPROCESS_INFORMATION pPI);
+#define SECURITY_WIN32
+#include <Security.h>//NameSamCompatible
+typedef BOOLEAN (WINAPI*GETUSERNAMEEX)(EXTENDED_NAME_FORMAT NameFormat,LPTSTR lpNameBuffer,PULONG nSize);
+#endif
+#ifdef UAC_INITIMPORTS
+ALLOWSETFOREGROUNDWINDOW _AllowSetForegroundWindow=0;
+OPENPROCESSTOKEN _OpenProcessToken=0;
+OPENTHREADTOKEN _OpenThreadToken=0;
+GETTOKENINFORMATION _GetTokenInformation=0;
+ALLOCATEANDINITIALIZESID _AllocateAndInitializeSid=0;
+FREESID _FreeSid=0;
+EQUALSID _EqualSid=0;
+CHECKTOKENMEMBERSHIP _CheckTokenMembership=0;
+#ifdef FEAT_CUSTOMRUNASDLG
+GETUSERNAME _GetUserName=0;
+GETUSERNAMEEX _GetUserNameEx=0;
+CREATEPROCESSWITHLOGONW _CreateProcessWithLogonW=0;
+#endif
+#else
+#ifdef FEAT_CUSTOMRUNASDLG
+extern GETUSERNAME _GetUserName;
+extern GETUSERNAMEEX _GetUserNameEx;
+extern CREATEPROCESSWITHLOGONW _CreateProcessWithLogonW;
+#endif
+#endif /* UAC_INITIMPORTS */
+
+
+extern DWORD DelayLoadDlls();
+#ifdef FEAT_CUSTOMRUNASDLG
+extern DWORD MyRunAs(HINSTANCE hInstDll,SHELLEXECUTEINFO&sei);
+#endif
+
+#if !defined(NTDDI_VISTA) || defined(BUILD_OLDSDK)
+//#if !defined(NTDDI_VERSION) || (NTDDI_VERSION < 0x06000000) || !defined(NTDDI_VISTA)
+//#if !defined(TOKEN_ELEVATION_TYPE) || defined(BUILD_OLDSDK)
+enum TOKEN_ELEVATION_TYPE {
+ TokenElevationTypeDefault = 1,
+ TokenElevationTypeFull,
+ TokenElevationTypeLimited
+};
+enum _TOKEN_INFORMATION_CLASS___VISTA {
+ TokenElevationType = (TokenOrigin+1),
+ TokenLinkedToken,
+ TokenElevation,
+ TokenHasRestrictions,
+ TokenAccessInformation,
+ TokenVirtualizationAllowed,
+ TokenVirtualizationEnabled,
+ TokenIntegrityLevel,
+ TokenUIAccess,
+ TokenMandatoryPolicy,
+ TokenLogonSid,
+};
+#endif
+
+
+#if defined(_DEBUG) || defined(BUILD_DBGRELEASE)
+//Simple debug helpers:
+#define BUILD_DBG
+/** /#define BUILD_XPTEST //Pretend UAC exists and "elevate" with NT runas */
+#define DBG_RESETDBGVIEW() do{HWND hDbgView=FindWindowA("dbgviewClass",0);PostMessage(hDbgView,WM_COMMAND,40020,0);if(0)SetForegroundWindow(hDbgView);}while(0)
+#define _pp_MakeStr_(x) #x
+#define pp_MakeStr(x) _pp_MakeStr_(x)
+#define TRACE OutputDebugStringA
+#define DBGONLY(_x) _x
+#ifndef ASSERT
+#define ASSERT(_x) do{if(!(_x)){MessageBoxA(GetActiveWindow(),#_x##"\n\n"##__FILE__##":"## pp_MakeStr(__LINE__),"SimpleAssert",0);/*TRACE(#_x##"\n"##__FILE__##":" pp_MakeStr(__LINE__)"\n");*/}}while(0)
+#endif
+#define VERIFY(_x) ASSERT(_x)
+static void TRACEF(const char*fmt,...) {va_list a;va_start(a,fmt);static TCHAR b[1024*4];if (sizeof(TCHAR)!=sizeof(char)){static TCHAR fmtBuf[COUNTOF(b)];VERIFY(wsprintf(fmtBuf,_T("%hs"),fmt)<COUNTOF(fmtBuf));fmt=(LPCSTR)fmtBuf;}wvsprintf(b,(TCHAR*)fmt,a);OutputDebugString(b);}
+#else
+#define TRACE /*(void)0*/
+#define DBGONLY(_x)
+#define ASSERT(_x)
+#define VERIFY(_x) ((void)(_x))
+#define TRACEF TRACE
+#endif /* DEBUG */
+
+#endif /* APSTUDIO_INVOKED */
+
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/nsProcess/Readme.txt
@@ -0,0 +1,59 @@
+*****************************************************************
+*** nsProcess NSIS plugin v1.5 ***
+*****************************************************************
+
+2006 Shengalts Aleksander aka Instructor (Shengalts@mail.ru)
+
+Source function FIND_PROC_BY_NAME based
+ upon the Ravi Kochhar (kochhar@physiology.wisc.edu) code
+Thanks iceman_k (FindProcDLL plugin) and
+ DITMan (KillProcDLL plugin) for direct me
+
+
+Features:
+- Find a process by name
+- Kill a process by name
+- Kill all processes with specified name (not only one)
+- The process name is case-insensitive
+- Win95/98/ME/NT/2000/XP support
+- Small plugin size (4 Kb)
+
+
+**** Find process ****
+${nsProcess::FindProcess} "[file.exe]" $var
+
+"[file.exe]" - Process name (e.g. "notepad.exe")
+
+$var 0 Success
+ 603 Process was not currently running
+ 604 Unable to identify system type
+ 605 Unsupported OS
+ 606 Unable to load NTDLL.DLL
+ 607 Unable to get procedure address from NTDLL.DLL
+ 608 NtQuerySystemInformation failed
+ 609 Unable to load KERNEL32.DLL
+ 610 Unable to get procedure address from KERNEL32.DLL
+ 611 CreateToolhelp32Snapshot failed
+
+
+**** Kill process ****
+${nsProcess::KillProcess} "[file.exe]" $var
+
+"[file.exe]" - Process name (e.g. "notepad.exe")
+
+$var 0 Success
+ 601 No permission to terminate process
+ 602 Not all processes terminated successfully
+ 603 Process was not currently running
+ 604 Unable to identify system type
+ 605 Unsupported OS
+ 606 Unable to load NTDLL.DLL
+ 607 Unable to get procedure address from NTDLL.DLL
+ 608 NtQuerySystemInformation failed
+ 609 Unable to load KERNEL32.DLL
+ 610 Unable to get procedure address from KERNEL32.DLL
+ 611 CreateToolhelp32Snapshot failed
+
+
+**** Unload plugin ****
+${nsProcess::Unload}
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/nsProcess/Source/ConvFunc.h
@@ -0,0 +1,820 @@
+/*****************************************************************
+ * Conversion functions header v1.9 *
+ * *
+ * 2006 Shengalts Aleksander aka Instructor (Shengalts@mail.ru) *
+ * *
+ * *
+ *Functions (ALLCONVFUNC): *
+ * xatoi, xatoiW, xitoa, xitoaW, xatoui, xatouiW, *
+ * xuitoa, xuitoaW, xatoi64, xatoi64W, xi64toa, xi64toaW, *
+ * hex2dec, hex2decW, dec2hex, dec2hexW *
+ * *
+ *Special functions (ALLCONVFUNCS): *
+ * str2hex, hex2str *
+ * *
+ *****************************************************************/
+
+#ifndef _CONVFUNC_
+#define _CONVFUNC_
+
+int xatoi(char *str);
+int xatoiW(wchar_t *wstr);
+char* xitoa(int number, char *str, int width);
+wchar_t* xitoaW(int number, wchar_t *wstr, int width);
+unsigned int xatoui(char *str);
+unsigned int xatouiW(wchar_t *wstr);
+char* xuitoa(unsigned int number, char *str, int width);
+wchar_t* xuitoaW(unsigned int number, wchar_t *wstr, int width);
+__int64 xatoi64(char *str);
+__int64 xatoi64W(wchar_t *wstr);
+char* xi64toa(__int64 number, char *str, int width);
+wchar_t* xi64toaW(__int64 number, wchar_t *wstr, int width);
+int hex2dec(char *hex);
+int hex2decW(wchar_t *whex);
+void dec2hex(unsigned int dec, char *hex, BOOL lowercase, unsigned int width);
+void dec2hexW(unsigned int dec, wchar_t *whex, BOOL lowercase, unsigned int width);
+
+void str2hex(unsigned char *str, char *hex, BOOL lowercase, unsigned int bytes);
+void hex2str(char *hex, char *str);
+
+#endif
+
+/********************************************************************
+ *
+ * xatoi
+ *
+ *Converts string to int.
+ *
+ *[in] char *str -string number
+ *
+ *Returns: integer
+ *
+ *Examples:
+ * xatoi("45") == 45;
+ * xatoi(" -0045:value") == -45;
+ ********************************************************************/
+#if defined xatoi || defined ALLCONVFUNC
+#define xatoi_INCLUDED
+#undef xatoi
+int xatoi(char *str)
+{
+ int nNumber=0;
+ BOOL bMinus=FALSE;
+
+ while (*str == ' ')
+ ++str;
+ if (*str == '+')
+ ++str;
+ else if (*str == '-')
+ {
+ bMinus=TRUE;
+ ++str;
+ }
+ for (; *str != '\0' && *str >= '0' && *str <= '9'; ++str)
+ nNumber=(nNumber * 10) + (*str - '0');
+ if (bMinus == TRUE)
+ nNumber=0 - nNumber;
+ return nNumber;
+}
+#endif
+
+/********************************************************************
+ *
+ * xatoiW
+ *
+ *Converts unicode string to int.
+ *
+ *[in] wchar_t *wstr -string number
+ *
+ *Returns: integer
+ *
+ *Examples:
+ * xatoiW(L"45") == 45;
+ * xatoiW(L" -0045:value") == -45;
+ ********************************************************************/
+#if defined xatoiW || defined ALLCONVFUNC
+#define xatoiW_INCLUDED
+#undef xatoiW
+int xatoiW(wchar_t *wstr)
+{
+ int nNumber=0;
+ BOOL bMinus=FALSE;
+
+ while (*wstr == ' ')
+ ++wstr;
+ if (*wstr == '+')
+ ++wstr;
+ else if (*wstr == '-')
+ {
+ bMinus=TRUE;
+ ++wstr;
+ }
+ for (; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr)
+ nNumber=(nNumber * 10) + (*wstr - '0');
+ if (bMinus == TRUE)
+ nNumber=0 - nNumber;
+ return nNumber;
+}
+#endif
+
+/********************************************************************
+ *
+ * xitoa [API: wsprintf(szResult, "%d", 45)]
+ *
+ *Converts int to string.
+ *
+ *[in] int number -integer
+ *[out] char *str -string number
+ *[in] int width -minimum number of characters to the output
+ *
+ *Returns: a pointer to string
+ *
+ *Examples:
+ * xitoa(45, szResult, 0); //szResult == "45"
+ * xitoa(-45, szResult, 0); //szResult == "-45"
+ * xitoa(45, szResult, 4); //szResult == "0045"
+ ********************************************************************/
+#if defined xitoa || defined ALLCONVFUNC
+#define xitoa_INCLUDED
+#undef xitoa
+char* xitoa(int number, char *str, int width)
+{
+ char tmp[128]="";
+ int a=0;
+ int b=0;
+
+ if (number == 0)
+ {
+ str[0]='0';
+ --width;
+ b=1;
+ }
+ else if (number < 0)
+ {
+ str[0]='-';
+ number=0 - number;
+ --width;
+ b=1;
+ }
+ for (tmp[a]='\0'; number != 0; ++a)
+ {
+ tmp[a]=(number % 10) + '0';
+ number=number / 10;
+ }
+ for (; width > a; ++a) tmp[a]='0';
+ for (--a; a >= 0; --a, ++b) str[b]=tmp[a];
+
+ str[b]='\0';
+ return str;
+}
+#endif
+
+/********************************************************************
+ *
+ * xitoaW [API: wsprintfW(wszResult, L"%d", 45)]
+ *
+ *Converts int to unicode string.
+ *
+ *[in] int number -integer
+ *[out] wchar_t *wstr -unicode string number
+ *[in] int width -minimum number of characters to the output
+ *
+ *Returns: a pointer to unicode string
+ *
+ *Examples:
+ * xitoaW(45, wszResult, 0); //wszResult == L"45"
+ * xitoaW(-45, wszResult, 0); //wszResult == L"-45"
+ * xitoaW(45, wszResult, 4); //wszResult == L"0045"
+ ********************************************************************/
+#if defined xitoaW || defined ALLCONVFUNC
+#define xitoaW_INCLUDED
+#undef xitoaW
+wchar_t* xitoaW(int number, wchar_t *wstr, int width)
+{
+ wchar_t wtmp[128]=L"";
+ int a=0;
+ int b=0;
+
+ if (number == 0)
+ {
+ wstr[0]='0';
+ --width;
+ b=1;
+ }
+ else if (number < 0)
+ {
+ wstr[0]='-';
+ number=0 - number;
+ --width;
+ b=1;
+ }
+ for (wtmp[a]='\0'; number != 0; ++a)
+ {
+ wtmp[a]=(number % 10) + '0';
+ number=number / 10;
+ }
+ for (; width > a; ++a) wtmp[a]='0';
+ for (--a; a >= 0; --a, ++b) wstr[b]=wtmp[a];
+
+ wstr[b]='\0';
+ return wstr;
+}
+#endif
+
+/********************************************************************
+ *
+ * xatoui
+ *
+ *Converts string to unsigned int.
+ *
+ *[in] char *str -string number
+ *
+ *Returns: unsigned integer
+ *
+ *Examples:
+ * xatoui("45") == 45;
+ * xatoui(" -0045:value") == 0;
+ ********************************************************************/
+#if defined xatoui || defined ALLCONVFUNC
+#define xatoui_INCLUDED
+#undef xatoui
+unsigned int xatoui(char *str)
+{
+ unsigned int nNumber=0;
+
+ while (*str == ' ')
+ ++str;
+ if (*str == '+')
+ ++str;
+ else if (*str == '-')
+ return 0;
+ for (; *str != '\0' && *str >= '0' && *str <= '9'; ++str)
+ nNumber=(nNumber * 10) + (*str - '0');
+ return nNumber;
+}
+#endif
+
+/********************************************************************
+ *
+ * xatouiW
+ *
+ *Converts unicode string to unsigned int.
+ *
+ *[in] wchar_t *wstr -unicode string number
+ *
+ *Returns: unsigned integer
+ *
+ *Examples:
+ * xatouiW(L"45") == 45;
+ * xatouiW(L" -0045:value") == 0;
+ ********************************************************************/
+#if defined xatouiW || defined ALLCONVFUNC
+#define xatouiW_INCLUDED
+#undef xatouiW
+unsigned int xatouiW(wchar_t *wstr)
+{
+ unsigned int nNumber=0;
+
+ while (*wstr == ' ')
+ ++wstr;
+ if (*wstr == '+')
+ ++wstr;
+ else if (*wstr == '-')
+ return 0;
+ for (; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr)
+ nNumber=(nNumber * 10) + (*wstr - '0');
+ return nNumber;
+}
+#endif
+
+/********************************************************************
+ *
+ * xuitoa
+ *
+ *Converts unsigned int to string.
+ *
+ *[in] unsigned int number -unsigned integer
+ *[out] char *str -string number
+ *[in] int width -minimum number of characters to the output
+ *
+ *Returns: a pointer to string
+ *
+ *Examples:
+ * xuitoa(45, szResult, 0); //szResult == "45"
+ * xuitoa(45, szResult, 4); //szResult == "0045"
+ ********************************************************************/
+#if defined xuitoa || defined ALLCONVFUNC
+#define xuitoa_INCLUDED
+#undef xuitoa
+char* xuitoa(unsigned int number, char *str, int width)
+{
+ char tmp[128]="";
+ int a=0;
+ int b=0;
+
+ if (number == 0)
+ {
+ str[0]='0';
+ --width;
+ b=1;
+ }
+ for (tmp[a]='\0'; number != 0; ++a)
+ {
+ tmp[a]=(number % 10) + '0';
+ number=number / 10;
+ }
+ for (; width > a; ++a) tmp[a]='0';
+ for (--a; a >= 0; --a, ++b) str[b]=tmp[a];
+
+ str[b]='\0';
+ return str;
+}
+#endif
+
+/********************************************************************
+ *
+ * xuitoaW
+ *
+ *Converts unsigned int to unicode string.
+ *
+ *[in] unsigned int number -unsigned integer
+ *[out] wchar_t *wstr -unicode string number
+ *[in] int width -minimum number of characters to the output
+ *
+ *Returns: a pointer to unicode string
+ *
+ *Examples:
+ * xuitoaW(45, wszResult, 0); //wszResult == L"45"
+ * xuitoaW(45, wszResult, 4); //wszResult == L"0045"
+ ********************************************************************/
+#if defined xuitoaW || defined ALLCONVFUNC
+#define xuitoaW_INCLUDED
+#undef xuitoaW
+wchar_t* xuitoaW(unsigned int number, wchar_t *wstr, int width)
+{
+ wchar_t wtmp[128]=L"";
+ int a=0;
+ int b=0;
+
+ if (number == 0)
+ {
+ wstr[0]='0';
+ --width;
+ b=1;
+ }
+ for (wtmp[a]='\0'; number != 0; ++a)
+ {
+ wtmp[a]=(number % 10) + '0';
+ number=number / 10;
+ }
+ for (; width > a; ++a) wtmp[a]='0';
+ for (--a; a >= 0; --a, ++b) wstr[b]=wtmp[a];
+
+ wstr[b]='\0';
+ return wstr;
+}
+#endif
+
+/********************************************************************
+ *
+ * xatoi64
+ *
+ *Converts string to int64.
+ *
+ *[in] char *str -string number
+ *
+ *Returns: 64-bit integer
+ *
+ *Examples:
+ * xatoi64("45") == 45;
+ * xatoi64(" -0045:value") == -45;
+ ********************************************************************/
+#if defined xatoi64 || defined ALLCONVFUNC
+#define xatoi64_INCLUDED
+#undef xatoi64
+__int64 xatoi64(char *str)
+{
+ __int64 nNumber=0;
+ BOOL bMinus=FALSE;
+
+ while (*str == ' ')
+ ++str;
+ if (*str == '+')
+ ++str;
+ else if (*str == '-')
+ {
+ bMinus=TRUE;
+ ++str;
+ }
+ for (; *str != '\0' && *str >= '0' && *str <= '9'; ++str)
+ nNumber=(nNumber * 10) + (*str - '0');
+ if (bMinus == TRUE)
+ nNumber=0 - nNumber;
+ return nNumber;
+}
+#endif
+
+/********************************************************************
+ *
+ * xatoi64W
+ *
+ *Converts unicode string to int64.
+ *
+ *[in] wchar_t *wstr -unicode string number
+ *
+ *Returns: 64-bit integer
+ *
+ *Examples:
+ * xatoi64W(L"45") == 45;
+ * xatoi64W(L" -0045:value") == -45;
+ ********************************************************************/
+#if defined xatoi64W || defined ALLCONVFUNC
+#define xatoi64W_INCLUDED
+#undef xatoi64W
+__int64 xatoi64W(wchar_t *wstr)
+{
+ __int64 nNumber=0;
+ BOOL bMinus=FALSE;
+
+ while (*wstr == ' ')
+ ++wstr;
+ if (*wstr == '+')
+ ++wstr;
+ else if (*wstr == '-')
+ {
+ bMinus=TRUE;
+ ++wstr;
+ }
+ for (; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr)
+ nNumber=(nNumber * 10) + (*wstr - '0');
+ if (bMinus == TRUE)
+ nNumber=0 - nNumber;
+ return nNumber;
+}
+#endif
+
+/********************************************************************
+ *
+ * xitoa64
+ *
+ *Converts int64 to string.
+ *
+ *[in] __int64 number -64-bit integer
+ *[out] char *str -string number
+ *[in] int width -minimum number of characters to the output
+ *
+ *Returns: a pointer to string
+ *
+ *Examples:
+ * xi64toa(45, szResult, 0); //szResult == "45"
+ * xi64toa(-45, szResult, 0); //szResult == "-45"
+ * xi64toa(45, szResult, 4); //szResult == "0045"
+ ********************************************************************/
+#if defined xi64toa || defined ALLCONVFUNC
+#define xi64toa_INCLUDED
+#undef xi64toa
+char* xi64toa(__int64 number, char *str, int width)
+{
+ char tmp[128]="";
+ int a=0;
+ int b=0;
+
+ if (number == 0)
+ {
+ str[0]='0';
+ --width;
+ b=1;
+ }
+ else if (number < 0)
+ {
+ str[0]='-';
+ number=0 - number;
+ --width;
+ b=1;
+ }
+ for (tmp[a]='\0'; number != 0; ++a)
+ {
+ tmp[a]=(char)((number % 10) + '0');
+ number=number / 10;
+ }
+ for (; width > a; ++a) tmp[a]='0';
+ for (--a; a >= 0; --a, ++b) str[b]=tmp[a];
+
+ str[b]='\0';
+ return str;
+}
+#endif
+
+/********************************************************************
+ *
+ * xitoa64W
+ *
+ *Converts int64 to unicode string.
+ *
+ *[in] __int64 number -64-bit integer
+ *[out] wchar_t *wstr -unicode string number
+ *[in] int width -minimum number of characters to the output
+ *
+ *Returns: a pointer to unicode string
+ *
+ *Examples:
+ * xi64toaW(45, wszResult, 0); //wszResult == L"45"
+ * xi64toaW(-45, wszResult, 0); //wszResult == L"-45"
+ * xi64toaW(45, wszResult, 4); //wszResult == L"0045"
+ ********************************************************************/
+#if defined xi64toaW || defined ALLCONVFUNC
+#define xi64toaW_INCLUDED
+#undef xi64toaW
+wchar_t* xi64toaW(__int64 number, wchar_t *wstr, int width)
+{
+ wchar_t wtmp[128]=L"";
+ int a=0;
+ int b=0;
+
+ if (number == 0)
+ {
+ wstr[0]='0';
+ --width;
+ b=1;
+ }
+ else if (number < 0)
+ {
+ wstr[0]='-';
+ number=0 - number;
+ --width;
+ b=1;
+ }
+ for (wtmp[a]='\0'; number != 0; ++a)
+ {
+ wtmp[a]=(char)((number % 10) + '0');
+ number=number / 10;
+ }
+ for (; width > a; ++a) wtmp[a]='0';
+ for (--a; a >= 0; --a, ++b) wstr[b]=wtmp[a];
+
+ wstr[b]='\0';
+ return wstr;
+}
+#endif
+
+/********************************************************************
+ *
+ * hex2dec
+ *
+ *Converts hex value to decimal.
+ *
+ *[in] char *hex -hex value
+ *
+ *Returns: integer
+ * -1 wrong hex value
+ *
+ *Examples:
+ * hex2dec("A1F") == 2591;
+ ********************************************************************/
+#if defined hex2dec || defined ALLCONVFUNC
+#define hex2dec_INCLUDED
+#undef hex2dec
+int hex2dec(char *hex)
+{
+ int a;
+ int b=0;
+
+ while (1)
+ {
+ a=*hex++;
+ if (a >= '0' && a <= '9') a-='0';
+ else if (a >= 'a' && a <= 'f') a-='a'-10;
+ else if (a >= 'A' && a <= 'F') a-='A'-10;
+ else return -1;
+
+ if (*hex) b=(b + a) * 16;
+ else return (b + a);
+ }
+}
+#endif
+
+/********************************************************************
+ *
+ * hex2decW
+ *
+ *Converts unicode hex value to decimal.
+ *
+ *[in] wchar_t *whex -unicode hex value
+ *
+ *Returns: integer
+ * -1 wrong hex value
+ *
+ *Examples:
+ * hex2decW(L"A1F") == 2591;
+ ********************************************************************/
+#if defined hex2decW || defined ALLCONVFUNC
+#define hex2decW_INCLUDED
+#undef hex2decW
+int hex2decW(wchar_t *whex)
+{
+ int a;
+ int b=0;
+
+ while (1)
+ {
+ a=*whex++;
+ if (a >= '0' && a <= '9') a-='0';
+ else if (a >= 'a' && a <= 'f') a-='a'-10;
+ else if (a >= 'A' && a <= 'F') a-='A'-10;
+ else return -1;
+
+ if (*whex) b=(b + a) * 16;
+ else return (b + a);
+ }
+}
+#endif
+
+/********************************************************************
+ *
+ * dec2hex [API: wsprintf(szResult, "%02x", 2591)]
+ *
+ *Converts decimal to hex value.
+ *
+ *[in] unsigned int dec -positive integer
+ *[out] char *hex -hex value (output)
+ *[in] BOOL lowercase -if TRUE hexadecimal value in lowercase
+ * if FALSE in uppercase.
+ *[in] unsigned int width -minimum number of characters to the output
+ *
+ *Examples:
+ * dec2hex(2591, szResult, FALSE, 2); //szResult == "A1F"
+ * dec2hex(10, szResult, TRUE, 2); //szResult == "0a"
+ ********************************************************************/
+#if defined dec2hex || defined ALLCONVFUNC
+#define dec2hex_INCLUDED
+#undef dec2hex
+void dec2hex(unsigned int dec, char *hex, BOOL lowercase, unsigned int width)
+{
+ unsigned int a=dec;
+ unsigned int b=0;
+ unsigned int c=0;
+ char d='1';
+ if (a == 0) d='0';
+
+ while (a)
+ {
+ b=a % 16;
+ a=a / 16;
+ if (b < 10) hex[c++]=b + '0';
+ else if (lowercase == TRUE) hex[c++]=b + 'a' - 10;
+ else hex[c++]=b + 'A' - 10;
+ }
+ while (width > c) hex[c++]='0';
+ hex[c]='\0';
+
+ if (d == '1')
+ for (b=0, --c; b < c; d=hex[b], hex[b++]=hex[c], hex[c--]=d);
+}
+#endif
+
+/********************************************************************
+ *
+ * dec2hexW [API: wsprintfW(wszResult, L"%02x", 2591)]
+ *
+ *Converts decimal to unicode hex value.
+ *
+ *[in] unsigned int dec -positive integer
+ *[out] wchar_t *whex -unicode hex value (output)
+ *[in] BOOL lowercase -if TRUE hexadecimal value in lowercase
+ * if FALSE in uppercase.
+ *[in] unsigned int width -minimum number of characters to the output
+ *
+ *Examples:
+ * dec2hexW(2591, wszResult, FALSE, 2); //wszResult == L"A1F"
+ * dec2hexW(10, wszResult, TRUE, 2); //wszResult == L"0a"
+ ********************************************************************/
+#if defined dec2hexW || defined ALLCONVFUNC
+#define dec2hexW_INCLUDED
+#undef dec2hexW
+void dec2hexW(unsigned int dec, wchar_t *whex, BOOL lowercase, unsigned int width)
+{
+ unsigned int a=dec;
+ unsigned int b=0;
+ unsigned int c=0;
+ wchar_t d='1';
+ if (a == 0) d='0';
+
+ while (a)
+ {
+ b=a % 16;
+ a=a / 16;
+ if (b < 10) whex[c++]=b + '0';
+ else if (lowercase == TRUE) whex[c++]=b + 'a' - 10;
+ else whex[c++]=b + 'A' - 10;
+ }
+ while (width > c) whex[c++]='0';
+ whex[c]='\0';
+
+ if (d == '1')
+ for (b=0, --c; b < c; d=whex[b], whex[b++]=whex[c], whex[c--]=d);
+}
+#endif
+
+/********************************************************************
+ *
+ * str2hex
+ *
+ *Converts string to hex values.
+ *
+ *[in] unsigned char *str -string
+ *[out] char *hex -hex string
+ *[in] BOOL lowercase -if TRUE hexadecimal value in lowercase
+ * if FALSE in uppercase.
+ *[in] unsigned int bytes -number of bytes in string
+ *
+ *Note:
+ * str2hex uses dec2hex
+ *
+ *Examples:
+ * str2hex((unsigned char *)"Some Text", szResult, TRUE, lstrlen("Some Text")); //szResult == "536f6d652054657874"
+ ********************************************************************/
+#if defined str2hex || defined ALLCONVFUNCS
+#define str2hex_INCLUDED
+#undef str2hex
+void str2hex(unsigned char *str, char *hex, BOOL lowercase, unsigned int bytes)
+{
+ char a[16];
+ unsigned int b=0;
+
+ for (hex[0]='\0'; b < bytes; ++b)
+ {
+ //wsprintf(a, "%02x", (unsigned int)str[b]);
+ dec2hex((unsigned int)str[b], a, lowercase, 2);
+ lstrcat(hex, a);
+ }
+}
+#endif
+
+/********************************************************************
+ *
+ * hex2str
+ *
+ *Converts hex values to string.
+ *
+ *[in] char *hex -hex string
+ *[out] char *str -string
+ *
+ *Examples:
+ * hex2str("536f6d652054657874", szResult); //szResult == "Some Text"
+ ********************************************************************/
+#if defined hex2str || defined ALLCONVFUNCS
+#define hex2str_INCLUDED
+#undef hex2str
+void hex2str(char *hex, char *str)
+{
+ char a[4];
+ int b;
+
+ while (*hex)
+ {
+ a[0]=*hex;
+ a[1]=*++hex;
+ a[2]='\0';
+
+ if (*hex++)
+ {
+ if ((b=hex2dec(a)) > 0) *str++=b;
+ else break;
+ }
+ else break;
+ }
+ *str='\0';
+}
+#endif
+
+
+/********************************************************************
+ * *
+ * Example *
+ * *
+ ********************************************************************
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <stdio.h>
+#include "ConvFunc.h"
+
+//insert functions
+#define xatoi
+#define xitoa
+#include "ConvFunc.h"
+
+void main()
+{
+ char szResult[MAX_PATH]="43";
+ char *pResult;
+ int nError;
+
+ nError=xatoi(szResult);
+ printf("nError={%d}\n", nError);
+
+ pResult=xitoa(45, szResult, 0);
+ printf("szResult={%s}, pResult={%s}\n", szResult, pResult);
+}
+
+*/
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/nsProcess/Source/nsProcess.c
@@ -0,0 +1,435 @@
+/*****************************************************************
+ * nsProcess NSIS plugin v1.5 *
+ * *
+ * 2006 Shengalts Aleksander aka Instructor (Shengalts@mail.ru) *
+ * *
+ * Source function FIND_PROC_BY_NAME based *
+ * upon the Ravi Kochhar (kochhar@physiology.wisc.edu) code *
+ * Thanks iceman_k (FindProcDLL plugin) and *
+ * DITMan (KillProcDLL plugin) for point me up *
+ *****************************************************************/
+
+#define UNICODE
+#define _UNICODE
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <Tlhelp32.h>
+#include "ConvFunc.h"
+
+/* Defines */
+#define NSIS_MAX_STRLEN 1024
+
+#define SystemProcessInformation 5
+#define STATUS_SUCCESS 0x00000000L
+#define STATUS_INFO_LENGTH_MISMATCH 0xC0000004L
+
+typedef struct _SYSTEM_THREAD_INFO {
+ FILETIME ftCreationTime;
+ DWORD dwUnknown1;
+ DWORD dwStartAddress;
+ DWORD dwOwningPID;
+ DWORD dwThreadID;
+ DWORD dwCurrentPriority;
+ DWORD dwBasePriority;
+ DWORD dwContextSwitches;
+ DWORD dwThreadState;
+ DWORD dwUnknown2;
+ DWORD dwUnknown3;
+ DWORD dwUnknown4;
+ DWORD dwUnknown5;
+ DWORD dwUnknown6;
+ DWORD dwUnknown7;
+} SYSTEM_THREAD_INFO;
+
+typedef struct _SYSTEM_PROCESS_INFO {
+ DWORD dwOffset;
+ DWORD dwThreadCount;
+ DWORD dwUnkown1[6];
+ FILETIME ftCreationTime;
+ DWORD dwUnkown2;
+ DWORD dwUnkown3;
+ DWORD dwUnkown4;
+ DWORD dwUnkown5;
+ DWORD dwUnkown6;
+ WCHAR *pszProcessName;
+ DWORD dwBasePriority;
+ DWORD dwProcessID;
+ DWORD dwParentProcessID;
+ DWORD dwHandleCount;
+ DWORD dwUnkown7;
+ DWORD dwUnkown8;
+ DWORD dwVirtualBytesPeak;
+ DWORD dwVirtualBytes;
+ DWORD dwPageFaults;
+ DWORD dwWorkingSetPeak;
+ DWORD dwWorkingSet;
+ DWORD dwUnkown9;
+ DWORD dwPagedPool;
+ DWORD dwUnkown10;
+ DWORD dwNonPagedPool;
+ DWORD dwPageFileBytesPeak;
+ DWORD dwPageFileBytes;
+ DWORD dwPrivateBytes;
+ DWORD dwUnkown11;
+ DWORD dwUnkown12;
+ DWORD dwUnkown13;
+ DWORD dwUnkown14;
+ SYSTEM_THREAD_INFO ati[ANYSIZE_ARRAY];
+} SYSTEM_PROCESS_INFO;
+
+
+/* Include conversion functions */
+#ifdef UNICODE
+#define xatoiW
+#define xitoaW
+#else
+#define xatoi
+#define xitoa
+#endif
+#include "ConvFunc.h"
+
+/* NSIS stack structure */
+typedef struct _stack_t {
+ struct _stack_t *next;
+ TCHAR text[1];
+} stack_t;
+
+stack_t **g_stacktop;
+TCHAR *g_variables;
+unsigned int g_stringsize;
+
+#define EXDLL_INIT() \
+{ \
+ g_stacktop=stacktop; \
+ g_variables=variables; \
+ g_stringsize=string_size; \
+}
+
+/* Global variables */
+TCHAR szBuf[NSIS_MAX_STRLEN];
+
+/* Funtions prototypes and macros */
+int FIND_PROC_BY_NAME(TCHAR *szProcessName, BOOL bTerminate);
+int popinteger();
+void pushinteger(int integer);
+int popstring(TCHAR *str, int len);
+void pushstring(const TCHAR *str, int len);
+
+
+/* NSIS functions code */
+void __declspec(dllexport) _FindProcess(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ EXDLL_INIT();
+ {
+ int nError;
+
+ popstring(szBuf, NSIS_MAX_STRLEN);
+ nError=FIND_PROC_BY_NAME(szBuf, FALSE);
+ pushinteger(nError);
+ }
+}
+
+void __declspec(dllexport) _KillProcess(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+ EXDLL_INIT();
+ {
+ int nError;
+
+ popstring(szBuf, NSIS_MAX_STRLEN);
+ nError=FIND_PROC_BY_NAME(szBuf, TRUE);
+ pushinteger(nError);
+ }
+}
+
+void __declspec(dllexport) _Unload(HWND hwndParent, int string_size,
+ TCHAR *variables, stack_t **stacktop)
+{
+}
+
+BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
+{
+ return TRUE;
+}
+
+int FIND_PROC_BY_NAME(TCHAR *szProcessName, BOOL bTerminate)
+// Find the process "szProcessName" if it is currently running.
+// This works for Win95/98/ME and also WinNT/2000/XP.
+// The process name is case-insensitive, i.e. "notepad.exe" and "NOTEPAD.EXE"
+// will both work. If bTerminate is TRUE, then process will be terminated.
+//
+// Return codes are as follows:
+// 0 = Success
+// 601 = No permission to terminate process
+// 602 = Not all processes terminated successfully
+// 603 = Process was not currently running
+// 604 = Unable to identify system type
+// 605 = Unsupported OS
+// 606 = Unable to load NTDLL.DLL
+// 607 = Unable to get procedure address from NTDLL.DLL
+// 608 = NtQuerySystemInformation failed
+// 609 = Unable to load KERNEL32.DLL
+// 610 = Unable to get procedure address from KERNEL32.DLL
+// 611 = CreateToolhelp32Snapshot failed
+//
+// Change history:
+// created 06/23/2000 - Ravi Kochhar (kochhar@physiology.wisc.edu)
+// http://www.neurophys.wisc.edu/ravi/software/
+// modified 03/08/2002 - Ravi Kochhar (kochhar@physiology.wisc.edu)
+// - Borland-C compatible if BORLANDC is defined as
+// suggested by Bob Christensen
+// modified 03/10/2002 - Ravi Kochhar (kochhar@physiology.wisc.edu)
+// - Removed memory leaks as suggested by
+// Jonathan Richard-Brochu (handles to Proc and Snapshot
+// were not getting closed properly in some cases)
+// modified 14/11/2005 - Shengalts Aleksander aka Instructor (Shengalts@mail.ru):
+// - Combine functions FIND_PROC_BY_NAME and KILL_PROC_BY_NAME
+// - Code has been optimized
+// - Now kill all processes with specified name (not only one)
+// - Cosmetic improvements
+// - Removed error 632 (Invalid process name)
+// - Changed error 602 (Unable to terminate process for some other reason)
+// - BORLANDC define not needed
+// modified 04/01/2006 - Shengalts Aleksander aka Instructor (Shengalts@mail.ru):
+// - Removed CRT dependency
+// modified 21/04/2006 - Shengalts Aleksander aka Instructor (Shengalts@mail.ru):
+// - Removed memory leak as suggested by {_trueparuex^}
+// (handle to hSnapShot was not getting closed properly in some cases)
+// modified 21/04/2006 - Shengalts Aleksander aka Instructor (Shengalts@mail.ru):
+// - Removed memory leak as suggested by {_trueparuex^}
+// (handle to hSnapShot was not getting closed properly in some cases)
+// modified 19/07/2006 - Shengalts Aleksander aka Instructor (Shengalts@mail.ru):
+// - Code for WinNT/2000/XP has been rewritten
+// - Changed error codes
+// modified 31/08/2006 - Shengalts Aleksander aka Instructor (Shengalts@mail.ru):
+// - Removed memory leak as suggested by Daniel Vanesse
+{
+#ifndef UNICODE
+ char szName[MAX_PATH];
+#endif
+ OSVERSIONINFO osvi;
+ HMODULE hLib;
+ HANDLE hProc;
+ ULONG uError;
+ BOOL bFound=FALSE;
+ BOOL bSuccess=FALSE;
+ BOOL bFailed=FALSE;
+
+ // First check what version of Windows we're in
+ osvi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
+ if (!GetVersionEx(&osvi)) return 604;
+
+ if (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT &&
+ osvi.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)
+ return 605;
+
+ if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
+ {
+ // WinNT/2000/XP
+
+ SYSTEM_PROCESS_INFO *spi;
+ SYSTEM_PROCESS_INFO *spiCount;
+ DWORD dwSize=0x4000;
+ DWORD dwData;
+ ULONG (WINAPI *NtQuerySystemInformationPtr)(ULONG, PVOID, LONG, PULONG);
+
+ if (hLib=LoadLibraryA("NTDLL.DLL"))
+ {
+ NtQuerySystemInformationPtr=(ULONG(WINAPI *)(ULONG, PVOID, LONG, PULONG))GetProcAddress(hLib, "NtQuerySystemInformation");
+
+ if (NtQuerySystemInformationPtr)
+ {
+ while (1)
+ {
+ if (spi=LocalAlloc(LMEM_FIXED, dwSize))
+ {
+ uError=(*NtQuerySystemInformationPtr)(SystemProcessInformation, spi, dwSize, &dwData);
+
+ if (uError == STATUS_SUCCESS) break;
+
+ LocalFree(spi);
+
+ if (uError != STATUS_INFO_LENGTH_MISMATCH)
+ {
+ uError=608;
+ break;
+ }
+ }
+ else
+ {
+ uError=608;
+ break;
+ }
+ dwSize*=2;
+ }
+ }
+ else uError=607;
+
+ FreeLibrary(hLib);
+ }
+ else uError=606;
+
+ if (uError != STATUS_SUCCESS) return uError;
+
+ spiCount=spi;
+
+ while (1)
+ {
+ if (spiCount->pszProcessName)
+ {
+#ifdef UNICODE
+ if (!lstrcmpi(spiCount->pszProcessName, szProcessName))
+#else
+ WideCharToMultiByte(CP_ACP, 0, spiCount->pszProcessName, -1, szName, MAX_PATH, NULL, NULL);
+
+ if (!lstrcmpi(szName, szProcessName))
+#endif
+ {
+ // Process found
+ bFound=TRUE;
+
+ if (bTerminate == TRUE)
+ {
+ // Open for termination
+ if (hProc=OpenProcess(PROCESS_TERMINATE, FALSE, spiCount->dwProcessID))
+ {
+ if (TerminateProcess(hProc, 0))
+ bSuccess=TRUE;
+ else
+ bFailed=TRUE;
+ CloseHandle(hProc);
+ }
+ }
+ else break;
+ }
+ }
+ if (spiCount->dwOffset == 0) break;
+ spiCount=(SYSTEM_PROCESS_INFO *)((char *)spiCount + spiCount->dwOffset);
+ }
+ LocalFree(spi);
+ }
+ else
+ {
+ // Win95/98/ME
+
+ PROCESSENTRY32 pe;
+ TCHAR *pName;
+ HANDLE hSnapShot;
+ BOOL bResult;
+ HANDLE (WINAPI *CreateToolhelp32SnapshotPtr)(DWORD, DWORD);
+ BOOL (WINAPI *Process32FirstPtr)(HANDLE, LPPROCESSENTRY32);
+ BOOL (WINAPI *Process32NextPtr)(HANDLE, LPPROCESSENTRY32);
+
+ if (hLib=LoadLibraryA("KERNEL32.DLL"))
+ {
+ CreateToolhelp32SnapshotPtr=(HANDLE(WINAPI *)(DWORD, DWORD)) GetProcAddress(hLib, "CreateToolhelp32Snapshot");
+ Process32FirstPtr=(BOOL(WINAPI *)(HANDLE, LPPROCESSENTRY32)) GetProcAddress(hLib, "Process32First");
+ Process32NextPtr=(BOOL(WINAPI *)(HANDLE, LPPROCESSENTRY32)) GetProcAddress(hLib, "Process32Next");
+
+ if (CreateToolhelp32SnapshotPtr && Process32NextPtr && Process32FirstPtr)
+ {
+ // Get a handle to a Toolhelp snapshot of all the systems processes.
+ if ((hSnapShot=(*CreateToolhelp32SnapshotPtr)(TH32CS_SNAPPROCESS, 0)) != INVALID_HANDLE_VALUE)
+ {
+ // Get the first process' information.
+ pe.dwSize=sizeof(PROCESSENTRY32);
+ bResult=(*Process32FirstPtr)(hSnapShot, &pe);
+
+ // While there are processes, keep looping and checking.
+ while (bResult)
+ {
+ //Get file name
+ for (pName=pe.szExeFile + lstrlen(pe.szExeFile) - 1; *pName != '\\' && *pName != '\0'; --pName);
+
+ if (!lstrcmpi(++pName, szProcessName))
+ {
+ // Process found
+ bFound=TRUE;
+
+ if (bTerminate == TRUE)
+ {
+ // Open for termination
+ if (hProc=OpenProcess(PROCESS_TERMINATE, FALSE, pe.th32ProcessID))
+ {
+ if (TerminateProcess(hProc, 0))
+ bSuccess=TRUE;
+ else
+ bFailed=TRUE;
+ CloseHandle(hProc);
+ }
+ }
+ else break;
+ }
+ //Keep looking
+ bResult=(*Process32NextPtr)(hSnapShot, &pe);
+ }
+ CloseHandle(hSnapShot);
+ }
+ else uError=611;
+ }
+ else uError=610;
+
+ FreeLibrary(hLib);
+ }
+ else uError=609;
+ }
+
+ if (bFound == FALSE) return 603;
+ if (bTerminate == TRUE)
+ {
+ if (bSuccess == FALSE) return 601;
+ if (bFailed == TRUE) return 602;
+ }
+ return 0;
+}
+
+int popinteger()
+{
+ TCHAR szInt[32];
+
+ popstring(szInt, 32);
+#ifdef UNICODE
+ return xatoiW(szInt);
+#else
+ return xatoi(szInt);
+#endif
+}
+
+void pushinteger(int integer)
+{
+ TCHAR szInt[32];
+
+#ifdef UNICODE
+ xitoaW(integer, szInt, 0);
+#else
+ xitoa(integer, szInt, 0);
+#endif
+ pushstring(szInt, 32);
+}
+
+//Function: Removes the element from the top of the NSIS stack and puts it in the buffer
+int popstring(TCHAR *str, int len)
+{
+ stack_t *th;
+
+ if (!g_stacktop || !*g_stacktop) return 1;
+ th=(*g_stacktop);
+ lstrcpyn(str, th->text, len);
+ *g_stacktop=th->next;
+ GlobalFree((HGLOBAL)th);
+ return 0;
+}
+
+//Function: Adds an element to the top of the NSIS stack
+void pushstring(const TCHAR *str, int len)
+{
+ stack_t *th;
+
+ if (!g_stacktop) return;
+ th=(stack_t*)GlobalAlloc(GPTR, sizeof(stack_t) + len);
+ lstrcpyn(th->text, str, len);
+ th->next=*g_stacktop;
+ *g_stacktop=th;
+}
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/nsProcess/Source/nsProcess.dsp
@@ -0,0 +1,108 @@
+# Microsoft Developer Studio Project File - Name="nsProcess" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=nsProcess - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "nsProcess.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "nsProcess.mak" CFG="nsProcess - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "nsProcess - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "nsProcess - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "nsProcess - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "nsProcess_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "nsProcess_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib /nologo /entry:"DllMain" /dll /machine:I386 /nodefaultlib /out:"nsProcess.dll" /opt:nowin98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "nsProcess - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "nsProcess_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "nsProcess_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib libcd.lib /nologo /dll /debug /machine:I386 /nodefaultlib /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "nsProcess - Win32 Release"
+# Name "nsProcess - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\nsProcess.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
new file mode 100644
--- /dev/null
+++ b/other-licenses/nsis/Contrib/nsProcess/Source/nsProcess.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "nsProcess"=.\nsProcess.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+