Debian Codegraph @

Source/exehead/fileform.h

raw
1 /*
2 * fileform.h
3 *
4 * This file is a part of NSIS.
5 *
6 * Copyright (C) 1999-2026 Nullsoft and Contributors
7 *
8 * Licensed under the zlib/libpng license (the "License");
9 * you may not use this file except in compliance with the License.
10 *
11 * Licence details can be found in the file COPYING.
12 *
13 * This software is provided 'as-is', without any express or implied
14 * warranty.
15 *
16 * Unicode support by Jim Park -- 08/13/2007
17 */
18
19 #include "config.h"
20 #include "../Platform.h"
21
22 #ifndef _FILEFORM_H_
23 #define _FILEFORM_H_
24
25
26 // * the installer is composed of the following parts:
27 // exehead (~34kb)
28 // firstheader (struct firstheader)
29 // * headers (compressed together):
30 // header (struct header - contains pointers to all blocks)
31 // * nsis blocks (described in header->blocks)
32 // pages (struct page)
33 // section headers (struct section)
34 // entries/instructions (struct entry)
35 // strings (null separated)
36 // language tables (language id, dialog offset, language strings)
37 // colors (struct color)
38 // data block (compressed files and uninstaller data)
39 // CRC (optional - 4 bytes)
40 //
41 // headers + datablock is at least 512 bytes if CRC enabled
42
43
44 #define MAX_ENTRY_OFFSETS 6
45
46
47 // if you want people to not be able to decompile your installers as easily,
48 // reorder the lines following EW_INVALID_OPCODE randomly.
49
50 enum
51 {
52 EW_INVALID_OPCODE, // zero is invalid. useful for catching errors. (otherwise an all zeroes instruction
53 // does nothing, which is easily ignored but means something is wrong)
54 EW_RET, // return from function call
55 EW_NOP, // Nop/Jump, do nothing: 1, [?new address+1:advance one]
56 EW_ABORT, // Abort: 1 [status]
57 EW_QUIT, // Quit: 0
58 EW_CALL, // Call: 1 [new address+1]
59 EW_UPDATETEXT, // Update status text: 2 [update str, ui_st_updateflag=?ui_st_updateflag:this]
60 EW_SLEEP, // Sleep: 1 [sleep time in milliseconds]
61 EW_BRINGTOFRONT, // BringToFront: 0
62 EW_CHDETAILSVIEW, // SetDetailsView: 2 [listaction,buttonaction]
63 EW_SETFILEATTRIBUTES, // SetFileAttributes: 2 [filename, attributes]
64 EW_CREATEDIR, // Create directory: 2, [path, ?update$INSTDIR, ?restrictAcl]
65 EW_IFFILEEXISTS, // IfFileExists: 3, [file name, jump amount if exists, jump amount if not exists]
66 EW_SETFLAG, // Sets a flag: 2 [id, data]
67 EW_IFFLAG, // If a flag: 4 [on, off, id, new value mask]
68 EW_GETFLAG, // Gets a flag: 2 [output, id]
69 #ifdef NSIS_SUPPORT_RENAME
70 EW_RENAME, // Rename: 3 [old, new, rebootok]
71 #endif
72 #ifdef NSIS_SUPPORT_FNUTIL
73 EW_GETFULLPATHNAME, // GetFullPathName: 2 [output, input, ?lfn:sfn]
74 EW_SEARCHPATH, // SearchPath: 2 [output, filename]
75 EW_GETTEMPFILENAME, // GetTempFileName: 2 [output, base_dir]
76 #endif
77 #ifdef NSIS_SUPPORT_FILE
78 EW_EXTRACTFILE, // File to extract: 6 [overwriteflag, output filename, compressed filedata, filedatetimelow, filedatetimehigh, allow ignore]
79 // overwriteflag: 0x1 = no. 0x0=force, 0x2=try, 0x3=if date is newer
80 #endif
81 #ifdef NSIS_SUPPORT_DELETE
82 EW_DELETEFILE, // Delete File: 2, [filename, rebootok]
83 #endif
84 #ifdef NSIS_SUPPORT_MESSAGEBOX
85 EW_MESSAGEBOX, // MessageBox: 5,[MB_flags,text,retv1:retv2,moveonretv1:moveonretv2]
86 #endif
87 #ifdef NSIS_SUPPORT_RMDIR
88 EW_RMDIR, // RMDir: 2 [path, recursiveflag]
89 #endif
90 #ifdef NSIS_SUPPORT_STROPTS
91 EW_STRLEN, // StrLen: 2 [output, input]
92 EW_ASSIGNVAR, // Assign: 4 [variable (0-9) to assign, string to assign, maxlen, startpos]
93 EW_STRCMP, // StrCmp: 5 [str1, str2, jump_if_equal, jump_if_not_equal, case-sensitive?]
94 #endif
95 #ifdef NSIS_SUPPORT_ENVIRONMENT
96 EW_READENVSTR, // ReadEnvStr/ExpandEnvStrings: 3 [output, string_with_env_variables, IsRead]
97 #endif
98 #ifdef NSIS_SUPPORT_INTOPTS
99 EW_INTCMP, // IntCmp: 6 [val1, val2, equal, val1<val2, val1>val2, flags] where flags: bit 0x01 is set for unsigned operations and bit 0x8000 is set for 64-bit operations
100 EW_INTOP, // IntOp: 4 [output, input1, input2, op] where op: 0=add, 1=sub, 2=mul, 3=div, 4=bor, 5=band, 6=bxor, 7=bnot input1, 8=lor, 9=land 10=mod, 11=shl, 12=sar, 13=shr (bneg is implemented with bxor in compiler)
101 EW_INTFMT, // IntFmt: 4 [output, format, input, 64-bit]
102 #endif
103 #ifdef NSIS_SUPPORT_STACK
104 EW_PUSHPOP, // Push/Pop/Exchange: 3 [variable/string, ?pop:push, ?exch]
105 #endif
106 #ifdef NSIS_SUPPORT_HWNDS
107 EW_FINDWINDOW, // FindWindow: 5, [outputvar, window class,window name, window_parent, window_after]
108 EW_SENDMESSAGE, // SendMessage: 6 [output, hwnd, msg, wparam, lparam, [wparamstring?1:0 | lparamstring?2:0 | timeout<<2]
109 EW_ISWINDOW, // IsWindow: 3 [hwnd, jump_if_window, jump_if_notwindow]
110 #endif
111
112 #ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT
113 EW_GETDLGITEM, // GetDlgItem: 3: [outputvar, dialog, item_id]
114 EW_SETCTLCOLORS, // SerCtlColors: 3: [hwnd, pointer to struct colors]
115 EW_LOADANDSETIMAGE, // SetBrandingImage/LoadAndSetImage: 5: [ctrl imagetype lrflags imageid [output]]
116 EW_CREATEFONT, // CreateFont: 5: [handle output, face name, height, weight, flags]
117 EW_SHOWWINDOW, // ShowWindow: 2: [hwnd, show state]
118 #endif
119
120 #ifdef NSIS_SUPPORT_SHELLEXECUTE
121 EW_SHELLEXEC, // ShellExecute program: 5, [SEE_MASK_FLAG_*, verb, file, parameters, showwindow] (Will wait if SEE_MASK_NOCLOSEPROCESS is set)
122 #endif
123
124 #ifdef NSIS_SUPPORT_EXECUTE
125 EW_EXECUTE, // Execute program: 3,[complete command line,waitflag,>=0?output errorcode]
126 #endif
127
128 #ifdef NSIS_SUPPORT_GETFILETIME
129 EW_GETFILETIME, // GetFileTime; 3 [file highout lowout]
130 #endif
131
132 #ifdef NSIS_SUPPORT_GETDLLVERSION
133 EW_GETDLLVERSION, // GetDLLVersion: 4 [file highout lowout fixedoffset]
134 #endif
135
136 #ifdef NSIS_SUPPORT_ACTIVEXREG
137 EW_REGISTERDLL, // Register DLL: 3,[DLL file name, string ptr of function to call, text to put in display (<0 if none/pass parms), 1 - no unload, 0 - unload]
138 #endif
139
140 #ifdef NSIS_SUPPORT_CREATESHORTCUT
141 EW_CREATESHORTCUT, // Make Shortcut: 5, [link file, target file, parameters, icon file, packed CS_*]
142 #endif
143
144 #ifdef NSIS_SUPPORT_COPYFILES
145 EW_COPYFILES, // CopyFiles: 3 [source mask, destination location, flags]
146 #endif
147
148 #ifdef NSIS_SUPPORT_REBOOT
149 EW_REBOOT, // Reboot: 0
150 #endif
151
152 #ifdef NSIS_SUPPORT_INIFILES
153 EW_WRITEINI, // Write INI String: 4, [Section, Name, Value, INI File]
154 EW_READINISTR, // ReadINIStr: 4 [output, section, name, ini_file]
155 #endif
156
157 #ifdef NSIS_SUPPORT_REGISTRYFUNCTIONS
158 EW_DELREG, // DeleteRegValue/DeleteRegKey: 4, [root key(int), KeyName, ValueName, ActionAndFlags(DELREG*)]
159 EW_WRITEREG, // Write Registry value: 5, [RootKey(int),KeyName,ItemName,ItemData,typelen]
160 // typelen=1 for str, 2 for dword, 3 for binary, 0 for expanded str
161 EW_READREGSTR, // ReadRegStr: 5 [output, rootkey(int), keyname, itemname, ==1?int::str]
162 EW_REGENUM, // RegEnum: 5 [output, rootkey, keyname, index, ?key:value]
163 #endif
164
165 #ifdef NSIS_SUPPORT_FILEFUNCTIONS
166 EW_FCLOSE, // FileClose: 1 [handle]
167 EW_FOPEN, // FileOpen: 4 [name, openmode, createmode, outputhandle]
168 EW_FPUTS, // FileWrite: 3 [handle, string, ?int:string]
169 EW_FGETS, // FileRead: 4 [handle, output, maxlen, ?getchar:gets]
170 EW_FSEEK, // FileSeek: 4 [handle, offset, mode, >=0?positionoutput]
171 #endif//NSIS_SUPPORT_FILEFUNCTIONS
172
173 #ifdef NSIS_SUPPORT_FINDFIRST
174 EW_FINDCLOSE, // FindClose: 1 [handle]
175 EW_FINDNEXT, // FindNext: 2 [output, handle]
176 EW_FINDFIRST, // FindFirst: 2 [filespec, output, handleoutput]
177 #endif
178
179 #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
180 EW_WRITEUNINSTALLER, // WriteUninstaller: 3 [name, offset, icon_size]
181 #endif
182
183 #ifdef NSIS_CONFIG_LOG
184 EW_LOG, // LogText: 2 [0, text] / LogSet: [1, logstate]
185 #endif
186
187 #ifdef NSIS_CONFIG_COMPONENTPAGE
188 EW_SECTIONSET, // SectionSetText: 3: [idx, 0, text]
189 // SectionGetText: 3: [idx, 1, output]
190 // SectionSetFlags: 3: [idx, 2, flags]
191 // SectionGetFlags: 3: [idx, 3, output]
192 EW_INSTTYPESET, // InstTypeSetFlags: 3: [idx, 0, flags]
193 // InstTypeGetFlags: 3: [idx, 1, output]
194 #endif
195
196 EW_GETOSINFO, // 1+ [operation, ...]
197 EW_RESERVEDOPCODE, // Free slot, feel free to use it for something
198
199 #ifdef NSIS_LOCKWINDOW_SUPPORT
200 EW_LOCKWINDOW,
201 #endif
202
203 #ifdef _UNICODE // opcodes available only in Unicode installers must be at the end of the enumeration
204 #ifdef NSIS_SUPPORT_FILEFUNCTIONS
205 EW_FPUTWS, // FileWriteUTF16LE: 4 [handle, string, ?int:string, TryWriteBOM]
206 EW_FGETWS, // FileReadUTF16LE: 4 [handle, output, maxlen, ?getchar:gets]
207 #endif//NSIS_SUPPORT_FILEFUNCTIONS
208 #endif
209
210 // Opcodes listed here are not actually used in exehead. No exehead opcodes should be present after these!
211 EW_GETLABELADDR, // --> EW_ASSIGNVAR
212 EW_GETFUNCTIONADDR, // --> EW_ASSIGNVAR
213 };
214
215 #pragma pack(push, 1) // fileform.cpp assumes no padding/alignment
216
217 #define FH_FLAGS_MASK 15
218 #define FH_FLAGS_UNINSTALL 1
219 #ifdef NSIS_CONFIG_SILENT_SUPPORT
220 # define FH_FLAGS_SILENT 2
221 #endif
222 #ifdef NSIS_CONFIG_CRC_SUPPORT
223 # define FH_FLAGS_NO_CRC 4
224 # define FH_FLAGS_FORCE_CRC 8
225 #endif
226
227 #define FH_SIG 0xDEADBEEF
228
229 // neato surprise signature that goes in firstheader. :)
230 #define FH_INT1 0x6C6C754E
231 #define FH_INT2 0x74666F73
232 #define FH_INT3 0x74736E49
233
234 typedef struct
235 {
236 int flags; // FH_FLAGS_*
237 int siginfo; // FH_SIG
238
239 int nsinst[3]; // FH_INT1,FH_INT2,FH_INT3
240
241 // these point to the header+sections+entries+stringtable in the datablock
242 int length_of_header;
243
244 // this specifies the length of all the data (including the firstheader and CRC)
245 int length_of_all_following_data;
246 } firstheader;
247
248 // Flags for common_header.flags
249 #define CH_FLAGS_DETAILS_SHOWDETAILS 1
250 #define CH_FLAGS_DETAILS_NEVERSHOW 2
251 #define CH_FLAGS_PROGRESS_COLORED 4
252 #ifdef NSIS_CONFIG_SILENT_SUPPORT
253 #define CH_FLAGS_SILENT 8
254 #define CH_FLAGS_SILENT_LOG 16
255 #endif
256 #define CH_FLAGS_AUTO_CLOSE 32
257 #define CH_FLAGS_DIR_NO_SHOW 64
258 #define CH_FLAGS_NO_ROOT_DIR 128
259 #ifdef NSIS_CONFIG_COMPONENTPAGE
260 #define CH_FLAGS_COMP_ONLY_ON_CUSTOM 256
261 #define CH_FLAGS_NO_CUSTOM 512
262 #endif
263
264 // nsis blocks
265 struct block_header {
266 #ifdef MAKENSIS
267 int offset;
268 #else
269 UINT_PTR offset; // exehead stores a memory location here so it needs to be pointer sized
270 #endif
271 int num;
272 };
273
274 enum {
275 #ifdef NSIS_CONFIG_VISIBLE_SUPPORT
276 NB_PAGES,
277 #endif
278 NB_SECTIONS,
279 NB_ENTRIES,
280 NB_STRINGS,
281 NB_LANGTABLES,
282 NB_CTLCOLORS,
283 #ifdef NSIS_SUPPORT_BGBG
284 NB_BGFONT,
285 #endif
286 NB_DATA,
287
288 BLOCKS_NUM
289 };
290
291 // nsis strings
292 typedef TCHAR NSIS_STRING[NSIS_MAX_STRLEN];
293
294 // Settings common to both installers and uninstallers
295 typedef struct
296 {
297 int flags; // CH_FLAGS_*
298 struct block_header blocks[BLOCKS_NUM]; // CEXEBuild::get_header_size needs to adjust the size of this based on the targets pointer size
299
300 // InstallDirRegKey stuff
301 int install_reg_rootkey;
302 // these two are not processed!
303 int install_reg_key_ptr, install_reg_value_ptr;
304
305 #ifdef NSIS_SUPPORT_BGBG
306 int bg_color1, bg_color2, bg_textcolor;
307 #endif
308
309 #ifdef NSIS_CONFIG_VISIBLE_SUPPORT
310 // installation log window colors
311 int lb_bg, lb_fg;
312 #endif
313
314 // langtable size
315 int langtable_size;
316
317 #ifdef NSIS_CONFIG_LICENSEPAGE
318 // license background color
319 int license_bg;
320 #endif//NSIS_CONFIG_LICENSEPAGE
321
322 #ifdef NSIS_SUPPORT_CODECALLBACKS
323 // .on* calls
324 int code_onInit;
325 int code_onInstSuccess;
326 int code_onInstFailed;
327 int code_onUserAbort;
328 #ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT
329 int code_onGUIInit;
330 int code_onGUIEnd;
331 int code_onMouseOverSection;
332 #endif//NSIS_CONFIG_ENHANCEDUI_SUPPORT
333 int code_onVerifyInstDir;
334 #ifdef NSIS_CONFIG_COMPONENTPAGE
335 int code_onSelChange;
336 #endif//NSIS_CONFIG_COMPONENTPAGE
337 #ifdef NSIS_SUPPORT_REBOOT
338 int code_onRebootFailed;
339 #endif//NSIS_SUPPORT_REBOOT
340 #endif//NSIS_SUPPORT_CODECALLBACKS
341
342 #ifdef NSIS_CONFIG_COMPONENTPAGE
343 int install_types[NSIS_MAX_INST_TYPES+1];
344 #endif
345
346 int install_directory_ptr; // default install dir.
347 int install_directory_auto_append; // auto append part
348
349 #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
350 int str_uninstchild;
351 int str_uninstcmd;
352 #endif//NSIS_CONFIG_UNINSTALL_SUPPORT
353 #ifdef NSIS_SUPPORT_MOVEONREBOOT
354 int str_wininit; // Points to the path of wininit.ini
355 #endif//NSIS_SUPPORT_MOVEONREBOOT
356 } header;
357
358 #ifdef NSIS_SUPPORT_CODECALLBACKS
359 // callback indices
360 enum
361 {
362 CB_ONINIT,
363 CB_ONINSTSUCCESS,
364 CB_ONINSTFAILED,
365 CB_ONUSERABORT,
366 #ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT
367 CB_ONGUIINIT,
368 CB_ONGUIEND,
369 CB_ONMOUSEOVERSECTION,
370 #endif//NSIS_CONFIG_ENHANCEDUI_SUPPORT
371 CB_ONVERIFYINSTDIR,
372 #ifdef NSIS_CONFIG_COMPONENTPAGE
373 CB_ONSELCHANGE,
374 #endif//NSIS_CONFIG_COMPONENTPAGE
375 #ifdef NSIS_SUPPORT_REBOOT
376 CB_ONREBOOTFAILED
377 #endif//NSIS_SUPPORT_REBOOT
378 };
379 #endif//NSIS_SUPPORT_CODECALLBACKS
380
381 // used for section->flags
382 #define SF_SELECTED 1
383 #define SF_SECGRP 2
384 #define SF_SECGRPEND 4
385 #define SF_BOLD 8
386 #define SF_RO 16
387 #define SF_EXPAND 32
388 #define SF_PSELECTED 64
389 #define SF_TOGGLED 128
390 #define SF_NAMECHG 256
391
392 typedef struct
393 {
394 int name_ptr; // initial name pointer
395 int install_types; // bits set for each of the different install_types, if any.
396 int flags; // SF_* - defined above
397 // for labels, it looks like it's only used to track how often it is used.
398 int code; // The "address" of the start of the code in count of struct entries.
399 int code_size; // The size of the code in num of entries?
400 int size_kb;
401 TCHAR name[NSIS_MAX_STRLEN]; // '' for invisible sections
402 } section;
403
404 #define SECTION_OFFSET(field) (FIELD_OFFSET(section, field)/sizeof(int))
405
406 typedef struct
407 {
408 int which; // EW_* enum. Look at the enum values to see what offsets mean.
409 int offsets[MAX_ENTRY_OFFSETS]; // count and meaning of offsets depend on 'which'
410 // sometimes they are just straight int values or bool
411 // values and sometimes they are indices into string
412 // tables.
413 } entry;
414
415 // page window proc
416 enum
417 {
418 #ifdef NSIS_CONFIG_LICENSEPAGE
419 PWP_LICENSE,
420 #endif
421 #ifdef NSIS_CONFIG_COMPONENTPAGE
422 PWP_SELCOM,
423 #endif
424 PWP_DIR,
425 PWP_INSTFILES,
426 #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
427 PWP_UNINST,
428 #endif
429 PWP_COMPLETED,
430 PWP_CUSTOM
431 };
432
433 // page flags
434 #define PF_BACK_ENABLE 256
435 #define PF_NEXT_ENABLE 2
436 #define PF_CANCEL_ENABLE 4
437 #define PF_BACK_SHOW 8 // must be SW_SHOWNA, don't change
438 #define PF_LICENSE_STREAM 16
439 #define PF_LICENSE_FORCE_SELECTION 32
440 #define PF_LICENSE_NO_FORCE_SELECTION 64
441 #define PF_LICENSE_SELECTED 1 // must be 1
442 #define PF_NO_NEXT_FOCUS 128
443 #define PF_PAGE_EX 512
444 #define PF_DIR_NO_BTN_DISABLE 1024
445
446 typedef struct
447 {
448 int dlg_id; // dialog resource id
449 int wndproc_id;
450
451 #ifdef NSIS_SUPPORT_CODECALLBACKS
452 // called before the page is created, or if custom to show the page
453 // use Abort to skip the page
454 int prefunc;
455 // called right before page is shown
456 int showfunc;
457 // called when the user leaves to the next page
458 // use Abort to force the user to stay on this page
459 int leavefunc;
460 #endif //NSIS_SUPPORT_CODECALLBACKS
461
462 int flags;
463
464 int caption;
465 int back;
466 int next;
467 int clicknext;
468 int cancel;
469
470 int parms[5];
471 } page;
472
473
474 // EW_LOADANDSETIMAGE flags, masks and shifts
475 #define LASIS_FITCTLW 31 // Top bit because it MUST shift to a value of 0 or 1
476 #define LASIF_FITCTLW ( (unsigned int)1 << LASIS_FITCTLW )
477 #define LASIF_FITCTLH ( (unsigned int)1 << 30 )
478 #define LASIM_IMAGE 0x00000003 // IMAGE_*
479 #define LASIF_EXERES 0x00000004 // GetModuleHandle(NULL).
480 #define LASIF_HWND 0x00000100 // Don't call GetDlgItem.
481 #define LASIF_STRID 0x00010000
482 #define LASIM_LR ( 0x0000fff0 & ~(LASIM_IMAGE|LASIF_EXERES|LASIF_HWND|LASIF_STRID) )
483 #define LASIF_LR_LOADFROMFILE 0x00000010
484
485
486 // ctlcolors text/bg color flags
487 #define CC_TEXT 1
488 #define CC_TEXT_SYS 2
489 #define CC_BK 4
490 #define CC_BK_SYS 8
491 #define CC_BKB 16
492 #define CC_FLAGSMASK 0x1f
493 #define CC_FLAGSSHIFTFORZERO 5
494
495 typedef struct {
496 COLORREF text;
497 COLORREF bkc;
498 UINT lbStyle;
499 #ifndef MAKENSIS
500 HBRUSH bkb;
501 #else
502 INT32 bkb;
503 #endif
504 int bkmode;
505 int flags;
506 } ctlcolors32;
507 typedef struct {
508 COLORREF text;
509 COLORREF bkc;
510 #ifndef MAKENSIS
511 HBRUSH bkb; // NOTE: Placed above lbStyle for better alignment
512 #else
513 INT64 bkb;
514 #endif
515 UINT lbStyle;
516 int bkmode;
517 int flags;
518 } ctlcolors64;
519 #if defined(_WIN64) && !defined(MAKENSIS)
520 # define ctlcolors ctlcolors64
521 #else
522 # define ctlcolors ctlcolors32
523 #endif
524
525
526 // constants for myDelete (util.c)
527 #define DEL_DIR 1
528 #define DEL_RECURSE 2
529 #define DEL_REBOOT 4
530 #define DEL_SIMPLE 8
531
532
533 #define REGROOTVIEW32 0x40000000
534 #define REGROOTVIEW64 0x20000000
535 #define REGROOTVIEWTOSAMVIEW(rv) ( (UINT)(((UINT_PTR)(rv)&(REGROOTVIEW32|REGROOTVIEW64)) >> 21) ) // REGROOTVIEWxx to KEY_WOW64_xxKEY
536 #define IsRegRootkeyForcedView(hKey) ( ((UINT_PTR) (hKey) & (REGROOTVIEW32|REGROOTVIEW64)) )
537 #define MAKEREGROOTVIEW(r, fv) ( (HKEY) ((UINT_PTR)(r) | (fv)) )
538 #define HKSHCTX ( (HKEY) 0 ) // Converted to HKCU or HKLM by GetRegRootKey
539 #define HKSHCTX32 MAKEREGROOTVIEW(HKSHCTX, REGROOTVIEW32)
540 #define HKSHCTX64 MAKEREGROOTVIEW(HKSHCTX, REGROOTVIEW64)
541 #define HKCR32 MAKEREGROOTVIEW(HKEY_CLASSES_ROOT, REGROOTVIEW32)
542 #define HKCR64 MAKEREGROOTVIEW(HKEY_CLASSES_ROOT, REGROOTVIEW64)
543 #define HKCU32 MAKEREGROOTVIEW(HKEY_CURRENT_USER, REGROOTVIEW32)
544 #define HKCU64 MAKEREGROOTVIEW(HKEY_CURRENT_USER, REGROOTVIEW64)
545 #define HKLM32 MAKEREGROOTVIEW(HKEY_LOCAL_MACHINE, REGROOTVIEW32)
546 #define HKLM64 MAKEREGROOTVIEW(HKEY_LOCAL_MACHINE, REGROOTVIEW64)
547 #define HKSHCTXANY MAKEREGROOTVIEW(HKSHCTX, REGROOTVIEW32|REGROOTVIEW64)
548 #define HKCRANY MAKEREGROOTVIEW(HKEY_CLASSES_ROOT, REGROOTVIEW32|REGROOTVIEW64)
549 #define HKCUANY MAKEREGROOTVIEW(HKEY_CURRENT_USER, REGROOTVIEW32|REGROOTVIEW64)
550 #define HKLMANY MAKEREGROOTVIEW(HKEY_LOCAL_MACHINE, REGROOTVIEW32|REGROOTVIEW64)
551 #define DELREG_VALUE 0 // TOK_DELETEREGVALUE
552 #define DELREG_KEY 1 // TOK_DELETEREGKEY
553 #define DELREGKEY_ONLYIFNOSUBKEYS 0x01 // Note: Shifted (stored as 2 in the binary) for compatibility with <= v3.1
554 #define DELREGKEY_ONLYIFNOVALUES 0x02
555 // DELREGKEY_SAMVIEWMASK REGROOTVIEWTOSAMVIEW(REGROOTVIEW32|REGROOTVIEW64) // Reserved for KEY_WOW64_xxKEY, cannot be used as flags!
556 #define DELREGKEYFLAGSSHIFT 1 // exehead removes the DELREG_KEY bit in parm4 by shifting. After shifting the bits are DELREGKEY_*.
557
558
559 #ifdef NSIS_SUPPORT_CREATESHORTCUT
560 #define CS_HK_MASK 0xffff0000 // HotKey
561 #define CS_HK_SHIFT 16
562 #define CS_NWD 0x00008000 // NoWorkingDirectory flag
563 #define CS_SC_MASK 0x00007000 // ShowCmd
564 #define CS_SC_SHIFT 12
565 #define CS_II_MASK 0x00000fff // IconIndex
566 #define CS_II_SHIFT 0
567 #define CS_II_MAX (CS_II_MASK >> CS_II_SHIFT)
568 #endif
569
570
571 #define GETOSINFO_KNOWNFOLDER 0
572 #define GETOSINFO_READMEMORY 1
573 typedef struct {
574 UINT32 WVBuild;
575 BYTE WVProd; // W9x: 0, WNT:AnyServer: & 2, WNT:DC: & 7 == 3
576 BYTE WVSP;
577 BYTE WVMin;
578 BYTE WVMaj;
579 } osinfo;
580 #define ABI_OSINFOOFFSET ( sizeof(exec_flags_t) )
581 #define ABI_OSINFOADDRESS ( 0 )
582
583 // special escape characters used in strings: (we use control codes in order to minimize conflicts with normal characters)
584 #define NS_LANG_CODE _T('\x01') // for a langstring
585 #define NS_SHELL_CODE _T('\x02') // for a shell folder path
586 #define NS_VAR_CODE _T('\x03') // for a variable
587 #define NS_SKIP_CODE _T('\x04') // to consider next character as a normal character
588 #define NS_IS_CODE(x) ((x) <= NS_SKIP_CODE) // NS_SKIP_CODE must always be the higher code
589
590 // We are doing this to store an integer value into a char string and we
591 // don't want false end of string values
592 #define CODE_SHORT(x) (WORD)((((WORD)(x) & 0x7F) | (((WORD)(x) & 0x3F80) << 1) | 0x8080))
593 #define MAX_CODED 0x3FFF
594 // This macro takes a pointer to CHAR
595 #define DECODE_SHORT(c) (((((char*)c)[1] & 0x7F) << 7) | (((char*)c)[0] & 0x7F))
596
597 #define NSIS_INSTDIR_INVALID 1
598 #define NSIS_INSTDIR_NOT_ENOUGH_SPACE 2
599
600 #define FIELDN(x, y) (((int *)&x)[y])
601
602 #pragma pack(pop)
603
604 #define NSIS_MAX_EXEDATASIZE 0x7fffffffUL // Maximum size of .exe including compressed installer data.
605 #ifndef NSIS_CONFIG_CRC_ANAL
606 #define NSIS_MAX_EXEFILESIZE 0xffffffffUL // Maximum size of .exe including compressed installer data AND 3rd-party appended data. (Windows refuses to run .EXE files larger than 4 GiB)
607 #else
608 #define NSIS_MAX_EXEFILESIZE NSIS_MAX_EXEDATASIZE
609 #endif
610
611 #ifdef EXEHEAD
612 // the following are only used/implemented in exehead, not makensis.
613
614 #if NSIS_MAX_EXEDATASIZE <= 0xffffffffUL
615 #define MAXEXEDATASIZETYPE UINT // Maximum size of .exe including compressed installer data. (Unsigned allows size including 3rd-party appended data to be 4 GiB instead of 2 GiB)
616 #endif
617 #define MAXSIZETYPE UINT
618
619 int NSISCALL isheader(firstheader *h); // returns 0 on not header, length_of_datablock on success
620
621 // returns nonzero on error
622 // returns 0 on success
623 // on success, m_header will be set to a pointer that should eventually be GlobalFree()'d.
624 // (or m_uninstheader)
625 const TCHAR * NSISCALL loadHeaders(int cl_flags);
626
627 int NSISCALL _dodecomp(int offset, HANDLE hFileOut, unsigned char *outbuf, int outbuflen);
628
629 #define GetCompressedDataFromDataBlock(offset, hFileOut) _dodecomp(offset,hFileOut,NULL,0)
630 #define GetCompressedDataFromDataBlockToMemory(offset, out, out_len) _dodecomp(offset,NULL,out,out_len)
631
632 extern HANDLE g_db_hFile;
633 extern int g_quit_flag;
634
635 BOOL NSISCALL ReadSelfFile(LPVOID lpBuffer, DWORD nNumberOfBytesToRead);
636 DWORD NSISCALL SetSelfFilePointer(LONG lDistanceToMove);
637
638 extern struct block_header g_blocks[BLOCKS_NUM];
639 extern header *g_header;
640 extern int g_flags;
641 extern UINT g_filehdrsize;
642 extern int g_is_uninstaller;
643
644 #define g_pages ( (page*) g_blocks[NB_PAGES].offset )
645 #define g_sections ( (section*) g_blocks[NB_SECTIONS].offset )
646 #define num_sections ( g_blocks[NB_SECTIONS].num )
647 #define g_entries ( (entry*) g_blocks[NB_ENTRIES].offset )
648 #endif
649
650 #endif //_FILEFORM_H_