Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | daniel-mar | 1 | (******************************************************************) |
2 | (* SFX for DelZip v1.80 *) |
||
3 | (* Copyright 2002-2005, 2008 *) |
||
4 | (* *) |
||
5 | (* originally written by Markus Stephany *) |
||
6 | (* modified by Russell Peters, Roger Aelbrecht |
||
7 | This library is free software; you can redistribute it and/or |
||
8 | modify it under the terms of the GNU Lesser General Public |
||
9 | License as published by the Free Software Foundation; either |
||
10 | version 2.1 of the License, or (at your option) any later version. |
||
11 | |||
12 | This library is distributed in the hope that it will be useful, |
||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||
15 | Lesser General Public License (licence.txt) for more details. |
||
16 | |||
17 | You should have received a copy of the GNU Lesser General Public |
||
18 | License along with this library; if not, write to the Free Software |
||
19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
||
20 | |||
21 | contact: problems AT delphizip DOT org |
||
22 | updates: http://www.delphizip.org |
||
23 | |||
24 | modified 12-Nov-2009 |
||
25 | ---------------------------------------------------------------------------*) |
||
26 | |||
27 | unit ZMSFXInt19; |
||
28 | |||
29 | { |
||
30 | this unit contains those definitions used by delzipsfx which |
||
31 | may be used by 3rd party units (like TZipMaster) too. |
||
32 | |||
33 | } |
||
34 | |||
35 | interface |
||
36 | |||
37 | uses |
||
38 | Windows; |
||
39 | |||
40 | const |
||
41 | // 'DZ'#0#12; // header signature |
||
42 | SFX_HEADER_SIG = $0C005A44; |
||
43 | // 'DZ'#7#12; // end of header signature |
||
44 | // SFX_HEADER_END_SIG = $0C075A44; |
||
45 | // // 'DZ'#0#1; // header signature |
||
46 | // SFX_HEADER_SIG = $01005A44; |
||
47 | // // 'DZ'#10#1; // end of header signature |
||
48 | // SFX_HEADER_END_SIG = $010A5A44; |
||
49 | |||
50 | |||
51 | // 'DZ'#0#13; // detached header signature |
||
52 | //@@ SFX_DETACHED_HEADER_SIG = $0D005A44; |
||
53 | // 'DZ'#7#13; // end of detached header signature |
||
54 | // SFX_DETACHED_HEADER_END_SIG = $0D075A44; |
||
55 | // // 'DZ'#20#1; // detached header signature |
||
56 | // SFX_DETACHED_HEADER_SIG = $01145A44; |
||
57 | // // 'DZ'#20#2; // end of detached header signature |
||
58 | // SFX_DETACHED_HEADER_END_SIG = $02145A44; |
||
59 | |||
60 | const |
||
61 | //enum TSFXOverwriteMode { somOverwrite, somSkip, somAsk }; |
||
62 | som_Overwrite = 0; |
||
63 | som_Skip = 1; |
||
64 | som_Ask = 3; |
||
65 | |||
66 | so_AskCmdLine = $001; |
||
67 | so_AskFiles = $002; |
||
68 | so_HideOverWriteBox = $004; |
||
69 | so_AutoRun = $008; |
||
70 | so_NoSuccessMsg = $010; |
||
71 | so_ExpandVariables = $020; |
||
72 | so_InitiallyHideFiles = $040; |
||
73 | so_ForceHideFiles = $080; |
||
74 | so_CheckAutoRunFileName = $100; |
||
75 | so_CanBeCancelled = $200; |
||
76 | // so_Detached = $400; // has no meaning in the stub |
||
77 | so_CreateEmptyDirs = $800; |
||
78 | so_SuccessAlways = $1000; |
||
79 | so_CompressedCmd = $8000; |
||
80 | |||
81 | // command string IDs |
||
82 | sc_Caption = $01; |
||
83 | sc_Path = $02; |
||
84 | sc_CmdLine = $03; |
||
85 | sc_RegFailPath = $04; |
||
86 | sc_StartMsg = $05; |
||
87 | // sc_DetachedName = $06; // optional - does not include number |
||
88 | // sc_DetachedExtn = $07; // optional - includes leading dot |
||
89 | |||
90 | type |
||
91 | // { file overwrite modes } |
||
92 | // TSFXOverwriteMode = (somOverwrite, somSkip, somAsk); |
||
93 | // |
||
94 | // { options } |
||
95 | // TSFXOption = ( |
||
96 | // soAskCmdLine, // allow user to prevent execution of the command line |
||
97 | // soAskFiles, // allow user to prevent certain files from extraction |
||
98 | // soHideOverWriteBox, // do not allow user to choose the overwrite mode |
||
99 | // soAutoRun, // start extraction + evtl. command line automatically |
||
100 | // // only if sfx filename starts with "!" or is "setup.exe" |
||
101 | // soNoSuccessMsg, // don't show success message after extraction |
||
102 | // soExpandVariables, // expand environment variables in path/cmd line... |
||
103 | // soInitiallyHideFiles, // dont show file listview on startup |
||
104 | // soForceHideFiles, // do not allow user to show files list |
||
105 | // // (no effect if shfInitiallyShowFiles is set) |
||
106 | // soCheckAutoRunFileName, // can only autorun if !... or setup.exe |
||
107 | // soCanBeCancelled, // extraction can be cancelled |
||
108 | // soDetached, // tells the stub that it has been created separate from the archive |
||
109 | // soCreateEmptyDirs // recreate empty directories |
||
110 | // ); |
||
111 | |||
112 | // set of TSFXOption |
||
113 | // TSFXOptions = set of TSFXOption; |
||
114 | (* |
||
115 | { sfx Strings header } |
||
116 | PSFXStringsHeader = ^TSFXStringsHeader; |
||
117 | TSFXStringsHeader = packed record |
||
118 | // signature: DZ#30#1 = version 01 |
||
119 | Signature: DWORD; |
||
120 | // overall strings size (must be DWORD-Aligned!) = header + string blocks |
||
121 | Size: word; |
||
122 | // number of language blocks |
||
123 | Count: word; |
||
124 | end; |
||
125 | |||
126 | { sfx Strings records - for each language} |
||
127 | PSFXStringsEntry = ^TSFXStringsEntry; |
||
128 | TSFXStringsEntry = packed record |
||
129 | // CPage: WORD; // target code page |
||
130 | LangID: WORD; // target locale |
||
131 | DOfs: WORD; // offset from SFXStringsHeader to SFXStringsData |
||
132 | end; |
||
133 | *) |
||
134 | PSFXStringsData = ^TSFXStringsData; |
||
135 | TSFXStringsData = packed record |
||
136 | // overall block size (must be DWORD-Aligned!) = header + compressed strings |
||
137 | CSize: WORD; // compressed size (bytes) |
||
138 | USize: WORD; // uncompressed size (bytes) |
||
139 | CRC: DWORD; |
||
140 | { data : array [1..DSize] of WORD - zip compressed } |
||
141 | end; |
||
142 | // Strings entries ident: word, siz: word, wchar[siz] ... followed 0; |
||
143 | (* |
||
144 | // the following record is only used by TZipSFX and TZipMasterSFX to quickly find the |
||
145 | // TSFXStringsHeader in the file, it's not used by the sfx itself. |
||
146 | // it's immediately stored after the TSFXStrings records |
||
147 | PSFXStringsEndOfHeader= ^TSFXStringsEndOfHeader; |
||
148 | TSFXStringsEndOfHeader= packed record |
||
149 | Signature: DWORD; //must be SFX_HEADER_END_SIG |
||
150 | HeaderSize: DWORD; //must be equal to TSFXStringsHeader.Size (dword for alignment issuses) |
||
151 | end; |
||
152 | *) |
||
153 | // compressed language string data - stored in resources |
||
154 | PSFX_LanguageData = ^TSFX_LanguageData; |
||
155 | TSFX_LanguageData = packed record |
||
156 | LangID: WORD; // target locale |
||
157 | // the rest is TSFXStringsData |
||
158 | // overall block size (must be DWORD-Aligned!) = header + compressed strings |
||
159 | CSize: WORD; // compressed size (bytes) |
||
160 | USize: WORD; // uncompressed size (bytes) |
||
161 | CRC: DWORD; |
||
162 | { data : array [1..DSize] of WORD - zip compressed } |
||
163 | end; |
||
164 | // Strings entries ident: word, siz: word, wchar[siz] ... followed 0; |
||
165 | |||
166 | { sfx file header } |
||
167 | PSFXFileHeader = ^TSFXFileHeader; |
||
168 | TSFXFileHeader = packed record |
||
169 | // signature: DZ#0#1 = version 01 |
||
170 | Signature: DWORD; |
||
171 | // overall header size (must be DWORD-Aligned!) |
||
172 | Size: word; |
||
173 | // flags |
||
174 | Options: WORD;//TSFXOptions; |
||
175 | // default overwrite mode |
||
176 | DefOVW: WORD;//TSFXOverwriteMode; |
||
177 | // MB_... (only used if StartMsgSize > 0) |
||
178 | StartMsgType: WORD;//DWORD; |
||
179 | // Compressed: byte; // if <> 0 TSFXStringsData will follow otherwise TSFXStringsHeader |
||
180 | { |
||
181 | Caption: string; if CaptionSize > 0, contains the caption of the sfx dialog (not #0-terminated) |
||
182 | |||
183 | + will be expanded if it contains % signs and soExpandEnvStrings is set |
||
184 | |||
185 | Path: string; if PathSize > 0, contains the default extraction path (not #0-terminated) |
||
186 | |||
187 | + will be expanded if it contains % signs and soExpandEnvStrings is set |
||
188 | |||
189 | + if set to "><", then use temp-dir |
||
190 | |||
191 | + If the first two characters are "HK" the extraction-path //##FR |
||
192 | will be read from the registry. If the registry-key doesn't exist, the |
||
193 | default path will be set to the temp path. Either full names |
||
194 | (HKEY_CURRENT_USER\...) or abbreviations (as known from INF-files) |
||
195 | for the root keys HKCU, HKLM and HKU are supported. |
||
196 | examples: |
||
197 | "HKEY_CURRENT_USER\Software\Borland\Delphi\2.0\Library\SearchPath" |
||
198 | "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir" |
||
199 | "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal" |
||
200 | "HKCU\Software\Microsoft\Office\8.0\Excel\Microsoft Excel\AddIn Path" |
||
201 | For subdirectories to be created use the pipe symbol "|", e.g. |
||
202 | "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\SystemRoot|NewDir" |
||
203 | will parse to : "C:\Windows\NewDir" (or whereever your system root is). |
||
204 | |||
205 | CmdLine: string; if CmdLineSize > 0, contains a command to execute after extraction completed |
||
206 | (not #0-terminated) |
||
207 | |||
208 | + will be expanded if it contains % signs and soExpandEnvStrings is set |
||
209 | |||
210 | + CmdLine has a special format: |
||
211 | all occurrences of "><" (greather than+less than) in this string will be replaced by |
||
212 | the actual extraction path, e.g. : |
||
213 | if the archive has been extracted to "c:\Program Files\foo", a CmdLine |
||
214 | of "><bar\some.txt" will parse to "c:\Progra~1\foo\bar\some.txt" |
||
215 | (because of limitations of the ShellExecute API on some platforms when using long |
||
216 | filenames the short filename is generated by delzipsfx) |
||
217 | |||
218 | if the pipe char "|" is found in the CmdLine, the part to the left of it is used as |
||
219 | the application to run and the part to the right as its command line, e.g.: |
||
220 | |||
221 | extraction path = "d:\unpack", CmdLine = "><setup.exe|><install.inf" |
||
222 | -> exec "d:\unpack\setup.exe" with args "d:\unpack\install.inf" |
||
223 | |||
224 | extraction path = "d:\unpack", CmdLine = "><readme.txt": |
||
225 | -> open "d:\unpack\readme.txt" with its associated program, if there is any. |
||
226 | |||
227 | extraction path = "d:\unpack", CmdLine = "><setup.exe": |
||
228 | -> exec "d:\unpack\setup.exe" without special parameters. |
||
229 | |||
230 | additionally, if soExpandEnvStrings is set in the Options field: |
||
231 | extraction path = "d:\unpack", CmdLine = "%windir%notepad.exe|><readme.txt", |
||
232 | Windows Dir="c:\Windows" |
||
233 | -> exec "c:\windows\notepad.exe" with args "d:\unpack\readme.txt" |
||
234 | |||
235 | + INF-scripts are accepted as well //##FR |
||
236 | "><setup.inf" will run the [DefaultInstall] section of "d:\unpack\setup.inf". |
||
237 | "><setup.inf|.ntx86" will run the [DefaultInstall] section if Win95 (98?), |
||
238 | but [DefaultInstall.ntx86] section if WinNT. |
||
239 | |||
240 | RegFailPath: string if RegFailPathSize > 0, contains the default extraction path, |
||
241 | if reading path from registry failed (not #0-terminated) |
||
242 | |||
243 | + will be expanded if it contains % signs and soExpandEnvStrings is set |
||
244 | |||
245 | + if set to "><", then use temp-dir |
||
246 | |||
247 | StartMsg: string; if StartMsgSize > 0, contains a message to display before showing the main dialog. |
||
248 | (not #0-terminated) |
||
249 | |||
250 | + will be expanded if it contains % signs and soExpandEnvStrings is set |
||
251 | |||
252 | if this messagebox is closed by pressing either IDCANCEL, IDABORT, IDNO or IDCLOSE button, |
||
253 | sfx terminates. |
||
254 | |||
255 | } |
||
256 | end; |
||
257 | |||
258 | (******************************) |
||
259 | (* SFX for DelZip v1.7 *) |
||
260 | (* Copyright 2002-2005 *) |
||
261 | (* written by Markus Stephany *) |
||
262 | const |
||
263 | SFX_LANG_DEF = 127; |
||
264 | SFX_LANG_BASE = 128; |
||
265 | |||
266 | const |
||
267 | // 'DZ'#0#1; // header signature |
||
268 | SFX_HEADER_SIG_17 = $01005A44; |
||
269 | // 'DZ'#10#1; // end of header signature |
||
270 | SFX_HEADER_END_SIG_17 = $010A5A44; |
||
271 | |||
272 | // 'DZ'#20#1; // detached header signature |
||
273 | SFX_DETACHED_HEADER_SIG_17 = $01145A44; |
||
274 | // 'DZ'#20#2; // end of detached header signature |
||
275 | SFX_DETACHED_HEADER_END_SIG_17 = $02145A44; |
||
276 | |||
277 | //type |
||
278 | { file overwrite modes } |
||
279 | // TSFXOverwriteMode_17 = (somOverwrite, somSkip, somAsk); |
||
280 | |||
281 | { options } |
||
282 | // TSFXOption_17 = ( |
||
283 | const |
||
284 | so_AskCmdLine_17 = $01; // allow user to prevent execution of the command line |
||
285 | so_AskFiles_17 = $02; // allow user to prevent certain files from extraction |
||
286 | so_HideOverWriteBox_17 = $04; // do not allow user to choose the overwrite mode |
||
287 | so_AutoRun_17 = $08; // start extraction + evtl. command line automatically |
||
288 | // only if sfx filename starts with "!" or is "setup.exe" |
||
289 | so_NoSuccessMsg_17 = $10; // don't show success message after extraction |
||
290 | so_ExpandVariables_17 = $20; // expand environment variables in path/cmd line... |
||
291 | so_InitiallyHideFiles_17 = $40; // dont show file listview on startup |
||
292 | so_ForceHideFiles_17 = $80; // do not allow user to show files list |
||
293 | // (no effect if shfInitiallyShowFiles is set) |
||
294 | so_CheckAutoRunFileName_17 = $100; // can only autorun if !... or setup.exe |
||
295 | so_CanBeCancelled_17 = $200; // extraction can be cancelled |
||
296 | so_Detached_17 = $400; // tells the stub that it has been created separate from the archive |
||
297 | so_CreateEmptyDirs_17 = $800; // recreate empty directories |
||
298 | // ); |
||
299 | |||
300 | // set of TSFXOption |
||
301 | // TSFXOptions_17 = set of TSFXOption_17; |
||
302 | type |
||
303 | { sfx file header } |
||
304 | PSFXFileHeader_17 = ^TSFXFileHeader_17; |
||
305 | TSFXFileHeader_17 = packed record |
||
306 | // signature: DZ#0#1 = version 01 |
||
307 | Signature: Cardinal; |
||
308 | // overall header size (must be DWORD-Aligned!) |
||
309 | Size: word; |
||
310 | // flags |
||
311 | Options: word;//TSFXOptions_17; |
||
312 | // default overwrite mode |
||
313 | DefOVW: byte;//TSFXOverwriteMode_17; |
||
314 | // length of the sfx dialog caption (0=default caption) |
||
315 | CaptionSize, |
||
316 | // length of the sfx default extraction path (0=current dir) |
||
317 | PathSize, |
||
318 | // length of the command line (0=no command line) |
||
319 | CmdLineSize, |
||
320 | // length of the extract path to be used if HK... failed (0=%temp%) |
||
321 | RegFailPathSize, |
||
322 | // length of the startup message (0=no message) |
||
323 | StartMsgSize: byte; |
||
324 | // MB_... (only used if StartMsgSize > 0) |
||
325 | StartMsgType: Cardinal; |
||
326 | { |
||
327 | Caption: string; if CaptionSize > 0, contains the caption of the sfx dialog (not #0-terminated) |
||
328 | Path: string; if PathSize > 0, contains the default extraction path (not #0-terminated) |
||
329 | CmdLine: string; if CmdLineSize > 0, contains a command to execute after extraction completed |
||
330 | RegFailPath: string if RegFailPathSize > 0, contains the default extraction path, |
||
331 | StartMsg: string; if StartMsgSize > 0, contains a message to display before showing the main dialog. |
||
332 | } |
||
333 | end; |
||
334 | |||
335 | type |
||
336 | // the following record is only used by TZipSFX and TZipMasterSFX to quickly find the |
||
337 | // TSFXFileHeader in the file, it's not used by the sfx itself. |
||
338 | // it's immediately stored after the TSFXFileHeader record |
||
339 | PSFXFileEndOfHeader_17= ^TSFXFileEndOfHeader_17; |
||
340 | TSFXFileEndOfHeader_17= packed record |
||
341 | Signature: DWORD; //must be SFX_HEADER_END_SIG |
||
342 | HeaderSize: DWORD; //must be equal to TSFXFileHeader.Size (dword for alignment issuses) |
||
343 | end; |
||
344 | |||
345 | // in detached sfx archives, the sfx contains an additional record following the header |
||
346 | PSFXDetachedHeader_17= ^TSFXDetachedHeader_17; |
||
347 | TSFXDetachedHeader_17= packed record |
||
348 | Signature: DWORD; // must be SFX_DETACHED_HEADER_SIG or SFX_DETACHED_HEADER_END_SIG |
||
349 | NameLen, |
||
350 | ExtLen: Cardinal; // contains the length of the filename/fileext of the archive (without path) |
||
351 | { |
||
352 | Name: string if NameLen > 0, Name contains the file name (without extension) of |
||
353 | the detached archive |
||
354 | Ext: string if ExtLen > 0, Ext contains the file Ext (without leading .) of |
||
355 | the detached archive |
||
356 | } |
||
357 | end; |
||
358 | |||
359 | implementation |
||
360 | |||
361 | (* the structure of a zipsfx-file : |
||
362 | |||
363 | - zipsfx-executable code (0-xxxxx) |
||
364 | |||
365 | // TSFXStringsHeader |
||
366 | // TSFXStringsBlock 1 |
||
367 | // ... |
||
368 | // TSFXStringsBlock n |
||
369 | // TSFXStringsEndOfHeader |
||
370 | |||
371 | - TSFXFileHeader record (see above) |
||
372 | - possibly one or more strings (depending on the headers' properties) (not #0 terminated) |
||
373 | Caption sfx dialog caption |
||
374 | Path sfx default extraction path |
||
375 | CmdLine command line to execute after extraction |
||
376 | RegFailPath default extract path if Path could not be read from registry |
||
377 | StartMsg startup message |
||
378 | |||
379 | NOTE: the complete header (including the strings) must be DWORD-aligned! |
||
380 | |||
381 | |||
382 | if not detached from the archive: |
||
383 | - the zip archive |
||
384 | |||
385 | if detached from the archive: |
||
386 | - TSFXDetachedHeader |
||
387 | - filename (optional) |
||
388 | - TSFXDetachedEndOfHeader |
||
389 | - centraldirectories[] + endofcentraldir of the zip archive |
||
390 | |||
391 | |||
392 | *) |
||
393 | |||
394 | end. |