| 1 |
/* |
| 2 |
Copyright (c) 2002 Robert Rainwater |
| 3 |
Contributors: Justin Frankel, Fritz Elfert, Amir Szekely, Sunil Kamath, Joost Verburg |
| 4 |
|
| 5 |
This software is provided 'as-is', without any express or implied |
| 6 |
warranty. In no event will the authors be held liable for any damages |
| 7 |
arising from the use of this software. |
| 8 |
|
| 9 |
Permission is granted to anyone to use this software for any purpose, |
| 10 |
including commercial applications, and to alter it and redistribute it |
| 11 |
freely, subject to the following restrictions: |
| 12 |
|
| 13 |
1. The origin of this software must not be misrepresented; you must not |
| 14 |
claim that you wrote the original software. If you use this software |
| 15 |
in a product, an acknowledgment in the product documentation would be |
| 16 |
appreciated but is not required. |
| 17 |
2. Altered source versions must be plainly marked as such, and must not be |
| 18 |
misrepresented as being the original software. |
| 19 |
3. This notice may not be removed or altered from any source distribution. |
| 20 |
|
| 21 |
*/ |
| 22 |
#ifndef MAKENSIS_H |
| 23 |
#define MAKENSIS_H |
| 24 |
|
| 25 |
#define _WIN32_IE 0x0400 |
| 26 |
#include "../../Source/Platform.h" |
| 27 |
#include <windows.h> |
| 28 |
#include <commctrl.h> |
| 29 |
#include "utils.h" |
| 30 |
#define _RICHEDIT_VER 0x0200 |
| 31 |
#include <richedit.h> |
| 32 |
#undef _RICHEDIT_VER |
| 33 |
|
| 34 |
#define DpiAwarePerMonitor2() ( FALSE ) // Not yet |
| 35 |
#define DpiAwarePerMonitor() ( FALSE ) |
| 36 |
#define SupportsWNT4() ( sizeof(void*) == 4 && !DpiAwarePerMonitor() ) // NT4 does not support the MultiMon API |
| 37 |
#define SupportsW9X() ( sizeof(TCHAR) == 1 ) |
| 38 |
#define SupportsW95() ( FALSE && SupportsW9X() && !DpiAwarePerMonitor() ) |
| 39 |
#define SupportsW2000() ( sizeof(void*) == 4 ) |
| 40 |
#define SupportsRTLUI() ( FALSE ) // UI is English only |
| 41 |
|
| 42 |
static inline bool IsWin9598ME() { return SupportsW9X() && (int) GetVersion() < 0; } |
| 43 |
static inline bool IsWin95() { return SupportsW95() && (GetVersion() & (0x8000FFFF & ~0x0300)) == 0x80000004; } |
| 44 |
|
| 45 |
// Defines |
| 46 |
#define NSIS_URL "https://nsis.sourceforge.io/" |
| 47 |
#define NSIS_FORUM_URL "http://forums.winamp.com/forumdisplay.php?forumid=65" |
| 48 |
#define NSIS_UC_URL "https://nsis.sourceforge.io/update.php?version=" |
| 49 |
#define NSIS_DL_URL "https://nsis.sourceforge.io/download/" |
| 50 |
#ifdef UNICODE |
| 51 |
#define USAGE _T("Usage:\r\n\r\n \x2022 File \x203a Load Script...\r\n \x2022 Drag the .nsi file into this window\r\n \x2022 Right click the .nsi file and choose \"Compile NSIS Script\"\r\n") |
| 52 |
#else |
| 53 |
#define USAGE _T("Usage:\r\n\r\n - File | Load Script...\r\n - Drag the .nsi file into this window\r\n - Right click the .nsi file and choose \"Compile NSIS Script\"\r\n") |
| 54 |
#endif |
| 55 |
#define COPYRIGHT _T("Copyright (C) 2002 Robert Rainwater") |
| 56 |
#define CONTRIB _T("Fritz Elfert, Justin Frankel, Amir Szekely, Sunil Kamath, Joost Verburg, Anders Kjersem") |
| 57 |
#define DONATE _T("<A>Donate</A> to support NSIS development.") |
| 58 |
#define DONATEURL { 'h'|x,'t','t'|x,'p',':'|x,'/'|x,'/'|x,'n'|x,'s'|x,'i'|x,'s'|x,'.'|x,'s'|x,'f'|x,'.','n'|x,'e'|x,'t'|x,'/'|x,'r','/'|x,'D'|x,'o'|x,'n'|x,'a'|x,'t'|x,'e'|x,'\0' } // "Encrypted" |
| 59 |
#define DOCURL "https://nsis.sourceforge.io/Docs/" |
| 60 |
#define LOCALDOCS _T("\\NSIS.chm") |
| 61 |
#define ERRBOXTITLE 0 //_T("Error") |
| 62 |
#define NSISERROR _T("Unable to initialize MakeNSIS. Please verify that makensis.exe is in the same directory as makensisw.exe.") |
| 63 |
#define DLGERROR _T("Unable to initialize MakeNSISW.") |
| 64 |
#define SYMBOLSERROR _T("Symbol cannot contain whitespace characters") |
| 65 |
#define MULTIDROPERROR _T("Dropping more than one script at a time is not supported") |
| 66 |
#define NSISUPDATEPROMPT _T("Running NSIS Update will close MakeNSISW.\nContinue?") |
| 67 |
#define REGSEC HKEY_CURRENT_USER |
| 68 |
#define REGSECDEF HKEY_LOCAL_MACHINE |
| 69 |
#define REGKEY _T("Software\\NSIS") |
| 70 |
#define REGLOC _T("MakeNSISWPlacement") |
| 71 |
#define REGVERBOSITY _T("MakeNSISWVerbosity") |
| 72 |
#define REGCOMPRESSOR _T("MakeNSISWCompressor") |
| 73 |
#define REGCOLORIZE _T("MakeNSISWColorize") |
| 74 |
#define REGSYMSUBKEY _T("Symbols") |
| 75 |
#define REGMRUSUBKEY _T("MRU") |
| 76 |
#define EXENAME _T("makensis.exe") |
| 77 |
#define MAX_STRING 256 |
| 78 |
#define TIMEOUT 100 |
| 79 |
#define MINWIDTH 400 |
| 80 |
#define MINHEIGHT 220 |
| 81 |
#define COMPRESSOR_MESSAGE _T("\n\nThe %s compressor created the smallest installer (%d bytes).") |
| 82 |
#define RESTORED_COMPRESSOR_MESSAGE _T("\n\nThe %s compressor created the smallest installer (%d bytes).") |
| 83 |
#define EXE_HEADER_COMPRESSOR_STAT _T("EXE header size:") |
| 84 |
#define TOTAL_SIZE_COMPRESSOR_STAT _T("Total size:") |
| 85 |
#define LOAD_SYMBOL_SET_DLG_NAME _T("Load Symbol Definitions Set") |
| 86 |
#define SAVE_SYMBOL_SET_DLG_NAME _T("Save Symbol Definitions Set") |
| 87 |
#define LOAD_BUTTON_TEXT _T("Load") |
| 88 |
#define SAVE_BUTTON_TEXT _T("Save") |
| 89 |
#define LOAD_SYMBOL_SET_MESSAGE _T("Please select a name for the Symbol Definitions Set to load.") |
| 90 |
#define SAVE_SYMBOL_SET_MESSAGE _T("Please enter or select a name for the Symbol Definitions Set to save.") |
| 91 |
#define TESTBTN_TIPTEXT _T("Test the generated installer") |
| 92 |
#define CLOSEBTN_TIPTEXT _T("Close MakeNSISW") |
| 93 |
|
| 94 |
#define WM_MAKENSIS_PROCESSCOMPLETE (WM_USER+1001) |
| 95 |
#define WM_MAKENSIS_LOADSYMBOLSET (WM_USER+1002) |
| 96 |
#define WM_MAKENSIS_SAVESYMBOLSET (WM_USER+1003) |
| 97 |
#define WM_MAKENSIS_UPDATEUISTATE (WM_USER+1004) |
| 98 |
#define WM_MAKENSIS_FREEZEEDITOR (WM_USER+1005) |
| 99 |
#define TID_CONFIGURECLOSEORABORT 1 |
| 100 |
|
| 101 |
namespace MakensisAPI { |
| 102 |
extern const TCHAR* SigintEventNameFmt; |
| 103 |
extern const TCHAR* SigintEventNameLegacy; |
| 104 |
|
| 105 |
enum datatransfer_e { |
| 106 |
NOTIFY_SCRIPT, |
| 107 |
NOTIFY_WARNING, |
| 108 |
NOTIFY_ERROR, |
| 109 |
NOTIFY_OUTPUT, |
| 110 |
PROMPT_FILEPATH |
| 111 |
}; |
| 112 |
enum sndmsg_e { |
| 113 |
QUERYHOST = WM_APP |
| 114 |
}; |
| 115 |
enum QUERYHOST_e { |
| 116 |
QH_OUTPUTCHARSET = 1, |
| 117 |
QH_ENABLESTDERR, |
| 118 |
QH_SUPPORTEDVERSION |
| 119 |
}; |
| 120 |
typedef struct { |
| 121 |
unsigned char Platform; |
| 122 |
unsigned char Reserved; |
| 123 |
TCHAR Path[1]; |
| 124 |
} PROMPT_FILEPATH_DATA; |
| 125 |
} |
| 126 |
|
| 127 |
typedef enum { |
| 128 |
COMPRESSOR_NONE_SELECTED = -1, |
| 129 |
COMPRESSOR_SCRIPT = 0, |
| 130 |
COMPRESSOR_ZLIB, |
| 131 |
COMPRESSOR_ZLIB_SOLID, |
| 132 |
COMPRESSOR_BZIP2, |
| 133 |
COMPRESSOR_BZIP2_SOLID, |
| 134 |
COMPRESSOR_LZMA, |
| 135 |
COMPRESSOR_LZMA_SOLID, |
| 136 |
COMPRESSOR_BEST, |
| 137 |
} NCOMPRESSOR; |
| 138 |
|
| 139 |
#ifdef MAKENSISW_CPP |
| 140 |
const TCHAR *compressor_names[] = {_T(""), |
| 141 |
_T("zlib"), |
| 142 |
_T("/SOLID zlib"), |
| 143 |
_T("bzip2"), |
| 144 |
_T("/SOLID bzip2"), |
| 145 |
_T("lzma"), |
| 146 |
_T("/SOLID lzma"), |
| 147 |
_T("Best")}; |
| 148 |
const TCHAR *compressor_display_names[] = {_T("Defined in Script/Compiler Default"), |
| 149 |
_T("ZLIB"), |
| 150 |
_T("ZLIB (solid)"), |
| 151 |
_T("BZIP2"), |
| 152 |
_T("BZIP2 (solid)"), |
| 153 |
_T("LZMA"), |
| 154 |
_T("LZMA (solid)"), |
| 155 |
_T("Best Compressor")}; |
| 156 |
const WORD compressor_commands[] = {IDM_COMPRESSOR_SCRIPT, |
| 157 |
IDM_ZLIB, |
| 158 |
IDM_ZLIB_SOLID, |
| 159 |
IDM_BZIP2, |
| 160 |
IDM_BZIP2_SOLID, |
| 161 |
IDM_LZMA, |
| 162 |
IDM_LZMA_SOLID, |
| 163 |
IDM_BEST}; |
| 164 |
#endif |
| 165 |
|
| 166 |
#ifdef TOOLBAR_CPP |
| 167 |
int compressor_bitmaps[] = {IDB_COMPRESSOR_SCRIPT, |
| 168 |
IDB_COMPRESSOR_ZLIB, |
| 169 |
IDB_COMPRESSOR_ZLIB, |
| 170 |
IDB_COMPRESSOR_BZIP2, |
| 171 |
IDB_COMPRESSOR_BZIP2, |
| 172 |
IDB_COMPRESSOR_LZMA, |
| 173 |
IDB_COMPRESSOR_LZMA, |
| 174 |
IDB_COMPRESSOR_BEST}; |
| 175 |
int compressor_strings[] = {IDS_SCRIPT, |
| 176 |
IDS_ZLIB, |
| 177 |
IDS_ZLIB_SOLID, |
| 178 |
IDS_BZIP2, |
| 179 |
IDS_BZIP2_SOLID, |
| 180 |
IDS_LZMA, |
| 181 |
IDS_LZMA_SOLID, |
| 182 |
IDS_BEST}; |
| 183 |
#endif |
| 184 |
|
| 185 |
// Extern Variables |
| 186 |
|
| 187 |
extern const TCHAR* NSISW_VERSION; |
| 188 |
extern void* g_ModalDlgData; |
| 189 |
|
| 190 |
DWORD WINAPI MakeNSISProc(LPVOID TreadParam); |
| 191 |
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 192 |
|
| 193 |
typedef struct { |
| 194 |
enum { TID_HEADER = 1 }; |
| 195 |
HFONT hHeaderFont, hFont, hBoldFont; |
| 196 |
INT AnimPos, AnimDir; |
| 197 |
UINT AnimSpeed, FinalHeaderPos; |
| 198 |
} ABOUTDLGDATA; |
| 199 |
INT_PTR ShowAboutDialog(HWND hwndOwner); |
| 200 |
|
| 201 |
INT_PTR CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); |
| 202 |
typedef struct { |
| 203 |
void*pOldMDD; |
| 204 |
BOOL LoadingMode; |
| 205 |
} SYMSETDLGDATA; |
| 206 |
INT_PTR ShowSymbolSetDialog(HWND hwndOwner, BOOL LoadingSet); |
| 207 |
|
| 208 |
INT_PTR CALLBACK CompressorProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); |
| 209 |
void SetScript(const TCHAR *script, bool clearArgs = true); |
| 210 |
void CompileNSISScript(); |
| 211 |
TCHAR* BuildSymbols(); |
| 212 |
void SetCompressor(NCOMPRESSOR); |
| 213 |
void RestoreSymbols(); |
| 214 |
void SaveSymbols(); |
| 215 |
void FreeSymbolSet(TCHAR **); |
| 216 |
void DeleteSymbolSet(const TCHAR *); |
| 217 |
TCHAR** LoadSymbolSet(const TCHAR *); |
| 218 |
void SaveSymbolSet(const TCHAR *, TCHAR **); |
| 219 |
void RestoreMRUList(); |
| 220 |
void SaveMRUList(); |
| 221 |
|
| 222 |
typedef struct NSISScriptData { |
| 223 |
TCHAR *script; |
| 224 |
HGLOBAL script_cmd_args; |
| 225 |
TCHAR *compile_command; |
| 226 |
TCHAR *output_exe; |
| 227 |
TCHAR *input_script; |
| 228 |
TCHAR *branding; |
| 229 |
char *brandingv; |
| 230 |
TCHAR **symbols; |
| 231 |
int retcode; |
| 232 |
unsigned char verbosity; |
| 233 |
DWORD logLength; |
| 234 |
DWORD warnings; |
| 235 |
HINSTANCE hInstance; |
| 236 |
HWND hwnd; |
| 237 |
HWND logwnd; |
| 238 |
HMENU menu; |
| 239 |
HMENU fileSubmenu; |
| 240 |
HMENU editSubmenu; |
| 241 |
HMENU toolsSubmenu; |
| 242 |
HANDLE thread; |
| 243 |
HANDLE sigint_event; |
| 244 |
HANDLE sigint_event_legacy; |
| 245 |
HWND focused_hwnd; |
| 246 |
void*pLogTextDoc; |
| 247 |
NCOMPRESSOR default_compressor; |
| 248 |
NCOMPRESSOR compressor; |
| 249 |
LPCTSTR compressor_name; |
| 250 |
TCHAR compressor_stats[512]; |
| 251 |
LPCTSTR best_compressor_name; |
| 252 |
int recompile_test; |
| 253 |
WORD log_zoom; |
| 254 |
} NSCRIPTDATA; |
| 255 |
|
| 256 |
extern NSCRIPTDATA g_sdata; |
| 257 |
|
| 258 |
typedef struct ResizeData { |
| 259 |
RECT resizeRect; |
| 260 |
RECT griprect; |
| 261 |
int dx; |
| 262 |
int dy; |
| 263 |
UINT bottompanelsize; |
| 264 |
} NRESIZEDATA; |
| 265 |
|
| 266 |
typedef struct FindReplaceDialog { |
| 267 |
FINDREPLACE fr; |
| 268 |
UINT uFindReplaceMsg; |
| 269 |
HWND hwndFind; |
| 270 |
} NFINDREPLACE; |
| 271 |
|
| 272 |
typedef struct ToolTipStruct { |
| 273 |
HWND tip; |
| 274 |
HWND tip_p; |
| 275 |
HHOOK hook; |
| 276 |
} NTOOLTIP; |
| 277 |
|
| 278 |
|
| 279 |
extern INT_PTR ShowWndSpy(HWND hOwner); |
| 280 |
extern INT_PTR ShowLookupDialog(HWND hOwner); |
| 281 |
|
| 282 |
#endif |