From 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:47:29 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- other-licenses/nsis/Contrib/ExDLL/SConscript | 25 +++ other-licenses/nsis/Contrib/ExDLL/exdll.c | 44 ++++ other-licenses/nsis/Contrib/ExDLL/exdll.dpr | 118 +++++++++++ other-licenses/nsis/Contrib/ExDLL/exdll.dsp | 111 ++++++++++ other-licenses/nsis/Contrib/ExDLL/exdll.dsw | 29 +++ other-licenses/nsis/Contrib/ExDLL/exdll.h | 234 +++++++++++++++++++++ .../nsis/Contrib/ExDLL/exdll_with_unit.dpr | 31 +++ other-licenses/nsis/Contrib/ExDLL/exdllutil.cpp | 131 ++++++++++++ other-licenses/nsis/Contrib/ExDLL/exdllutil.h | 119 +++++++++++ other-licenses/nsis/Contrib/ExDLL/extdll.inc | 145 +++++++++++++ other-licenses/nsis/Contrib/ExDLL/nsis.pas | 126 +++++++++++ other-licenses/nsis/Contrib/ExDLL/tchar.h | 210 ++++++++++++++++++ 12 files changed, 1323 insertions(+) create mode 100644 other-licenses/nsis/Contrib/ExDLL/SConscript create mode 100644 other-licenses/nsis/Contrib/ExDLL/exdll.c create mode 100644 other-licenses/nsis/Contrib/ExDLL/exdll.dpr create mode 100644 other-licenses/nsis/Contrib/ExDLL/exdll.dsp create mode 100644 other-licenses/nsis/Contrib/ExDLL/exdll.dsw create mode 100644 other-licenses/nsis/Contrib/ExDLL/exdll.h create mode 100644 other-licenses/nsis/Contrib/ExDLL/exdll_with_unit.dpr create mode 100644 other-licenses/nsis/Contrib/ExDLL/exdllutil.cpp create mode 100644 other-licenses/nsis/Contrib/ExDLL/exdllutil.h create mode 100644 other-licenses/nsis/Contrib/ExDLL/extdll.inc create mode 100644 other-licenses/nsis/Contrib/ExDLL/nsis.pas create mode 100644 other-licenses/nsis/Contrib/ExDLL/tchar.h (limited to 'other-licenses/nsis/Contrib/ExDLL') diff --git a/other-licenses/nsis/Contrib/ExDLL/SConscript b/other-licenses/nsis/Contrib/ExDLL/SConscript new file mode 100644 index 0000000000..2c6308545f --- /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') + diff --git a/other-licenses/nsis/Contrib/ExDLL/exdll.c b/other-licenses/nsis/Contrib/ExDLL/exdll.c new file mode 100644 index 0000000000..c46e621a03 --- /dev/null +++ b/other-licenses/nsis/Contrib/ExDLL/exdll.c @@ -0,0 +1,44 @@ +// Unicode support by Jim Park -- 08/02/2007 + +#include +#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; +} diff --git a/other-licenses/nsis/Contrib/ExDLL/exdll.dpr b/other-licenses/nsis/Contrib/ExDLL/exdll.dpr new file mode 100644 index 0000000000..ab3f03d3dd --- /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. diff --git a/other-licenses/nsis/Contrib/ExDLL/exdll.dsp b/other-licenses/nsis/Contrib/ExDLL/exdll.dsp new file mode 100644 index 0000000000..9888726515 --- /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 diff --git a/other-licenses/nsis/Contrib/ExDLL/exdll.dsw b/other-licenses/nsis/Contrib/ExDLL/exdll.dsw new file mode 100644 index 0000000000..f40ce32de8 --- /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> +{{{ +}}} + +############################################################################### + diff --git a/other-licenses/nsis/Contrib/ExDLL/exdll.h b/other-licenses/nsis/Contrib/ExDLL/exdll.h new file mode 100644 index 0000000000..c923c5197d --- /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 +#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_ diff --git a/other-licenses/nsis/Contrib/ExDLL/exdll_with_unit.dpr b/other-licenses/nsis/Contrib/ExDLL/exdll_with_unit.dpr new file mode 100644 index 0000000000..007e350dc0 --- /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. diff --git a/other-licenses/nsis/Contrib/ExDLL/exdllutil.cpp b/other-licenses/nsis/Contrib/ExDLL/exdllutil.cpp new file mode 100644 index 0000000000..f1413767aa --- /dev/null +++ b/other-licenses/nsis/Contrib/ExDLL/exdllutil.cpp @@ -0,0 +1,131 @@ +// Unicode support by Jim Park -- 08/23/2007 + +#include +#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)); +} diff --git a/other-licenses/nsis/Contrib/ExDLL/exdllutil.h b/other-licenses/nsis/Contrib/ExDLL/exdllutil.h new file mode 100644 index 0000000000..51897fc643 --- /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 +#include +// 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(); + diff --git a/other-licenses/nsis/Contrib/ExDLL/extdll.inc b/other-licenses/nsis/Contrib/ExDLL/extdll.inc new file mode 100644 index 0000000000..4c48ae5ce5 --- /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 diff --git a/other-licenses/nsis/Contrib/ExDLL/nsis.pas b/other-licenses/nsis/Contrib/ExDLL/nsis.pas new file mode 100644 index 0000000000..356d26cbde --- /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. diff --git a/other-licenses/nsis/Contrib/ExDLL/tchar.h b/other-licenses/nsis/Contrib/ExDLL/tchar.h new file mode 100644 index 0000000000..5c18ffb778 --- /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 -- cgit v1.2.3