Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | daniel-mar | 1 | unit ZMStructs19; |
2 | |||
3 | (* |
||
4 | ZMStructs19.pas - Zip file internal structures |
||
5 | Copyright (C) 2009, 2010 by Russell J. Peters, Roger Aelbrecht, |
||
6 | Eric W. Engler and Chris Vleghert. |
||
7 | |||
8 | This file is part of TZipMaster Version 1.9. |
||
9 | |||
10 | TZipMaster is free software: you can redistribute it and/or modify |
||
11 | it under the terms of the GNU Lesser General Public License as published by |
||
12 | the Free Software Foundation, either version 3 of the License, or |
||
13 | (at your option) any later version. |
||
14 | |||
15 | TZipMaster is distributed in the hope that it will be useful, |
||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
18 | GNU Lesser General Public License for more details. |
||
19 | |||
20 | You should have received a copy of the GNU Lesser General Public License |
||
21 | along with TZipMaster. If not, see <http://www.gnu.org/licenses/>. |
||
22 | |||
23 | contact: problems@delphizip.org (include ZipMaster in the subject). |
||
24 | updates: http://www.delphizip.org |
||
25 | DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip |
||
26 | |||
27 | modified 2007-06-07 |
||
28 | ---------------------------------------------------------------------------*) |
||
29 | |||
30 | interface |
||
31 | |||
32 | {$I '.\ZipVers19.inc'} |
||
33 | uses Windows;//, ZMCompat19; |
||
34 | |||
35 | type |
||
36 | TWordRec = packed record |
||
37 | Lo, Hi: Byte; |
||
38 | end; |
||
39 | |||
40 | type |
||
41 | TZipSystem = (zsMSDOS, zsAMIGA, zsVMS, zsUNIX, zsVM_CMS, zsATARI, zsHPFS, |
||
42 | zsMACOS, zsZSYSTEM, zsCPM, zsTOPS20, zsNTFS, zsQDOS, zsRISCOS, |
||
43 | zsVFAT, zsMVS, zsBEOS, zsTANDEM, zsTHEOS); |
||
44 | |||
45 | const |
||
46 | Invalid_Handle = -1; |
||
47 | PathDelimAlt = '/'; |
||
48 | WILD_MULTI = '*'; |
||
49 | WILD_CHAR = '?'; |
||
50 | WILD_ALL = '*.*'; |
||
51 | DIR_PARENT = '..'; |
||
52 | DIR_THIS = '.'; |
||
53 | SPEC_SEP = '|'; |
||
54 | {$IFNDEF VERD7up} |
||
55 | PathDelim = '\'; |
||
56 | DriveDelim = ':'; |
||
57 | {$ENDIF} |
||
58 | |||
59 | type |
||
60 | TZipLocalHeader = packed record |
||
61 | HeaderSig: Longword; // (4) |
||
62 | VersionNeeded: Word; // (2) |
||
63 | Flag: Word; // (2) |
||
64 | ComprMethod: Word; // (2) |
||
65 | // ModifTime: Word; // (2) |
||
66 | // ModifDate: Word; // (2) |
||
67 | ModifDateTime: LongWord; |
||
68 | CRC32: Longword; // (4) |
||
69 | ComprSize: Longword; // (4) |
||
70 | UnComprSize: Longword; // (4) |
||
71 | FileNameLen: Word; // (2) |
||
72 | ExtraLen: Word; // (2) |
||
73 | end; |
||
74 | PZipLocalHeader = ^TZipLocalHeader; |
||
75 | |||
76 | // An entry in the central dir: |
||
77 | type |
||
78 | TZipCentralHeader = packed record //fixed part size : 42 bytes |
||
79 | HeaderSig: Longword; // hex: 02014B50(4) |
||
80 | // VersionMadeBy0: Byte; //version made by(1) |
||
81 | // VersionMadeBy1: Byte; //host number(1) |
||
82 | VersionMadeBy: Word; // host number and version |
||
83 | VersionNeeded: Word; // version needed to extract(2) |
||
84 | Flag: Word; //generalPurpose bitflag(2) |
||
85 | ComprMethod: Word; //compression method(2) |
||
86 | // ModifTime: Word; // modification time(2) |
||
87 | // ModifDate: Word; // modification date(2) |
||
88 | ModifDateTime: LongWord; // dos date/time |
||
89 | CRC32: Longword; //Cycling redundancy check (4) |
||
90 | ComprSize: Longword; //compressed file size (4) |
||
91 | UncomprSize: Longword; //uncompressed file size (4) |
||
92 | FileNameLen: Word; //(2) |
||
93 | ExtraLen: Word; //(2) |
||
94 | FileComLen: Word; //(2) |
||
95 | DiskStart: Word; //starts on disk number xx(2) |
||
96 | IntFileAtt: Word; //internal file attributes(2) |
||
97 | ExtFileAtt: Longword; //external file attributes(4) |
||
98 | RelOffLocal: Longword; //relative offset of local file header(4) |
||
99 | // not used as part of this record structure: |
||
100 | // filename, extra data, file comment |
||
101 | end; |
||
102 | PZipCentralHeader = ^TZipCentralHeader; |
||
103 | |||
104 | type |
||
105 | TZipDataDescriptor = packed record |
||
106 | DataDescSig: Longword; // Should be 0x08074B50 (4) |
||
107 | CRC32: Longword; // (4) |
||
108 | ComprSize: Longword; // (4) |
||
109 | UnComprSize: Longword; // (4) |
||
110 | end; |
||
111 | |||
112 | type |
||
113 | TZipDataDescriptor64 = packed record |
||
114 | DataDescSig: Longword; // Should be 0x08074B50 (4) |
||
115 | CRC32: Longword; // (4) |
||
116 | ComprSize: Int64; // (8) |
||
117 | UnComprSize: Int64; // (8) |
||
118 | end; |
||
119 | |||
120 | type |
||
121 | TZipEndOfCentral = packed record //Fixed part size : 22 bytes |
||
122 | HeaderSig: Longword; //(4) hex=06054B50 |
||
123 | ThisDiskNo: Word; //(2)This disk's number |
||
124 | CentralDiskNo: Word; //(2)Disk number central dir start |
||
125 | CentralEntries: Word; //(2)Number of central dir entries on this disk |
||
126 | TotalEntries: Word; //(2)Number of entries in central dir |
||
127 | CentralSize: Longword; //(4)Size of central directory |
||
128 | CentralOffset: Longword; //(4)offset of central dir on 1st disk |
||
129 | ZipCommentLen: Word; //(2) |
||
130 | // not used as part of this record structure: |
||
131 | // ZipComment |
||
132 | end; |
||
133 | PZipEndOfCentral = ^TZipEndOfCentral; |
||
134 | |||
135 | type |
||
136 | // must be same disk as EOC |
||
137 | TZip64EOCLocator = packed record |
||
138 | LocSig: Longword; // (4) Should be 0x07064B50 |
||
139 | EOC64DiskStt: Longword; // (4) |
||
140 | EOC64RelOfs: Int64; // (8) relative to start of it's disk |
||
141 | NumberDisks: Longword; // (4) total disks |
||
142 | end; |
||
143 | PZip64EOCLocator = ^TZip64EOCLocator; |
||
144 | |||
145 | type |
||
146 | TZipEOC64 = packed record |
||
147 | EOC64Sig: LongWord; // (4) should be 0x06064b50 |
||
148 | vsize: Int64; // (8) size of variable part |
||
149 | // variable part - fields as needed? (old field = 0XFFFF or 0XFF) |
||
150 | VersionMade: Word; // (2) |
||
151 | VersionNeed: Word; // (2) |
||
152 | ThisDiskNo: LongWord; // (4) |
||
153 | CentralDiskNo: LongWord; // (4) |
||
154 | CentralEntries: Int64; // (8) Number of central dir entries on this disk |
||
155 | TotalEntries: Int64; // (8) Number of entries in central dir |
||
156 | CentralSize: Int64; // (8) Size of central directory |
||
157 | CentralOffset: Int64; // (8) offsett of central dir on 1st disk |
||
158 | // zip64 extensible data sector (variable size) |
||
159 | end; |
||
160 | |||
161 | type |
||
162 | TZipCentralDigitSignature = packed record |
||
163 | CenDigSig: LongWord; // (4) should be 0x05054b50 |
||
164 | vsize: Word; // (2) |
||
165 | // data[vsize] |
||
166 | end; |
||
167 | |||
168 | const { these are stored in reverse order } |
||
169 | CentralFileHeaderSig = $02014B50; { 'PK'12 } |
||
170 | LocalFileHeaderSig = $04034B50; { 'PK'34 (in file: 504b0304) } |
||
171 | CentralDigSig = $05054B50; { 'PK'55 } |
||
172 | EndCentralDirSig = $06054B50; { 'PK'56 } |
||
173 | ExtLocalSig = $08074B50; { 'PK'78 } // also 'span' mark |
||
174 | EndCentral64Sig = $06064B50; { 'PK'66 } |
||
175 | EOC64LocatorSig = $07064B50; { 'PK'67 } |
||
176 | |||
177 | Zip64_data_tag = $0001; // Zip64 extra field tag |
||
178 | NTFS_data_tag = $000A; // NTFS date stamps |
||
179 | UPath_Data_Tag = $7075; // Info-Zip UTF8 path field |
||
180 | UCmnt_Data_Tag = $6375; // Info-Zip UTF8 comment field |
||
181 | // Tag - 2 byte |
||
182 | // total size - 2 byte |
||
183 | // version - 1 byte = 1 |
||
184 | // crc -4 bytes = crc of orig field |
||
185 | // utf8 string - total size - 9 |
||
186 | |||
187 | type |
||
188 | PUString_Data_Header = ^TUString_Data_Header; |
||
189 | TUString_Data_Header = packed record |
||
190 | tag: word; |
||
191 | totsiz: word; |
||
192 | version: byte; |
||
193 | origcrc: DWORD; |
||
194 | end; |
||
195 | |||
196 | const |
||
197 | MAX_UNSIGNED = $FFFFFFFF; |
||
198 | MAX_WORD = $FFFF; |
||
199 | MAX_BYTE = $FF; |
||
200 | |||
201 | const |
||
202 | CRYPT_HEAD_SIZE = 12; |
||
203 | |||
204 | const |
||
205 | FS_FAT = 0; |
||
206 | FS_HPFS = 6; |
||
207 | FS_NTFS = 11; |
||
208 | FLAG_UTF8_BIT = $0800; |
||
209 | |||
210 | ZIP64_VER = 45; |
||
211 | OSMask = $FF00; |
||
212 | VerMask = $00FF; |
||
213 | |||
214 | type |
||
215 | TZM_StreamHeader = packed record |
||
216 | Method: WORD; |
||
217 | CRC: DWORD; |
||
218 | end; |
||
219 | // compression method values |
||
220 | const |
||
221 | TZMDeflateEncrypt = 1024; // or-ed with METHOD_DEFLATED in Stream Header |
||
222 | METHOD_DEFLATED = 8; |
||
223 | METHOD_STORED = 0; |
||
224 | |||
225 | (* |
||
226 | const |
||
227 | // 'DZ'#0#1; // header signature |
||
228 | SFX_HEADER_SIG = $01005A44; |
||
229 | // 'DZ'#10#1; // end of header signature |
||
230 | SFX_HEADER_END_SIG = $010A5A44; |
||
231 | |||
232 | // 'DZ'#20#1; // detached header signature |
||
233 | // SFX_DETACHED_HEADER_SIG = $01145A44; |
||
234 | // 'DZ'#20#2; // end of detached header signature |
||
235 | // SFX_DETACHED_HEADER_END_SIG = $02145A44; |
||
236 | |||
237 | type |
||
238 | { sfx file header } |
||
239 | PSFXFileHeader = ^TSFXFileHeader; |
||
240 | TSFXFileHeader = packed record |
||
241 | // signature: DZ#0#1 = version 01 |
||
242 | Signature: DWORD;//Cardinal; |
||
243 | // overall header size (must be DWORD-Aligned!) |
||
244 | Size: word; |
||
245 | // flags |
||
246 | Options: DWORD;//TSFXOpts;//TSFXOptions; |
||
247 | // default overwrite mode |
||
248 | DefOVW: DWORD;//TZMOvrOpts;//TSFXOverwriteMode; |
||
249 | // length of the sfx dialog caption (0=default caption) |
||
250 | CaptionSize, |
||
251 | // length of the sfx default extraction path (0=current dir) |
||
252 | PathSize, |
||
253 | // length of the command line (0=no command line) |
||
254 | CmdLineSize, |
||
255 | // length of the extract path to be used if HK... failed (0=%temp%) |
||
256 | RegFailPathSize, |
||
257 | // length of the startup message (0=no message) |
||
258 | StartMsgSize: byte; |
||
259 | // MB_... (only used if StartMsgSize > 0) |
||
260 | StartMsgType: DWORD;//Cardinal; |
||
261 | { |
||
262 | Caption: string; if CaptionSize > 0, contains the caption of the sfx dialog (not #0-terminated) |
||
263 | |||
264 | + will be expanded if it contains % signs and soExpandEnvStrings is set |
||
265 | |||
266 | Path: string; if PathSize > 0, contains the default extraction path (not #0-terminated) |
||
267 | |||
268 | + will be expanded if it contains % signs and soExpandEnvStrings is set |
||
269 | |||
270 | + if set to "><", then use temp-dir |
||
271 | |||
272 | + If the first two characters are "HK" the extraction-path //##FR |
||
273 | will be read from the registry. If the registry-key doesn't exist, the |
||
274 | default path will be set to the temp path. Either full names |
||
275 | (HKEY_CURRENT_USER\...) or abbreviations (as known from INF-files) |
||
276 | for the root keys HKCU, HKLM and HKU are supported. |
||
277 | examples: |
||
278 | "HKEY_CURRENT_USER\Software\Borland\Delphi\2.0\Library\SearchPath" |
||
279 | "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir" |
||
280 | "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal" |
||
281 | "HKCU\Software\Microsoft\Office\8.0\Excel\Microsoft Excel\AddIn Path" |
||
282 | For subdirectories to be created use the pipe symbol "|", e.g. |
||
283 | "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\SystemRoot|NewDir" |
||
284 | will parse to : "C:\Windows\NewDir" (or whereever your system root is). |
||
285 | |||
286 | CmdLine: string; if CmdLineSize > 0, contains a command to execute after extraction completed |
||
287 | (not #0-terminated) |
||
288 | |||
289 | + will be expanded if it contains % signs and soExpandEnvStrings is set |
||
290 | |||
291 | + CmdLine has a special format: |
||
292 | all occurrences of "><" (greather than+less than) in this string will be replaced by |
||
293 | the actual extraction path, e.g. : |
||
294 | if the archive has been extracted to "c:\Program Files\foo", a CmdLine |
||
295 | of "><bar\some.txt" will parse to "c:\Progra~1\foo\bar\some.txt" |
||
296 | (because of limitations of the ShellExecute API on some platforms when using long |
||
297 | filenames the short filename is generated by delzipsfx) |
||
298 | |||
299 | if the pipe char "|" is found in the CmdLine, the part to the left of it is used as |
||
300 | the application to run and the part to the right as its command line, e.g.: |
||
301 | |||
302 | extraction path = "d:\unpack", CmdLine = "><setup.exe|><install.inf" |
||
303 | -> exec "d:\unpack\setup.exe" with args "d:\unpack\install.inf" |
||
304 | |||
305 | extraction path = "d:\unpack", CmdLine = "><readme.txt": |
||
306 | -> open "d:\unpack\readme.txt" with its associated program, if there is any. |
||
307 | |||
308 | extraction path = "d:\unpack", CmdLine = "><setup.exe": |
||
309 | -> exec "d:\unpack\setup.exe" without special parameters. |
||
310 | |||
311 | additionally, if soExpandEnvStrings is set in the Options field: |
||
312 | extraction path = "d:\unpack", CmdLine = "%windir%notepad.exe|><readme.txt", |
||
313 | Windows Dir="c:\Windows" |
||
314 | -> exec "c:\windows\notepad.exe" with args "d:\unpack\readme.txt" |
||
315 | |||
316 | + INF-scripts are accepted as well //##FR |
||
317 | "><setup.inf" will run the [DefaultInstall] section of "d:\unpack\setup.inf". |
||
318 | "><setup.inf|.ntx86" will run the [DefaultInstall] section if Win95 (98?), |
||
319 | but [DefaultInstall.ntx86] section if WinNT. |
||
320 | |||
321 | RegFailPath: string if RegFailPathSize > 0, contains the default extraction path, |
||
322 | if reading path from registry failed (not #0-terminated) |
||
323 | |||
324 | + will be expanded if it contains % signs and soExpandEnvStrings is set |
||
325 | |||
326 | + if set to "><", then use temp-dir |
||
327 | |||
328 | StartMsg: string; if StartMsgSize > 0, contains a message to display before showing the main dialog. |
||
329 | (not #0-terminated) |
||
330 | |||
331 | + will be expanded if it contains % signs and soExpandEnvStrings is set |
||
332 | |||
333 | if this messagebox is closed by pressing either IDCANCEL, IDABORT, IDNO or IDCLOSE button, |
||
334 | sfx terminates. |
||
335 | |||
336 | } |
||
337 | end; |
||
338 | |||
339 | // the following record is only used by TZipSFX20 and TZipMasterSFX to quickly find the |
||
340 | // TSFXFileHeader in the file, it's not used by the sfx itself. |
||
341 | // it's immediately stored after the TSFXFileHeader record |
||
342 | PSFXFileEndOfHeader= ^TSFXFileEndOfHeader; |
||
343 | TSFXFileEndOfHeader= packed record |
||
344 | Signature: DWORD; //must be SFX_HEADER_END_SIG |
||
345 | HeaderSize: DWORD; //must be equal to TSFXFileHeader.Size (dword for alignment issuses) |
||
346 | end; |
||
347 | (* |
||
348 | // in detached sfx archives, the sfx contains an additional record following the header |
||
349 | PSFXDetachedHeader= ^TSFXDetachedHeader; |
||
350 | TSFXDetachedHeader= packed record |
||
351 | Signature: DWORD; // must be SFX_DETACHED_HEADER_SIG or SFX_DETACHED_HEADER_END_SIG |
||
352 | NameLen, |
||
353 | ExtLen: DWORD; // contains the length of the filename/fileext of the archive (without path) |
||
354 | { |
||
355 | Name: string if NameLen > 0, Name contains the file name (without extension) of |
||
356 | the detached archive |
||
357 | Ext: string if ExtLen > 0, Ext contains the file Ext (without leading .) of |
||
358 | the detached archive |
||
359 | } |
||
360 | end; |
||
361 | *) |
||
362 | { the structure of a zipsfx-file : |
||
363 | - zipsfx-executable code (0-xxxxx) |
||
364 | - TSFXFileHeader record (see above) |
||
365 | - possibly one or more strings (depending on the headers' properties) (not #0 terminated) |
||
366 | Caption sfx dialog caption |
||
367 | Path sfx default extraction path |
||
368 | CmdLine command line to execute after extraction |
||
369 | RegFailPath default extract path if Path could not be read from registry |
||
370 | StartMsg startup message |
||
371 | |||
372 | NOTE: the complete header (including the strings) must be DWORD-aligned! |
||
373 | |||
374 | if not detached from the archive: |
||
375 | - the zip archive |
||
376 | |||
377 | if detached from the archive: |
||
378 | - TSFXDetachedHeader + filename + TSFXDetachedHeader |
||
379 | - centraldirectories[] + endofcentraldir of the zip archive |
||
380 | } |
||
381 | (* |
||
382 | type |
||
383 | PSFXDetachedHeader = ^TSFXDetachedHeader; |
||
384 | TSFXDetachedHeader= packed record |
||
385 | Signature: DWORD; // must be SFX_DETACHED_HEADER_SIG or SFX_DETACHED_HEADER_END_SIG |
||
386 | NameLen, |
||
387 | ExtLen: Cardinal; // contains the length of the filename/fileext of the archive (without path) |
||
388 | { |
||
389 | Name: string if NameLen > 0, Name contains the file name (without extension) of |
||
390 | the detached archive |
||
391 | Ext: string if ExtLen > 0, Ext contains the file Ext (without leading .) of |
||
392 | the detached archive |
||
393 | } |
||
394 | end; |
||
395 | *) |
||
396 | type |
||
397 | PImageResourceDirectory = ^_IMAGE_RESOURCE_DIRECTORY; |
||
398 | _IMAGE_RESOURCE_DIRECTORY = packed record |
||
399 | Characteristics : DWORD; |
||
400 | TimeDateStamp : DWORD; |
||
401 | MajorVersion : Word; |
||
402 | MinorVersion : Word; |
||
403 | NumberOfNamedEntries : Word; |
||
404 | NumberOfIdEntries : Word; |
||
405 | end; |
||
406 | TImageResourceDirectory = _IMAGE_RESOURCE_DIRECTORY; |
||
407 | |||
408 | PImageResourceDirectoryEntry = ^_IMAGE_RESOURCE_DIRECTORY_ENTRY; |
||
409 | _IMAGE_RESOURCE_DIRECTORY_ENTRY = packed record |
||
410 | un1: record |
||
411 | case Integer of |
||
412 | 1: (NameIsString: DWORD); // Bit 31 |
||
413 | 2: (NameOffset: DWORD); // Bits 30..0 |
||
414 | 3: (Name: DWORD); |
||
415 | 4: (Id: Word); |
||
416 | end; |
||
417 | un2: record |
||
418 | case Integer of |
||
419 | 1: (OffsetToData: DWORD); |
||
420 | 2: (DataIsDirectory: DWORD); // Bit 31 |
||
421 | 3: (OffsetToDirectory: DWORD); // Bits 30..0 |
||
422 | end; |
||
423 | end; |
||
424 | TImageResourceDirectoryEntry = _IMAGE_RESOURCE_DIRECTORY_ENTRY; |
||
425 | |||
426 | PImageResourceDataEntry = ^_IMAGE_RESOURCE_DATA_ENTRY; |
||
427 | _IMAGE_RESOURCE_DATA_ENTRY = packed record |
||
428 | OffsetToData : DWORD; |
||
429 | Size : DWORD; |
||
430 | CodePage : DWORD; |
||
431 | Reserved : DWORD; |
||
432 | end; |
||
433 | TImageResourceDataEntry = _IMAGE_RESOURCE_DATA_ENTRY; |
||
434 | |||
435 | |||
436 | PIconDir = ^ICONDIR; |
||
437 | ICONDIR = packed record |
||
438 | Reserved : Word; |
||
439 | ResType : Word; |
||
440 | ResCount : Word; |
||
441 | // idEntries[]: ICONDIRENTRY |
||
442 | end; |
||
443 | TIconDir = ICONDIR; |
||
444 | |||
445 | PIconDirEntry = ^ICONDIRENTRY; |
||
446 | ICONDIRENTRY = packed record |
||
447 | bWidth, |
||
448 | bHeight, |
||
449 | bColorCount, |
||
450 | bReserved : Byte; |
||
451 | wPlanes, |
||
452 | wBitCount : Word; |
||
453 | dwBytesInRes, |
||
454 | dwImageOffset : DWORD; |
||
455 | end; |
||
456 | TIconDirEntry = ICONDIRENTRY; |
||
457 | |||
458 | const |
||
459 | IMAGE_RESOURCE_DATA_IS_DIRECTORY = $80000000; |
||
460 | |||
461 | const |
||
462 | IMAGE_PE_SIGNATURE = $00004550; |
||
463 | |||
464 | |||
465 | //----------------Icon resource info needed SFX ----------------------------------- |
||
466 | (*{$IFDEF VERD2D3} |
||
467 | const |
||
468 | IMAGE_DIRECTORY_ENTRY_RESOURCE = 2; |
||
469 | IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 16; |
||
470 | IMAGE_SIZEOF_SHORT_NAME = 8; |
||
471 | IMAGE_DOS_SIGNATURE = $5A4D; |
||
472 | IMAGE_NT_SIGNATURE = $00004550; |
||
473 | |||
474 | type |
||
475 | pIMAGE_DOS_HEADER = ^IMAGE_DOS_HEADER; |
||
476 | |||
477 | IMAGE_DOS_HEADER = packed record { DOS .EXE header } |
||
478 | e_magic: Word; { Magic number } |
||
479 | e_cblp: Word; { Bytes on last page of file } |
||
480 | e_cp: Word; { Pages in file } |
||
481 | e_crlc: Word; { Relocations } |
||
482 | e_cparhdr: Word; { Size of header in paragraphs } |
||
483 | e_minalloc: Word; { Minimum extra paragraphs needed } |
||
484 | e_maxalloc: Word; { Maximum extra paragraphs needed } |
||
485 | e_ss: Word; { Initial (relative) SS value } |
||
486 | e_sp: Word; { Initial SP value } |
||
487 | e_csum: Word; { Checksum } |
||
488 | e_ip: Word; { Initial IP value } |
||
489 | e_cs: Word; { Initial (relative) CS value } |
||
490 | e_lfarlc: Word; { File address of relocation table } |
||
491 | e_ovno: Word; { Overlay number } |
||
492 | e_res: packed array[0..3] of Word; { Reserved words } |
||
493 | e_oemid: Word; { OEM identifier (for e_oeminfo) } |
||
494 | e_oeminfo: Word; { OEM information; e_oemid specific } |
||
495 | e_res2: packed array[0..9] of Word; { Reserved words } |
||
496 | _lfanew: Longint; { File address of new exe header } |
||
497 | end; |
||
498 | |||
499 | type |
||
500 | pImageDataDirectory = ^IMAGE_DATA_DIRECTORY; |
||
501 | |||
502 | _IMAGE_DATA_DIRECTORY = record |
||
503 | VirtualAddress: DWORD; |
||
504 | Size: DWORD; |
||
505 | end; |
||
506 | IMAGE_DATA_DIRECTORY = _IMAGE_DATA_DIRECTORY; |
||
507 | |||
508 | type |
||
509 | pImageFileHeader = ^IMAGE_FILE_HEADER; |
||
510 | |||
511 | _IMAGE_FILE_HEADER = packed record |
||
512 | Machine: Word; |
||
513 | NumberOfSections: Word; |
||
514 | TimeDateStamp: DWORD; |
||
515 | PointerToSymbolTable: DWORD; |
||
516 | NumberOfSymbols: DWORD; |
||
517 | SizeOfOptionalHeader: Word; |
||
518 | Characteristics: Word; |
||
519 | end; |
||
520 | IMAGE_FILE_HEADER = _IMAGE_FILE_HEADER; |
||
521 | |||
522 | type |
||
523 | pImageOptionalHeader = ^IMAGE_OPTIONAL_HEADER; |
||
524 | |||
525 | _IMAGE_OPTIONAL_HEADER = packed record |
||
526 | { Standard fields. } |
||
527 | Magic: Word; |
||
528 | MajorLinkerVersion: Byte; |
||
529 | MinorLinkerVersion: Byte; |
||
530 | SizeOfCode: DWORD; |
||
531 | SizeOfInitializedData: DWORD; |
||
532 | SizeOfUninitializedData: DWORD; |
||
533 | AddressOfEntryPoint: DWORD; |
||
534 | BaseOfCode: DWORD; |
||
535 | BaseOfData: DWORD; |
||
536 | { NT additional fields. } |
||
537 | ImageBase: DWORD; |
||
538 | SectionAlignment: DWORD; |
||
539 | FileAlignment: DWORD; |
||
540 | MajorOperatingSystemVersion: Word; |
||
541 | MinorOperatingSystemVersion: Word; |
||
542 | MajorImageVersion: Word; |
||
543 | MinorImageVersion: Word; |
||
544 | MajorSubsystemVersion: Word; |
||
545 | MinorSubsystemVersion: Word; |
||
546 | Win32VersionValue: DWORD; |
||
547 | SizeOfImage: DWORD; |
||
548 | SizeOfHeaders: DWORD; |
||
549 | CheckSum: DWORD; |
||
550 | Subsystem: Word; |
||
551 | DllCharacteristics: Word; |
||
552 | SizeOfStackReserve: DWORD; |
||
553 | SizeOfStackCommit: DWORD; |
||
554 | SizeOfHeapReserve: DWORD; |
||
555 | SizeOfHeapCommit: DWORD; |
||
556 | LoaderFlags: DWORD; |
||
557 | NumberOfRvaAndSizes: DWORD; |
||
558 | DataDirectory: packed array[0..IMAGE_NUMBEROF_DIRECTORY_ENTRIES - 1] of |
||
559 | IMAGE_DATA_DIRECTORY; |
||
560 | end; |
||
561 | IMAGE_OPTIONAL_HEADER = _IMAGE_OPTIONAL_HEADER; |
||
562 | |||
563 | type |
||
564 | TISHMisc = packed record |
||
565 | case Integer of |
||
566 | 0: (PhysicalAddress: DWORD); |
||
567 | 1: (VirtualSize: DWORD); |
||
568 | end; |
||
569 | |||
570 | pImageSectionHeader = ^IMAGE_SECTION_HEADER; |
||
571 | |||
572 | _IMAGE_SECTION_HEADER = packed record |
||
573 | Name: packed array[0..IMAGE_SIZEOF_SHORT_NAME - 1] of Byte; |
||
574 | Misc: TISHMisc; |
||
575 | VirtualAddress: DWORD; |
||
576 | SizeOfRawData: DWORD; |
||
577 | PointerToRawData: DWORD; |
||
578 | PointerToRelocations: DWORD; |
||
579 | PointerToLinenumbers: DWORD; |
||
580 | NumberOfRelocations: Word; |
||
581 | NumberOfLinenumbers: Word; |
||
582 | Characteristics: DWORD; |
||
583 | end; |
||
584 | IMAGE_SECTION_HEADER = _IMAGE_SECTION_HEADER; |
||
585 | {$ENDIF} *) |
||
586 | |||
587 | type |
||
588 | PISH = ^IMAGE_SECTION_HEADER; |
||
589 | |||
590 | PEheader = packed record |
||
591 | signature: DWord; |
||
592 | _head: IMAGE_FILE_HEADER; |
||
593 | opt_head: IMAGE_OPTIONAL_HEADER; |
||
594 | section_header: IMAGE_SECTION_HEADER; |
||
595 | end; |
||
596 | |||
597 | IMAGE_RESOURCE_DIR_STRING_U = packed record |
||
598 | Length: Word; |
||
599 | NameString: array[0..0] of WChar; |
||
600 | end; |
||
601 | PIRDSU = ^IMAGE_RESOURCE_DIR_STRING_U; |
||
602 | |||
603 | IMAGE_RESOURCE_DIRECTORY_ENTRY = packed record |
||
604 | un1: record |
||
605 | case Integer of |
||
606 | 1: (NameIsString: DWord); // Bit 32 |
||
607 | 2: (NameOffset: DWord); // Bits 31..0 |
||
608 | 3: (Name: DWord); |
||
609 | 4: (Id: Word); |
||
610 | end; |
||
611 | un2: record |
||
612 | case Integer of |
||
613 | 1: (OffsetToData: DWord); |
||
614 | 2: (DataIsDirectory: Dword); // Bit 32 |
||
615 | 3: (OffsetToDirectory: DWord); // Bits 31..0 |
||
616 | end; |
||
617 | end; |
||
618 | PIRDirE = ^IMAGE_RESOURCE_DIRECTORY_ENTRY; |
||
619 | |||
620 | PIDD = ^IMAGE_DATA_DIRECTORY; |
||
621 | |||
622 | IMAGE_RESOURCE_DIRECTORY = packed record |
||
623 | Characteristics: DWord; |
||
624 | TimeDateStamp: DWord; |
||
625 | MajorVersion: Word; |
||
626 | MinorVersion: Word; |
||
627 | NumberOfNamedEntries: Word; |
||
628 | NumberOfIdEntries: Word; |
||
629 | end; |
||
630 | PIRD = ^IMAGE_RESOURCE_DIRECTORY; |
||
631 | |||
632 | IMAGE_RESOURCE_DATA_ENTRY = packed record |
||
633 | OffsetToData: DWord; |
||
634 | Size: DWord; |
||
635 | CodePage: DWord; |
||
636 | Reserved: DWord; |
||
637 | end; |
||
638 | PIRDatE = ^IMAGE_RESOURCE_DATA_ENTRY; |
||
639 | // ---- end SFX needed |
||
640 | // ---- ===== ----- ===== end of implementation data ===== ----- ===== ----- |
||
641 | |||
642 | implementation |
||
643 | |||
644 | end. |
||
645 |