home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / nastroje / d23456 / NSIS.EXE / Source / exehead / fileform.h < prev    next >
C/C++ Source or Header  |  2001-05-30  |  8KB  |  210 lines

  1. #include "config.h"
  2.  
  3. #ifndef _FILEFORM_H_
  4. #define _FILEFORM_H_
  5.  
  6.  
  7. // stored in file:
  8. // exehead (around 34k)
  9. // firstheader (as of 4/17/01, 32 bytes)
  10. // datablock (at least 512 bytes if CRC enabled)
  11. // CRC (optional - 4 bytes)
  12.  
  13. // stored in datablock, at firstheader.header_ptr:
  14. // (if install)
  15. //   header
  16. //   sections
  17. //   entries
  18. //   string table
  19. // (if uninstall)
  20. //   uninstall_header
  21. //   entries
  22. //   string table
  23.  
  24.  
  25. #define MAX_ENTRY_OFFSETS 5
  26.  
  27.  
  28. // maximum install types. note that this should not exceed 31, ever.
  29. #define MAX_INST_TYPES 8
  30.  
  31.  
  32. enum
  33. {
  34.   EW_INVALID_OPCODE,    // zero is invalid. useful for catching errors. (otherwise an all zeroes instruction does nothing, which is
  35.                         // easily ignored.
  36.   EW_NOP,               // Nop, do nothing: 1, [advance amount]
  37.   EW_UPDATETEXT,        // Update status text: 1 [update str]
  38.   EW_SETOUTPUTDIR,      // Set output dir: 1,[new directory]
  39.   EW_CREATEDIR,         // 
  40.   EW_EXTRACTFILE,       // File to extract: 4,[overwriteflag, output filename, compressed filedata, filedatetimehigh, filedatetimelow]
  41.                         //  overwriteflag: 0x1 = no. 0x0=force, 0x2=try, 0x3=if date is newer
  42.   EW_EXECUTE,           // Execute program: 2,[complete command line,waitflag]
  43.   EW_SHELLEXEC,         // ShellExecute program: 4, [shell action, complete commandline, parameters, showwindow]
  44.   EW_REGISTERDLL,       // Register DLL: 3,[DLL file name, string ptr of function to call, text to put in display]
  45.   EW_INSTNETSCAPE,      // Install Netscape Plug-in: 5, [DLL file name without path, isuninstall, compressed filedata, filedatetimehigh, filedatetimelow]
  46.   EW_WRITEREG,          // Write Registry value: 5, [RootKey(int),KeyName,ItemName,ItemData,typelen]
  47.                         //  typelen=1 for str, 2 for dword, 3 for binary
  48.   EW_DELREG,            // DeleteRegValue/DeleteRegKey: 4, [root key(int), KeyName, ValueName, delkeyonlyifempty]. ValueName is -1 if delete key
  49.   EW_WRITEINI,          // Write INI String: 4, [Section, Name, Value, INI File]
  50.   EW_CREATESHORTCUT,    // Make Shortcut: 5, [link file, target file, parameters, icon file, iconindex|show mode<<8|hotkey<<16]
  51.   EW_DELETEFILE,        // Delete File: 2, [filename, rebootok]
  52.   EW_FINDWINDOW,        //  FindWindow: 5, [whattodo,window class,string for whattodo, use_title, jumpamount]
  53.                         //  whattodo: 0: close window, and wait. 1: close window, and resume. 
  54.                         //  2: prompt user to close window, and display text in parm 3, 3=jump jumpamount
  55.   EW_MESSAGEBOX,        // MessageBox: 4,[MB_flags,text,retv,moveonretv]
  56.   EW_RMDIR,             // RMDir: 2 [path, recursiveflag]
  57.   EW_COPYFILES,         // CopyFiles: 2 [source mask, destination location]
  58.   EW_SLEEP,             // Sleep: 1 [sleep time in milliseconds]
  59.   EW_BRINGTOFRONT,      // BringToFront: 0
  60.   EW_HIDEWINDOW,        // HideWindow: 0
  61.   EW_IFFILEEXISTS,      // IfFileExists: 3, [file name, jump amount if exists, jump amount if not exists]
  62.   EW_RENAME,            // Rename: 3 [old, new, rebootok]
  63.   EW_SETFILEATTRIBUTES, // SetFileAttributes: 2 [filename, attributes]
  64.  
  65.   EW_ABORT,             // Abort: 1 [status]
  66.   EW_CHDETAILSVIEW,     // SetDetailsView: 1 [0: hide, 1: show]
  67.   EW_SETWINDOWCLOSE,    // SetWindowClose: 1 [0: no window close at end, 1: window close at end]
  68.  
  69.   EW_IFERRORS,           // IfErrors: 3 [jump if error, jump if not error, new_erflag]
  70.  
  71.   EW_ASSIGNVAR,         // Assign: 3 [variable (0-9) to assign, string to assign, maxlen]
  72.   EW_READREGSTR,        // ReadRegStr: 4 [output, rootkey(int), keyname, itemname]
  73.   EW_READINISTR,        // ReadINIStr: 4 [output, section, name, ini_file]
  74.   EW_STRCMP,            // StrCmp: 4 [str1, str2, jump_if_equal, jump_if_not_equal] (case-insensitive)
  75.   EW_GETPARENT,         // GetParentDir 2 [output, input]
  76.  
  77.   EW_CALL,              // Call: 2 [start offset, end offset]
  78.  
  79.   EW_GETFULLDLLPATH,    // GetFullDllPath: 2 [output, dll name]
  80.   EW_COMPAREDLLS,       // CompareDLLVersions 5 [dll1, dll2, jumpif1newer, jumpif2newer, [ver_low]]
  81.  // if dll2&0x80000000 then dll1 is the low dword of version, [4] is the high dword
  82.   EW_COMPAREFILETIMES,  // CompareFileTImes 5 [file1, file2, jumpif1newer, jumpif2newer, [time_low]]
  83.  // if file2&0x80000000 then file1 is the low dword of time, [4] is the high dword
  84. };
  85.  
  86. typedef struct
  87. {
  88.   int flags; // &1=CRC, &2=uninstall, &4=silent 
  89.   int siginfo;  // FH_SIG
  90.  
  91.   int nsinst[3]; // FH_INT1,FH_INT2,FH_INT3 (That's "NullSoftInst")
  92.  
  93.   // these point to the header+sections+entries+stringtable in the datablock
  94.   int length_of_header;
  95.   int header_ptr;
  96.  
  97.   // this specifies the length of all the data (including the firstheader and CRC)
  98.   int length_of_all_following_data;
  99. } firstheader;
  100.  
  101.  
  102. typedef struct
  103. {
  104.   // all these _ptr ones are in the string table.
  105.   int name_ptr; // name of installer
  106.   int caption_ptr; // name of installer + " Setup" or whatever.
  107.   int text_ptr; // directory page text
  108.   int componenttext_ptr; // component page text
  109.   int licensetext_ptr; // license page text
  110.   int licensedata_ptr; // license text
  111.   int install_directory_ptr; // default install dir.
  112.   
  113.   int install_reg_rootkey, install_reg_key_ptr, install_reg_value_ptr; 
  114.  
  115.   int install_types_ptr[MAX_INST_TYPES]; // -1 if not used. can describe as lite, normal, full, etc.
  116.   int no_custom_instmode_flag;
  117.  
  118.   int num_sections; // total number of sections
  119.  
  120.   int num_entries; // total number of entries
  121.  
  122. #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
  123.   int uninstall_exe_name_ptr; // names executable for uninstaller
  124.   int uninstdata_offset; // -1 if no uninst data.
  125.   int uninstexehead_iconoffset; // offset in exe head that the icon is in (for replacing)
  126. #endif
  127.  
  128. #ifdef NSIS_SUPPORT_BGBG 
  129.   int bg_color1, bg_color2, bg_textcolor;
  130. #endif
  131.   int lb_bg, lb_fg;
  132.  
  133.   // .on* calls
  134.   int code_onInit[2];
  135.   int code_onInstSuccess[2];
  136.   int code_onInstFailed[2];
  137.   int code_onUserAbort[2];
  138.   int code_onVerifyInstDir[2];
  139.  
  140.   // additional flags
  141.   char silent_install, auto_close, show_details, no_show_dirpage;
  142.  
  143. } header;
  144.  
  145. typedef struct 
  146. {
  147.   int name_ptr;
  148.   int uninstalltext_ptr;
  149.  
  150.   int num_entries; // entries used
  151.  
  152.   int code[2];
  153. #ifdef NSIS_SUPPORT_BGBG 
  154.   int bg_color1, bg_color2, bg_textcolor;
  155. #endif
  156.   int lb_bg, lb_fg;
  157. } uninstall_header;
  158.  
  159. typedef struct 
  160. {
  161.   int name_ptr; // '' for non-optional components
  162.   int default_state; // bits 0-3 set for each of the different install_types, if any.
  163.   int code[2];
  164.   int size_kb;
  165. } section;
  166.  
  167.  
  168. typedef struct 
  169. {
  170.   int which;
  171.   int offsets[MAX_ENTRY_OFFSETS];    // count and meaning of offsets depend on 'which'
  172. } entry;
  173.  
  174.  
  175. #define FH_FLAGS_MASK 7
  176. #define FH_FLAGS_CRC 1
  177. #define FH_FLAGS_UNINSTALL 2
  178. #define FH_FLAGS_SILENT 4
  179.  
  180. #define FH_SIG 0xDEADBEEF
  181.  
  182. // neato surprise signature that goes in firstheader. :)
  183. #define FH_INT1 0x6C6C754E
  184. #define FH_INT2 0x74666F53
  185. #define FH_INT3 0x74736E49
  186.  
  187.  
  188. // amount of bmp/ico in resource to skip (apparently the first 20/22 bytes can be different)
  189. #define BMP_HDRSKIP 20
  190. #define ICO_HDRSKIP 22
  191.  
  192. // the following are only used/implemented in exehead, not makensis.
  193.  
  194. int isheader(firstheader *h); // returns 0 on not header, length_of_datablock on success
  195.  
  196. // returns nonzero on error
  197. // returns 0 on success
  198. // on success, m_header will be set to a pointer that should eventually be GlobalFree()'d.
  199. // (or m_uninstheader)
  200. int loadHeaders(void);
  201.  
  202. extern HANDLE g_db_hFile;
  203. extern int g_db_offset;
  204.  
  205. char *GetStringFromStringTab(int offs);
  206. int GetCompressedDataFromDataBlock(int offset, HANDLE hFileOut);
  207. int GetCompressedDataFromDataBlockToMemory(int offset, char *out, int out_len);
  208.  
  209. #endif //_FILEFORM_H_
  210.