diff -ur file-3.30/Magdir/msdos file-3.30-mea/Magdir/msdos --- file-3.30/Magdir/msdos Sun Oct 31 23:59:27 1999 +++ file-3.30-mea/Magdir/msdos Sat Dec 23 10:08:45 2000 @@ -19,55 +19,79 @@ # probably some linker directive to set it. The linker version was # 3.0, except for one ".exe" which had it as 4.20 (same damn linker!). # -128 string PE\0\0 MS Windows PE ->150 leshort&0x0100 >0 32-bit ->132 leshort 0x0 unknown processor ->132 leshort 0x14c Intel 80386 ->132 leshort 0x166 MIPS R4000 ->132 leshort 0x184 Alpha ->132 leshort 0x268 Motorola 68000 ->132 leshort 0x1f0 PowerPC ->132 leshort 0x290 PA-RISC ->148 leshort >27 ->>220 leshort 0 unknown subsystem ->>220 leshort 1 native ->>220 leshort 2 GUI ->>220 leshort 3 console ->>220 leshort 7 POSIX ->150 leshort&0x2000 =0 executable -#>>136 ledate x stamp %s, ->>150 leshort&0x0001 >0 not relocatable -#>>150 leshort&0x0004 =0 with line numbers, -#>>150 leshort&0x0008 =0 with local symbols, -#>>150 leshort&0x0200 =0 with debug symbols, ->>150 leshort&0x1000 >0 system file -#>>148 leshort >0 -#>>>154 byte x linker %d -#>>>155 byte x \b.%d, -#>>148 leshort >27 -#>>>192 leshort x requires OS %d -#>>>194 leshort x \b.%d, -#>>>196 leshort x user version %d -#>>>198 leshort x \b.%d, -#>>>200 leshort x subsystem version %d -#>>>202 leshort x \b.%d, ->150 leshort&0x2000 >0 DLL -#>>136 ledate x stamp %s, ->>150 leshort&0x0001 >0 not relocatable -#>>150 leshort&0x0004 =0 with line numbers, -#>>150 leshort&0x0008 =0 with local symbols, -#>>150 leshort&0x0200 =0 with debug symbols, ->>150 leshort&0x1000 >0 system file -#>>148 leshort >0 -#>>>154 byte x linker %d -#>>>155 byte x \b.%d, -#>>148 leshort >27 -#>>>192 leshort x requires OS %d -#>>>194 leshort x \b.%d, -#>>>196 leshort x user version %d -#>>>198 leshort x \b.%d, -#>>>200 leshort x subsystem version %d -#>>>202 leshort x \b.%d, +0 string MZ +>(60.s)& string NE MS Windows NE file (Win-16 DLL) +# +>(60.s)& string PE\0\0 MS Windows PE file, +# & = 130 (with '128' as standard reference for PE block start) +# The base address from indirection is 128, but the size isn't +# strings four bytes, but short's two bytes! +# >>150 -> >>&20 ("Characteristics", last of mandatory PE header fields) +>>&4 leshort x %d sections, +>>&14 lelong >0 %d symbols, +>>&20 leshort&0x0100 >0 32-bit +>>&20 leshort&0x0040 >0 16-bit +>>&2 leshort 0x0 unknown processor, +>>&2 leshort 0x14c Intel 80386, +>>&2 leshort 0x166 MIPS R4000, +>>&2 leshort 0x184 Alpha, +>>&2 leshort 0x268 Motorola 68000, +>>&2 leshort 0x1f0 PowerPC, +>>&2 leshort 0x290 PA-RISC, +# & = 130 +>>&20 leshort&0x2000 >0 DLL Image, +# & = 152 +>>>&-2 leshort&0x0001 >0 executable, +>>>&-16 ledate x stamp %s, +>>>&-2 leshort&0x0001 =0 relocatable, +>>>&-2 leshort&0x0001 >0 not relocatable, +>>>&-2 leshort&0x0004 =0 with line numbers, +>>>&-2 leshort&0x0008 =0 with local symbols, +>>>&-2 leshort&0x0200 =0 with debug symbols, +>>>&-2 leshort&0x0020 >0 understands addresses over 2G, +>>>&-2 leshort&0x1000 >0 system file, +>>>&-2 leshort&0x4000 >0 NO SMP, +>>>&-2 leshort&0x8080 >0 BIG ENDIAN BYTE SWAP! +#>>>&-4 leshort >0 +# & = 150 +#>>>>&4 byte x linker %d +#>>>>&5 byte x \b.%d, +>>&20 leshort&0x2000 =0 +# & = 152 +>>>&-2 leshort&0x0001 >0 executable, +>>>&-16 ledate x stamp %s, +>>>&-2 leshort&0x0001 =0 relocatable, +>>>&-2 leshort&0x0001 >0 not relocatable, +>>>&-2 leshort&0x0004 =0 with line numbers, +>>>&-2 leshort&0x0008 =0 with local symbols, +>>>&-2 leshort&0x0200 =0 with debug symbols, +>>>&-2 leshort&0x0020 >0 understands addresses over 2G, +>>>&-2 leshort&0x1000 >0 system file, +>>>&-2 leshort&0x4000 >0 NO SMP, +>>>&-2 leshort&0x8080 >0 BIG ENDIAN BYTE SWAP! +#>>>&-4 leshort >0 +# & = 150 +#>>>>&4 byte x linker %d +#>>>>&5 byte x \b.%d, +#>>>&-4 leshort >27 +# If size of the optional header >= 28, we can continue.. +>>&18 leshort >27 +# & = 150 +# >>>220 -> >>>&70 +>>>&70 leshort 0 unknown subsystem +>>>&70 leshort 1 native +>>>&70 leshort 2 GUI +>>>&70 leshort 3 console +>>>&70 leshort 7 POSIX +#>>>&-4 leshort >27 +# & = 150 +#>>>>192 leshort x requires OS %d +#>>>>194 leshort x \b.%d, +#>>>>196 leshort x user version %d +#>>>>198 leshort x \b.%d, +#>>>>200 leshort x subsystem version %d +#>>>>202 leshort x \b.%d, + 0 leshort 0x14c MS Windows COFF Intel 80386 object file #>4 ledate x stamp %s 0 leshort 0x166 MS Windows COFF MIPS R4000 object file diff -ur file-3.30/apprentice.c file-3.30-mea/apprentice.c --- file-3.30/apprentice.c Tue Apr 11 05:06:57 2000 +++ file-3.30-mea/apprentice.c Sat Dec 23 07:21:51 2000 @@ -267,6 +267,10 @@ t = l; if (*t++ != ')') magwarn("missing ')' in indirect offset"); + if (*t == '&') { + m->flag |= INDIRSET; + ++t; + } l = t; } diff -ur file-3.30/file.h file-3.30-mea/file.h --- file-3.30/file.h Tue Apr 11 05:32:35 2000 +++ file-3.30-mea/file.h Sat Dec 23 07:21:11 2000 @@ -45,9 +45,10 @@ struct magic { short flag; -#define INDIR 1 /* if '>(...)' appears, */ -#define UNSIGNED 2 /* comparison is unsigned */ -#define ADD 4 /* if '>&' appears, */ +#define INDIR 1 /* if '>(...)' appears, */ +#define INDIRSET 2 /* if '>(...)&' appears */ +#define UNSIGNED 4 /* comparison is unsigned */ +#define ADD 8 /* if '>&' appears, */ short cont_level; /* level of ">" */ struct { unsigned char type; /* byte short long */ diff -ur file-3.30/softmagic.c file-3.30-mea/softmagic.c --- file-3.30/softmagic.c Sun Nov 28 22:02:30 1999 +++ file-3.30-mea/softmagic.c Sat Dec 23 07:50:48 2000 @@ -147,6 +147,9 @@ oldoff=magic[magindex].offset; magic[magindex].offset += tmpoff[cont_level-1]; } + if (magic[magindex].flag & INDIRSET) { + oldoff=magic[magindex].offset; + } if (mget(&p, s, &magic[magindex], nbytes) && mcheck(&p, &magic[magindex])) { /* @@ -179,7 +182,7 @@ tmplen += 20)) == NULL) error("out of memory\n"); } - if (magic[magindex].flag & ADD) { + if (magic[magindex].flag & (ADD|INDIRSET)) { magic[magindex].offset = oldoff; } } @@ -388,6 +391,9 @@ mdebug(offset, (char *) p, sizeof(union VALUETYPE)); mdump(m); } + } + if (m->flag & INDIRSET) { + m->offset = offset; } if (!mconvert(p, m)) return 0;