diff options
author | Xin LI <delphij@FreeBSD.org> | 2022-07-04 00:05:11 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2022-07-04 00:05:11 +0000 |
commit | ba49e6371b088bc2fe0fa286104eaa6eba8074d1 (patch) | |
tree | 011cac5811086ca413aa199086c371ca162dc281 | |
parent | 048bd4094ff308722af59e857c54819c9313875a (diff) |
Vendor import of file 5.42.vendor/file/5.42
88 files changed, 5429 insertions, 1966 deletions
diff --git a/ChangeLog b/ChangeLog index 0bb334c9fd88..d9bf953f1ac0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,40 @@ +2022-06-10 9:40 Christos Zoulas <christos@zoulas.com> + + * release 5.42 + +2022-05-31 14:50 Christos Zoulas <christos@zoulas.com> + + * PR/348: add missing cases to prevent file from aborting on + random magic files. + +2022-05-27 21:05 Christos Zoulas <christos@zoulas.com> + + * PR/351: octalify filenames when not raw before printing. + +2022-04-18 17:51 Christos Zoulas <christos@zoulas.com> + + * fix regex cacheing bug (Dirk Mueller) + * merge file_regcomp and file_regerror() to simplify the code + and reduce memory requirements for storing regexes (Dirk Mueller) + +2022-03-19 12:56 Christos Zoulas <christos@zoulas.com> + + * cache regex (Dirk Mueller) + * detect filesystem full by flushing output (Dirk Mueller) + +2021-11-19 12:36 Christos Zoulas <christos@zoulas.com> + + * implement running decompressor programs using + posix_spawnp(2) instead of vfork(2) + +2021-10-24 11:51 Christos Zoulas <christos@zoulas.com> + + * Add support for msdos dates and times + +2021-10-20 9:55 Christos Zoulas <christos@zoulas.com> + + * use the system byte swapping functions if available (Werner Fink) + 2021-10-18 11:57 Christos Zoulas <christos@zoulas.com> * release 5.41 diff --git a/Makefile.am b/Makefile.am index b10b1cb14daa..e816779b8c53 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,7 @@ ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = MAINT RELEASE-PROCEDURE README.DEVELOPER m4/visibility.m4 +EXTRA_DIST = MAINT RELEASE-PROCEDURE README.DEVELOPER README.md \ + m4/visibility.m4 SUBDIRS = src magic tests doc python diff --git a/Makefile.in b/Makefile.in index 79e1d05b5d73..e2f067361f5c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -192,8 +192,8 @@ CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(srcdir)/libmagic.pc.in AUTHORS COPYING ChangeLog INSTALL \ - NEWS TODO compile config.guess config.sub depcomp install-sh \ - ltmain.sh missing + NEWS TODO compile config.guess config.sub install-sh ltmain.sh \ + missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -358,7 +358,9 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = MAINT RELEASE-PROCEDURE README.DEVELOPER m4/visibility.m4 +EXTRA_DIST = MAINT RELEASE-PROCEDURE README.DEVELOPER README.md \ + m4/visibility.m4 + SUBDIRS = src magic tests doc python # This variable must have 'exec' in its name, in order to be installed diff --git a/README.md b/README.md new file mode 100644 index 000000000000..37a3b17856c6 --- /dev/null +++ b/README.md @@ -0,0 +1,155 @@ +## README for file(1) Command and the libmagic(3) library ## + + @(#) $File: README.md,v 1.4 2021/10/21 01:51:31 christos Exp $ + +- Bug Tracker: <https://bugs.astron.com/> +- Build Status: <https://travis-ci.org/file/file> +- Download link: <ftp://ftp.astron.com/pub/file/> +- E-mail: <christos@astron.com> +- Fuzzing link: <https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:file> +- Home page: https://www.darwinsys.com/file/ +- Mailing List archives: <https://mailman.astron.com/pipermail/file/> +- Mailing List: <file@astron.com> +- Public repo: <https://github.com/file/file> +- Test framework: <https://github.com/file/file-tests> + +Phone: Do not even think of telephoning me about this program. Send +cash first! + +This is Release 5.x of Ian Darwin's (copyright but distributable) +file(1) command, an implementation of the Unix File(1) command. +It knows the 'magic number' of several thousands of file types. +This version is the standard "file" command for Linux, *BSD, and +other systems. (See "patchlevel.h" for the exact release number). + +The major changes for 5.x are CDF file parsing, indirect magic, +name/use (recursion) and overhaul in mime and ascii encoding +handling. + +The major feature of 4.x is the refactoring of the code into a +library, and the re-write of the file command in terms of that +library. The library itself, libmagic can be used by 3rd party +programs that wish to identify file types without having to fork() +and exec() file. The prime contributor for 4.0 was Mans Rullgard. + +UNIX is a trademark of UNIX System Laboratories. + +The prime contributor to Release 3.8 was Guy Harris, who put in +megachanges including byte-order independence. + +The prime contributor to Release 3.0 was Christos Zoulas, who put +in hundreds of lines of source code changes, including his own +ANSIfication of the code (I liked my own ANSIfication better, but +his (__P()) is the "Berkeley standard" way of doing it, and I wanted +UCB to include the code...), his HP-like "indirection" (a feature +of the HP file command, I think), and his mods that finally got +the uncompress (-z) mode finished and working. + +This release has compiled in numerous environments; see PORTING +for a list and problems. + +This fine freeware file(1) follows the USG (System V) model of the +file command, rather than the Research (V7) version or the V7-derived +4.[23] Berkeley one. That is, the file /etc/magic contains much of +the ritual information that is the source of this program's power. +My version knows a little more magic (including tar archives) than +System V; the /etc/magic parsing seems to be compatible with the +(poorly documented) System V /etc/magic format (with one exception; +see the man page). + +In addition, the /etc/magic file is built from a subdirectory +for easier(?) maintenance. I will act as a clearinghouse for +magic numbers assigned to all sorts of data files that +are in reasonable circulation. Send your magic numbers, +in magic(5) format please, to the maintainer, Christos Zoulas. + +COPYING - read this first. +* `README` - read this second (you are currently reading this file). +* `INSTALL` - read on how to install +* `src/apprentice.c` - parses /etc/magic to learn magic +* `src/apptype.c` - used for OS/2 specific application type magic +* `src/ascmagic.c` - third & last set of tests, based on hardwired assumptions. +* `src/asctime_r.c` - replacement for OS's that don't have it. +* `src/asprintf.c` - replacement for OS's that don't have it. +* `src/buffer.c` - buffer handling functions. +* `src/cdf.[ch]` - parser for Microsoft Compound Document Files +* `src/cdf_time.c` - time converter for CDF. +* `src/compress.c` - handles decompressing files to look inside. +* `src/ctime_r.c` - replacement for OS's that don't have it. +* `src/der.[ch]` - parser for Distinguished Encoding Rules +* `src/dprintf.c` - replacement for OS's that don't have it. +* `src/elfclass.h` - common code for elf 32/64. +* `src/encoding.c` - handles unicode encodings +* `src/file.c` - the main program +* `src/file.h` - header file +* `src/file_opts.h` - list of options +* `src/fmtcheck.c` - replacement for OS's that don't have it. +* `src/fsmagic.c` - first set of tests the program runs, based on filesystem info +* `src/funcs.c` - utilility functions +* `src/getline.c` - replacement for OS's that don't have it. +* `src/getopt_long.c` - replacement for OS's that don't have it. +* `src/gmtime_r.c` - replacement for OS's that don't have it. +* `src/is_csv.c` - knows about Comma Separated Value file format (RFC 4180). +* `src/is_json.c` - knows about JavaScript Object Notation format (RFC 8259). +* `src/is_tar.c, tar.h` - knows about Tape ARchive format (courtesy John Gilmore). +* `src/localtime_r.c` - replacement for OS's that don't have it. +* `src/magic.h.in` - source file for magic.h +* `src/mygetopt.h` - replacement for OS's that don't have it. +* `src/magic.c` - the libmagic api +* `src/names.h` - header file for ascmagic.c +* `src/pread.c` - replacement for OS's that don't have it. +* `src/print.c` - print results, errors, warnings. +* `src/readcdf.c` - CDF wrapper. +* `src/readelf.[ch]` - Stand-alone elf parsing code. +* `src/softmagic.c` - 2nd set of tests, based on /etc/magic +* `src/mygetopt.h` - replacement for OS's that don't have it. +* `src/strcasestr.c` - replacement for OS's that don't have it. +* `src/strlcat.c` - replacement for OS's that don't have it. +* `src/strlcpy.c` - replacement for OS's that don't have it. +* `src/strndup.c` - replacement for OS's that don't have it. +* `src/tar.h` - tar file definitions +* `src/vasprintf.c` - for systems that don't have it. +* `doc/file.man` - man page for the command +* `doc/magic.man` - man page for the magic file, courtesy Guy Harris. + Install as magic.4 on USG and magic.5 on V7 or Berkeley; cf Makefile. + +Magdir - directory of /etc/magic pieces +------------------------------------------------------------------------------ + +If you submit a new magic entry please make sure you read the following +guidelines: + +- Initial match is preferably at least 32 bits long, and is a _unique_ match +- If this is not feasible, use additional check +- Match of <= 16 bits are not accepted +- Delay printing string as much as possible, don't print output too early +- Avoid printf arbitrary byte as string, which can be a source of + crash and buffer overflow + +- Provide complete information with entry: + * One line short summary + * Optional long description + * File extension, if applicable + * Full name and contact method (for discussion when entry has problem) + * Further reference, such as documentation of format + +gpg for dummies: +------------------------------------------------------------------------------ + +``` +$ gpg --verify file-X.YY.tar.gz.asc file-X.YY.tar.gz +gpg: assuming signed data in `file-X.YY.tar.gz' +gpg: Signature made WWW MMM DD HH:MM:SS YYYY ZZZ using DSA key ID KKKKKKKK +``` + +To download the key: + +``` +$ gpg --keyserver hkp://keys.gnupg.net --recv-keys KKKKKKKK +``` +------------------------------------------------------------------------------ + + +Parts of this software were developed at SoftQuad Inc., developers +of SGML/HTML/XML publishing software, in Toronto, Canada. +SoftQuad was swallowed up by Corel in 2002 and does not exist any longer. diff --git a/config.h.in b/config.h.in index ec46e2d8fb99..f058839efe68 100644 --- a/config.h.in +++ b/config.h.in @@ -18,6 +18,9 @@ /* Define to 1 if you have the `asprintf' function. */ #undef HAVE_ASPRINTF +/* Define to 1 if you have the <byteswap.h> header file. */ +#undef HAVE_BYTESWAP_H + /* Define to 1 if you have the <bzlib.h> header file. */ #undef HAVE_BZLIB_H @@ -128,12 +131,18 @@ /* Define to 1 if you have the `pipe2' function. */ #undef HAVE_PIPE2 +/* Define to 1 if you have the `posix_spawnp' function. */ +#undef HAVE_POSIX_SPAWNP + /* Define to 1 if you have the `pread' function. */ #undef HAVE_PREAD /* Have sig_t type */ #undef HAVE_SIG_T +/* Define to 1 if you have the <spawn.h> header file. */ +#undef HAVE_SPAWN_H + /* Define to 1 if you have the <stdint.h> header file. */ #undef HAVE_STDINT_H @@ -173,6 +182,12 @@ /* Define to 1 if `tm_zone' is a member of `struct tm'. */ #undef HAVE_STRUCT_TM_TM_ZONE +/* Define to 1 if you have the <sys/bswap.h> header file. */ +#undef HAVE_SYS_BSWAP_H + +/* Define to 1 if you have the <sys/ioctl.h> header file. */ +#undef HAVE_SYS_IOCTL_H + /* Define to 1 if you have the <sys/mman.h> header file. */ #undef HAVE_SYS_MMAN_H diff --git a/configure b/configure index d6a18d038f4a..0dd7b845a5fa 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for file 5.41. +# Generated by GNU Autoconf 2.69 for file 5.42. # # Report bugs to <christos@astron.com>. # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='file' PACKAGE_TARNAME='file' -PACKAGE_VERSION='5.41' -PACKAGE_STRING='file 5.41' +PACKAGE_VERSION='5.42' +PACKAGE_STRING='file 5.42' PACKAGE_BUGREPORT='christos@astron.com' PACKAGE_URL='' @@ -1334,7 +1334,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures file 5.41 to adapt to many kinds of systems. +\`configure' configures file 5.42 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1404,7 +1404,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of file 5.41:";; + short | recursive ) echo "Configuration of file 5.42:";; esac cat <<\_ACEOF @@ -1524,7 +1524,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -file configure 5.41 +file configure 5.42 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2180,7 +2180,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by file $as_me 5.41, which was +It was created by file $as_me 5.42, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3046,7 +3046,7 @@ fi # Define the identity of the package. PACKAGE='file' - VERSION='5.41' + VERSION='5.42' cat >>confdefs.h <<_ACEOF @@ -12900,7 +12900,7 @@ $as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h fi -for ac_header in stdint.h fcntl.h inttypes.h unistd.h +for ac_header in stdint.h fcntl.h inttypes.h unistd.h byteswap.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -12913,7 +12913,7 @@ fi done -for ac_header in utime.h wchar.h wctype.h +for ac_header in spawn.h utime.h wchar.h wctype.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -12939,7 +12939,7 @@ fi done -for ac_header in sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h sys/sysmacros.h +for ac_header in sys/bswap.h sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h sys/sysmacros.h sys/ioctl.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -14290,7 +14290,7 @@ fi fi -for ac_func in strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem pipe2 +for ac_func in strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem pipe2 posix_spawnp do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -15310,7 +15310,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by file $as_me 5.41, which was +This file was extended by file $as_me 5.42, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15376,7 +15376,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -file config.status 5.41 +file config.status 5.42 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index ccc57e13343d..ffbe0f694ece 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([file],[5.41],[christos@astron.com]) +AC_INIT([file],[5.42],[christos@astron.com]) AM_INIT_AUTOMAKE([subdir-objects foreign]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -99,10 +99,10 @@ gl_VISIBILITY dnl Checks for headers AC_HEADER_MAJOR AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(stdint.h fcntl.h inttypes.h unistd.h) -AC_CHECK_HEADERS(utime.h wchar.h wctype.h) +AC_CHECK_HEADERS(stdint.h fcntl.h inttypes.h unistd.h byteswap.h) +AC_CHECK_HEADERS(spawn.h utime.h wchar.h wctype.h) AC_CHECK_HEADERS(getopt.h err.h xlocale.h) -AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h sys/sysmacros.h) +AC_CHECK_HEADERS(sys/bswap.h sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h sys/sysmacros.h sys/ioctl.h) if test "$enable_zlib" != "no"; then AC_CHECK_HEADERS(zlib.h) fi @@ -165,7 +165,7 @@ else fi]) dnl Checks for functions -AC_CHECK_FUNCS(strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem pipe2) +AC_CHECK_FUNCS(strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem pipe2 posix_spawnp) dnl Provide implementation of some required functions if necessary AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf) diff --git a/magic/Magdir/animation b/magic/Magdir/animation index d59497d8005a..28a0f2d217aa 100644 --- a/magic/Magdir/animation +++ b/magic/Magdir/animation @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: animation,v 1.87 2021/08/24 09:25:11 christos Exp $ +# $File: animation,v 1.88 2022/05/14 22:06:04 christos Exp $ # animation: file(1) magic for animation/movie formats # # animation formats @@ -940,6 +940,7 @@ # DIF digital video file format <mpruett@sgi.com> 0 belong&0xffffff00 0x1f070000 DIF +!:mime video/x-dv >4 byte &0x01 (DVCPRO) movie file >4 byte ^0x01 (DV) movie file >3 byte &0x80 (PAL) diff --git a/magic/Magdir/archive b/magic/Magdir/archive index d4fd3c920d36..fb535ac0ff26 100644 --- a/magic/Magdir/archive +++ b/magic/Magdir/archive @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# $File: archive,v 1.151 2021/08/16 10:19:56 christos Exp $ +# $File: archive,v 1.162 2022/05/27 21:27:59 christos Exp $ # archive: file(1) magic for archive formats (see also "msdos" for self- # extracting compressed archives) # @@ -150,7 +150,7 @@ # Incremental snapshot gnu-tar format from: # https://www.gnu.org/software/tar/manual/html_node/Snapshot-Files.html 0 string GNU\ tar- GNU tar incremental snapshot data ->&0 regex [0-9]\.[0-9]+-[0-9]+ version %s +>&0 regex [0-9]\\.[0-9]+-[0-9]+ version %s # cpio archives # @@ -518,46 +518,65 @@ #>-3 ubyte x \b, last 3 bytes 0x%2.2x #>-2 ubeshort x \b%4.4x # From: Joerg Jenderek -# URL: https://wiki.68kmla.org/DiskCopy_4.2_format_specification +# URL: https://en.wikipedia.org/wiki/Disk_Copy # reference: http://nulib.com/library/FTN.e00005.htm 0x52 ubeshort 0x0100 # test for disk image size equal or above 400k >0x40 ubelong >409599 # test also for disk image size equal or below 1440k to skip # windows7en.mbr UNICODE.DAT ->>0x40 ubelong <1474561 -# To skip Flags$StringJoiner.class with size 00106A61h test also for only 4 disk image sizes -# 00064000 for 400k GCR disks -# 000c8000 for 800k GCR disks -# 000b4000 for 720k MFM disks -# 00168000 for 1440k MFM disks ->>>0x40 ubelong&0xffE03fFF 0 ->>>>0 use dc42-floppy +#>>0x40 ubelong <1474561 +# test now for "low" disk image size equal or below 64 MiB to skip +# windows7en.mbr (B441BBAAh) UNICODE.DAT (0400AF05h) +>>0x40 ubelong <0x04000001 +# To skip Flags$StringJoiner.class with size 00106A61h test also for valid disk image sizes +# 00064000 for 400k GCR disks dc42-400k-gcr.trid.xml +# 000c8000 for 800k GCR disks dc42-800k-gcr.trid.xml +# 000b4000 for 720k MFM disks dc42-720k-mfm.trid.xml +# 00168000 for 1440k MFM disks dc42-1440k-mfm.trid.xml +# https://lisaem.sunder.net/LisaProjectDocs.txt +# 00500000 05M available +# 00A00000 10M available +# 01800000 24M possible +# 02000000 32M uncertain +# 04000000 64M uncertain +>>>0x40 ubelong&0xf8003fFF 0 +# skip samples with invalid disk name length like: +# 181 (biosmd80.rom) 202 (Flags$StringJoiner.class) 90 (UNICODE.DAT) +>>>>0x0 ubyte <64 +>>>>>0 use dc42-floppy # display information of Apple DiskCopy 4.2 floppy image 0 name dc42-floppy -# image pascal name padded with NULs like Microsoft Mail +# disk name length; maximal 63 +#>0 ubyte x DISK NAME LENGTH %u +# ASCII image pascal (maximal 63 bytes) name padded with NULs like: +# "Microsoft Mail" "Disquette 2" "IIe Installer Disk" +# "-lisaem.sunder.net hd-" (dc42-lisaem.trid.xml) "-not a Macintosh disk" (dc42-nonmac.trid.xml) >00 pstring/B x Apple DiskCopy 4.2 image %s #!:mime application/octet-stream !:mime application/x-dc42-floppy-image !:apple dCpydImg -!:ext image/dc42 -# data size in bytes like 409600 +# probably also img like: "Utilitaires 2.img" "Installation 7.img" +!:ext image/dc42/img +# data size in bytes like: 409600 737280 819200 1474560 >0x40 ubelong x \b, %u bytes # for debugging purpose size in hexadecimal #>0x40 ubelong x (%#8.8x) -# tag size in bytes +# tag size in bytes like: 0 (often) 2580h (PUID fmt/625) 4B00h (Microsoft Mail.image) >0x44 ubelong >0 \b, %#x tag size # data checksum #>0x48 ubelong x \b, %#x checksum # tag checksum #>0x4c ubelong x \b, %#x tag checksum -# disk encoding +# disk encoding like: 0 1 2 3 (PUID: fmt/625) >0x50 ubyte 0 \b, GCR CLV ssdd (400k) >0x50 ubyte 1 \b, GCR CLV dsdd (800k) >0x50 ubyte 2 \b, MFM CAV dsdd (720k) >0x50 ubyte 3 \b, MFM CAV dshd (1440k) >0x50 ubyte >3 \b, %#x encoding -# format byte +# format byte like: 12h (Lisa 400K) 24h (400K Macintosh) 96h (800K Apple II disk) +# 2 (Mac 400k "Disquette Installation 13.image") +# 22h (double-sided MFM or Mac 800k "Disco 12.image" "IIe Installer Disk.image") >0x51 ubyte x \b, %#x format #>0x54 ubequad x \b, data %#16.16llx # ESP, could this conflict with Easy Software Products' (e.g.ESP ghostscript) documentation? @@ -670,7 +689,15 @@ # 2 bytes: length of data + mentioned bytes # # SZDD variant Haruhiko Okumura's LZSS or 7z type MsLZ +# URL: http://fileformats.archiveteam.org/wiki/MS-DOS_installation_compression +# Reference: http://www.cabextract.org.uk/libmspack/doc/szdd_kwaj_format.html +# http://mark0.net/download/triddefs_xml.7z/defs/s/szdd.trid.xml +# Note: called "Microsoft SZDD compressed (Haruhiko Okumura's LZSS)" by TrID +# verfied by 7-Zip `7z l -tMsLZ -slt *.??_` as MsLZ +# `deark -l -m lzss_oku -d2 setup-1-41.bin` as "LZSS.C by Haruhiko Okumura" >0 string SZDD MS Compress archive data, SZDD variant +# 2nd part of signature +#>>4 ubelong 0x88F02733 \b, SIGNATURE OK !:mime application/x-ms-compress-szdd !:ext ??_ # The character missing from the end of the filename (0=unknown) @@ -679,6 +706,24 @@ # Compression mode: "A" (0x41) found but sometimes "B" in Windows 3.1 builds 026 and 034e >>8 string !A \b, %-.1s method >>10 ulelong >0 \b, original size: %u bytes +# Summary: InstallShield archive with SZDD compressed +# URL: https://community.flexera.com/t5/InstallShield-Knowledge-Base/InstallShield-Redistributable-Files/ta-p/5647 +# From: Joerg Jenderek +1 search/48/bs SZDD\x88\xF0\x27\x33 InstallShield archive +#!:mime application/octet-stream +!:mime application/x-installshield-compress-szdd +!:ext ibt +# name of compressed archive member like: setup.dl_ _setup7int.dl_ _setup2k.dl_ _igdi.dl_ cabinet.dl_ +>0 string x %s +# name of uncompressed archive member like: setup.dll _Setup.dll IGdi.dll CABINET.DLL +>>&1 string x (%s) +# probably version like: 9.0.0.333 9.1.0.429 11.50.0.42618 +>>>&1 string x \b, version %s +# SZDD member length like: 168048 169333 181842 +>>>>&1 string x \b, %s bytes +# MS Compress archive data +#>&0 string SZDD \b, SIGNATURE FOUND +>&0 indirect x # QBasic SZDD variant 3 string \x88\xf0\x27 >0 string SZ\x20 MS Compress archive data, QBasic variant @@ -686,6 +731,17 @@ !:ext ??$ >>8 ulelong >0 \b, original size: %u bytes +# Summary: CAZIP compressed file +# From: Joerg Jenderek +# URL: http://fileformats.archiveteam.org/wiki/CAZIP +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/c/caz.trid.xml +# Note: Format is distinct from CAZIPXP compressed +0 string \x0D\x0A\x1ACAZIP CAZIP compressed file +#!:mime application/octet-stream +!:mime application/x-compress-cazip +# like: BLINKER.WR_ CLIPDEFS._ CAOSETUP.EX_ CLIPPER.EX_ FILEIO.C_ +!:ext ??_/?_/_ + # Summary: FTCOMP compressed archive # From: Joerg Jenderek # URL: http://fileformats.archiveteam.org/wiki/FTCOMP @@ -772,13 +828,43 @@ 0 string NSK NaShrink archive data # SAPCAR 0 string #\ CAR\ archive\ header SAPCAR archive data -0 string CAR\ 2.00RG SAPCAR archive data +0 string CAR\ 2.00 SAPCAR archive data +0 string CAR\ 2.01 SAPCAR archive data +#!:mime application/octet-stream +!:mime application/vnd.sar +!:ext sar # Disintegrator 0 string DST Disintegrator archive data # ASD 0 string ASD ASD archive data # InstallShield CAB -0 string ISc( InstallShield CAB +# Update: Joerg Jenderek at Nov 2021 +# URL: https://en.wikipedia.org/wiki/InstallShield +# Reference: https://github.com/twogood/unshield/blob/master/lib/cabfile.h +# Note: Not compatible with Microsoft CAB files +# http://mark0.net/download/triddefs_xml.7z/defs/a/ark-cab-ishield.trid.xml +# CAB_SIGNATURE 0x28635349 +0 string ISc( InstallShield +#!:mime application/octet-stream +!:mime application/x-installshield +# http://mark0.net/download/triddefs_xml.7z/defs/a/ark-cab-ishield-hdr.trid.xml +>16 ulelong !0 setup header +# like: _SYS1.HDR _USER1.HDR data1.hdr +!:ext hdr +>16 ulelong =0 CAB +# like: _SYS1.CAB _USER1.CAB DATA1.CAB data2.cab +!:ext cab +# https://github.com/twogood/unshield/blob/master/lib/helper.c +# version like: 0x1005201 0x100600c 0x1007000 0x1009500 +# 0x2000578 0x20005dc 0x2000640 0x40007d0 0x4000834 +>4 ulelong x \b, version %#x +# volume_info like: 0 +>8 ulelong !0 \b, volume_info %#x +# cab_descriptor_offset like: 0x200 +>12 ulelong !0x200 \b, offset %#x +#>0x200 ubequad x \b, at 0x200 %#16.16llx +# cab_descriptor_size like: 0 (*.cab) BD5 C8B DA5 E2A E36 116C 251D 4DA9 56F0 5CC2 6E4B 777D 779E 1F7C2 +>16 ulelong !0 \b, descriptor size %#x # TOP4 0 string T4\x1a TOP4 archive data # BatComp left out: sig looks like COM executable @@ -925,30 +1011,143 @@ >3 byte&0xf0 0x30 >>3 byte x (v%c) # JAR archiver (.j), this is the successor to ARJ, not Java's JAR (which is essentially ZIP) +# Update: Joerg Jenderek +# URL: http://fileformats.archiveteam.org/wiki/JAR_(ARJ_Software) +# reference: http://mark0.net/download/triddefs_xml.7z/defs/a/ark-jar.trid.xml +# https://www.sac.sk/download/pack/jar102x.exe/TECHNOTE.DOC +# Note: called "JAR compressed archive" by TrID 0xe string \x1aJar\x1b JAR (ARJ Software, Inc.) archive data +#!:mime application/octet-stream +!:mime application/x-compress-j +>0 ulelong x \b, CRC32 %#x +# standard suffix is ".j"; for multi volumes following order j01 j02 ... j99 100 ... 990 +!:ext j/j01/j02 +# URL: http://fileformats.archiveteam.org/wiki/JARCS +# reference: http://mark0.net/download/triddefs_xml.7z/defs/a/ark-jarcs.trid.xml +# Note: called "JARCS compressed archive" by TrID 0 string JARCS JAR (ARJ Software, Inc.) archive data +#!:mime application/octet-stream +!:mime application/x-compress-jar +!:ext jar # ARJ archiver (jason@jarthur.Claremont.EDU) -0 leshort 0xea60 ARJ archive data +# URL: http://fileformats.archiveteam.org/wiki/ARJ +# reference: http://mark0.net/download/triddefs_xml.7z/defs/a/ark-arj.trid.xml +# https://github.com/FarGroup/FarManager/ +# blob/master/plugins/multiarc/arc.doc/arj.txt +# Note: called "ARJ compressed archive" by TrID and +# "ARJ File Format" by DROID via PUID fmt/610 +# verified by `7z l -tarj PHRACK1.ARJ` and +# `arj.exe l TEST-hk9.ARJ` +0 leshort 0xea60 +# skip DROID fmt-610-signature-id-946.arj by check for valid file type of main header +>0xA ubyte 2 +>>0 use arj-archive +0 name arj-archive +>0 leshort x ARJ archive !:mime application/x-arj ->5 byte x \b, v%d, ->8 byte &0x04 multi-volume, ->8 byte &0x10 slash-switched, ->8 byte &0x20 backup, ->34 string x original name: %s, ->7 byte 0 os: MS-DOS ->7 byte 1 os: PRIMOS ->7 byte 2 os: Unix ->7 byte 3 os: Amiga ->7 byte 4 os: Macintosh ->7 byte 5 os: OS/2 ->7 byte 6 os: Apple ][ GS ->7 byte 7 os: Atari ST ->7 byte 8 os: NeXT ->7 byte 9 os: VAX/VMS ->3 byte >0 %d] +# look for terminating 0-character of filename +>0x26 search/1024 \0 +# file name extension is normally .arj but not for parts of multi volume +#>>&-5 string x extension %.4s +>>&-5 string/c .arj data +!:ext arj +>>&-5 default x +# for multi volume first name is archive.arj then following parts archive.a01 archive.a02 ... +>>>8 byte &0x04 data +!:ext a01/a02 +# for SFX first name is archive.exe then following parts archive.e01 archive.e02 ... +>>>8 byte ^0x04 data, SFX multi-volume +!:ext e01/e02 +# basic header size like: 0x002b 0x002c 0x04e0 0x04e3 0x04e7 +#>2 uleshort x basic header size %#4.4x +# next fragment content like: 0x0a200a003a8fc713 0x524a000010bb3471 0x524a0000c73c70f9 +#>(2.s) ubequad x NEXT FRAGMENT CONTENT %#16.16llx +# first_hdr_size; seems to be same as basic header size +#>2 uleshort x 1st header size %#x +# archiver version number like: 3 4 6 11 102 +>5 byte x \b, v%d +# minimum archiver version to extract like: 1 +>6 ubyte !1 \b, minimum %u to extract +# FOR DEBUGGING +#>8 byte x \b, FLAGS %#x +# GARBLED_FLAG1; garble with password; g switch +>8 byte &0x01 \b, password-protected +# encryption version: 0~old 1~old 2~new 3~reserved 4~40 bit key GOST +>>0x20 ubyte x (v%u) +#>8 byte &0x02 \b, secured +# ANSIPAGE_FLAG; indicates ANSI codepage used by ARJ32; hy switch +>8 byte &0x02 \b, ANSI codepage +# VOLUME_FLAG indicates presence of succeeding volume; but apparently not for SFX +>8 byte &0x04 \b, multi-volume +#>8 byte &0x08 \b, file-offset +# ARJPROT_FLAG; build with data protection record; hk switch +>8 byte &0x08 \b, recoverable +# arj protection factor; maximal 10; switch hky -> factor=y+1 +>>0x22 byte x (factor %u) +>8 byte &0x10 \b, slash-switched +# BACKUP_FLAG; obsolete +>8 byte &0x20 \b, backup +# SECURED_FLAG; +>8 byte &0x40 \b, secured, +# ALTNAME_FLAG; indicates dual-name archive +>8 byte &0x80 \b, dual-name +# security version; 0~old 2~current +>9 ubyte !0 +>>9 ubyte !2 \b, security version %u +# file type; 2 in main header; 0~binary 1~7-bitText 2~comment 3~directory 4~VolumeLabel 5=ChapterLabel +>0xA ubyte !2 \b, file type %u +# date+time when original archive was created in MS-DOS format via ./msdos +>0xC ulelong x \b, created +>0xC use dos-date +# or date and time by new internal function +#>0xE lemsdosdate x %s +#>0xC lemsdostime x %s +# FOR DEBUGGING +#>0x12 uleshort x RAW DATE %#4.4x +#>0x10 uleshort x RAW TIME %#4.4x +# date+time when archive was last modified; sometimes nil or +# maybe wrong like in HP4DRVR.ARJ +#>0x10 ulelong >0 \b, modified +#>>0x10 use dos-date +# or date and time by new internal function +#>>0x12 lemsdosdate x %s +#>>0x10 lemsdostime x %s +# archive size (currently used only for secured archives); MAYBE? +#>0x14 ulelong !0 \b, file size %u +# security envelope file position; MAYBE? +#>0x18 ulelong !0 \b, at %#x security envelope +# filespec position in filename; WHAT IS THAT? +#>0x1C uleshort >0 \b, filespec position %#x +# length in bytes of security envelope data like: 2CAh 301h 364h 471h +>0x1E uleshort !0 \b, security envelope length %#x +# last chapter like: 0 1 +>0x21 ubyte !0 \b, last chapter %u +# filename (null-terminated string); sometimes at 0x26 when 4 bytes for extra data +>34 byte x \b, original name: +# with extras data +>34 byte <0x0B +>>38 string x %s +# without extras data +>34 byte >0x0A +>>34 string x %s +# host OS: 0~MSDOS ... 11~WIN32 +>7 byte 0 \b, os: MS-DOS +>7 byte 1 \b, os: PRIMOS +>7 byte 2 \b, os: Unix +>7 byte 3 \b, os: Amiga +>7 byte 4 \b, os: Macintosh +>7 byte 5 \b, os: OS/2 +>7 byte 6 \b, os: Apple ][ GS +>7 byte 7 \b, os: Atari ST +>7 byte 8 \b, os: NeXT +>7 byte 9 \b, os: VAX/VMS +>7 byte 10 \b, os: WIN95 +>7 byte 11 \b, os: WIN32 # [JW] idarc says this is also possible 2 leshort 0xea60 ARJ archive data +#2 leshort 0xea60 +#>2 use arj-archive # HA archiver (Greg Roelofs, newt@uchicago.edu) # This is a really bad format. A file containing HAWAII will match this... @@ -1276,6 +1475,18 @@ !:mime application/vnd.sun.xml.base !:ext sdb +# URL: https://wiki.openoffice.org/wiki/Documentation/DevGuide/Extensions/File_Format +# From: Joerg Jenderek +# Note: only few OXT samples are detected here by mimetype member +# is used by OpenOffice and LibreOffice and probably also NeoOffice +# verified by `unzip -Zv *.oxt` or `7z l -slt *.oxt` +>>50 string vnd.openofficeorg. OpenOffice +>>>68 string extension \b/LibreOffice Extension +# http://extension.nirsoft.net/oxt +!:mime application/vnd.openofficeorg.extension +# like: Gallery-Puzzle.2.1.0.1.oxt +!:ext oxt + # OpenDocument formats (for OpenOffice 2.x / StarOffice >= 8) # URL: http://fileformats.archiveteam.org/wiki/OpenDocument # https://lists.oasis-open.org/archives/office/200505/msg00006.html @@ -1522,12 +1733,30 @@ !:mime application/x-bittorrent # Atari MSA archive - Teemu Hukkanen <tjhukkan@iki.fi> -0 beshort 0x0e0f Atari MSA archive data ->2 beshort x \b, %d sectors per track ->4 beshort 0 \b, 1 sided ->4 beshort 1 \b, 2 sided ->6 beshort x \b, starting track: %d ->8 beshort x \b, ending track: %d +# URL: http://fileformats.archiveteam.org/wiki/MSA_(Magic_Shadow_Archiver) +# Reference: http://info-coach.fr/atari/documents/_mydoc/FD_Image_File_Format.pdf +# http://mark0.net/download/triddefs_xml.7z/defs/m/msa.trid.xml +# Update: Joerg Jenderek +# Note: called by TrID "Atari MSA Disk Image" and verified by +# command like `deark -l -m msa -d2 PDATS578.msa` as " Atari ST floppy disk image" +# GRR: line below is too general as it matches setup.skin +0 beshort 0x0e0f +# skip foo setup.skin with unrealistic high number 52255 of sides by check for valid "low" value +>4 ubeshort <2 Atari MSA archive data +#!:mime application/octet-stream +!:mime application/x-atari-msa +!:ext msa +# sectors per track like: 9 10 +>>2 beshort x \b, %d sectors per track +# sides (0 or 1; add 1 to this to get correct number of sides) +>>4 beshort 0 \b, 1 sided +>>4 beshort 1 \b, 2 sided +# starting track like: 0 +>>6 beshort x \b, starting track: %d +# ending track like: 39 79 80 81 +>>8 beshort x \b, ending track: %d +# tracks content +#>>10 ubequad x \b, track content %#16.16llx # Alternate ZIP string (amc@arwen.cs.berkeley.edu) 0 string PK00PK\003\004 Zip archive data @@ -1537,6 +1766,8 @@ # ACE archive (from http://www.wotsit.org/download.asp?f=ace) # by Stefan `Sec` Zehl <sec@42.org> 7 string **ACE** ACE archive data +!:mime application/x-ace-compressed +!:ext ace >15 byte >0 version %d >16 byte =0x00 \b, from MS-DOS >16 byte =0x01 \b, from OS/2 diff --git a/magic/Magdir/aria b/magic/Magdir/aria new file mode 100644 index 000000000000..c3a6bf57e464 --- /dev/null +++ b/magic/Magdir/aria @@ -0,0 +1,38 @@ + +#------------------------------------------------------------------------------ +# URL: https://de.wikipedia.org/wiki/Aria_(Software) +# Reference: https://github.com/aria2/aria2/blob/master/doc/manual-src/en/technical-notes.rst +# From: Joerg Jenderek +# Note: only version 1 suited +# check for valid version one +0 beshort 0x0001 +# skip most uncompressed DEGAS med-res bitmap *.PI2 and GEM bitmap (v1) *.IMG +# by test for valid infoHashCheck extension +>2 ubelong&0xffFFffFE 0x00000000 +# skip DEGAS med-res bitmap DIAGRAM1.PI2 by test for valid length of download +>>(6.L+14) ubequad >0 +>>>0 use aria +0 name aria +# version; (0x0000) or (0x0001); for 0 all multi-byte are in host byte order. For 1 big endian +>0 beshort x aria2 control file, version %u +#!:mime application/octet-stream +!:mime application/x-aria +!:ext aria2 +# EXTension; if EXT[3]&1 == 1 checks whether saved InfoHash and current downloading the same; infoHashCheck extension +>2 ubelong !0 \b, infoHashCheck %#x +# info hash length like: 0 14h +>6 ubelong !0 \b, %#x bytes info hash +# info hash; BitTorrent InfoHash +>>10 ubequad x %#16.16llx... +# piece length; the length of the piece like: 400h 100000h +>(6.L+10) ubelong x \b, piece length 0x%x +# total length; the total length of the download +>(6.L+14) ubequad x \b, total length %llu +#>(6.L+14) ubequad x \b, total length %#llx +# upload length; the uploaded length of download like: 0 400h +>(6.L+22) ubequad !0 \b, upload length %#llx +# bitfield length; the length of bitfield like: 4 6 Ah 10h 13h 167h +>(6.L+30) ubelong x \b, %#x bytes bitfield +# bitfield; bitfield which represents current download progress +>(6.L+34) ubequad !0 %#llx... + diff --git a/magic/Magdir/asf b/magic/Magdir/asf index faae6a8aa9cf..9f274ede2ff8 100644 --- a/magic/Magdir/asf +++ b/magic/Magdir/asf @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: asf,v 1.2 2021/04/26 15:56:00 christos Exp $ +# $File: asf,v 1.3 2022/04/25 17:33:13 christos Exp $ # asf: file(1) magic for Microsoft Advanced Systems Format (ASF) files # http://www.staroceans.org/e-book/ASF_Specification.pdf @@ -88,7 +88,7 @@ >0 guid 26F18B5D-4584-47EC-9F5F-0E651F0452C9 ASF_Compatibility_Object >0 guid 43058533-6981-49E6-9B74-AD12CB86D58C ASF_Advanced_Content_Encryption_Object >0 guid 59DACFC0-59E6-11D0-A3AC-00A0C90348F6 ASF_Command_Media ->0 guid B61BE100-5B4E-11CF-A8FD-00805F5C44 ASF_JFIF_Media +>0 guid B61BE100-5B4E-11CF-A8FD-00805F5C442B ASF_JFIF_Media >0 guid 35907DE0-E415-11CF-A917-00805F5C442B ASF_Degradable_JPEG_Media >0 guid 91BD222C-F21C-497A-8B6D-5AA86BFC0185 ASF_File_Transfer_Media >0 guid 3AFB65E2-47EF-40F2-AC2C-70A90D71D343 ASF_Binary_Media diff --git a/magic/Magdir/bytecode b/magic/Magdir/bytecode index 501cd9d4415f..94fb8b38cb03 100644 --- a/magic/Magdir/bytecode +++ b/magic/Magdir/bytecode @@ -1,6 +1,6 @@ #------------------------------------------------------------ -# $File: bytecode,v 1.2 2021/06/30 11:57:32 christos Exp $ +# $File: bytecode,v 1.3 2022/03/24 15:48:58 christos Exp $ # magic for various bytecodes # From: Mikhail Gusarov <dottedmag@dottedmag.net> @@ -27,4 +27,4 @@ >8 string BE \b, big endian >11 string 4 \b, 32bit >11 string 8 \b, 64bit ->13 regex .\.. \b, bytecode v%s +>13 regex .\\.. \b, bytecode v%s diff --git a/magic/Magdir/c64 b/magic/Magdir/c64 index 52a4e22d99e9..9a635aedc978 100644 --- a/magic/Magdir/c64 +++ b/magic/Magdir/c64 @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: c64,v 1.9 2021/04/26 15:56:00 christos Exp $ +# $File: c64,v 1.12 2022/05/14 20:03:39 christos Exp $ # c64: file(1) magic for various commodore 64 related files # # From: Dirk Jagdmann <doj@cubic.org> @@ -8,9 +8,146 @@ 0x16500 belong 0x12014100 D64 Image 0x16500 belong 0x12014180 D71 Image 0x61800 belong 0x28034400 D81 Image -0 string C64\40CARTRIDGE CCS C64 Emultar Cartridge Image 0 belong 0x43154164 X64 Image +# C64 (and other CBM) cartridges +# Extended by David Korth <gerbilsoft@gerbilsoft.com> +# Reference: https://vice-emu.sourceforge.io/vice_17.html#SEC391 + +0 string C64\40CARTRIDGE Commodore 64 cartridge +>0x20 ubyte 0 \b, +>0x20 ubyte !0 +>>0x20 string/T x \b: "%.32s", +>0x16 beshort 0 +>>0x18 beshort 0x0000 16 KB game +>>0x18 beshort 0x0001 8 KB game +>>0x18 beshort 0x0100 UltiMax mode +>>0x18 beshort 0x0101 RAM/disabled +>0x16 beshort 1 Action Replay +>0x16 beshort 2 KCS Power Cartridge +>0x16 beshort 3 Final Cartridge III +>0x16 beshort 4 Simons' BASIC +>0x16 beshort 5 Ocean type 1 +>0x16 beshort 6 Expert Cartridge +>0x16 beshort 7 Fun Play, Power Play +>0x16 beshort 8 Super Games +>0x16 beshort 9 Atomic Power +>0x16 beshort 10 Epyx Fastload +>0x16 beshort 11 Westermann Learning +>0x16 beshort 12 Rex Utility +>0x16 beshort 13 Final Cartridge I +>0x16 beshort 14 Magic Formel +>0x16 beshort 15 C64 Game System, System 3 +>0x16 beshort 16 Warp Speed +>0x16 beshort 17 Dinamic +>0x16 beshort 18 Zaxxon / Super Zaxxon (Sega) +>0x16 beshort 19 Magic Desk, Domark, HES Australia +>0x16 beshort 20 Super Snapshot V5 +>0x16 beshort 21 Comal-80 +>0x16 beshort 22 Structured BASIC +>0x16 beshort 23 Ross +>0x16 beshort 24 Dela EP64 +>0x16 beshort 25 Dela EP7x8 +>0x16 beshort 26 Dela EP256 +>0x16 beshort 27 Rex EP256 +>0x16 beshort 28 Mikro Assembler +>0x16 beshort 29 Final Cartridge Plus +>0x16 beshort 30 Action Replay 4 +>0x16 beshort 31 Stardos +>0x16 beshort 32 EasyFlash +>0x16 beshort 33 EasyFlash Xbank +>0x16 beshort 34 Capture +>0x16 beshort 35 Action Replay 3 +>0x16 beshort 36 +>>0x1A ubyte 1 Nordic Replay +>>0x1A ubyte !1 Retro Replay +>0x16 beshort 37 MMC64 +>0x16 beshort 38 MMC Replay +>0x16 beshort 39 IDE64 +>0x16 beshort 40 Super Snapshot V4 +>0x16 beshort 41 IEEE-488 +>0x16 beshort 42 Game Killer +>0x16 beshort 43 Prophet64 +>0x16 beshort 44 EXOS +>0x16 beshort 45 Freeze Frame +>0x16 beshort 46 Freeze Machine +>0x16 beshort 47 Snapshot64 +>0x16 beshort 48 Super Explode V5.0 +>0x16 beshort 49 Magic Voice +>0x16 beshort 50 Action Replay 2 +>0x16 beshort 51 MACH 5 +>0x16 beshort 52 Diashow-Maker +>0x16 beshort 53 Pagefox +>0x16 beshort 54 Kingsoft +>0x16 beshort 55 Silverrock 128K Cartridge +>0x16 beshort 56 Formel 64 +>0x16 beshort 57 +>>0x1A ubyte 1 Hucky +>>0x1A ubyte !1 RGCD +>0x16 beshort 58 RR-Net MK3 +>0x16 beshort 59 EasyCalc +>0x16 beshort 60 GMod2 +>0x16 beshort 61 MAX Basic +>0x16 beshort 62 GMod3 +>0x16 beshort 63 ZIPP-CODE 48 +>0x16 beshort 64 Blackbox V8 +>0x16 beshort 65 Blackbox V3 +>0x16 beshort 66 Blackbox V4 +>0x16 beshort 67 REX RAM-Floppy +>0x16 beshort 68 BIS-Plus +>0x16 beshort 69 SD-BOX +>0x16 beshort 70 MultiMAX +>0x16 beshort 71 Blackbox V9 +>0x16 beshort 72 Lt. Kernal Host Adaptor +>0x16 beshort 73 RAMLink +>0x16 beshort 74 H.E.R.O. +>0x16 beshort 75 IEEE Flash! 64 +>0x16 beshort 76 Turtle Graphics II +>0x16 beshort 77 Freeze Frame MK2 + +0 string C128\40CARTRIDGE Commodore 128 cartridge +>0x20 ubyte 0 \b, +>0x20 ubyte !0 +>>0x20 string/T x \b: "%.32s", +>0x16 beshort 0 generic cartridge +>0x16 beshort 1 Warpspeed128 +>>0x1A ubyte 1 \b, REU support +>>0x1A ubyte 2 \b, REU support, with I/O and ROM banking + +0 string CBM2\40CARTRIDGE Commodore CBM-II cartridge +>0x20 ubyte !0 +>>0x20 string/T x \b: "%.32s" + +0 string VIC20\40CARTRIDGE Commodore VIC-20 cartridge +>0x20 ubyte 0 \b, +>0x20 ubyte !0 +>>0x20 string/T x \b: "%.32s", +>0x16 beshort 0 generic cartridge +>0x16 beshort 1 Mega-Cart +>0x16 beshort 2 Behr Bonz +>0x16 beshort 3 Vic Flash Plugin +>0x16 beshort 4 UltiMem +>0x16 beshort 5 Final Expansion + +0 string PLUS4\40CARTRIDGE Commodore 16/Plus4 cartridge +>0x20 ubyte !0 +>>0x20 string/T x \b: "%.32s" + + +# DreamLoad archives see: +# https://www.lemon64.com/forum/viewtopic.php?t=37415\ +# &sid=494dc2ca91289e05dadf80a7f8a968fe (at the bottom). +# https://www.c64-wiki.com/wiki/DreamLoad. +# Example HVSC Commodore 64 music collection: +# https://kohina.duckdns.org/HVSC/C64Music/10_Years_HVSC.dfi + +0 byte 0 +>1 string DREAMLOAD\40FILE\40ARCHIVE +>>0x17 byte 0 DFI Image +>>>0x1a leshort x version: %d. +>>>0x18 leshort x \b%d +>>>0x1c lelong x tracks: %d + 0 string GCR-1541 GCR Image >8 byte x version: %i >9 byte x tracks: %i diff --git a/magic/Magdir/cad b/magic/Magdir/cad index 530f72f31e95..46a35497c2f2 100644 --- a/magic/Magdir/cad +++ b/magic/Magdir/cad @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: cad,v 1.28 2021/04/26 15:56:00 christos Exp $ +# $File: cad,v 1.29 2021/12/06 19:33:27 christos Exp $ # autocad: file(1) magic for cad files # @@ -287,6 +287,8 @@ >6 leshort 0x2 >>8 lelong 0xa >>>16 leshort 0x3d3d 3D Studio model +# Beat sgi MMV +!:strength +20 !:mime image/x-3ds !:ext 3ds diff --git a/magic/Magdir/ccf b/magic/Magdir/ccf new file mode 100644 index 000000000000..1d5ba19e00e2 --- /dev/null +++ b/magic/Magdir/ccf @@ -0,0 +1,14 @@ + +#------------------------------------------------------------------------------ +# $File: ccf,v 1.1 2022/02/15 12:57:45 christos Exp $ +# file(1) magic(5) data for Phillips remote controls + +# Exchange format for Philips Pronto universal infrared remote controls +# A CCF file describes a learned/customized remote control, +# i.e. it contains button UI and infrared pulse code definitions +# (Georg Sauthoff) +# http://files.remotecentral.com/download/45/pan-air-csakr.zip.html +# https://github.com/gsauthof/pronto-ccf/blob/ + +8 string @\xa5Z@_CCF +>32 string CCF\x00 Philips Pronto IR remote control CCF diff --git a/magic/Magdir/commands b/magic/Magdir/commands index 705a72861ac0..a257eb2b7a13 100644 --- a/magic/Magdir/commands +++ b/magic/Magdir/commands @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: commands,v 1.66 2021/07/03 13:50:29 christos Exp $ +# $File: commands,v 1.69 2022/04/20 21:14:23 christos Exp $ # commands: file(1) magic for various shells and interpreters # #0 string/w : shell archive or script for antique kernel text @@ -35,7 +35,7 @@ !:mime text/x-shellscript 0 string/fwt #!\ /usr/local/bin/zsh Paul Falstad's zsh script text executable !:mime text/x-shellscript -0 search/1 #!/usr/bin/env\ zsh Paul Falstad's zsh script text executable +0 string/fwt #!\ /usr/bin/env\ zsh Paul Falstad's zsh script text executable !:mime text/x-shellscript 0 string/fwt #!\ /bin/ash Neil Brown's ash script text executable @@ -98,7 +98,7 @@ !:mime text/x-shellscript 0 string/wt #!\ a ->&-1 string x %s script text executable +>&-1 string/T x %s script text executable 0 search/1/fwt #!\ /usr/bin/tclsh Tcl/Tk script text executable !:mime text/x-tcl @@ -153,6 +153,32 @@ 0 string Zend\x00 PHP script Zend Optimizer data +# From: Anatol Belski <ab@php.net> +0 string OPCACHE +>7 ubyte 0 PHP opcache filecache data + +0 search/64 --TEST-- +>16 search/64 --FILE-- +>24 search/8192 --EXPECT PHP core test +!:ext phpt + +# https://www.php.net/manual/en/phar.fileformat.signature.php +-4 string GBMB PHP phar archive +>-8 ubyte 0x1 with MD5 signature +!:ext phar +>-8 ubyte 0x2 with SHA1 signature +!:ext phar +>-8 ubyte 0x3 with SHA256 signature +!:ext phar +>-8 ubyte 0x4 with SHA512 signature +!:ext phar +>-8 ubyte 0x10 with OpenSSL signature +!:ext phar +>-8 ubyte 0x11 with OpenSSL SHA256 signature +!:ext phar +>-8 ubyte 0x12 with OpenSSL SHA512 signature +!:ext phar + 0 string/t $! DCL command file # Type: Pdmenu diff --git a/magic/Magdir/console b/magic/Magdir/console index d31932d5834c..367aeec36004 100644 --- a/magic/Magdir/console +++ b/magic/Magdir/console @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: console,v 1.63 2021/04/26 15:56:00 christos Exp $ +# $File: console,v 1.68 2022/05/14 20:04:43 christos Exp $ # Console game magic # Toby Deshane <hac@shoelace.digivill.net> @@ -78,8 +78,8 @@ >23 byte !1 FMC- >23 byte 1 FSC- >16 string x \b%.3s ->15 byte x \b, mfr %02X ->20 byte x (Rev.%02u) +>15 ubyte x \b, mfr %02X +>20 ubyte x (Rev.%02u) # Headered version. 0 string FDS\x1A @@ -228,21 +228,56 @@ >0x10 use sega-mega-drive-header >0 byte x \b, 2352-byte sectors -# Sega Mega Drive, 32X, Pico, and Mega CD Boot ROM images. +# Sega Mega Drive: Identify the system ID. 0x100 string SEGA ->0x3C0 bequad 0x4D41525320434845 Sega 32X ROM image +>0x3C0 string MARS\ CHECK\ MODE Sega 32X ROM image !:mime application/x-genesis-32x-rom >>0 use sega-mega-drive-header ->0x3C0 bequad !0x4D41525320434845 ->>0x105 belong 0x5049434F Sega Pico ROM image +>0x104 string \ PICO Sega Pico ROM image !:mime application/x-sega-pico-rom ->>>0 use sega-mega-drive-header ->>0x105 belong !0x5049434F ->>>0x180 beshort 0x4252 Sega Mega CD Boot ROM image +>>0 use sega-mega-drive-header +>0x104 string TOYS\ PICO Sega Pico ROM image +!:mime application/x-sega-pico-rom +>>0 use sega-mega-drive-header +>0x104 string \ TOYS\ PICO Sega Pico ROM image +!:mime application/x-sega-pico-rom +>>0 use sega-mega-drive-header +>0x104 string \ IAC Sega Pico ROM image +!:mime application/x-sega-pico-rom +>>0 use sega-mega-drive-header +>0x104 string \ TERA68K Sega Teradrive (68K) ROM image +!:mime application/x-sega-teradrive-rom +>>0 use sega-mega-drive-header +>0x104 string \ TERA286 Sega Teradrive (286) ROM image +!:mime application/x-sega-teradrive-rom +>>0 use sega-mega-drive-header +>0x180 string BR Sega Mega CD Boot ROM image !:mime application/x-genesis-rom ->>>0x180 beshort !0x4252 Sega Mega Drive / Genesis ROM image +>>0 use sega-mega-drive-header +>0x104 default x Sega Mega Drive / Genesis ROM image !:mime application/x-genesis-rom ->>>0 use sega-mega-drive-header +>>0 use sega-mega-drive-header + +# Sega Mega Drive: Some ROMs have "SEGA" at 0x101, not 0x100. +0x100 string \ SEGA Sega Mega Drive / Genesis ROM image +>0 use sega-mega-drive-header + +# Sega Pico ROMs that don't start with "SEGA". +0x100 string SAMSUNG\ PICO Samsung Pico ROM image +!:mime application/x-sega-pico-rom +>0 use sega-mega-drive-header +0x100 string IMA\ IKUNOUJYUKU Samsung Pico ROM image +!:mime application/x-sega-pico-rom +>0 use sega-mega-drive-header +0x100 string IMA IKUNOJYUKU Samsung Pico ROM image +!:mime application/x-sega-pico-rom +>0 use sega-mega-drive-header + +# Sega Picture Magic (modified 32X) +0x100 string Picture\ Magic +>0x3C0 string PICTURE MAGIC-01 Sega 32X ROM image +!:mime application/x-genesis-32x-rom +>>0 use sega-mega-drive-header #------------------------------------------------------------------------------ # genesis: file(1) magic for the Super MegaDrive ROM dump format @@ -474,12 +509,13 @@ # - https://neogpc.googlecode.com/svn-history/r10/trunk/src/core/neogpc.cpp # - https://www.devrs.com/ngp/files/ngpctech.txt # -0x0A string BY\ SNK\ CORPORATION Neo Geo Pocket +0x0A string BY\ SNK\ CORPORATION Neo Geo Pocket !:mime application/x-neo-geo-pocket-rom ->0x23 byte 0x10 Color ->0 byte x ROM image ->0x24 string >\0 \b: "%.12s" ->0x1F byte 0xFF (debug mode enabled) +>0x23 byte 0x10 Color +>0 byte x ROM image +>0x24 string >\0 \b: "%.12s" +>0x21 uleshort x \b, NEOP%04X +>0x1F ubyte 0xFF (debug mode enabled) #------------------------------------------------------------------------------ # msx: file(1) magic for MSX game cartridge dumps @@ -639,17 +675,21 @@ >>0 use xbox-360-package # Atari Lynx cartridge dump (EXE/BLL header) -# From: "Stefan A. Haubenthal" <polluks@web.de> - +# From: "Stefan A. Haubenthal" <polluks@sdf.lonestar.org> +# Reference: +# https://raw.githubusercontent.com/cc65/cc65/master/libsrc/lynx/exehdr.s # Double-check that the image type matches too, 0x8008 conflicts with # 8 character OMF-86 object file headers. 0 beshort 0x8008 >6 string BS93 Lynx homebrew cartridge !:mime application/x-atari-lynx-rom >>2 beshort x \b, RAM start $%04x ->6 string LYNX Lynx cartridge +0 string LYNX Lynx cartridge !:mime application/x-atari-lynx-rom ->>2 beshort x \b, RAM start $%04x +>4 leshort/4 >0 \b, bank 0 %dk +>6 leshort/4 >0 \b, bank 1 %dk +>10 string >\0 \b, "%.32s" +>42 string >\0 \b, "%.16s" # Opera file system that is used on the 3DO console # From: Serge van den Boom <svdb@stack.nl> @@ -898,6 +938,16 @@ !:mime application/x-gamecube-rom >>>>0x8000 use nintendo-gcn-disc-common +# Type: Nintendo GameCube/Wii disc image (RVZ format) +0 string RVZ\001 Nintendo +>0x48 belong 1 GameCube +!:mime application/x-gamecube-rom +>0x48 belong 2 Wii +!:mime application/x-wii-rom +>0x48 default x GameCube/Wii +>0x48 belong x disc image (RVZ format): +>>0x58 use nintendo-gcn-disc-common + #------------------------------------------------------------------------------ # Nintendo 3DS file formats. # @@ -1126,14 +1176,3 @@ >>0x34 ubyte 1 [FastROM] >>0x35 ubyte 1 [SRAM] >>0x35 ubyte 3 [Special] - -# Type: Nintendo GameCube/Wii disc image (RVZ format) -0 string RVZ\001 Nintendo ->0x48 belong 1 GameCube -!:mime application/x-gamecube-rom ->0x48 belong 2 Wii -!:mime application/x-wii-rom ->0x48 default x GameCube/Wii ->0x48 belong x disc image (RVZ format): ->>0x58 use nintendo-gcn-disc-common - diff --git a/magic/Magdir/ctf b/magic/Magdir/ctf index ebea8f316961..d91684d18c40 100644 --- a/magic/Magdir/ctf +++ b/magic/Magdir/ctf @@ -20,4 +20,4 @@ # CTF metadata (plain text) 0 string /*\x20CTF\x20 Common Trace Format (CTF) plain text metadata !:strength + 5 # this is to make sure we beat C ->&0 regex [0-9]+\.[0-9]+ \b, v%s +>&0 regex [0-9]+\\.[0-9]+ \b, v%s diff --git a/magic/Magdir/database b/magic/Magdir/database index 7f93f8e2da96..ee4b1cb98f9d 100644 --- a/magic/Magdir/database +++ b/magic/Magdir/database @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: database,v 1.63 2021/10/04 00:44:30 christos Exp $ +# $File: database,v 1.66 2022/02/26 17:42:21 christos Exp $ # database: file(1) magic for various databases # # extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk) @@ -151,6 +151,7 @@ # https://www.clicketyclick.dk/databases/xbase/format/dbf.html # inspect VVYYMMDD , where 1<= MM <= 12 and 1<= DD <= 31 0 ubelong&0x0000FFFF <0x00000C20 +!:strength +10 # skip Infocom game Z-machine >2 ubyte >0 # skip Androids *.xml @@ -399,7 +400,9 @@ >>>>>>>>>>4 ushort 0 # check for valid FoxPro field type >>>>>>>>>>>512 ubelong <3 ->>>>>>>>>>>>0 use foxpro-memo-print +# skip LXMDCLN4.OUT LXMDCLN6.OUT LXMDALG6.OUT with invalid blocksize 170=AAh +>>>>>>>>>>>>6 ubeshort&0x002f 0 +>>>>>>>>>>>>>0 use foxpro-memo-print # dBASE III DBT , garbage # skip WORD1XW.DOC with improbably high free block index >>>>>>>>>0 ulelong <0x400000 @@ -415,9 +418,11 @@ >>>>>>>>>>0 ulelong <0x400000 # skip AI070GEP.EPS by printable 1st character of 1st memo item >>>>>>>>>>>512 ubyte >037 +# skip some Microsoft Visual C, OMF library like: BZ2.LIB WATTCPWL.LIB ZLIB.LIB +>>>>>>>>>>>>512 ubyte <0200 # skip gluon-ffhat-1.0-tp-link-tl-wr1043n-nd-v2-sysupgrade.bin by printable 2nd character ->>>>>>>>>>>>513 ubyte >037 ->>>>>>>>>>>>>0 use dbase3-memo-print +>>>>>>>>>>>>>513 ubyte >037 +>>>>>>>>>>>>>>0 use dbase3-memo-print # dBASE IV DBT with positive block size >>>>>>>20 uleshort >0 # dBASE IV DBT with valid block length like 512, 1024 @@ -440,7 +445,10 @@ #>20 uleshort =0 \b, block length %u >20 uleshort !0 \b, block length %u # dBase III memo field terminated by \032\032 +# like: "WHAT IS XBASE" test.dbt "Borges, Malte" biblio.dbt "First memo\032\032" T2.DBT >512 string >\0 \b, 1st item "%s" +# For DEBUGGING +#>512 ubelong x \b, 1ST item %#8.8x # https://www.clicketyclick.dk/databases/xbase/format/dbt.html # Print the information of dBase IV DBT memo file 0 name dbase4-memo-print @@ -486,7 +494,7 @@ >0 belong x FoxPro FPT !:mime application/x-fpt !:ext fpt -# Size of blocks for FoxPro ( 64,256 ) +# Size of blocks for FoxPro ( 64,256 ); probably a multiple of two >6 ubeshort x \b, blocks size %u # next available block #>0 belong =0 \b, next free block index %u diff --git a/magic/Magdir/dataone b/magic/Magdir/dataone index 8ef3f798163f..566633eff22c 100644 --- a/magic/Magdir/dataone +++ b/magic/Magdir/dataone @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: dataone,v 1.2 2019/04/19 00:42:27 christos Exp $ +# $File: dataone,v 1.3 2022/04/18 21:38:10 christos Exp $ # # DataONE- files from Dave Vieglais <dave.vieglais@gmail.com> & # Pratik Shrivastava <pratikshrivastava23@gmail.com> @@ -9,39 +9,39 @@ #------------------------------------------------------------------------------ # EML (Ecological Metadata Language Format) -0 string <?xml ->&0 regex (eml)-[0-9].[0-9].[0-9]+ eml://ecoinformatics.org/%s +0 string \<?xml\ version= +>&0 regex/1024 eml-[0-9]\\.[0-9]\\.[0-9]+ eml://ecoinformatics.org/%s # onedcx (DataONE Dublin Core Extended v1.0) ->&0 regex (onedcx/v)[0-9].[0-9]+ https://ns.dataone.org/metadata/schema/onedcx/v1.0 +>&0 regex/1024 onedcx/v[0-9]\\.[0-9]+ https://ns.dataone.org/metadata/schema/onedcx/v1.0 # FGDC-STD-001-1998 (Content Standard for Digital Geospatial Metadata, # version 001-1998) ->&0 regex fgdc FGDC-STD-001-1998 +>&0 search/1024 fgdc FGDC-STD-001-1998 # Mercury (Oak Ridge National Lab Mercury Metadata version 1.0) ->&0 regex (mercury/terms/v)[0-9].[0-9] https://purl.org/ornl/schema/mercury/terms/v1.0 +>&0 regex/1024 mercury/terms/v[0-9]\\.[0-9] https://purl.org/ornl/schema/mercury/terms/v1.0 # ISOTC211 (Geographic MetaData (GMD) Extensible Markup Language) ->&0 regex isotc211 ->>&0 regex eng;USA https://www.isotc211.org/2005/gmd +>&0 search/1024 isotc211 +>>&0 search/1024 eng;USA https://www.isotc211.org/2005/gmd # ISOTC211 (NOAA Variant Geographic MetaData (GMD) Extensible Markup Language) ->>&0 regex gov.noaa.nodc:[0-9]+ https://www.isotc211.org/2005/gmd-noaa +>>&0 regex/1024 gov\\.noaa\\.nodc:[0-9]+ https://www.isotc211.org/2005/gmd-noaa # ISOTC211 PANGAEA Variant Geographic MetaData (GMD) Extensible Markup Language ->>&0 regex pangaea.dataset[0-9][0-9][0-9][0-9][0-9][0-9]+ https://www.isotc211.org/2005/gmd-pangaea +>>&0 regex/1024 pangaea\\.dataset[0-9][0-9][0-9][0-9][0-9][0-9]+ https://www.isotc211.org/2005/gmd-pangaea !:mime text/xml # Object Reuse and Exchange Vocabulary -0 string <?xml ->&0 regex rdf ->>&0 regex openarchives https://www.openarchives.org/ore/terms +0 string \<?xml\ version= +>&0 search/1024 rdf +>>&0 search/1024 openarchives https://www.openarchives.org/ore/terms !:mime application/rdf+xml # Dryad Metadata Application Profile Version 3.1 0 string <DryadData ->&0 regex (dryad-bibo/v)[0-9].[0-9] https://datadryad.org/profile/v3.1 +>&0 regex/1024 dryad-bibo/v[0-9]\\.[0-9] https://datadryad.org/profile/v3.1 !:mime text/xml diff --git a/magic/Magdir/dsf b/magic/Magdir/dsf new file mode 100644 index 000000000000..e6c4b6e3e059 --- /dev/null +++ b/magic/Magdir/dsf @@ -0,0 +1,25 @@ + +#------------------------------------------------------------ +# $File: dsf,v 1.1 2022/01/08 16:29:18 christos Exp $ +# dsf: file(1) magic for DSD Stream File +# URL: https://en.wikipedia.org/wiki/Direct_Stream_Digital +# Reference: https://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf +0 string DSD\x20 DSD Stream File, +>0x30 leshort 1 mono, +>0x30 leshort 2 stereo, +>0x30 leshort 3 three-channel, +>0x30 leshort 4 quad-channel, +>0x30 leshort 5 3.1 4-channel, +>0x30 leshort 6 five-channel, +>0x30 leshort 7 5.1 surround, +>0x30 default x +>>0x30 leshort x unknown channel format (%d), +>0x38 lelong 2822400 simple-rate, +>0x38 lelong 5644800 double-rate, +>0x38 default x +>>0x38 lelong x %d Hz, +>0x3c leshort 1 1 bit, +>0x3c leshort 8 8 bit, +>0x3c default x +>>0x3c leshort x %d bit, +>0x40 lelong x %d samples diff --git a/magic/Magdir/filesystems b/magic/Magdir/filesystems index 283f9c4ac9b6..dee053b0a812 100644 --- a/magic/Magdir/filesystems +++ b/magic/Magdir/filesystems @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# $File: filesystems,v 1.145 2021/09/07 18:57:50 christos Exp $ +# $File: filesystems,v 1.149 2022/05/21 22:50:28 christos Exp $ # filesystems: file(1) magic for different filesystems # 0 name partid @@ -2317,6 +2317,8 @@ >0x10070 lequad x \b%lld bytes used, >0x10088 lequad x %lld devices +0 string btrfs-stream BTRFS stream file + # dvdisaster's .ecc # From: "Nelson A. de Oliveira" <naoliv@gmail.com> 0 string *dvdisaster* dvdisaster error correction file @@ -2399,12 +2401,167 @@ 0 string ACT\020Apricot\020disk\020image\032\004 floppy image data (ApriDisk) -0 beshort 0xAA58 floppy image data (IBM SaveDskF, old) -0 beshort 0xAA59 floppy image data (IBM SaveDskF) -0 beshort 0xAA5A floppy image data (IBM SaveDskF, compressed) +# URL: http://fileformats.archiveteam.org/wiki/LoadDskF/SaveDskF +# Update: Joerg Jenderek +# Note: called "IBM SKF disk image" by TrID +# verfied by 7-Zip `7z l -tFAT -slt *.dsk` and +# `deark -l -m loaddskf 06200D19.DSK` +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/d/dsk-skf-old.trid.xml +0 beshort 0xAA58 +>0 use SaveDskF +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/d/dsk-skf.trid.xml +0 beshort 0xAA59 +>0 use SaveDskF +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/d/dsk-skf-comp.trid.xml +0 beshort 0xAA5A +# skip foo by additional check for unused upper byte of media type in SaveDskF header +#>3 ubyte =0 +# skip bar by additional check for valid "low" number of heads in SaveDskF header +#>>26 uleshort <3 +# skip foo by additional check for unused double word field in SaveDskF header +#>>>30 long =0 +#>>>>0 use SaveDskF +>0 use SaveDskF +# display information about IBM SaveDskF floppy disk images +0 name SaveDskF +# SaveDskF magic +>0 beshort x floppy image data (IBM SaveDskF +#!:mime application/octet-stream +!:mime application/x-ibm-dsk +!:ext dsk +# also suffix with digit (1dk .2dk ...); NO example FOUND! +#!:ext dsk/1dk/2dk +>1 ubyte =0x58 \b, old) +>1 ubyte =0x59 \b) +>1 ubyte =0x5A \b, compressed) +# media type; the first byte of the FAT like: 0xF0 (usual floppy) 0xF9 0xFE +# https://en.wikipedia.org/wiki/Design_of_the_FAT_file_system +>2 ubyte !0xF0 \b, Media descriptor %#x +# upper byte of media type is not used; so this seems to be nil +>3 ubyte !0 \b, upper byte of media type %#x +# sector size in bytes as in the BIOS parameter block like: 512 ; SAVEDSKF.EXE with other sizes produce garbage images +>4 uleshort !512 \b, Bytes/sector %u +# cluster mask; number of sectors per cluster, minus 1 +>6 uleshort+1 >1 \b, sectors/cluster %u +#>6 uleshort+1 x \b, sectors/cluster %u +# cluster shift; log2(cluster size / sector size) like: 0~1=ClusterSize/SectorSize +>7 ubyte >0 \b, cluster shift %u +#>7 ubyte x \b, cluster shift %u +# reserved sectors; as in the BIOS parameter block like: 1 256 (2M256R-K.DSK) +>8 uleshort >1 \b, reserved sectors %u +#>8 uleshort x \b, reserved sectors %u +# FAT copies; as in the BIOS parameter block like: 2 (usual) 1 (2-NK.DSK) +>10 ubyte !2 \b, FAT +# plural s +>>10 ubyte >1 \bs +>>10 ubyte x %u +# root directory entries; as in the BIOS parameter block like: 224 (usual) 64 (H1-NK.DSK) 4096 (2-NK.DSK) +>11 uleshort !224 \b, root entries %u +# sector number of first cluster (count sectors used by boot sector, FATs and root directory) like: 7 10 29 33 288 +>13 uleshort !33 \b, 1st cluster at sector %u +# number of clusters in image; empty clusters at the end are not saved and counted like: 2372 2848 +>15 uleshort x \b, %u clusters +# sectors/FAT; as in the BIOS parameter block like: 1 (H1-NK.DSK) 7 9 +>17 ubyte !9 \b, sectors/FAT %u +# sector number of root directory (ie, count of sectors used by boot sector and FATs) like: 3 (H1-NK.DSK) 9 10 15 19 274 (2M256R-K.DSK) +>18 uleshort !19 \b, root directory at sector %u +# checksum; sum of all bytes in the file +>20 ulelong x \b, checksum %#8.8x +# cylinders; number of cylinders like: 40 80 +>24 uleshort !80 \b, %u cylinders +#>24 uleshort x \b, %u cylinders +# heads; number of heads as in the BIOS parameter block like: 1 (H1-NK.DSK) 2 +>26 uleshort !2 \b, heads %u +#>26 uleshort x \b, heads %u +# sectors/track; number of sectors per track as in the BIOS parameter block like: 8 15 18 36 +>28 uleshort !18 \b, sectors/track %u +#>28 uleshort x \b, sectors/track %u +# unused double word field seems to be always like: 0 +>30 ulelong !0 \b, at 0x1E %#x +# number of sectors in images like: 1017 2786 2880 +>34 uleshort x \b, sectors %u +# if string is "printable" it can be a real comment +>(36.s) ubyte !0x00 +# if 1st sector is far enough away (> 0x29) then there is space for comment part +>>38 uleshort >41 +# offset to comment string like: 28h=40 +>>>36 uleshort x \b, at %#x +# comment string terminated with \r\n\0 +>>>(36.s) string x "%s" +# offset to the first sector like: 0 (If this is 0, assume it is 0x200) 29h=41 (DISPLAY3.DSK) 31h 43h 45h 46h 48h 50h 200h=512 +>38 uleshort !0 \b, 1st sector at %#x +# FOR DEBUGGING! +#>(38.s) ubelong x SECTOR CONTENT %x +# not compressed floppy image implies readable DOS boot sector inside image +>>1 ubyte !0x5A +# when not compressed it is readable as DOS boot sector via ./filesystems +#>>>(38.s) indirect x \b; contains +>38 uleshort =0 \b, 1st sector at 0x200 (0) +# maybe standard DOS boot sector; NO example FOUND HERE! +#>>0x200 indirect x \b; contains 0 string \074CPM_Disk\076 disk image data (YAZE) +# From: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/Central_Point_Software#cite_note-6 +# Reference: https://www.robcraig.com/download/transcopy-5-x-file-format +# https://www.robcraig.com/download/transcopy-file-format-by-gene-thompson +# http://mark0.net/download/triddefs_xml.7z/defs/t/tc-transcopy.trid.xml +# TransCopy signature +0 beshort 0x5AA5 +# skip Intel serial flash ROM with invalid 0 disk sides handled by ./intel +>0x103 ubyte !0 +# skip Intel serial flash ROM with unlikely "high" start cylinder 100 handled by ./intel +#>>0x101 ubyte <100 VALID_START_CYLINDER +# skip Intel serial flash ROM with unlikely description handled by ./intel +#>>>2 beshort !0xF00f VALID_DESCRIPTION +# skip Intel serial flash ROM with invalid disk types 89h 88h handled by ./intel +#>>>>0x100 byte !0x89 VALID_DISK_TYPE +>>0 use tc-floppy +# display information of Central Point Software (CPS) Option Board TransCopy floppy image +0 name tc-floppy +>0 beshort x TransCopy disk image +#!:mime application/octet-stream +!:mime application/x-floppy-image-tc +# like: disk04.tc VOCALC2.TC WIZ5_A.tc WIZ2_720.IMG +!:ext tc/img +# 1st description (optional 0-terminated maximal 32) like: +# "Project Workbench 2.20" "Visi On Calc" "Wizardry V Disk 1 of 3" +>2 string >\0 %.32s +# 2nd desc. (optional 0-terminated maximal 32) like: +# "(1988)." "Advanced - Utility" 'Program Disk 2" +>0x22 string >\0 "%.32s" +# Looks like ascii (like MESSAGES) formatted with attribute bytes (190)? +# not needed for disk copy +#>>0x42 string x '%.190s' +#>>0x88 lestring16 x "%.8s" +# disktype: 2~MFM High Density 3~MFM Double Density 4~Apple II GCR 5~FM Single Density +# 6~Commodore GCR 7~MFM Double Density 8~Commodore Amiga Ch~Atari FM FFh~Unknown +>0x100 ubyte !0xFF \b, disk type %u +# StartingCylinder like: 0 +>0x101 ubyte x \b, cylinder +>0x101 ubyte !0 start=%u +# EndingCylinder like: 40 (often) 41 79 +>0x102 ubyte x end=%u +# NumberOfSides like: 2 +>0x103 ubyte !2 \b, %u sides +# TrackIncrement like: 1 +>0x104 ubyte !1 \b, track increment %u +# TrackPosTbl Track skew +#>0x105 ubequad x \b, Track skew %#16.16llx +# TrackOffsTbl +#>0x305 ubequad x \b, TrackOffsTbl %#16.16llx +# TrackLngthTbl +#>0x505 ubequad x \b, TrackLngthTbl %#16.16llx +# TrackTypeTable +#>0x705 ubequad x \b, TrackTypeTable %#16.16llx +# Address mark timing +#>0x905 ubequad x \b, Address mark timing %#16.16llx +# Track fragment +#>0x2905 ubequad !0 \b, Track fragment %#16.16llx +# Track data +#>0x4000 ubequad !0 \b, Track data %#16.16llx + # ReFS # Richard W.M. Jones <rjones@redhat.com> 0 string \0\0\0ReFS\0 ReFS filesystem image diff --git a/magic/Magdir/fonts b/magic/Magdir/fonts index c53822271e05..de3e5354c785 100644 --- a/magic/Magdir/fonts +++ b/magic/Magdir/fonts @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: fonts,v 1.46 2021/04/26 15:56:00 christos Exp $ +# $File: fonts,v 1.50 2022/03/21 21:28:13 christos Exp $ # fonts: file(1) magic for font data # 0 search/1 FONT ASCII vfont text @@ -8,13 +8,56 @@ 0 short 017001 byte-swapped Berkeley vfont data # PostScript fonts (must precede "printer" entries), quinlan@yggdrasil.com +# Modified by: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/PostScript_fonts +# http://fileformats.archiveteam.org/wiki/Adobe_Type_1 +# Reference: http://mark0.net/download/triddefs_xml.7z +# defs/p/pfb.trid.xml +# Note: PFB stands for Printer Font Binary 0 string %!PS-AdobeFont-1. PostScript Type 1 font text +#!:mime font/x-postscript-pfb +#!:ext pfb >20 string >\0 (%s) -6 string %!PS-AdobeFont-1. PostScript Type 1 font program data ->26 string >\0 (%s) +# http://www.nationalarchives.gov.uk/pronom/fmt/525 +6 string %!PS-AdobeFont-1. +# skip DROID fmt-525-signature-id-816.pfb by checking for content after header +>24 ubyte x PostScript Type 1 font program data +#!:mime application/octet-stream +!:mime font/x-postscript-pfb +!:ext pfb +# often followed by colon (3Ah) and space (20h) and font name like: DarkGardenMK LetterGothic +>>24 ubyte =0x3A +>>>26 string >\0 (%s) +# some times instead of colon %%CreationDate: and "font name" later +>>24 ubyte !0x3A +# font name directive followed by def like: c0633bt_.pfb +>>>25 search/1247 /FontName\040/ +# show font name in parentheses like: Frankfurt Lithos CharterBT-BoldItalic Courier10PitchBT-Bold +>>>>&0 regex [A-Za-z0-9-]+ (%s) +# http://cd.textfiles.com/maxfonts/ATM/M/MIRROR__.PFB +6 string %PS-AdobeFont-1. PostScript Type 1 font program data +!:mime font/x-postscript-pfb +!:ext pfb +# font name like: Times-Mirror +>25 string >\0 (%s) 0 string %!FontType1 PostScript Type 1 font program data +#!:mime font/x-postscript-pfb +#!:ext pfb 6 string %!FontType1 PostScript Type 1 font program data +#!:mime application/octet-stream +!:mime font/x-postscript-pfb +!:ext pfb +# font name like: CaslonOpenFace FetteFraktur Kaufmann Linotext MesozoicGothic Old-Town +>23 string >\0 (%s) +# http://cd.textfiles.com/maxfonts/ATM/P/PLAYBI.PFB +230 string %!FontType1 PostScript Type 1 font program data +!:mime font/x-postscript-pfb +!:ext pfb +# font name like: Playbill +>247 string >\0 (%s) 0 string %!PS-Adobe-3.0\ Resource-Font PostScript Type 1 font text +#!:mime font/x-postscript-pfb +#!:ext pfb # Summary: PostScript Type 1 Printer Font Metrics # URL: https://en.wikipedia.org/wiki/PostScript_fonts @@ -67,15 +110,23 @@ >>>90 ubyte 65 script proportional # X11 font files in SNF (Server Natural Format) format -# updated by Joerg Jenderek at Feb 2013 +# updated by Joerg Jenderek at Feb 2013 and Nov 2021 # http://computer-programming-forum.com/51-perl/8f22fb96d2e34bab.htm -0 belong 00000004 X11 SNF font data, MSB first -#>104 belong 00000004 X11 SNF font data, MSB first +# URL: http://fileformats.archiveteam.org/wiki/SNF +# Reference: https://cgit.freedesktop.org/xorg/lib/libXfont/tree/src/bitmap/snfstr.h +0 belong 00000004 +# version2 same as version1 in struct _snfFontInfo +>104 belong 00000004 X11 SNF font data, MSB first +# GRR: line above is too general as it catches also DEGAS low-res bitmap like: +# http://cd.textfiles.com/geminiatari/FILES/GRAPHICS/ANIMAT/SPID_PAT/BIGSPID.PI1 !:mime application/x-font-sfn -# GRR: line below too general as it catches also Xbase index file t3-CHAR.NDX +!:ext snf +# GRR: line below is too general as it catches also Xbase index file t3-CHAR.NDX 0 lelong 00000004 >104 lelong 00000004 X11 SNF font data, LSB first !:mime application/x-font-sfn +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/s/snf-x11-lsb.trid.xml +!:ext snf # X11 Bitmap Distribution Format, from Daniel Quinlan (quinlan@yggdrasil.com) 0 search/1 STARTFONT\ X11 BDF font text @@ -384,11 +435,13 @@ # https://www.w3.org/TR/WOFF/ 0 string wOFF Web Open Font Format +!:mime font/woff >0 use woff >20 beshort x \b, version %d >22 beshort x \b.%d # https://www.w3.org/TR/WOFF2/ 0 string wOF2 Web Open Font Format (Version 2) +!:mime font/woff2 >0 use woff #>20 belong x \b, totalCompressedSize %d >24 beshort x \b, version %d diff --git a/magic/Magdir/freebsd b/magic/Magdir/freebsd index a01ac4a28575..66aff6caf2ac 100644 --- a/magic/Magdir/freebsd +++ b/magic/Magdir/freebsd @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: freebsd,v 1.7 2009/09/19 16:28:09 christos Exp $ +# $File: freebsd,v 1.9 2022/01/19 12:44:13 christos Exp $ # freebsd: file(1) magic for FreeBSD objects # # All new-style FreeBSD magic numbers are in host byte order (i.e., @@ -142,3 +142,23 @@ >9 byte 2 %d bytes in header, >>10 byte x %d chars wide by >>11 byte x %d chars high + +# +# FreeBSD kernel minidumps +# +0 string minidump\040FreeBSD/ FreeBSD kernel minidump +# powerpc uses 32-byte magic, followed by 32-byte mmu kind, then version +>17 string powerpc +>>17 string >\0 for %s, +>>>32 string >\0 %s, +>>>>64 byte 0 big endian, +>>>>>64 belong x version %d +>>>>64 default x little endian, +>>>>>64 lelong x version %d +# all other architectures use 24-byte magic, followed by version +>17 default x +>>17 string >\0 for %s, +>>>24 byte 0 big endian, +>>>>24 belong x version %d +>>>24 default x little endian, +>>>>24 lelong x version %d diff --git a/magic/Magdir/games b/magic/Magdir/games index 65af681bad00..b5d4664c8891 100644 --- a/magic/Magdir/games +++ b/magic/Magdir/games @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: games,v 1.24 2021/04/26 15:56:00 christos Exp $ +# $File: games,v 1.25 2022/05/31 18:40:20 christos Exp $ # games: file(1) for games # Fabio Bonelli <fabiobonelli@libero.it> @@ -496,25 +496,17 @@ >4 ulelong x version %d, used in GTA IV, >>8 ulelong x %d items -0 uleshort 0x5250 RAGE Package Format (RPF), ->2 uleshort 0x4630 version 0, used in Rockstar Table Tennis, ->>4 ulelong x %d bytes, ->>>8 ulelong x %d entries ->2 uleshort 0x4632 version 2, used in GTA IV, ->>4 ulelong x %d bytes, ->>>8 ulelong x %d entries ->2 uleshort 0x4633 version 3, used in GTA IV Audio & Midnight Club: LA, ->>4 ulelong x %d bytes, ->>>8 ulelong x %d entries ->2 uleshort 0x4634 version 4, used in Max Payne 3, ->>4 ulelong x %d bytes, ->>>8 ulelong x %d entries ->2 uleshort 0x4636 version 6, used in RDR, ->>4 ulelong x %d bytes, ->>>8 ulelong x %d entries ->2 uleshort 0x4637 version 7, used in GTA V, ->>4 ulelong x %d bytes, ->>>8 ulelong x %d entries ->2 uleshort 0x4638 version 8, used in RDR 2, +# RPF[0-8] +0 ulelong&0xfffffff0 =0x52504630 +>0 ulelong&0xf <9 RAGE Package Format (RPF), version %d, used in +>>0 ulelong&0xf =0 Rockstar Table Tennis, +>>0 ulelong&0xf =1 *unknown* +>>0 ulelong&0xf =2 GTA IV, +>>0 ulelong&0xf =3 GTA IV Audio & Midnight Club: LA, +>>0 ulelong&0xf =4 Max Payne 3, +>>0 ulelong&0xf =5 *unknown* +>>0 ulelong&0xf =6 RDR, +>>0 ulelong&0xf =7 GTA V, +>>0 ulelong&0xf =8 RDR 2, >>4 ulelong x %d bytes, >>>8 ulelong x %d entries diff --git a/magic/Magdir/geo b/magic/Magdir/geo index d72e514a2338..dda5f738311d 100644 --- a/magic/Magdir/geo +++ b/magic/Magdir/geo @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: geo,v 1.7 2019/04/19 00:42:27 christos Exp $ +# $File: geo,v 1.8 2022/03/24 15:48:58 christos Exp $ # Geo- files from Kurt Schwehr <schwehr@ccom.unh.edu> ###################################################################### @@ -28,8 +28,8 @@ # Knudsen subbottom chirp profiler - Binary File Format: B9 # KEB D409-03167 V1.75 Huffman 0 string KEB\ Knudsen seismic KEL binary (KEB) - ->4 regex [-A-Z0-9]* Software: %s ->>&1 regex V[0-9]*\.[0-9]* version %s +>4 regex [-A-Z0-9]+ Software: %s +>>&1 regex V[0-9]+\\.[0-9]+ version %s ###################################################################### # @@ -40,7 +40,7 @@ # Caris LIDAR format for LADS comes as two parts... ascii location file and binary waveform data 0 string HCA LADS Caris Ascii Format (CAF) bathymetric lidar ->4 regex [0-9]*\.[0-9]* version %s +>4 regex [0-9]+\\.[0-9]+ version %s 0 string HCB LADS Caris Binary Format (CBF) bathymetric lidar waveform data >3 byte x version %d . @@ -69,7 +69,7 @@ # mb121 https://www.saic.com/maritime/gsf/ 8 string GSF-v SAIC generic sensor format (GSF) sonar data, ->&0 regex [0-9]*\.[0-9]* version %s +>&0 regex [0-9]+\\.[0-9]+ version %s # MGD77 - https://www.ngdc.noaa.gov/mgg/dat/geodas/docs/mgd77.htm # mb161 diff --git a/magic/Magdir/iff b/magic/Magdir/iff index 8da0350dbfac..258d16a4e1e3 100644 --- a/magic/Magdir/iff +++ b/magic/Magdir/iff @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: iff,v 1.17 2021/02/23 01:07:32 christos Exp $ +# $File: iff,v 1.18 2022/03/21 19:57:18 christos Exp $ # iff: file(1) magic for Interchange File Format (see also "audio" & "images") # # Daniel Quinlan (quinlan@yggdrasil.com) -- IFF was designed by Electronic @@ -45,6 +45,7 @@ >8 string ACBM \b, ACBM continuous image >8 string FAXX \b, FAXX fax image >8 string STFX \b, ST-Fax image +>8 string IMAGIHDR \b, CD-i image # other formats >8 string FTXT \b, FTXT formatted text >8 string CTLG \b, CTLG message catalog diff --git a/magic/Magdir/images b/magic/Magdir/images index 6ce087255570..95004d1d9f47 100644 --- a/magic/Magdir/images +++ b/magic/Magdir/images @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: images,v 1.205 2021/10/18 13:56:29 christos Exp $ +# $File: images,v 1.223 2022/05/14 20:05:09 christos Exp $ # images: file(1) magic for image formats (see also "iff", and "c-lang" for # XPM bitmaps) # @@ -123,46 +123,46 @@ # date >>>>&365 ubequad&0xffffFFFFffff0000 !0 # Day ->>>>>&-6 uleshort x %d +>>>>>&-6 uleshort x %d # Month ->>>>>&-8 uleshort x \b-%d +>>>>>&-8 uleshort x \b-%d # Year ->>>>>&-4 uleshort x \b-%d +>>>>>&-4 uleshort x \b-%d # time >>>>&371 ubequad&0xffffFFFFffff0000 !0 # hour ->>>>>&-8 uleshort x %d +>>>>>&-8 uleshort x %d # minutes ->>>>>&-6 uleshort x \b:%.2d +>>>>>&-6 uleshort x \b:%.2d # second ->>>>>&-4 uleshort x \b:%.2d +>>>>>&-4 uleshort x \b:%.2d # JobName[41] ->>>>&377 string >\0 - job "%-.40s" +>>>>&377 string >\0 - job "%-.40s" # JobHour Jobminute Jobsecond >>>>&418 ubequad&0xffffFFFFffff0000 !0 ->>>>>&-8 uleshort x %d ->>>>>&-6 uleshort x \b:%.2d ->>>>>&-4 uleshort x \b:%.2d +>>>>>&-8 uleshort x %d +>>>>>&-6 uleshort x \b:%.2d +>>>>>&-4 uleshort x \b:%.2d # SoftwareId[41] ->>>>&424 string >\0 - %-.40s +>>>>&424 string >\0 - %-.40s # SoftwareVersionNumber ->>>>&424 ubyte >0 ->>>>>&40 uleshort/100 x %d ->>>>>&40 uleshort%100 x \b.%d +>>>>&424 ubyte >0 +>>>>>&40 uleshort/100 x %d +>>>>>&40 uleshort%100 x \b.%d # VersionLetter ->>>>>&42 ubyte >0x20 \b%c +>>>>>&42 ubyte >0x20 \b%c # KeyColor ->>>>&468 ulelong >0 - keycolor %#8.8x +>>>>&468 ulelong >0 - keycolor %#8.8x # Denominator of Pixel ratio. 0~no pixel aspect ->>>>&474 uleshort >0 +>>>>&474 uleshort >0 # Numerator ->>>>>&-4 uleshort >0 - aspect %d ->>>>>&-2 uleshort x \b/%d +>>>>>&-4 uleshort >0 - aspect %d +>>>>>&-2 uleshort x \b/%d # Denominator of Gamma ratio. 0~no Gamma value ->>>>&478 uleshort >0 +>>>>&478 uleshort >0 # Numerator ->>>>>&-4 uleshort >0 - gamma %d ->>>>>&-2 uleshort x \b/%d +>>>>>&-4 uleshort >0 - gamma %d +>>>>>&-2 uleshort x \b/%d # ColorOffset #>>>>&480 ulelong x - col offset %#8.8x # StampOffset @@ -179,7 +179,7 @@ # adding 65 to strength so that Netpbm images comes before "x86 boot sector" or # "DOS/MBR boot sector" identified by ./filesystems 0 name netpbm ->3 regex/s =[0-9]{1,50}\ [0-9]{1,50} Netpbm image data +>3 regex/s =[0-9]{1,50}[\040\t\f\r\n]+[0-9]{1,50} Netpbm image data >>&0 regex =[0-9]{1,50} \b, size = %s x >>>&0 regex =[0-9]{1,50} \b %s @@ -260,11 +260,11 @@ >4 string \013 MGI Type 11 >4 string \021 MGI Type 17 0 string .MDA MicroDesign data ->21 byte 48 version 2 ->21 byte 51 version 3 +>21 ubyte 48 version 2 +>21 ubyte 51 version 3 0 string .MDP MicroDesign page data ->21 byte 48 version 2 ->21 byte 51 version 3 +>21 ubyte 48 version 2 +>21 ubyte 51 version 3 # NIFF (Navy Interchange File Format, a modification of TIFF) images # [GRR: this *must* go before TIFF] @@ -277,8 +277,8 @@ # URL: https://www.sno.phy.queensu.ca/~phil/exiftool/canon_raw.html 0 string II\x1a\0\0\0HEAPCCDR Canon CIFF raw image data !:mime image/x-canon-crw ->16 leshort x \b, version %d. ->14 leshort x \b%d +>16 uleshort x \b, version %d. +>14 uleshort x \b%d # Canon RAW version 2 (CR2) files are a kind of TIFF with an extra magic # number. Put this above the TIFF test to make sure we detect them. @@ -288,8 +288,8 @@ 0 string II\x2a\0\x10\0\0\0CR Canon CR2 raw image data !:mime image/x-canon-cr2 !:strength +80 ->10 byte x \b, version %d. ->11 byte x \b%d +>10 ubyte x \b, version %d. +>11 ubyte x \b%d # Fujifilm RAF RAW image files with embedded JPEG data and compressed # or uncompressed CFA RAW data. Byte order: Big Endian. @@ -320,148 +320,148 @@ >(4.l) use tiff_ifd 0 name tiff_ifd ->0 leshort x \b, direntries=%d +>0 uleshort x \b, direntries=%d >2 use tiff_entry 0 name tiff_entry # NewSubFileType ->0 leshort 0xfe +>0 uleshort 0xfe >>12 use tiff_entry ->0 leshort 0x100 ->>4 lelong 1 +>0 uleshort 0x100 +>>4 ulelong 1 >>>12 use tiff_entry ->>>8 leshort x \b, width=%d ->0 leshort 0x101 ->>4 lelong 1 ->>>8 leshort x \b, height=%d +>>>8 uleshort x \b, width=%d +>0 uleshort 0x101 +>>4 ulelong 1 +>>>8 uleshort x \b, height=%d >>>12 use tiff_entry ->0 leshort 0x102 ->>8 leshort x \b, bps=%d +>0 uleshort 0x102 +>>8 uleshort x \b, bps=%d >>12 use tiff_entry ->0 leshort 0x103 ->>4 lelong 1 \b, compression= ->>>8 leshort 1 \bnone ->>>8 leshort 2 \bhuffman ->>>8 leshort 3 \bbi-level group 3 ->>>8 leshort 4 \bbi-level group 4 ->>>8 leshort 5 \bLZW ->>>8 leshort 6 \bJPEG (old) ->>>8 leshort 7 \bJPEG ->>>8 leshort 8 \bdeflate ->>>8 leshort 9 \bJBIG, ITU-T T.85 ->>>8 leshort 0xa \bJBIG, ITU-T T.43 ->>>8 leshort 0x7ffe \bNeXT RLE 2-bit ->>>8 leshort 0x8005 \bPackBits (Macintosh RLE) ->>>8 leshort 0x8029 \bThunderscan RLE ->>>8 leshort 0x807f \bRasterPadding (CT or MP) ->>>8 leshort 0x8080 \bRLE (Line Work) ->>>8 leshort 0x8081 \bRLE (High-Res Cont-Tone) ->>>8 leshort 0x8082 \bRLE (Binary Line Work) ->>>8 leshort 0x80b2 \bDeflate (PKZIP) ->>>8 leshort 0x80b3 \bKodak DCS ->>>8 leshort 0x8765 \bJBIG ->>>8 leshort 0x8798 \bJPEG2000 ->>>8 leshort 0x8799 \bNikon NEF Compressed +>0 uleshort 0x103 +>>4 ulelong 1 \b, compression= +>>>8 uleshort 1 \bnone +>>>8 uleshort 2 \bhuffman +>>>8 uleshort 3 \bbi-level group 3 +>>>8 uleshort 4 \bbi-level group 4 +>>>8 uleshort 5 \bLZW +>>>8 uleshort 6 \bJPEG (old) +>>>8 uleshort 7 \bJPEG +>>>8 uleshort 8 \bdeflate +>>>8 uleshort 9 \bJBIG, ITU-T T.85 +>>>8 uleshort 0xa \bJBIG, ITU-T T.43 +>>>8 uleshort 0x7ffe \bNeXT RLE 2-bit +>>>8 uleshort 0x8005 \bPackBits (Macintosh RLE) +>>>8 uleshort 0x8029 \bThunderscan RLE +>>>8 uleshort 0x807f \bRasterPadding (CT or MP) +>>>8 uleshort 0x8080 \bRLE (Line Work) +>>>8 uleshort 0x8081 \bRLE (High-Res Cont-Tone) +>>>8 uleshort 0x8082 \bRLE (Binary Line Work) +>>>8 uleshort 0x80b2 \bDeflate (PKZIP) +>>>8 uleshort 0x80b3 \bKodak DCS +>>>8 uleshort 0x8765 \bJBIG +>>>8 uleshort 0x8798 \bJPEG2000 +>>>8 uleshort 0x8799 \bNikon NEF Compressed >>>8 default x ->>>>8 leshort x \b(unknown %#x) +>>>>8 uleshort x \b(unknown %#x) >>>12 use tiff_entry ->0 leshort 0x106 \b, PhotometricIntepretation= +>0 uleshort 0x106 \b, PhotometricIntepretation= >>8 clear x ->>8 leshort 0 \bWhiteIsZero ->>8 leshort 1 \bBlackIsZero ->>8 leshort 2 \bRGB ->>8 leshort 3 \bRGB Palette ->>8 leshort 4 \bTransparency Mask ->>8 leshort 5 \bCMYK ->>8 leshort 6 \bYCbCr ->>8 leshort 8 \bCIELab +>>8 uleshort 0 \bWhiteIsZero +>>8 uleshort 1 \bBlackIsZero +>>8 uleshort 2 \bRGB +>>8 uleshort 3 \bRGB Palette +>>8 uleshort 4 \bTransparency Mask +>>8 uleshort 5 \bCMYK +>>8 uleshort 6 \bYCbCr +>>8 uleshort 8 \bCIELab >>8 default x ->>>8 leshort x \b(unknown=%#x) +>>>8 uleshort x \b(unknown=%#x) >>12 use tiff_entry # FillOrder ->0 leshort 0x10a ->>4 lelong 1 +>0 uleshort 0x10a +>>4 ulelong 1 >>>12 use tiff_entry # DocumentName ->0 leshort 0x10d +>0 uleshort 0x10d >>(8.l) string x \b, name=%s >>>12 use tiff_entry # ImageDescription ->0 leshort 0x10e +>0 uleshort 0x10e >>(8.l) string x \b, description=%s >>>12 use tiff_entry # Make ->0 leshort 0x10f +>0 uleshort 0x10f >>(8.l) string x \b, manufacturer=%s >>>12 use tiff_entry # Model ->0 leshort 0x110 +>0 uleshort 0x110 >>(8.l) string x \b, model=%s >>>12 use tiff_entry # StripOffsets ->0 leshort 0x111 +>0 uleshort 0x111 >>12 use tiff_entry # Orientation ->0 leshort 0x112 \b, orientation= ->>8 leshort 1 \bupper-left ->>8 leshort 3 \blower-right ->>8 leshort 6 \bupper-right ->>8 leshort 8 \blower-left ->>8 leshort 9 \bundefined +>0 uleshort 0x112 \b, orientation= +>>8 uleshort 1 \bupper-left +>>8 uleshort 3 \blower-right +>>8 uleshort 6 \bupper-right +>>8 uleshort 8 \blower-left +>>8 uleshort 9 \bundefined >>8 default x ->>>8 leshort x \b[*%d*] +>>>8 uleshort x \b[*%d*] >>12 use tiff_entry # XResolution ->0 leshort 0x11a ->>8 lelong x \b, xresolution=%d +>0 uleshort 0x11a +>>8 ulelong x \b, xresolution=%d >>12 use tiff_entry # YResolution ->0 leshort 0x11b ->>8 lelong x \b, yresolution=%d +>0 uleshort 0x11b +>>8 ulelong x \b, yresolution=%d >>12 use tiff_entry # ResolutionUnit ->0 leshort 0x128 ->>8 leshort x \b, resolutionunit=%d +>0 uleshort 0x128 +>>8 uleshort x \b, resolutionunit=%d >>12 use tiff_entry # Software ->0 leshort 0x131 +>0 uleshort 0x131 >>(8.l) string x \b, software=%s >>12 use tiff_entry # Datetime ->0 leshort 0x132 +>0 uleshort 0x132 >>(8.l) string x \b, datetime=%s >>12 use tiff_entry # HostComputer ->0 leshort 0x13c +>0 uleshort 0x13c >>(8.l) string x \b, hostcomputer=%s >>12 use tiff_entry # WhitePoint ->0 leshort 0x13e +>0 uleshort 0x13e >>12 use tiff_entry # PrimaryChromaticities ->0 leshort 0x13f +>0 uleshort 0x13f >>12 use tiff_entry # YCbCrCoefficients ->0 leshort 0x211 +>0 uleshort 0x211 >>12 use tiff_entry # YCbCrPositioning ->0 leshort 0x213 +>0 uleshort 0x213 >>12 use tiff_entry # ReferenceBlackWhite ->0 leshort 0x214 +>0 uleshort 0x214 >>12 use tiff_entry # Copyright ->0 leshort 0x8298 +>0 uleshort 0x8298 >>(8.l) string x \b, copyright=%s >>12 use tiff_entry # ExifOffset ->0 leshort 0x8769 +>0 uleshort 0x8769 >>12 use tiff_entry # GPS IFD ->0 leshort 0x8825 \b, GPS-Data +>0 uleshort 0x8825 \b, GPS-Data >>12 use tiff_entry -#>0 leshort x \b, unknown=%#x +#>0 uleshort x \b, unknown=%#x #>>12 use tiff_entry 0 string MM\x00\x2b Big TIFF image data, big-endian @@ -478,17 +478,17 @@ # IHDR parser 0 name png-ihdr ->0 belong x \b, %d x ->4 belong x %d, ->8 byte x %d-bit ->9 byte 0 grayscale, ->9 byte 2 \b/color RGB, ->9 byte 3 colormap, ->9 byte 4 gray+alpha, ->9 byte 6 \b/color RGBA, -#>10 byte 0 deflate/32K, ->12 byte 0 non-interlaced ->12 byte 1 interlaced +>0 ubelong x \b, %d x +>4 ubelong x %d, +>8 ubyte x %d-bit +>9 ubyte 0 grayscale, +>9 ubyte 2 \b/color RGB, +>9 ubyte 3 colormap, +>9 ubyte 4 gray+alpha, +>9 ubyte 6 \b/color RGBA, +#>10 ubyte 0 deflate/32K, +>12 ubyte 0 non-interlaced +>12 ubyte 1 interlaced # Standard PNG image. 0 string \x89PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0DIHDR PNG image data @@ -532,24 +532,24 @@ !:ext gif >4 string 7a \b, version 8%s, >4 string 9a \b, version 8%s, ->6 leshort >0 %d x ->8 leshort >0 %d -#>10 byte &0x80 color mapped, -#>10 byte&0x07 =0x00 2 colors -#>10 byte&0x07 =0x01 4 colors -#>10 byte&0x07 =0x02 8 colors -#>10 byte&0x07 =0x03 16 colors -#>10 byte&0x07 =0x04 32 colors -#>10 byte&0x07 =0x05 64 colors -#>10 byte&0x07 =0x06 128 colors -#>10 byte&0x07 =0x07 256 colors +>6 uleshort >0 %d x +>8 uleshort >0 %d +#>10 ubyte &0x80 color mapped, +#>10 ubyte&0x07 =0x00 2 colors +#>10 ubyte&0x07 =0x01 4 colors +#>10 ubyte&0x07 =0x02 8 colors +#>10 ubyte&0x07 =0x03 16 colors +#>10 ubyte&0x07 =0x04 32 colors +#>10 ubyte&0x07 =0x05 64 colors +#>10 ubyte&0x07 =0x06 128 colors +#>10 ubyte&0x07 =0x07 256 colors # ITC (CMU WM) raster files. It is essentially a byte-reversed Sun raster, # 1 plane, no encoding. 0 string \361\0\100\273 CMU window manager raster image data ->4 lelong >0 %d x ->8 lelong >0 %d, ->12 lelong >0 %d-bit +>4 ulelong >0 %d x +>8 ulelong >0 %d, +>12 ulelong >0 %d-bit # Magick Image File Format # URL: https://imagemagick.org/script/miff.php @@ -596,8 +596,49 @@ >4 long 3 \b, rectangular 32-bit (24-bit with matte) # FIG (Facility for Interactive Generation of figures), an object-based format -0 search/1 #FIG FIG image text +# URL: http://fileformats.archiveteam.org/wiki/Fig +# https://en.wikipedia.org/wiki/Xfig +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/f/fig.trid.xml +# https://web.archive.org/web/20070920204655/http://epb.lbl.gov/xfig/fig-format.html +# Update: Joerg Jenderek +# Note: called "FIG vector drawing" by TrID, +# 4 byte magic is assumed to be always at offset 0 and +# verified by `fig2mpdf -v bootloader.fig && file bootloader.pdf` +#0 search/1/tb #FIG FIG image text +# GRR: with --keep-going option the line above gives duplicate messages +0 search/1/ts #FIG +>&0 use image-xfig +# binary data variant with non ASCII text characters like Control-A or °C in thermostat.fig +0 search/1/bs #FIG +>&0 use image-xfig +# display XFIG image describing text, mime type, file name extension and version +0 name image-xfig +>8 ubyte x FIG image text +#!:mime text/plain +# https://reposcope.com/mimetype/image/x-xfig +!:mime image/x-xfig +!:ext fig +# version string like: 1.4 2.1 3.1 3.2 >5 string x \b, version %.3s +# some times after version text like: "Produced by xfig version 3.2.5-alpha5" +>8 ubyte >0x0D +>>8 string x "%s" +# should be point character (2Eh) of version string according to TrID +#>6 ubyte !0x2E \b, at 6 %#x +# caret character (23h) at the beginning in most or probaly all exanples +#>0 ubyte !0x23 \b, starting with character %#x +# URL: http://fileformats.archiveteam.org/wiki/DeskMate_Draw +# http://en.wikipedia.org/wiki/Deskmate +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/d/dm-fig.trid.xml +# From: Joerg Jenderek +# Note: called "DeskMate Draw drawing" by TrID +0 string \x14FIG DeskMate Drawing +#!:mime application/octet-stream +!:mime image/x-deskmate-fig +!:ext fig +# TODO: +# "Cabri 3D Figure" by TrID fig-cabri.trid.xml +# "Playmation Figure" by TrID fig-playmation.trid.xml # PHIGS 0 string ARF_BEGARF PHIGS clear text archive @@ -626,8 +667,8 @@ # facsimile data 1 string PC\ Research,\ Inc group 3 fax data ->29 byte 0 \b, normal resolution (204x98 DPI) ->29 byte 1 \b, fine resolution (204x196 DPI) +>29 ubyte 0 \b, normal resolution (204x98 DPI) +>29 ubyte 1 \b, fine resolution (204x196 DPI) # From: Herbert Rosmanith <herp@wildsau.idv.uni.linz.at> 0 string Sfff structured fax file @@ -652,23 +693,23 @@ # http://biosgfx.narod.ru/abr-2/ 0 string AWBM # Note: by bitmap-awbm.trid.xml called "Award BIOS logo bitmap (v2)" ->4 leshort <1981 Award BIOS Logo, version 2 -#>4 leshort <1981 Award BIOS bitmap +>4 uleshort <1981 Award BIOS Logo, version 2 +#>4 uleshort <1981 Award BIOS bitmap !:mime image/x-award-bioslogo2 #!:mime image/x-award-bmp !:ext epa/bmp # image width is a multiple of 4 ->>4 leshort&0x0003 0 ->>>4 leshort x \b, %d ->>>6 leshort x x %d ->>4 leshort&0x0003 >0 \b, ->>>4 leshort&0x0003 =1 ->>>>4 leshort x %d+3 ->>>4 leshort&0x0003 =2 ->>>>4 leshort x %d+2 ->>>4 leshort&0x0003 =3 ->>>>4 leshort x %d+1 ->>>6 leshort x x %d +>>4 uleshort&0x0003 0 +>>>4 uleshort x \b, %d +>>>6 uleshort x x %d +>>4 uleshort&0x0003 >0 \b, +>>>4 uleshort&0x0003 =1 +>>>>4 uleshort x %d+3 +>>>4 uleshort&0x0003 =2 +>>>>4 uleshort x %d+2 +>>>4 uleshort&0x0003 =3 +>>>>4 uleshort x %d+1 +>>>6 uleshort x x %d # at offset 8 starts imagedata followed by "RGB " marker # PC bitmaps (OS/2, Windows BMP files) (Greg Roelofs, newt@uchicago.edu) @@ -677,15 +718,15 @@ # Note: variant starting direct with DIB header see # http://fileformats.archiveteam.org/wiki/BMP # verified by ImageMagick version 6.8.9-8 command `identify *.dib` -0 leshort 40 +0 uleshort 40 # skip bad samples like GAME by looking for valid number of color planes >12 uleshort 1 Device independent bitmap graphic !:mime image/x-ms-bmp !:apple ????BMPp !:ext dib ->>4 lelong x \b, %d x ->>8 lelong x %d x ->>14 leshort x %d +>>4 ulelong x \b, %d x +>>8 ulelong x %d x +>>14 uleshort x %d # number of color planes (must be 1) #>>12 uleshort >1 \b, %u color planes # compression method: 0~no 1~RLE 8-bit/pixel 3~Huffman 1D @@ -694,8 +735,8 @@ # image size is the size of raw bitmap; a dummy 0 can be given for BI_RGB bitmaps >>20 ulelong x \b, image size %u # horizontal and vertical resolution of the image (pixel per metre, signed integer) ->>24 lelong >0 \b, resolution %d x ->>>28 lelong x %d px/m +>>24 ulelong >0 \b, resolution %d x +>>>28 ulelong x %d px/m # number of colors in palette, or 0 to default to 2**n #>>32 ulelong >0 \b, %u colors # number of important colors used, or 0 when every color is important @@ -737,14 +778,14 @@ # 0 string BM # check for magic and version 2 of VDC bitmap or BMP with cbSize=715=CB02 ->2 beshort 0xCB02 +>2 ubeshort 0xCB02 >>6 short =0 >>>0 use bitmap-bmp # VDC bitmap height or maybe a few OS/2 BMP with nonzero "hotspot coordinates" >>6 short !0 >>>0 use bitmap-vbm # check for magic and version 3 of VDC bitmap or BMP with cbSize=971=CB03 ->2 beshort 0xCB03 +>2 ubeshort 0xCB03 # check for reserved value (=0) of VDC bitmap >>14 short =0 >>>0 use bitmap-vbm @@ -755,15 +796,15 @@ >2 default x >>0 use bitmap-bmp 0 name bitmap-bmp ->14 lelong 12 PC bitmap, OS/2 1.x format +>14 ulelong 12 PC bitmap, OS/2 1.x format !:mime image/bmp !:ext bmp ->>18 leshort x \b, %d x ->>20 leshort x %d +>>18 uleshort x \b, %d x +>>20 uleshort x %d # number of color planes (must be 1) -#>>22 leshort !1 \b, %u color planes +#>>22 uleshort !1 \b, %u color planes # number of bits per pixel (color depth); found 4 8 ->>24 leshort x x %d +>>24 uleshort x x %d # x, y coordinates of the hotspot >>6 uleshort >0 \b, hotspot %ux >>>8 uleshort x \b%u @@ -771,7 +812,7 @@ >>2 ulelong x \b, cbSize %u #>>2 ulelong x \b, cbSize 0x%8.8x # offBits; offset to bitmap data like: ->>10 ulelong x \b, bits offset %u +>>10 ulelong x \b, bits offset %u # http://fileformats.archiveteam.org/wiki/BMP#OS.2F2_BMP_2.0 no examples found >14 ulelong 48 PC bitmap, OS/2 2.x format (DIB header size=48) >14 ulelong 24 PC bitmap, OS/2 2.x format (DIB header size=24) @@ -795,9 +836,9 @@ >>2 ulelong x \b, cbSize %u #>>2 ulelong x \b, cbSize 0x%x # offBits; offset to bitmap data like: 41E ->>10 ulelong x \b, bits offset %u -#>>10 ulelong x \b, bits offset 0x%x ->14 lelong 64 PC bitmap, OS/2 2.x format +>>10 ulelong x \b, bits offset %u +#>>10 ulelong x \b, bits offset 0x%x +>14 ulelong 64 PC bitmap, OS/2 2.x format !:mime image/bmp !:apple ????BMPp !:ext bmp @@ -815,18 +856,18 @@ # BMP with cbSize 000002CBh=715 or 000003CBh=971 maybe misinterpreted as VDC bitmap #>>2 ulelong x \b, cbSize %#x # offBits; offset to bitmap data like 56h 5Eh 8Eh 43Eh ->>10 ulelong x \b, bits offset %u -#>>10 ulelong x \b, bits offset %#x -#>>(10.l) ubequad !0 \b, bits %#16.16llx +>>10 ulelong x \b, bits offset %u +#>>10 ulelong x \b, bits offset %#x +#>>(10.l) ubequad !0 \b, bits %#16.16llx # BITMAPV2INFOHEADER adds RGB bit masks ->14 lelong 52 PC bitmap, Adobe Photoshop +>14 ulelong 52 PC bitmap, Adobe Photoshop !:mime image/bmp !:apple ????BMPp !:ext bmp ->>18 lelong x \b, %d x ->>22 lelong x %d x +>>18 ulelong x \b, %d x +>>22 ulelong x %d x # number of bits per pixel (color depth); found 16 32 ->>28 leshort x %d +>>28 uleshort x %d # x, y coordinates of the hotspot; should be zero for Windows variant >>6 uleshort >0 \b, hotspot %ux >>>8 uleshort x \b%u @@ -834,17 +875,17 @@ >>2 ulelong x \b, cbSize %u #>>2 ulelong x \b, cbSize 0x%x # offBits; offset to bitmap data like: 42h ->>10 ulelong x \b, bits offset %u -#>>10 ulelong x \b, bits offset 0x%x +>>10 ulelong x \b, bits offset %u +#>>10 ulelong x \b, bits offset 0x%x # BITMAPV3INFOHEADER adds alpha channel bit mask ->14 lelong 56 PC bitmap, Adobe Photoshop with alpha channel mask +>14 ulelong 56 PC bitmap, Adobe Photoshop with alpha channel mask !:mime image/bmp !:apple ????BMPp !:ext bmp ->>18 lelong x \b, %d x ->>22 lelong x %d x +>>18 ulelong x \b, %d x +>>22 ulelong x %d x # number of bits per pixel (color depth); found 16 32 ->>28 leshort x %d +>>28 uleshort x %d # x, y coordinates of the hotspot; should be zero for Windows variant >>6 uleshort >0 \b, hotspot %ux >>>8 uleshort x \b%u @@ -854,15 +895,15 @@ # offBits; offset to bitmap data like: 46h >>10 ulelong x \b, bits offset %u #>>10 ulelong x \b, bits offset 0x%x ->14 lelong 40 +>14 ulelong 40 # jump 4 bytes before end of file/header to skip fmt-116-signature-id-118.dib # broken for large bitmaps #>>(2.l-4) ulong x PC bitmap, Windows 3.x format ->>14 lelong 40 PC bitmap, Windows 3.x format +>>14 ulelong 40 PC bitmap, Windows 3.x format !:mime image/bmp !:apple ????BMPp ->>>18 lelong x \b, %d x ->>>22 lelong x %d +>>>18 ulelong x \b, %d x +>>>22 ulelong x %d # 320 x 400 https://en.wikipedia.org/wiki/LOGO.SYS >>>18 ulequad =0x0000019000000140 x !:ext bmp/sys @@ -882,7 +923,7 @@ >>>>>18 default x x !:ext bmp # number of bits per pixel (color depth); found 1 2 4 8 16 24 32 ->>>28 leshort x %d +>>>28 uleshort x %d # x, y coordinates of the hotspot; there is no hotspot in bitmaps, so values 0 #>>>6 uleshort >0 \b, hotspot %ux #>>>>8 uleshort x \b%u @@ -894,8 +935,8 @@ # image size is the size of raw bitmap; a dummy 0 can be given for BI_RGB bitmaps >>>34 ulelong >0 \b, image size %u # horizontal and vertical resolution of the image (pixel per metre, signed integer) ->>>38 lelong >0 \b, resolution %d x ->>>>42 lelong x %d px/m +>>>38 ulelong >0 \b, resolution %d x +>>>>42 ulelong x %d px/m # number of colors in palette 16 256, or 0 to default to 2**n #>>>46 ulelong >0 \b, %u colors # number of important colors used, or 0 when every color is important @@ -904,63 +945,63 @@ >>>2 ulelong x \b, cbSize %u #>>>2 ulelong x \b, cbSize %#x # offBits; offset to bitmap data like 36h 76h BEh 236h 406h 436h 4E6h ->>>10 ulelong x \b, bits offset %u -#>>>10 ulelong x \b, bits offset %#x -#>>>(10.l) ubequad !0 \b, bits %#16.16llxd ->14 lelong 124 PC bitmap, Windows 98/2000 and newer format +>>>10 ulelong x \b, bits offset %u +#>>>10 ulelong x \b, bits offset %#x +#>>>(10.l) ubequad !0 \b, bits %#16.16llxd +>14 ulelong 124 PC bitmap, Windows 98/2000 and newer format !:mime image/bmp !:ext bmp ->>18 lelong x \b, %d x ->>22 lelong x %d x +>>18 ulelong x \b, %d x +>>22 ulelong x %d x # color planes; must be 1 #>>>26 uleshort >1 \b, %u color planes # number of bits per pixel (color depth); found 4 8 16 24 32 1 (fmt-119-signature-id-121.bmp) 0 (rgb24jpeg.bmp rgb24png.bmp) ->>28 leshort x %d +>>28 uleshort x %d # x, y coordinates of the hotspot; should be zero for Windows variant ->>6 leshort >0 \b, hotspot %ux ->>>8 leshort x \b%u +>>6 uleshort >0 \b, hotspot %ux +>>>8 uleshort x \b%u # cbSize; size of file like: 8E AA 48A 999 247A 4F02 7F8A 3F88E B216E 1D4C8A 100008A >>2 ulelong x \b, cbSize %u #>>2 ulelong x \b, cbSize 0x%x # offBits; offset to bitmap data like: 8A 47A ABABABAB (fmt-119-signature-id-121.bmp) ->>10 ulelong x \b, bits offset %u -#>>10 ulelong x \b, bits offset 0x%x ->14 lelong 108 PC bitmap, Windows 95/NT4 and newer format +>>10 ulelong x \b, bits offset %u +#>>10 ulelong x \b, bits offset 0x%x +>14 ulelong 108 PC bitmap, Windows 95/NT4 and newer format !:mime image/bmp !:ext bmp ->>18 lelong x \b, %d x ->>22 lelong x %d x +>>18 ulelong x \b, %d x +>>22 ulelong x %d x # number of bits per pixel (color depth); found 8 24 32 ->>28 leshort x %d +>>28 uleshort x %d # x, y coordinates of the hotspot; should be zero for Windows variant ->>6 leshort >0 \b, hotspot %ux ->>>8 leshort x \b%u +>>6 uleshort >0 \b, hotspot %ux +>>>8 uleshort x \b%u # cbSize; size of file like: 82 8A 9A 9F86 1E07A 3007A 88B7A C007A >>2 ulelong x \b, cbSize %u #>>2 ulelong x \b, cbSize 0x%x # offBits; offset to bitmap data like: 7A 7E 46A ->>10 ulelong x \b, bits offset %u -#>>10 ulelong x \b, bits offset 0x%x +>>10 ulelong x \b, bits offset %u +#>>10 ulelong x \b, bits offset 0x%x # Update: Joerg Jenderek # URL: http://fileformats.archiveteam.org/wiki/OS/2_Icon # Reference: http://www.fileformat.info # /format/os2bmp/spec/902d5c253f2a43ada39c2b81034f27fd/view.htm # Note: verified by command like `deark -l -d3 OS2MEMU.ICO` -0 string IC +0 string IC # skip Lotus smart icon *.smi by looking for valid hotspot coordinates >6 ulelong&0xFF00FF00 =0 OS/2 icon # jump 4 bytes before end of header/file and test for accessibility -#>>(2.l-4) ubelong x End of header is OK! +#>>(2.l-4) ubelong x End of header is OK! !:mime image/x-os2-ico !:ext ico # cbSize; size of header or file in bytes like 1ah 120h 420h ->>2 ulelong x \b, cbSize %u +>>2 ulelong x \b, cbSize %u # xHotspot, yHotspot; coordinates of the hotspot for icons like 16 32 ->>6 uleshort x \b, hotspot %ux ->>8 uleshort x \b%u +>>6 uleshort x \b, hotspot %ux +>>8 uleshort x \b%u # offBits; offset in bytes to the beginning of the bit-map pel data like 20h ->>10 ulelong x \b, bits offset %u -#>>(10.l) ubequad x \b, bits %#16.16llx +>>10 ulelong x \b, bits offset %u +#>>(10.l) ubequad x \b, bits %#16.16llx #0 string PI PC pointer image data #0 string CI PC color icon data 0 string CI @@ -991,15 +1032,15 @@ >>>30 ulelong 3 \b, Huffman 1D compression #>>>30 ulelong >0 \b, %u compression # xHotspot, yHotspot; coordinates of the hotspot like 0 1 16 20 32 33 63 64 ->>6 uleshort x \b, hotspot %ux ->>8 uleshort x \b%u +>>6 uleshort x \b, hotspot %ux +>>8 uleshort x \b%u # cbSize; size of header or maybe file in bytes like 1Ah 4Eh 84Eh ->>2 ulelong x \b, cbSize %u -#>>2 ulelong x \b, cbSize %x +>>2 ulelong x \b, cbSize %u +#>>2 ulelong x \b, cbSize %x # offBits; offset to bitmap data (pixel array) like E4h 3Ah 66h 6Ah 33Ah 4A4h ->>10 ulelong x \b, bits offset %u -#>>10 ulelong x \b, bits offset %#x -#>>(10.l) ubequad !0 \b, bits %#16.16llx +>>10 ulelong x \b, bits offset %u +#>>10 ulelong x \b, bits offset %#x +#>>(10.l) ubequad !0 \b, bits %#16.16llx # dib header size: 12~Ch~OS/2 1.x 64~40h~OS/2 2.x #>>14 ulelong x \b, dib header size %u #0 string CP PC color pointer image data @@ -1040,15 +1081,15 @@ >>>30 ulelong 3 \b, Huffman 1D compression #>>>30 ulelong >0 \b, %u compression # xHotspot, yHotspot; coordinates of the hotspot like 0 3 4 8 15 16 23 27 31 ->>6 uleshort x \b, hotspot %ux ->>8 uleshort x \b%u +>>6 uleshort x \b, hotspot %ux +>>8 uleshort x \b%u # cbSize; size of header or maybe file in bytes like 1Ah 4Eh ->>2 ulelong x \b, cbSize %u -#>>2 ulelong x \b, cbSize %x +>>2 ulelong x \b, cbSize %u +#>>2 ulelong x \b, cbSize %x # offBits; offset to bitmap data (pixel array) like 6Ah A4h E4h 4A4h ->>10 ulelong x \b, bits offset %u -#>>10 ulelong x \b, bits offset %#x -#>>(10.l) ubequad !0 \b, bits %#16.16llx +>>10 ulelong x \b, bits offset %u +#>>10 ulelong x \b, bits offset %#x +#>>(10.l) ubequad !0 \b, bits %#16.16llx # dib header size: 12~Ch~OS/2 1.x 64~40h~OS/2 2.x #>>14 ulelong x \b, dib header size %u # Conflicts with other entries [BABYL] @@ -1061,12 +1102,12 @@ !:mime image/x-os2-graphics #!:apple ????BMPf # cbSize; size of header like 28h 5Ch ->>2 ulelong x \b, cbSize %u -#>>2 ulelong x \b, cbSize %#x +>>2 ulelong x \b, cbSize %u +#>>2 ulelong x \b, cbSize %#x # offNext; offset to data like 0 48h F2h 4Eh 64h C6h D2h D6h DAh E6h EAh 348h ->>6 ulelong >0 \b, data offset %u -#>>6 ulelong >0 \b, data offset %#x -#>>(6.l) ubequad !0 \b, data %#16.16llx +>>6 ulelong >0 \b, data offset %u +#>>6 ulelong >0 \b, data offset %#x +#>>(6.l) ubequad !0 \b, data %#16.16llx # dimensions of the intended device like 640 x 480 for VGA or 1024 x 768 >>10 uleshort >0 \b, display %u >>>12 uleshort >0 x %u @@ -1088,22 +1129,68 @@ >>14 indirect x # XPM icons (Greg Roelofs, newt@uchicago.edu) -0 search/1 /*\ XPM\ */ X pixmap image text -!:mime image/x-xpmi +# Update: Joerg Jenderek +# URL: http://fileformats.archiveteam.org/wiki/XPM +# Reference: http://www.x.org/docs/XPM/xpm.pdf +# http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-xpm.trid.xml +# Note: called "X PixMap bitmap" by TrID and "X-Windows Pixmap Image" by DROID via PUID x-fmt/208 +# starting with c comment like: logo.xpm +0 string /*\040 +# 9 byte c-comment "/* XPM */" not at the beginning like: mozicon16.xpm mozicon50.xpm (thunderbird) +>0 search/0xCE /*\ XPM\ */ +# skip DROID x-fmt-208-signature-id-620.xpm by looking for char aray without explict length +# and match mh-logo.xpm (emacs) +>>&0 search/1249 [] +>>>0 use xpm-image +# non standard because no 9 byte c-comment "/* XPM */" like: logo.xpm in qemu package +>0 default x +# words are separated by a white space which can be composed of space and tabulation characters +>>0 search/0x52 static\040char\040 +# skip debug.c testmlc.c by looking for char aray without explict length +# https://www.clamav.net/downloads/production/clamav-0.104.2.tar.gz +# clamav-0.104.2\libclammspack\mspack\debug.c +>>>&0 search/64 [] +>>>>0 use xpm-image +# display X pixmap image information +0 name xpm-image +>0 string x X pixmap image text +#!:mime text/plain +# https://reposcope.com/mimetype/image/x-xpixmap +# alias +#!:mime image/x-xpm +!:mime image/x-xpixmap +!:ext xpm +# NO pm example found! +#!:ext xpm/pm +# look for start of character array at beginning of a line like: psetupl.xpm (OpenOffice 4.1.7) +>0 search/0x406 \n" +# DEBUG VALUES string +#>>&0 string x '%s' +# width with optional white space before like: 16 24 32 48 1280 +>>&0 regex/8 [0-9]{1,5} \b, %s +# height with white space like: 15 16 17 24 32 48 1024 +>>>&0 regex/8 [0-9]{1,5} x %s +# number of colors with white space like: 1 2 3 4 5 8 11 14 162 255 but unrelistic 4294967295 by hardcopy tool +>>>>&0 regex/12 [0-9]{1,9} x %s +# chars_per_pixel with white space like: 1 2 +>>>>>&0 regex/14 [0-9]{1,2} \b, %s chars/pixel +# non standard because not starting with 9 byte c-comment "/* XPM */" +>0 string !/*\ XPM\ */ +>>0 string x \b, 1st line "%s" # Utah Raster Toolkit RLE images (janl@ifi.uio.no) -0 leshort 0xcc52 RLE image data, ->6 leshort x %d x ->8 leshort x %d ->2 leshort >0 \b, lower left corner: %d ->4 leshort >0 \b, lower right corner: %d ->10 byte&0x1 =0x1 \b, clear first ->10 byte&0x2 =0x2 \b, no background ->10 byte&0x4 =0x4 \b, alpha channel ->10 byte&0x8 =0x8 \b, comment ->11 byte >0 \b, %d color channels ->12 byte >0 \b, %d bits per pixel ->13 byte >0 \b, %d color map channels +0 uleshort 0xcc52 RLE image data, +>6 uleshort x %d x +>8 uleshort x %d +>2 uleshort >0 \b, lower left corner: %d +>4 uleshort >0 \b, lower right corner: %d +>10 ubyte&0x1 =0x1 \b, clear first +>10 ubyte&0x2 =0x2 \b, no background +>10 ubyte&0x4 =0x4 \b, alpha channel +>10 ubyte&0x8 =0x8 \b, comment +>11 ubyte >0 \b, %d color channels +>12 ubyte >0 \b, %d bits per pixel +>13 ubyte >0 \b, %d color map channels # image file format (Robert Potter, potter@cs.rochester.edu) 0 string Imagefile\ version- iff image data @@ -1111,55 +1198,55 @@ >10 string >\0 %s # Sun raster images, from Daniel Quinlan (quinlan@yggdrasil.com) -0 belong 0x59a66a95 Sun raster image data ->4 belong >0 \b, %d x ->8 belong >0 %d, ->12 belong >0 %d-bit, -#>16 belong >0 %d bytes long, ->20 belong 0 old format, -#>20 belong 1 standard, ->20 belong 2 compressed, ->20 belong 3 RGB, ->20 belong 4 TIFF, ->20 belong 5 IFF, ->20 belong 0xffff reserved for testing, ->24 belong 0 no colormap ->24 belong 1 RGB colormap ->24 belong 2 raw colormap -#>28 belong >0 colormap is %d bytes long +0 ubelong 0x59a66a95 Sun raster image data +>4 ubelong >0 \b, %d x +>8 ubelong >0 %d, +>12 ubelong >0 %d-bit, +#>16 ubelong >0 %d bytes long, +>20 ubelong 0 old format, +#>20 ubelong 1 standard, +>20 ubelong 2 compressed, +>20 ubelong 3 RGB, +>20 ubelong 4 TIFF, +>20 ubelong 5 IFF, +>20 ubelong 0xffff reserved for testing, +>24 ubelong 0 no colormap +>24 ubelong 1 RGB colormap +>24 ubelong 2 raw colormap +#>28 ubelong >0 colormap is %d bytes long # SGI image file format, from Daniel Quinlan (quinlan@yggdrasil.com) # # See # http://reality.sgi.com/grafica/sgiimage.html # -0 beshort 474 SGI image data -#>2 byte 0 \b, verbatim ->2 byte 1 \b, RLE -#>3 byte 1 \b, normal precision ->3 byte 2 \b, high precision ->4 beshort x \b, %d-D ->6 beshort x \b, %d x ->8 beshort x %d ->10 beshort x \b, %d channel ->10 beshort !1 \bs +0 ubeshort 474 SGI image data +#>2 ubyte 0 \b, verbatim +>2 ubyte 1 \b, RLE +#>3 ubyte 1 \b, normal precision +>3 ubyte 2 \b, high precision +>4 ubeshort x \b, %d-D +>6 ubeshort x \b, %d x +>8 ubeshort x %d +>10 ubeshort x \b, %d channel +>10 ubeshort !1 \bs >80 string >0 \b, "%s" 0 string IT01 FIT image data ->4 belong x \b, %d x ->8 belong x %d x ->12 belong x %d +>4 ubelong x \b, %d x +>8 ubelong x %d x +>12 ubelong x %d # 0 string IT02 FIT image data ->4 belong x \b, %d x ->8 belong x %d x ->12 belong x %d +>4 ubelong x \b, %d x +>8 ubelong x %d x +>12 ubelong x %d # 2048 string PCD_IPI Kodak Photo CD image pack file ->0xe02 byte&0x03 0x00 , landscape mode ->0xe02 byte&0x03 0x01 , portrait mode ->0xe02 byte&0x03 0x02 , landscape mode ->0xe02 byte&0x03 0x03 , portrait mode +>0xe02 ubyte&0x03 0x00 , landscape mode +>0xe02 ubyte&0x03 0x01 , portrait mode +>0xe02 ubyte&0x03 0x02 , landscape mode +>0xe02 ubyte&0x03 0x03 , portrait mode 0 string PCD_OPA Kodak Photo CD overview pack file # FITS format. Jeff Uphoff <juphoff@tarsier.cv.nrao.edu> @@ -1181,7 +1268,7 @@ # From SunOS 5.5.1 "/etc/magic" - appeared right before Sun raster image # stuff. # -0 beshort 0x1010 PEX Binary Archive +0 ubeshort 0x1010 PEX Binary Archive # DICOM medical imaging data # URL: https://en.wikipedia.org/wiki/DICOM#Data_format @@ -1192,23 +1279,138 @@ !:ext dcm/dicom/dic # XWD - X Window Dump file. +# URL: http://fileformats.archiveteam.org/wiki/XWD +# Reference: https://wiki.multimedia.cx/index.php?title=XWD +# http://mark0.net/download/triddefs_xml.7z/defs/x/xdm-x11.trid.xml +# Note: called "X-Windows Screen Dump (X11)" by TrID and +# "X-Windows Screen Dump" version X11 by DROID via PUID fmt/483 +# verfied by XnView `nconvert -in xwd -info *` +# and ImageMagick 6.9.11 `identify -verbose *` as XWD X Windows system window dump +# and `xwud -in fig41.wxd -dumpheader` # As described in /usr/X11R6/include/X11/XWDFile.h # used by the xwd program. # Bradford Castalia, idaeim, 1/01 -# updated by Adam Buchbinder, 2/09 +# updated by Adam Buchbinder, 2/09 and Joerg Jenderek, May 2022 # The following assumes version 7 of the format; the first long is the length # of the header, which is at least 25 4-byte longs, and the one at offset 8 # is a constant which is always either 1 or 2. Offset 12 is the pixmap depth, # which is a maximum of 32. -0 belong >100 ->8 belong <3 ->>12 belong <33 ->>>4 belong 7 XWD X Window Dump image data +# Size of the entire file header (bytes) like: 100 104 105 106 107 109 110 113 114 115 118 172 +0 ubelong >99 +# pixmap_format; Pixmap format; 0~1-bit (XYBitmap) format 1~single-plane (XYPixmap) 2~bitmap with two or more planes (ZPixmap) +>8 ubelong <3 +# pixmap_depth; Pixmap depth; value 1 - 32 +>>12 ubelong <33 +# file_version; XWD_FILE_VERSION=7 +>>>4 ubelong 7 +# skip DROID fmt-401-signature-id-618.xwd by test for existing border field +>>>>96 ubelong x X-Window screen dump image data, version X11 +# ./images (version 1.205) labeled the above entry as "XWD X Window Dump image data" +# https://reposcope.com/mimetype/image/x-xwindowdump +!:mime image/x-xwindowdump +#!:ext xwd +!:ext xwd/dmp +# https://www.xnview.com/en/image_formats/ NO example with x11 suffix FOUND! +#!:ext xwd/dmp/x11 +# https://www.nationalarchives.gov.uk/PRONOM/fmt/401 NO example with xdm suffix FOUND! +#!:ext xwd/dmp/x11/xmd +# file comment if header > 100; so not in MARBLES.XWD and hardcopy-x-window-v11.xwd +>>>>>0 ubelong >100 +# comment or windows name +>>>>>>100 string >\0 \b, "%s" +# pixmap_width; pixmap width like: 576 800 1014 1280 1419 NOT -1414812757=abABabABh +>>>>>16 ubelong x \b, %dx +# pixmap_height; pixmap height like: 449 454 600 704 720 1001 1024 NOT -1414812757=abABabABh +>>>>>20 ubelong x \b%dx +# pixmap_depth; pixmap depth +>>>>>12 ubelong x \b%d +# XOffset; Bitmap X offset; pixel numbers to ignore at the beginning of each scan-line +#>>>>>24 ubelong x \b, %u ignore +# ByteOrder; byte order of image data: 0~least significant byte first 1~most significant byte first +>>>>>28 ubelong >0 \b, order %u +# BitmapUnit; bitmap base data size unit in each scan line like: 8 16 32 +#>>>>>32 ubelong x \b, unit %u +# BitmapBitOrder; bit-order of image data; apparently same as ByteOrder +#>>>>>36 ubelong x \b, bit order %u +# BitmapPad; number of padding bits added to each scan line like: 8 16 32 +#>>>>>40 ubelong x \b, pad %u +# BitsPerPixel; Bits per pixel: 1~StaticGray and GrayScale 2-15~StaticColor and PseudoColor 16,24,32~TrueColor and DirectColor +#>>>>>44 ubelong x \b, %u bits/pixel +# BytesPerLine; size of each scan line in bytes +#>>>>>48 ubelong x \b, %u bytes/line +# VisualClass; class of the image: 0~StaticGray 1~GrayScale 2~StaticColor 3~PseudoColor 4~TrueColor 5~DirectColor +#>>>>>52 ubelong x \b, %u Class +# RedMask; red RGB mask values used by ZPixmaps like: 0 0xff0000 +#>>>>>56 ubelong !0 \b, %#x red +# GreenMask; green mask like: 0 +#>>>>>60 ubelong !0 \b, %#x green +# BlueMask; blue mask like: 0 0xff +#>>>>>64 ubelong !0 \b, %#x blue +# BitsPerRgb; Size of each color mask in bits like: 0 1 8 24 +#>>>>>68 ubelong x \b, %u bits/RGB +# NumberOfColors; number of colors in image like: 256 4 2 0 (WHAT DOES THIS MEAN?) +>>>>>72 ubelong x \b, %u colors +# ColorMapEntries; number of entries in color map like: 256 16 2 0~no color map +>>>>>76 ubelong x %u entries +# WindowWidth; window width +#>>>>>80 ubelong x \b, %u width +# WindowHeight; window height +#>>>>>84 ubelong x \b, %u height +# WindowX; Window upper left X coordinate like: 0 24 32 80 237 290 422 466 568 (lenna.dmp) +>>>>>88 ubelong !0 \b, x=%d +# WindowY; Window upper left Y coordinate like: 0 8 18 26 60 73 107 (fig41.xwd) 128 +>>>>>92 ubelong !0 \b, y=%d +# WindowBorderWidth; Window border width; apparently pixmap_width=WindowWidth+2*WindowBorderWidth +# like: 1 (fig41.xwd) 2 (maze.dmp) 3 (lenna.dmp mandrill.dmp) +>>>>>96 ubelong >0 \b, %u border +# From: Joerg Jenderek +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/x/xdm-x10.trid.xml +# Note: called "X-Windows Screen Dump (X10)" by TrID and +# "X-Windows Screen Dump" version X10 by DROID via PUID x-fmt/300 +# verfied by XnView `nconvert -in xwd -info *` +# HeaderSize is the size of the header in bytes; always 40 for X10 variant +0 ubelong =0x000000028 +# FileVersion; always 6 for X10 variant +>4 ubelong =6 +# skip DROID x-fmt-300-signature-id-619.xdm by test existing border field +>>36 ubeshort x X-Window screen dump image data, version X10 !:mime image/x-xwindowdump ->>>>100 string >\0 \b, "%s" ->>>>16 belong x \b, %dx ->>>>20 belong x \b%dx ->>>>12 belong x \b%d +!:ext xwd +# http://www.nationalarchives.gov.uk/pronom/fmt/401 NO example with xdm suffix FOUND! +#!:ext xwd/xdm +# PixmapWidth; pixmap width like: 127 1280 +>>>20 ubelong x \b, %d +# PixmapHeight; pixmap height like: 64 1024 +>>>24 ubelong x \bx%d +# DisplayPlanes; number of display planes like: 1 4 8 +>>>12 ubelong x \bx%u +# DisplayType; display type like: 1 3 +#>>>8 ubelong x \b, type %u +# PixmapFormat; pixmap format like: 1~bitmap with two or more planes (ZPixmap) 0~single-plane bitmap (XYBitmap) +#>>>16 ubelong x \b, %u format +# WindowWidth; window width; probably PixmapWidth=WindowWidth+2*WindowBorderWidth +#>>>28 ubeshort x \b, width %u +# WindowHeight; window height; probably PixmapWidth=PixmapHeight+2*WindowBorderWidth +#>>>30 ubeshort x \b, height %u +# WindowX; window upper left X coordinate like: 0 +>>>32 ubeshort !0 \b, x=%d +# WindowY; window upper left Y coordinate like: 0 +>>>34 ubeshort !0 \b, y=%d +# WindowBorderWidth; window border width like: 0 +>>>36 ubeshort !0 \b, %u border +# WindowNumColors; Number of color entries in window like: 2 16 256 +#>>>38 ubeshort x \b, %u colors +# if the image is a PseudoColor image, a color map immediately follows the header. X10COLORMAP[WindowNumColors]; +# EntryNumber; number of the color-map entry like: 0 +#>>>40 ubeshort x \b, colors #%u +# Red; red-channel value +#>>>42 ubeshort !0 \b, red %#x +# Green; green-channel value +#>>>44 ubeshort !0 \b, green %#x +# Blue; blue-channel value +#>>>46 ubeshort !0 \b, blue %#x +# 2ND Entry like: 2 +#>>>48 ubeshort x \b, colors #%u # PDS - Planetary Data System # These files use Parameter Value Language in the header section. @@ -1231,15 +1433,174 @@ # used for runs of yy. # 0 string pM85 Atari ST STAD bitmap image data (hor) ->5 byte 0x00 (white background) ->5 byte 0xFF (black background) +>5 ubyte 0x00 (white background) +>5 ubyte 0xFF (black background) 0 string pM86 Atari ST STAD bitmap image data (vert) ->5 byte 0x00 (white background) ->5 byte 0xFF (black background) +>5 ubyte 0x00 (white background) +>5 ubyte 0xFF (black background) # From: Alex Myczko <alex@aiei.ch> # https://www.atarimax.com/jindroush.atari.org/afmtatr.html -0 leshort 0x0296 Atari ATR image +0 uleshort 0x0296 Atari ATR image + +# URL: http://fileformats.archiveteam.org/wiki/DEGAS_image +# Reference: https://wiki.multimedia.cx/index.php?title=Degas +# From: Joerg Jenderek +# http://mark0.net/download/triddefs_xml.7z/defs/b +# bitmap-pi2-degas.trid.xml bitmap-pi3-degas.trid.xml +# bitmap-pc1-degas.trid.xml bitmap-pc2-degas.trid.xml bitmap-pc3-degas.trid.xml +# Note: verified by NetPBM `pi3topbm sigirl1.pi3 | file` +# `deark -m degas -l -d2 ataribak.pi1` +# XnView `nconvert -fullinfo *.p??` +# DEGAS low-res uncompressed bitmap *.pi1 +0 beshort 0x0000 +# skip some ISO 9660 CD-ROM filesystems like plpbt.iso by test for 4 non black colors in palette entries +>2 quad !0 +# skip g3test.g3 by test for unused bits of 2nd color entry +>>4 ubeshort&0xF000 0 +>>>0 use degas-bitmap +# DEGAS mid-res uncompressed bitmap *.pi2 (strength=50) after GEM Images like: +# BEETHVEN.IMG CHURCH.IMG GAMEOVR4.IMG TURKEY.IMG clinton.img +0 beshort 0x0001 +#!:strength +0 +# skip many control files like gnucash-4.8.setup.exe.aria2 by test for non black in 4 palette entries +>2 quad !0 +# skip control file load-v0001.aria2 by test for unused bits of 5th color palette entry +>>10 ubeshort&0xF000 0 +# skip many GEM Image data like DANCER.IMG GAMEOVR4.IMG SHIP.IMG by test for unused bits of 8th color palette entry +>>>16 ubeshort&0xF000 0 +# skip many GEM Image data like BEETHVEN.IMG CABINETS.IMG MEMO.IMG by test for unused bits of 14th color palette entry +>>>>28 ubeshort&0xF000 0 +# skip few GEM Image data like CHURCH.IMG by test for unused bits of 15th color palette entry +>>>>>30 ubeshort&0xF000 0 +# skip many GEM Image data like TIGER.IMG TURKEY.IMG XMAS.IMG by test for unused bits of 16th color palette entry +>>>>>>32 ubeshort&0xF000 0 +# skip GEM Image data like clinton.img by test for existing bytes at the end +>>>>>>>32026 quad x +>>>>>>>>0 use degas-bitmap +# DEGAS high-res uncompressed bitmap *.pi3 +0 beshort 0x0002 +# skip Intel ia64 COFF msvcrt.lib by test for unused bits of 1st atari color palette entry +>2 ubeshort&0xF000 0 +# skip few Adobe PhotoShop Brushes like Faux-Spitzen.abr by check +# for invalid Adobe PhotoShop Brush UTF16-LE string length +>>19 ubyte =0 +# many like: 4th_ofj2.pi3 GEMINI03.PI3 PEOPLE18.PI3 POWERFIX.PI3 abydos.pi3 highres.pi3 sigirl1.pi3 vanna5.pi3 +>>>0 use degas-bitmap +# Adobe PhotoShop Brush UTF16-LE string length 15 "Gitter - klein " 8 "Kreis 1 " +>>19 ubyte !0 +#>>19 ubyte !0 \b, NOTE LENGTH %u +#>>>21 lestring16 x \b, BRUSH NOTE "%s" +>>>(19.b*2) ubequad x +# maybe last character of Adobe PhotoShop Brush UTF16-LE string and terminating nul char like +# 006e0000 for n in "Faux-Spitzen.abr" 00310000 for 1 in "Verschiedene Spitzen.abr" +# 00000000 "LEREDACT.PI3" 03730773 "TBX_DEMO.PI3" +#>>>>&8 ubelong x \b, LAST CHAR+NIL %8.8x +>>>>&8 ubelong&0xff00ffFF !0 +# many DEGAS bitmap like: ARABDEMO.PI3 ELMRSESN.PI3 GEMVIEW.PI3 LEREDACT.PI3 PICCOLO.PI3 REPRO_JR.PI3 ST_TOOLS.PI3 TBX_DEMO.PI3 evgem7.pi3 +>>>>>0 use degas-bitmap +# test for last character of Adobe PhotoShop Brush UTF16-LE string and terminating nul char +>>>>&8 ubelong&0xff00ffFF =0 +# select last DEGAS bitmaps by invalid last char of brush note like BASICNES.PI3 DB_HELP.PI3 DB_WRITR.PI3 LEREDACT.PI3 +>>>>>&-4 ubelong&0x00FF0000 <0x00200000 +>>>>>>0 use degas-bitmap +# last character of Adobe PhotoShop Brush UTF16-LE note +#>>>>>&-4 ubelong&0x00FF0000 >0x001F0000 \b, THAT IS ABR +# DEGAS low-res compressed bitmap *.pc1 like: BATTLSHP.PC1 GNUCHESS.PC1 MEDUSABL.PC1 MOONLORD.PC1 WILDROSE.PC1 +0 beshort 0x8000 +# skip lif files handled via ./lif by test for unused bits of 1st palette entry +>2 ubeshort&0xF000 0 +>>0 use degas-bitmap +# DEGAS mid-res compressed bitmap *.pc2 like: abydos.pc2 ARTIS3.PC2 SMTHDRAW.PC2 STAR_2K.PC2 TX2_DEMO.PC2 +0 beshort 0x8001 +>0 use degas-bitmap +# DEGAS high-res compressed bitmap *.pc3 like: abydos.pc3 COYOTE.PC3 ELEPHANT.PC3 TX2_DEMO.PC3 SMTHDRAW.PC3 +0 beshort 0x8002 +>0 use degas-bitmap +# display information of Atari DEGAS and DEGAS Elite bitmap images +0 name degas-bitmap +>0 ubyte x Atari DEGAS +#!:mime application/octet-stream +!:mime image/x-atari-degas +# compressed +>0 ubyte =0x80 Elite compressed +# uncompressed +#>0 ubyte =0x00 uncompressed +#>0 ubyte =0x00 un. +>0 ubyte =0x00 +# check for existence of footer for DEGAS Elite images +>>32042 ubequad x Elite +>0 beshort 0x0000 bitmap +!:ext pi1 +>0 beshort 0x0001 bitmap +!:ext pi2 +>0 beshort 0x0002 bitmap +# no example with SUH extension found +#!:ext pi3/suh +!:ext pi3 +>0 beshort 0x8000 bitmap +!:ext pc1 +>0 beshort 0x8001 bitmap +!:ext pc2 +>0 beshort 0x8002 bitmap +!:ext pc3 +# low resolution; 320x200, 16 colors +>1 ubyte =0 320 x 200 x 16 +# medium resolution; 640x200, 4 colors +>1 ubyte =1 640 x 200 x 4 +# high resolution; 640x400, 2 colors +>1 ubyte =2 640 x 400 x 2 +# http://fileformats.archiveteam.org/wiki/Atari_ST_color_palette +# hardware_palette[16]; 9 bit ?????RRR?GGG?BBB; 12 bit ????RRRRGGGGBBBB for Atari STE +# for Atari DEGAS apparently no Spectrum 512 Enhanced 15 bit palette RGB?RRRRGGGGBBBB +# Red Green Blue unused bit ? often 0 but not bilboule.pi1; color_value (examples or numbers) +# 1st color palette entry like: 0777 (61) 0fff (LEREDACT.PI3) 0fcf (devgem7.pi3) 0001 (9) +>2 ubeshort x \b, color palette %4.4x +# 2nd palette entry like: 0000 (32) 0700 (38) 0f00 (LEREDACT.PI3 devgem7.pi3) +>4 ubeshort x %4.4x +# 3rd palette entry +>6 ubeshort x %4.4x +# 4th palette entry like: 0000 (72) +>8 ubeshort x %4.4x +# 5th palette entry +>10 ubeshort x %4.4x +>2 ubeshort x ... +# 6th palette entry +#>12 ubeshort x %4.4x +# 7th palette entry like: 0000 (16) 0001 (ELMRSESN.PI3 elmrsesn.pi3) 0070 (51) 00f0 (BASICNES.PI3 LEREDACT.PI3) 00f8 (devgem7.pi3) +#>14 ubeshort x %4.4x +# 8th palette entry +#>16 ubeshort x %4.4x +# 9 palette entry +#>18 ubeshort x %4.4x +# 10 palette entry +#>20 ubeshort x %4.4x +# 11 palette entry +#>22 ubeshort x %4.4x +# 12 palette entry +#>24 ubeshort x %4.4x +# 13 palette entry +#>26 ubeshort x %4.4x +# 14th palette entry +#>28 ubeshort x %4.4x +# 15th palette entry +#>30 ubeshort x %4.4x +# 16th palette entry +#>32 ubeshort x %4.4x +# data[16000] for uncompressed images; pixel data +#>34 ubequad x \b, DATA %#16.16llx... +# footer for Elite variant images +# https://www.fileformat.info/format/atari/egff.htm +# https://pulkomandy.tk/projects/GrafX2/wiki/Develop/FileFormats/Atari +# left_color_animation[4]; like: 0000000000000000 0000000100020003 fffafff000000030 (bigspid.pi1) +#>32034 ubequad !0 \b, color animations %16.16llx (left) +# right_color_animation[4]; like: 0000000000000000 0000000100020003 +#>>32042 ubequad !0 %16.16llx (right) +# channel_direction[4]; 0~left 1~none 2~right like: 0001000100010001 0002000000010001 (cycle2.pi1) +# sometimes unexpected like: feaafc0000000000 (bigspid.pi1) +#>32050 ubequad !0 \b, channel directions %16.16llx +# channel_delay[4]; 128 - channel delay, timebase 1/60 s +#>32058 ubequad !0 \b, channel delays %16.16llx # From: Joerg Jenderek # URL: http://fileformats.archiveteam.org/wiki/ImageLab/PrintTechnic @@ -1261,22 +1622,22 @@ # This is bad magic 0x5249 == 'RI' conflicts with RIFF and other # magic. # SGI RICE image file <mpruett@sgi.com> -#0 beshort 0x5249 RICE image -#>2 beshort x v%d -#>4 beshort x (%d x -#>6 beshort x %d) -#>8 beshort 0 8 bit -#>8 beshort 1 10 bit -#>8 beshort 2 12 bit -#>8 beshort 3 13 bit -#>10 beshort 0 4:2:2 -#>10 beshort 1 4:2:2:4 -#>10 beshort 2 4:4:4 -#>10 beshort 3 4:4:4:4 -#>12 beshort 1 RGB -#>12 beshort 2 CCIR601 -#>12 beshort 3 RP175 -#>12 beshort 4 YUV +#0 ubeshort 0x5249 RICE image +#>2 ubeshort x v%d +#>4 ubeshort x (%d x +#>6 ubeshort x %d) +#>8 ubeshort 0 8 bit +#>8 ubeshort 1 10 bit +#>8 ubeshort 2 12 bit +#>8 ubeshort 3 13 bit +#>10 ubeshort 0 4:2:2 +#>10 ubeshort 1 4:2:2:4 +#>10 ubeshort 2 4:4:4 +#>10 ubeshort 3 4:4:4:4 +#>12 ubeshort 1 RGB +#>12 ubeshort 2 CCIR601 +#>12 ubeshort 3 RP175 +#>12 ubeshort 4 YUV # PCX image files # From: Dan Fandrich <dan@coneharvesters.com> @@ -1303,14 +1664,14 @@ >>>>10 uleshort x %d], >>>>65 ubyte >1 %d planes each of >>>>3 ubyte x %d-bit ->>>>68 byte 1 colour, ->>>>68 byte 2 grayscale, +>>>>68 ubyte 1 colour, +>>>>68 ubyte 2 grayscale, # this should not happen >>>>68 default x image, ->>>>12 leshort >0 %d x +>>>>12 uleshort >0 %d x >>>>>14 uleshort x %d dpi, ->>>>2 byte 0 uncompressed ->>>>2 byte 1 RLE compressed +>>>>2 ubyte 0 uncompressed +>>>>2 ubyte 1 RLE compressed # Adobe Photoshop # From: Asbjoern Sloth Toennesen <asbjorn@lila.io> @@ -1320,7 +1681,7 @@ # and ImageMagick `identify -verbose *.pdd` 0 string 8BPS # skip DROID x-fmt-92-signature-id-277.psd by checking valid width ->18 belong >0 Adobe Photoshop +>18 ubelong >0 Adobe Photoshop !:mime image/vnd.adobe.photoshop !:apple ????8BPS # version: always equal to 1, but 2 for PSB @@ -1408,17 +1769,17 @@ 0 name gem_info # version is 2 for some XIMG and 1 for all others ->0 beshort <0x0003 GEM +>0 ubeshort <0x0003 GEM # https://www.snowstone.org.uk/riscos/mimeman/mimemap.txt !:mime image/x-gem # header_size 24 25 27 59 779 words for colored bitmaps ->>2 beshort >9 +>>2 ubeshort >9 >>>16 string STTT\0\x10 STTT >>>16 string TIMG\0 TIMG # HYPERPAINT or NOSIG variant >>>16 string \0\x80 ->>>>2 beshort =24 NOSIG ->>>>2 beshort !24 HYPERPAINT +>>>>2 ubeshort =24 NOSIG +>>>>2 ubeshort !24 HYPERPAINT # NOSIG or XIMG variant >>>16 default x >>>>16 string !XIMG\0 NOSIG @@ -1428,85 +1789,109 @@ >>16 string !XIMG\0 Image data !:ext img # header_size is 9 for Ventura files and 8 for other GEM Paint files ->>2 beshort 9 (Ventura) -#>>2 beshort 8 (Paint) ->>12 beshort x %d x ->>14 beshort x %d, +>>2 ubeshort 9 (Ventura) +#>>2 ubeshort 8 (Paint) +>>12 ubeshort x %d x +>>14 ubeshort x %d, # 1 4 8 ->>4 beshort x %d planes, +>>4 ubeshort x %d planes, # in tenths of a millimetre ->>8 beshort x %d x ->>10 beshort x %d pixelsize +>>8 ubeshort x %d x +>>10 ubeshort x %d pixelsize # pattern_size 1-8. 2 for GEM Paint ->>6 beshort !2 \b, pattern size %d +>>6 ubeshort !2 \b, pattern size %d # GEM Metafile (Wolfram Kleff) -0 lelong 0x0018FFFF GEM Metafile data ->4 leshort x version %d +0 ulelong 0x0018FFFF GEM Metafile data +>4 uleshort x version %d # # SMJPEG. A custom Motion JPEG format used by Loki Entertainment # Software Torbjorn Andersson <d91tan@Update.UU.SE>. # 0 string \0\nSMJPEG SMJPEG ->8 belong x %d.x data +>8 ubelong x %d.x data # According to the specification you could find any number of _TXT # headers here, but I can't think of any way of handling that. None of # the SMJPEG files I tried it on used this feature. Even if such a # file is encountered the output should still be reasonable. ->16 string _SND \b, ->>24 beshort >0 %d Hz ->>26 byte 8 8-bit ->>26 byte 16 16-bit ->>28 string NONE uncompressed -# >>28 string APCM ADPCM compressed ->>27 byte 1 mono ->>28 byte 2 stereo +>16 string _SND \b, +>>24 ubeshort >0 %d Hz +>>26 ubyte 8 8-bit +>>26 ubyte 16 16-bit +>>28 string NONE uncompressed +# >>28 string APCM ADPCM compressed +>>27 ubyte 1 mono +>>28 ubyte 2 stereo # Help! Isn't there any way to avoid writing this part twice? ->>32 string _VID \b, -# >>>48 string JFIF JPEG ->>>40 belong >0 %d frames ->>>44 beshort >0 (%d x ->>>46 beshort >0 %d) ->16 string _VID \b, -# >>32 string JFIF JPEG ->>24 belong >0 %d frames ->>28 beshort >0 (%d x ->>30 beshort >0 %d) +# Yes, use a name/use +>>32 string _VID \b, +# >>>48 string JFIF JPEG +>>>40 ubelong >0 %d frames +>>>44 ubeshort >0 (%d x +>>>46 ubeshort >0 %d) +>16 string _VID \b, +# >>32 string JFIF JPEG +>>24 ubelong >0 %d frames +>>28 ubeshort >0 (%d x +>>30 ubeshort >0 %d) 0 string Paint\ Shop\ Pro\ Image\ File Paint Shop Pro Image File # taken from fkiss: (<yav@mte.biglobe.ne.jp> ?) -0 string KiSS KISS/GS ->4 byte 16 color ->>5 byte x %d bit ->>8 leshort x %d colors ->>10 leshort x %d groups ->4 byte 32 cell ->>5 byte x %d bit ->>8 leshort x %d x ->>10 leshort x %d ->>12 leshort x +%d ->>14 leshort x +%d +0 string KiSS KISS/GS +>4 ubyte 16 color +>>5 ubyte x %d bit +>>8 uleshort x %d colors +>>10 uleshort x %d groups +>4 ubyte 32 cell +>>5 ubyte x %d bit +>>8 uleshort x %d x +>>10 uleshort x %d +>>12 uleshort x +%d +>>14 uleshort x +%d # Webshots (www.webshots.com), by John Harrison 0 string C\253\221g\230\0\0\0 Webshots Desktop .wbz file # Hercules DASD image files -# From Jan Jaeger <jj@septa.nl> +# From Jan Jaeger <jj@septa.nl> and Jay Maynard <jaymaynard@gmail.com> 0 string CKD_P370 Hercules CKD DASD image file ->8 long x \b, %d heads per cylinder ->12 long x \b, track size %d bytes +>8 lelong x \b, %d heads per cylinder +>12 lelong x \b, track size %d bytes >16 byte x \b, device type 33%2.2X 0 string CKD_C370 Hercules compressed CKD DASD image file ->8 long x \b, %d heads per cylinder ->12 long x \b, track size %d bytes +>8 lelong x \b, %d heads per cylinder +>12 lelong x \b, track size %d bytes >16 byte x \b, device type 33%2.2X +>552 lelong x \b, %d total cylinders +>>557 byte 0 \b, no compression +>>557 byte 1 \b, ZLIB compression +>>557 byte 2 \b, BZ2 compression 0 string CKD_S370 Hercules CKD DASD shadow file ->8 long x \b, %d heads per cylinder ->12 long x \b, track size %d bytes +>8 lelong x \b, %d heads per cylinder +>12 lelong x \b, track size %d bytes +>16 byte x \b, device type 33%2.2X + +0 string CKD_P064 Hercules CKD64 DASD image file +>8 lelong x \b, %d heads per cylinder +>12 lelong x \b, track size %d bytes +>16 byte x \b, device type 33%2.2X + +0 string CKD_C064 Hercules compressed CKD64 DASD image file +>8 lelong x \b, %d heads per cylinder +>12 lelong x \b, track size %d bytes +>16 byte x \b, device type 33%2.2X +>524 lelong x \b, %d total cylinders +>>585 byte 0 \b, no compression +>>585 byte 1 \b, ZLIB compression +>>585 byte 2 \b, BZ2 compression + +0 string CKD_S064 Hercules CKD64 DASD shadow file +>8 lelong x \b, %d heads per cylinder +>12 lelong x \b, track size %d bytes >16 byte x \b, device type 33%2.2X # Squeak images and programs - etoffi@softhome.net @@ -1517,17 +1902,17 @@ # Author: Hans-Joachim Baader <hjb@pro-linux.de> 0 string PaRtImAgE-VoLuMe PartImage >0x0020 string 0.6.1 file version %s ->>0x0060 lelong >-1 volume %d +>>0x0060 ulelong >-1 volume %d #>>0x0064 8 byte identifier #>>0x007c reserved >>0x0200 string >\0 type %s >>0x1400 string >\0 device %s, >>0x1600 string >\0 original filename %s, # Some fields omitted ->>0x2744 lelong 0 not compressed ->>0x2744 lelong 1 gzip compressed ->>0x2744 lelong 2 bzip2 compressed ->>0x2744 lelong >2 compressed with unknown algorithm +>>0x2744 ulelong 0 not compressed +>>0x2744 ulelong 1 gzip compressed +>>0x2744 ulelong 2 bzip2 compressed +>>0x2744 ulelong >2 compressed with unknown algorithm >0x0020 string >0.6.1 file version %s >0x0020 string <0.6.1 file version %s @@ -1536,27 +1921,27 @@ # From: Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de> # Update: Joerg Jenderek # URL: http://fileformats.archiveteam.org/wiki/DCX -0 lelong 987654321 DCX multi-page +0 ulelong 987654321 DCX multi-page # http://www.nationalarchives.gov.uk/pronom/x-fmt/348 !:mime image/x-dcx !:ext dcx # The first file offset usually starts at file offset 0x1004 # print 1 space after 0x100? offset and then handles PCX images by ./images ->4 lelong x \b, at %#x +>4 ulelong x \b, at %#x >(4.l) indirect x # possible 2nd PCX image -#>8 lelong !0 \b, at %#x +#>8 ulelong !0 \b, at %#x #>>(8.l) indirect x # possible 3rd PCX image -#>12 lelong !0 \b, at %#x +#>12 ulelong !0 \b, at %#x #>>(12.l) indirect x # Simon Walton <simonw@matteworld.com> # Kodak Cineon format for scanned negatives # http://www.kodak.com/US/en/motion/support/dlad/ -0 lelong 0xd75f2a80 Cineon image data ->200 belong >0 \b, %d x ->204 belong >0 %d +0 ulelong 0xd75f2a80 Cineon image data +>200 ubelong >0 \b, %d x +>204 ubelong >0 %d # Bio-Rad .PIC is an image format used by microscope control systems @@ -1565,13 +1950,13 @@ # BOOL values are two-byte integers; use them to rule out false positives. # https://web.archive.org/web/20050317223257/www.cs.ubc.ca/spider/ladic/text/biorad.txt # Samples: https://www.loci.wisc.edu/software/sample-data -14 leshort <2 ->62 leshort <2 ->>54 leshort 12345 Bio-Rad .PIC Image File ->>>0 leshort >0 %d x ->>>2 leshort >0 %d, ->>>4 leshort =1 1 image in file ->>>4 leshort >1 %d images in file +14 uleshort <2 +>62 uleshort <2 +>>54 uleshort 12345 Bio-Rad .PIC Image File +>>>0 uleshort >0 %d x +>>>2 uleshort >0 %d, +>>>4 uleshort =1 1 image in file +>>>4 uleshort >1 %d images in file # From Jan "Yenya" Kasprzak <kas@fi.muni.cz> # The description of *.mrw format can be found at @@ -1596,38 +1981,38 @@ # Originally by Marc Espie # Modified by Robert Minsk <robertminsk at yahoo.com> # https://www.openexr.com/openexrfilelayout.pdf -0 lelong 20000630 OpenEXR image data, +0 ulelong 20000630 OpenEXR image data, !:mime image/x-exr ->4 lelong&0x000000ff x version %d, ->4 lelong ^0x00000200 storage: scanline ->4 lelong &0x00000200 storage: tiled +>4 ulelong&0x000000ff x version %d, +>4 ulelong ^0x00000200 storage: scanline +>4 ulelong &0x00000200 storage: tiled >8 search/0x1000 compression\0 \b, compression: ->>&16 byte 0 none ->>&16 byte 1 rle ->>&16 byte 2 zips ->>&16 byte 3 zip ->>&16 byte 4 piz ->>&16 byte 5 pxr24 ->>&16 byte 6 b44 ->>&16 byte 7 b44a ->>&16 byte 8 dwaa ->>&16 byte 9 dwab ->>&16 byte >9 unknown +>>&16 ubyte 0 none +>>&16 ubyte 1 rle +>>&16 ubyte 2 zips +>>&16 ubyte 3 zip +>>&16 ubyte 4 piz +>>&16 ubyte 5 pxr24 +>>&16 ubyte 6 b44 +>>&16 ubyte 7 b44a +>>&16 ubyte 8 dwaa +>>&16 ubyte 9 dwab +>>&16 ubyte >9 unknown >8 search/0x1000 dataWindow\0 \b, dataWindow: ->>&10 lelong x (%d ->>&14 lelong x %d)- ->>&18 lelong x \b(%d ->>&22 lelong x %d) +>>&10 ulelong x (%d +>>&14 ulelong x %d)- +>>&18 ulelong x \b(%d +>>&22 ulelong x %d) >8 search/0x1000 displayWindow\0 \b, displayWindow: ->>&10 lelong x (%d ->>&14 lelong x %d)- ->>&18 lelong x \b(%d ->>&22 lelong x %d) +>>&10 ulelong x (%d +>>&14 ulelong x %d)- +>>&18 ulelong x \b(%d +>>&22 ulelong x %d) >8 search/0x1000 lineOrder\0 \b, lineOrder: ->>&14 byte 0 increasing y ->>&14 byte 1 decreasing y ->>&14 byte 2 random y ->>&14 byte >2 unknown +>>&14 ubyte 0 increasing y +>>&14 ubyte 1 decreasing y +>>&14 ubyte 2 random y +>>&14 ubyte >2 unknown # SMPTE Digital Picture Exchange Format, SMPTE DPX # @@ -1643,36 +2028,59 @@ >0 use \^dpx_info 0 name dpx_info ->768 beshort <4 ->>772 belong x %dx ->>776 belong x \b%d, ->768 beshort >3 ->>776 belong x %dx ->>772 belong x \b%d, ->768 beshort 0 left to right/top to bottom ->768 beshort 1 right to left/top to bottom ->768 beshort 2 left to right/bottom to top ->768 beshort 3 right to left/bottom to top ->768 beshort 4 top to bottom/left to right ->768 beshort 5 top to bottom/right to left ->768 beshort 6 bottom to top/left to right ->768 beshort 7 bottom to top/right to left +>768 ubeshort <4 +>>772 ubelong x %dx +>>776 ubelong x \b%d, +>768 ubeshort >3 +>>776 ubelong x %dx +>>772 ubelong x \b%d, +>768 ubeshort 0 left to right/top to bottom +>768 ubeshort 1 right to left/top to bottom +>768 ubeshort 2 left to right/bottom to top +>768 ubeshort 3 right to left/bottom to top +>768 ubeshort 4 top to bottom/left to right +>768 ubeshort 5 top to bottom/right to left +>768 ubeshort 6 bottom to top/left to right +>768 ubeshort 7 bottom to top/right to left # From: Tom Hilinski <tom.hilinski@comcast.net> -# https://www.unidata.ucar.edu/software/netcdf/ -0 string CDF\001 NetCDF Data Format data +# Update: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/NetCDF +# http://fileformats.archiveteam.org/wiki/NetCDF +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/n/netcdf.trid.xml +# https://www.loc.gov/preservation/digital/formats/fdd/fdd000330.shtml +# Note: called "NetCDF Network Common Data Form" by TrID and +# "netCDF-3 Classic" by DROID via PUID fmt/282 +# https://www.unidata.ucar.edu/packages/netcdf/ +0 string CDF\001 +# skip DROID fmt-282-signature-id-298.nc by test for more content bytes +>3 uleshort >0 NetCDF Data Format data +#!:mime application/netcdf +# https://reposcope.com/mimetype/application/x-netcdf +!:mime application/x-netcdf +!:ext nc +# https://fileinfo.com/extension/cdf +# https://www.file-extensions.org/cdf-file-extension-unidata-network-common-data-form +# in 1994 changed from CDF to NC file extension avoid a clash with other file formats +#!:ext nc/cdf # 64-bit offset netcdf Classic https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications -0 string CDF\002 NetCDF Data Format data (64-bit offset) +# Note: called "netCDF-3 64-bit" by DROID via PUID fmt/283 +0 string CDF\002 +# skip DROID fmt-283-signature-id-299.nc by test for more content bytes +>3 uleshort >0 NetCDF Data Format data (64-bit offset) +#!:mime application/netcdf +!:mime application/x-netcdf +!:ext nc # From: Michael Liu # https://en.wikipedia.org/wiki/Common_Data_Format -0 belong 0xCDF30001 Common Data Format (Version 3 or later) data +0 ubelong 0xCDF30001 Common Data Format (Version 3 or later) data !:mime application/x-cdf -0 belong 0xCDF26002 Common Data Format (Version 2.6 or 2.7) data +0 ubelong 0xCDF26002 Common Data Format (Version 2.6 or 2.7) data !:mime application/x-cdf -0 belong 0x0000FFFF Common Data Format (Version 2.5 or earlier) data +0 ubelong 0x0000FFFF Common Data Format (Version 2.5 or earlier) data !:mime application/x-cdf # Hierarchical Data Format, used to facilitate scientific data exchange @@ -1680,7 +2088,7 @@ # URL: http://fileformats.archiveteam.org/wiki/HDF # https://en.wikipedia.org/wiki/Hierarchical_Data_Format # Reference: https://portal.hdfgroup.org/download/attachments/52627880/HDF5_File_Format_Specification_Version-3.0.pdf -0 belong 0x0e031301 Hierarchical Data Format (version 4) data +0 ubelong 0x0e031301 Hierarchical Data Format (version 4) data !:mime application/x-hdf !:ext hdf/hdf4/h4 0 string \211HDF\r\n\032\n Hierarchical Data Format (version 5) data @@ -1728,15 +2136,15 @@ # From Albert Cahalan <acahalan@gmail.com> # puredigital used it for the CVS disposable camcorder -#8 lelong 4 ZBM bitmap image data -#>4 leshort x %u x -#>6 leshort x %u +#8 lelong 4 ZBM bitmap image data +#>4 uleshort x %u x +#>6 uleshort x %u # From Albert Cahalan <acahalan@gmail.com> # uncompressed 5:6:5 HighColor image for OLPC XO firmware icons -0 string C565 OLPC firmware icon image data ->4 leshort x %u x ->6 leshort x %u +0 string C565 OLPC firmware icon image data +>4 uleshort x %u x +>6 uleshort x %u # Applied Images - Image files from Cytovision # Gustavo Junior Alves <gjalves@gjalves.com.br> @@ -1760,24 +2168,24 @@ # Note: Different versions exist for e.g. 8 bit and 16 bit images. # Documentation is incomplete. 0 string/b PCO- PCO B16 image data ->12 lelong x \b, %dx ->16 lelong x \b%d ->20 lelong 0 \b, short header ->20 lelong -1 \b, extended header ->>24 lelong 0 \b, grayscale ->>>36 lelong 0 linear LUT ->>>36 lelong 1 logarithmic LUT ->>>28 lelong x [%d ->>>32 lelong x \b,%d] ->>24 lelong 1 \b, color ->>>64 lelong 0 linear LUT ->>>64 lelong 1 logarithmic LUT ->>>40 lelong x r[%d ->>>44 lelong x \b,%d] ->>>48 lelong x g[%d ->>>52 lelong x \b,%d] ->>>56 lelong x b[%d ->>>60 lelong x \b,%d] +>12 ulelong x \b, %dx +>16 ulelong x \b%d +>20 ulelong 0 \b, short header +>20 ulelong -1 \b, extended header +>>24 ulelong 0 \b, grayscale +>>>36 ulelong 0 linear LUT +>>>36 ulelong 1 logarithmic LUT +>>>28 ulelong x [%d +>>>32 ulelong x \b,%d] +>>24 ulelong 1 \b, color +>>>64 ulelong 0 linear LUT +>>>64 ulelong 1 logarithmic LUT +>>>40 ulelong x r[%d +>>>44 ulelong x \b,%d] +>>>48 ulelong x g[%d +>>>52 ulelong x \b,%d] +>>>56 ulelong x b[%d +>>>60 ulelong x \b,%d] # Polar Monitor Bitmap (.pmb) used as logo for Polar Electro watches # From: Markus Heidelberg <markus.heidelberg at web.de> @@ -1840,8 +2248,8 @@ # actual common use, it should replace the one below. 0 string PFS1\x0a PFS HDR image data #!mime image/x-pfs ->1 regex [0-9]*\ \b, %s ->>1 regex \ [0-9]{4} \bx%s +>1 regex [0-9]*\ \b, %s +>>1 regex \ [0-9]{4} \bx%s # Type: Foveon X3F # URL: https://www.photofo.com/downloads/x3f-raw-format.pdf @@ -1850,10 +2258,10 @@ # there's a canonical type for this format, it should replace this one. 0 string FOVb Foveon X3F raw image data !:mime image/x-x3f ->6 leshort x \b, version %d. ->4 leshort x \b%d ->28 lelong x \b, %dx ->32 lelong x \b%d +>6 uleshort x \b, version %d. +>4 uleshort x \b%d +>28 ulelong x \b, %dx +>32 ulelong x \b%d # Paint.NET file # From Adam Buchbinder <adam.buchbinder@gmail.com> @@ -1866,53 +2274,53 @@ # doc: https://www.shikino.co.jp/eng/products/images/FLOWER.jpg.zip # example: https://www.shikino.co.jp/eng/products/images/FLOWER.wdp.zip -90 bequad 0x574D50484F544F00 JPEG-XR Image ->98 byte&0x08 =0x08 \b, hard tiling ->99 byte&0x80 =0x80 \b, tiling present ->99 byte&0x40 =0x40 \b, codestream present ->99 byte&0x38 x \b, spatial xform= ->99 byte&0x38 0x00 \bTL ->99 byte&0x38 0x08 \bBL ->99 byte&0x38 0x10 \bTR ->99 byte&0x38 0x18 \bBR ->99 byte&0x38 0x20 \bBT ->99 byte&0x38 0x28 \bRB ->99 byte&0x38 0x30 \bLT ->99 byte&0x38 0x38 \bLB ->100 byte&0x80 =0x80 \b, short header ->>102 beshort+1 x \b, %d ->>104 beshort+1 x \bx%d ->100 byte&0x80 =0x00 \b, long header ->>102 belong+1 x \b, %x ->>106 belong+1 x \bx%x ->101 beshort&0xf x \b, bitdepth= ->>101 beshort&0xf 0x0 \b1-WHITE=1 ->>101 beshort&0xf 0x1 \b8 ->>101 beshort&0xf 0x2 \b16 ->>101 beshort&0xf 0x3 \b16-SIGNED ->>101 beshort&0xf 0x4 \b16-FLOAT ->>101 beshort&0xf 0x5 \b(reserved 5) ->>101 beshort&0xf 0x6 \b32-SIGNED ->>101 beshort&0xf 0x7 \b32-FLOAT ->>101 beshort&0xf 0x8 \b5 ->>101 beshort&0xf 0x9 \b10 ->>101 beshort&0xf 0xa \b5-6-5 ->>101 beshort&0xf 0xb \b(reserved %d) ->>101 beshort&0xf 0xc \b(reserved %d) ->>101 beshort&0xf 0xd \b(reserved %d) ->>101 beshort&0xf 0xe \b(reserved %d) ->>101 beshort&0xf 0xf \b1-BLACK=1 ->101 beshort&0xf0 x \b, colorfmt= ->>101 beshort&0xf0 0x00 \bYONLY ->>101 beshort&0xf0 0x10 \bYUV240 ->>101 beshort&0xf0 0x20 \bYWV422 ->>101 beshort&0xf0 0x30 \bYWV444 ->>101 beshort&0xf0 0x40 \bCMYK ->>101 beshort&0xf0 0x50 \bCMYKDIRECT ->>101 beshort&0xf0 0x60 \bNCOMPONENT ->>101 beshort&0xf0 0x70 \bRGB ->>101 beshort&0xf0 0x80 \bRGBE ->>101 beshort&0xf0 >0x80 \b(reserved %#x) +90 ubequad 0x574D50484F544F00 JPEG-XR Image +>98 ubyte&0x08 =0x08 \b, hard tiling +>99 ubyte&0x80 =0x80 \b, tiling present +>99 ubyte&0x40 =0x40 \b, codestream present +>99 ubyte&0x38 x \b, spatial xform= +>99 ubyte&0x38 0x00 \bTL +>99 ubyte&0x38 0x08 \bBL +>99 ubyte&0x38 0x10 \bTR +>99 ubyte&0x38 0x18 \bBR +>99 ubyte&0x38 0x20 \bBT +>99 ubyte&0x38 0x28 \bRB +>99 ubyte&0x38 0x30 \bLT +>99 ubyte&0x38 0x38 \bLB +>100 ubyte&0x80 =0x80 \b, short header +>>102 ubeshort+1 x \b, %d +>>104 ubeshort+1 x \bx%d +>100 ubyte&0x80 =0x00 \b, long header +>>102 ubelong+1 x \b, %x +>>106 ubelong+1 x \bx%x +>101 ubeshort&0xf x \b, bitdepth= +>>101 ubeshort&0xf 0x0 \b1-WHITE=1 +>>101 ubeshort&0xf 0x1 \b8 +>>101 ubeshort&0xf 0x2 \b16 +>>101 ubeshort&0xf 0x3 \b16-SIGNED +>>101 ubeshort&0xf 0x4 \b16-FLOAT +>>101 ubeshort&0xf 0x5 \b(reserved 5) +>>101 ubeshort&0xf 0x6 \b32-SIGNED +>>101 ubeshort&0xf 0x7 \b32-FLOAT +>>101 ubeshort&0xf 0x8 \b5 +>>101 ubeshort&0xf 0x9 \b10 +>>101 ubeshort&0xf 0xa \b5-6-5 +>>101 ubeshort&0xf 0xb \b(reserved %d) +>>101 ubeshort&0xf 0xc \b(reserved %d) +>>101 ubeshort&0xf 0xd \b(reserved %d) +>>101 ubeshort&0xf 0xe \b(reserved %d) +>>101 ubeshort&0xf 0xf \b1-BLACK=1 +>101 ubeshort&0xf0 x \b, colorfmt= +>>101 ubeshort&0xf0 0x00 \bYONLY +>>101 ubeshort&0xf0 0x10 \bYUV240 +>>101 ubeshort&0xf0 0x20 \bYWV422 +>>101 ubeshort&0xf0 0x30 \bYWV444 +>>101 ubeshort&0xf0 0x40 \bCMYK +>>101 ubeshort&0xf0 0x50 \bCMYKDIRECT +>>101 ubeshort&0xf0 0x60 \bNCOMPONENT +>>101 ubeshort&0xf0 0x70 \bRGB +>>101 ubeshort&0xf0 0x80 \bRGBE +>>101 ubeshort&0xf0 >0x80 \b(reserved %#x) # From: Johan van der Knijff <johan.vanderknijff@kb.nl> # @@ -1944,82 +2352,82 @@ # by RECOIL `recoil2png -o TMP.PNG input.tim; file TMP.PNG` and often # as "PSX TIM" by ImageMagick version 7.1.0-10 command `identify *.tim` # here signed integers are used but according to Kaitai unsigned -0 lelong 0x00000010 +0 ulelong 0x00000010 # 32 Flag bits *cttt; c~CLUT flag t~type 000~4BPP 001~8BPP 010~16BPP 011~24BPP 100~Mixed -#>4 lelong x FLAGS=%#x +#>4 ulelong x FLAGS=%#x # 12+Size of CLUT (2Ch for 4BPP; 20Ch 40Ch 60Ch 80Ch C0Ch for 8BPP) or # +image data size (800Ch 2000Ch 2580C for 16BPP) (02000003h for dBase memo test.dbt) -#>8 lelong x \b, 12+CLUT or data size=%#8.8x +#>8 ulelong x \b, 12+CLUT or data size=%#8.8x # CLUT or data size remainder is 12 (Ch), but 03 for dBase memo test.dbt #>8 ubyte&0x0F =0x0C \b, SIZE REMAINDER IS 12 # skip dBase III memo test.dbt with invalid flags 22D10189h ->4 lelong&0xffFFffF0 =0 Sony PlayStation PSX image, +>4 ulelong&0xffFFffF0 =0 Sony PlayStation PSX image, # file (version 5.40) labeled the above entry as "TIM image" !:mime image/x-sony-tim !:ext tim -#>>4 lelong&0x00000007 x \b, BPP~%u +#>>4 ulelong&0x00000007 x \b, BPP~%u # 4BPP and 8BPP examples exist with CLUT or without CLUT ->>4 lelong&0x07 0x0 4-Bit, ->>4 lelong&0x07 0x1 8-Bit, +>>4 ulelong&0x07 0x0 4-Bit, +>>4 ulelong&0x07 0x1 8-Bit, # 16BPP and 24BPP examples have no CLUT ->>4 lelong 0x2 15-Bit, ->>4 lelong 0x3 24-Bit, +>>4 ulelong 0x2 15-Bit, +>>4 ulelong 0x3 24-Bit, # no example ->>4 lelong&0x07 0x4 Mixed-Bit, +>>4 ulelong&0x07 0x4 Mixed-Bit, # CLUT flag set ->>4 lelong &8 +>>4 ulelong &8 # 12 + size of CLUT like: 1000Ch 800Ch 400Ch 40Ch and 2FEh (KAGE.TIM) -#>>>(8.l+8) lelong x \b, 12+CLUT SIZE=%#8.8x ->>>(8.l+12) leshort x Pixel at (%d, ->>>(8.l+14) leshort x \b%d) Size= +#>>>(8.l+8) ulelong x \b, 12+CLUT SIZE=%#8.8x +>>>(8.l+12) uleshort x Pixel at (%d, +>>>(8.l+14) uleshort x \b%d) Size= # image width (to get actual width multiply by 4 for 4BPP and by 2 for 8BPP) ->>>>4 lelong 0x8 ->>>>>(8.l+16) leshort*4 x \b%d ->>>>4 lelong 0x9 ->>>>>(8.l+16) leshort*2 x \b%d +>>>>4 ulelong 0x8 +>>>>>(8.l+16) uleshort*4 x \b%d +>>>>4 ulelong 0x9 +>>>>>(8.l+16) uleshort*2 x \b%d # image height like: 32 64 128 144 160 208 256 ->>>(8.l+18) leshort x \bx%d, ->>>4 lelong 0x8 16 CLUT Entries at ->>>4 lelong 0x9 256 CLUT Entries at ->>>12 leshort x (%d, ->>>14 leshort x \b%d) +>>>(8.l+18) uleshort x \bx%d, +>>>4 ulelong 0x8 16 CLUT Entries at +>>>4 ulelong 0x9 256 CLUT Entries at +>>>12 uleshort x (%d, +>>>14 uleshort x \b%d) # no Color LookUp Table (CLUT) ->>4 lelong ^8 -# image orgin X Y ->>>12 leshort x Pixel at (%d, ->>>14 leshort x \b%d) Size= +>>4 ulelong ^8 +# image origin X Y +>>>12 uleshort x Pixel at (%d, +>>>14 uleshort x \b%d) Size= # real image width = multiply by 4 (4BPP) 2 (8BPP) 1 (16BPP) 2/3 (24BPP) ->>>>4 lelong 0x0 ->>>>>16 leshort*4 x \b%d ->>>>4 lelong 0x1 ->>>>>16 leshort*2 x \b%d ->>>>4 lelong 0x2 ->>>>>16 leshort x \b%d ->>>>4 lelong 0x3 +>>>>4 ulelong 0x0 +>>>>>16 uleshort*4 x \b%d +>>>>4 ulelong 0x1 +>>>>>16 uleshort*2 x \b%d +>>>>4 ulelong 0x2 +>>>>>16 uleshort x \b%d +>>>>4 ulelong 0x3 # GRR: NOT working -#>>>>>16 leshort*2/3 x \b%d ->>>>>16 leshort x \b2/3*%d +#>>>>>16 uleshort*2/3 x \b%d +>>>>>16 uleshort x \b2/3*%d # mixed format width not explained! ->>>>4 lelong 0x4 ->>>>>16 leshort x \b%d +>>>>4 ulelong 0x4 +>>>>>16 uleshort x \b%d # image height like: 64 240 256 ->>>18 leshort x \bx%d +>>>18 uleshort x \bx%d # TIM image data # MDEC streams -0 lelong 0x80010160 MDEC video stream, ->16 leshort x %dx ->18 leshort x \b%d -#>8 lelong x %d frames -#>4 leshort x secCount=%d; -#>6 leshort x nSectors=%d; -#>12 lelong x frameSize=%d; +0 ulelong 0x80010160 MDEC video stream, +>16 uleshort x %dx +>18 uleshort x \b%d +#>8 ulelong x %d frames +#>4 uleshort x secCount=%d; +#>6 uleshort x nSectors=%d; +#>12 ulelong x frameSize=%d; # BS encoded bitstreams -2 leshort 0x3800 BS image, ->6 leshort x Version %d, ->4 leshort x Quantization %d, ->0 leshort x (Decompresses to %d words) +2 uleshort 0x3800 BS image, +>6 uleshort x Version %d, +>4 uleshort x Quantization %d, +>0 uleshort x (Decompresses to %d words) # Type: farbfeld image. # Url: http://tools.suckless.org/farbfeld/ @@ -2029,6 +2437,185 @@ >8 ubelong x %dx >12 ubelong x \b%d +# Type: Microsoft DirectDraw Surface (DXGI formats) +# URL: https://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/DDSFileReference/ddsfileformat.asp +# From: Morten Hustveit <morten@debian.org> +# Updated by: David Korth <gerbilsoft@gerbilsoft.com> +0 name ms-directdraw-dx10 +>0 ulelong x \b, DXGI format: +>0 ulelong 1 R32G32B32A32_TYPELESS +>0 ulelong 2 R32G32B32A32_FLOAT +>0 ulelong 3 R32G32B32A32_UINT +>0 ulelong 4 R32G32B32A32_SINT +>0 ulelong 5 R32G32B32_TYPELESS +>0 ulelong 6 R32G32B32_FLOAT +>0 ulelong 7 R32G32B32_UINT +>0 ulelong 8 R32G32B32_SINT +>0 ulelong 9 R16G16B16A16_TYPELESS +>0 ulelong 10 R16G16B16A16_FLOAT +>0 ulelong 11 R16G16B16A16_UNORM +>0 ulelong 12 R16G16B16A16_UINT +>0 ulelong 13 R16G16B16A16_SNORM +>0 ulelong 14 R16G16B16A16_SINT +>0 ulelong 15 R32G32_TYPELESS +>0 ulelong 16 R32G32_FLOAT +>0 ulelong 17 R32G32_UINT +>0 ulelong 18 R32G32_SINT +>0 ulelong 19 R32G8X24_TYPELESS +>0 ulelong 20 D32_FLOAT_S8X24_UINT +>0 ulelong 21 R32_FLOAT_X8X24_TYPELESS +>0 ulelong 22 X32_TYPELESS_G8X24_UINT +>0 ulelong 23 R10G10B10A2_TYPELESS +>0 ulelong 24 R10G10B10A2_UNORM +>0 ulelong 25 R10G10B10A2_UINT +>0 ulelong 26 R11G11B10_FLOAT +>0 ulelong 27 R8G8B8A8_TYPELESS +>0 ulelong 28 R8G8B8A8_UNORM +>0 ulelong 29 R8G8B8A8_UNORM_SRGB +>0 ulelong 30 R8G8B8A8_UINT +>0 ulelong 31 R8G8B8A8_SNORM +>0 ulelong 32 R8G8B8A8_SINT +>0 ulelong 33 R16G16_TYPELESS +>0 ulelong 34 R16G16_FLOAT +>0 ulelong 35 R16G16_UNORM +>0 ulelong 36 R16G16_UINT +>0 ulelong 37 R16G16_SNORM +>0 ulelong 38 R16G16_SINT +>0 ulelong 39 R32_TYPELESS +>0 ulelong 40 D32_FLOAT +>0 ulelong 41 R32_FLOAT +>0 ulelong 42 R32_UINT +>0 ulelong 43 R32_SINT +>0 ulelong 44 R24G8_TYPELESS +>0 ulelong 45 D24_UNORM_S8_UINT +>0 ulelong 46 R24_UNORM_X8_TYPELESS +>0 ulelong 47 X24_TYPELESS_G8_UINT +>0 ulelong 48 R8G8_TYPELESS +>0 ulelong 49 R8G8_UNORM +>0 ulelong 50 R8G8_UINT +>0 ulelong 51 R8G8_SNORM +>0 ulelong 52 R8G8_SINT +>0 ulelong 53 R16_TYPELESS +>0 ulelong 54 R16_FLOAT +>0 ulelong 55 D16_UNORM +>0 ulelong 56 R16_UNORM +>0 ulelong 57 R16_UINT +>0 ulelong 58 R16_SNORM +>0 ulelong 59 R16_SINT +>0 ulelong 60 R8_TYPELESS +>0 ulelong 61 R8_UNORM +>0 ulelong 62 R8_UINT +>0 ulelong 63 R8_SNORM +>0 ulelong 64 R8_SINT +>0 ulelong 65 A8_UNORM +>0 ulelong 66 R1_UNORM +>0 ulelong 67 R9G9B9E5_SHAREDEXP +>0 ulelong 68 R8G8_B8G8_UNORM +>0 ulelong 69 G8R8_G8B8_UNORM +>0 ulelong 70 BC1_TYPELESS +>0 ulelong 71 BC1_UNORM +>0 ulelong 72 BC1_UNORM_SRGB +>0 ulelong 73 BC2_TYPELESS +>0 ulelong 74 BC2_UNORM +>0 ulelong 75 BC2_UNORM_SRGB +>0 ulelong 76 BC3_TYPELESS +>0 ulelong 77 BC3_UNORM +>0 ulelong 78 BC3_UNORM_SRGB +>0 ulelong 79 BC4_TYPELESS +>0 ulelong 80 BC4_UNORM +>0 ulelong 81 BC4_SNORM +>0 ulelong 82 BC5_TYPELESS +>0 ulelong 83 BC5_UNORM +>0 ulelong 84 BC5_SNORM +>0 ulelong 85 B5G6R5_UNORM +>0 ulelong 86 B5G5R5A1_UNORM +>0 ulelong 87 B8G8R8A8_UNORM +>0 ulelong 88 B8G8R8X8_UNORM +>0 ulelong 89 R10G10B10_XR_BIAS_A2_UNORM +>0 ulelong 90 B8G8R8A8_TYPELESS +>0 ulelong 91 B8G8R8A8_UNORM_SRGB +>0 ulelong 92 B8G8R8X8_TYPELESS +>0 ulelong 93 B8G8R8X8_UNORM_SRGB +>0 ulelong 94 BC6H_TYPELESS +>0 ulelong 95 BC6H_UF16 +>0 ulelong 96 BC6H_SF16 +>0 ulelong 97 BC7_TYPELESS +>0 ulelong 98 BC7_UNORM +>0 ulelong 99 BC7_UNORM_SRGB +>0 ulelong 100 AYUV +>0 ulelong 101 Y410 +>0 ulelong 102 Y416 +>0 ulelong 103 NV12 +>0 ulelong 104 P010 +>0 ulelong 105 P016 +>0 ulelong 106 420_OPAQUE +>0 ulelong 107 YUY2 +>0 ulelong 108 Y210 +>0 ulelong 109 Y216 +>0 ulelong 110 NV11 +>0 ulelong 111 AI44 +>0 ulelong 112 IA44 +>0 ulelong 113 P8 +>0 ulelong 114 A8P8 +>0 ulelong 115 B4G4R4A4_UNORM + +>0 ulelong 116 XBOX_R10G10B10_7E3_A2_FLOAT +>0 ulelong 117 XBOX_R10G10B10_6E4_A2_FLOAT +>0 ulelong 118 XBOX_D16_UNORM_S8_UINT +>0 ulelong 119 XBOX_R16_UNORM_X8_TYPELESS +>0 ulelong 120 XBOX_X16_TYPELESS_G8_UINT + +>0 ulelong 130 DXGI_FORMAT_P208 +>0 ulelong 131 DXGI_FORMAT_V208 +>0 ulelong 132 DXGI_FORMAT_V408 + +>0 ulelong 133 ASTC_4X4_TYPELESS +>0 ulelong 134 ASTC_4X4_UNORM +>0 ulelong 135 ASTC_4X4_UNORM_SRGB +>0 ulelong 137 ASTC_5X4_TYPELESS +>0 ulelong 138 ASTC_5X4_UNORM +>0 ulelong 139 ASTC_5X4_UNORM_SRGB +>0 ulelong 141 ASTC_5X5_TYPELESS +>0 ulelong 142 ASTC_5X5_UNORM +>0 ulelong 143 ASTC_5X5_UNORM_SRGB +>0 ulelong 145 ASTC_6X5_TYPELESS +>0 ulelong 146 ASTC_6X5_UNORM +>0 ulelong 147 ASTC_6X5_UNORM_SRGB +>0 ulelong 149 ASTC_6X6_TYPELESS +>0 ulelong 150 ASTC_6X6_UNORM +>0 ulelong 151 ASTC_6X6_UNORM_SRGB +>0 ulelong 153 ASTC_8X5_TYPELESS +>0 ulelong 154 ASTC_8X5_UNORM +>0 ulelong 155 ASTC_8X5_UNORM_SRGB +>0 ulelong 157 ASTC_8X6_TYPELESS +>0 ulelong 158 ASTC_8X6_UNORM +>0 ulelong 159 ASTC_8X6_UNORM_SRGB +>0 ulelong 161 ASTC_8X8_TYPELESS +>0 ulelong 162 ASTC_8X8_UNORM +>0 ulelong 163 ASTC_8X8_UNORM_SRGB +>0 ulelong 165 ASTC_10X5_TYPELESS +>0 ulelong 166 ASTC_10X5_UNORM +>0 ulelong 167 ASTC_10X5_UNORM_SRGB +>0 ulelong 169 ASTC_10X6_TYPELESS +>0 ulelong 170 ASTC_10X6_UNORM +>0 ulelong 171 ASTC_10X6_UNORM_SRGB +>0 ulelong 173 ASTC_10X8_TYPELESS +>0 ulelong 174 ASTC_10X8_UNORM +>0 ulelong 175 ASTC_10X8_UNORM_SRGB +>0 ulelong 177 ASTC_10X10_TYPELESS +>0 ulelong 178 ASTC_10X10_UNORM +>0 ulelong 179 ASTC_10X10_UNORM_SRGB +>0 ulelong 181 ASTC_12X10_TYPELESS +>0 ulelong 182 ASTC_12X10_UNORM +>0 ulelong 183 ASTC_12X10_UNORM_SRGB +>0 ulelong 185 ASTC_12X12_TYPELESS +>0 ulelong 186 ASTC_12X12_UNORM +>0 ulelong 187 ASTC_12X12_UNORM_SRGB + +>0 ulelong 190 XBOX_R10G10B10_SNORM_A2_UNORM +>0 ulelong 189 XBOX_R4G4_UNORM +>0 ulelong 0xFFFFFFFF DXGI_FORMAT_FORCE_UINT + # Type: Microsoft DirectDraw Surface (common data) # URL: https://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/DDSFileReference/ddsfileformat.asp # From: Morten Hustveit <morten@debian.org> @@ -2041,7 +2628,9 @@ # Determine the pixel format. >0x50 ulelong&0x4 4 # FIXME: Handle DX10 and XBOX formats. ->>0x54 string x \b, compressed using %.4s +>>0x54 string DX10 +>>>0x80 use ms-directdraw-dx10 +>>0x54 string !DX10 \b, compressed using %.4s >0x50 ulelong&0x2 0x2 \b, alpha only >0x50 ulelong&0x200 0x200 \b, YUV >0x50 ulelong&0x20000 0x20000 \b, luminance @@ -2147,37 +2736,37 @@ # Sega PVR header. 0 name sega-pvr-image-header ->0x0C leshort x %u x ->0x0E leshort x %u +>0x0C uleshort x %u x +>0x0E uleshort x %u # Image format. ->0x08 byte 0 \b, ARGB1555 ->0x08 byte 1 \b, RGB565 ->0x08 byte 2 \b, ARGB4444 ->0x08 byte 3 \b, YUV442 ->0x08 byte 4 \b, Bump ->0x08 byte 5 \b, 4bpp ->0x08 byte 6 \b, 8bpp +>0x08 ubyte 0 \b, ARGB1555 +>0x08 ubyte 1 \b, RGB565 +>0x08 ubyte 2 \b, ARGB4444 +>0x08 ubyte 3 \b, YUV442 +>0x08 ubyte 4 \b, Bump +>0x08 ubyte 5 \b, 4bpp +>0x08 ubyte 6 \b, 8bpp # Image data type. ->0x09 byte 0x01 \b, square twiddled ->0x09 byte 0x02 \b, square twiddled & mipmap ->0x09 byte 0x03 \b, VQ ->0x09 byte 0x04 \b, VQ & mipmap ->0x09 byte 0x05 \b, 8-bit CLUT twiddled ->0x09 byte 0x06 \b, 4-bit CLUT twiddled ->0x09 byte 0x07 \b, 8-bit direct twiddled ->0x09 byte 0x08 \b, 4-bit direct twiddled ->0x09 byte 0x09 \b, rectangle ->0x09 byte 0x0B \b, rectangular stride ->0x09 byte 0x0D \b, rectangular twiddled ->0x09 byte 0x10 \b, small VQ ->0x09 byte 0x11 \b, small VQ & mipmap ->0x09 byte 0x12 \b, square twiddled & mipmap +>0x09 ubyte 0x01 \b, square twiddled +>0x09 ubyte 0x02 \b, square twiddled & mipmap +>0x09 ubyte 0x03 \b, VQ +>0x09 ubyte 0x04 \b, VQ & mipmap +>0x09 ubyte 0x05 \b, 8-bit CLUT twiddled +>0x09 ubyte 0x06 \b, 4-bit CLUT twiddled +>0x09 ubyte 0x07 \b, 8-bit direct twiddled +>0x09 ubyte 0x08 \b, 4-bit direct twiddled +>0x09 ubyte 0x09 \b, rectangle +>0x09 ubyte 0x0B \b, rectangular stride +>0x09 ubyte 0x0D \b, rectangular twiddled +>0x09 ubyte 0x10 \b, small VQ +>0x09 ubyte 0x11 \b, small VQ & mipmap +>0x09 ubyte 0x12 \b, square twiddled & mipmap # Sega PVR image. 0 string PVRT >0x10 string DDS\040\174\000\000\000 Sega PVR (Xbox) image: >>0x20 use ms-directdraw-surface ->0x10 belong !0x44445320 Sega PVR image: +>0x10 ubelong !0x44445320 Sega PVR image: >>0 use sega-pvr-image-header # Sega PVR image with GBIX. @@ -2185,25 +2774,25 @@ >0x10 string PVRT >>0x10 string DDS\040\174\000\000\000 Sega PVR (Xbox) image: >>>0x20 use ms-directdraw-surface ->>0x10 belong !0x44445320 Sega PVR image: +>>0x10 ubelong !0x44445320 Sega PVR image: >>>0x10 use sega-pvr-image-header ->>0x08 lelong x \b, global index = %u +>>0x08 ulelong x \b, global index = %u # Sega GVR header. 0 name sega-gvr-image-header ->0x0C beshort x %u x ->0x0E beshort x %u +>0x0C ubeshort x %u x +>0x0E ubeshort x %u # Image data format. ->0x0B byte 0 \b, I4 ->0x0B byte 1 \b, I8 ->0x0B byte 2 \b, IA4 ->0x0B byte 3 \b, IA8 ->0x0B byte 4 \b, RGB565 ->0x0B byte 5 \b, RGB5A3 ->0x0B byte 6 \b, ARGB8888 ->0x0B byte 8 \b, CI4 ->0x0B byte 9 \b, CI8 ->0x0B byte 14 \b, DXT1 +>0x0B ubyte 0 \b, I4 +>0x0B ubyte 1 \b, I8 +>0x0B ubyte 2 \b, IA4 +>0x0B ubyte 3 \b, IA8 +>0x0B ubyte 4 \b, RGB565 +>0x0B ubyte 5 \b, RGB5A3 +>0x0B ubyte 6 \b, ARGB8888 +>0x0B ubyte 8 \b, CI4 +>0x0B ubyte 9 \b, CI8 +>0x0B ubyte 14 \b, DXT1 # Sega GVR image. 0 string GVRT Sega GVR image: @@ -2213,22 +2802,22 @@ 0 string GBIX >0x10 string GVRT Sega GVR image: >>0x10 use sega-gvr-image-header ->>0x08 belong x \b, global index = %u +>>0x08 ubelong x \b, global index = %u # Sega GVR image with GCIX. (Wii) 0 string GCIX >0x10 string GVRT Sega GVR image: >>0x10 use sega-gvr-image-header ->>0x08 belong x \b, global index = %u +>>0x08 ubelong x \b, global index = %u # Light Field Picture # Documentation: http://optics.miloush.net/lytro/TheFileFormat.aspx # Typical file extensions: .lfp .lfr .lfx -0 belong 0x894C4650 ->4 belong 0x0D0A1A0A ->12 belong 0x00000000 Lytro Light Field Picture ->8 belong x \b, version %d +0 ubelong 0x894C4650 +>4 ubelong 0x0D0A1A0A +>12 ubelong 0x00000000 Lytro Light Field Picture +>8 ubelong x \b, version %d # Type: Vision Research Phantom CINE Format # URL: https://www.phantomhighspeed.com/ @@ -2238,24 +2827,24 @@ # This has a short "CI" code but the 44 is the size of the struct which is # stable 0 string CI ->2 leshort 44 Vision Research CINE Video, ->>4 leshort 0 Grayscale, ->>4 leshort 1 JPEG Compressed, ->>4 leshort 2 RAW, ->>6 leshort x version %d, ->>20 lelong x %d frames, ->>48 lelong x %dx ->>52 lelong x \b%d +>2 uleshort 44 Vision Research CINE Video, +>>4 uleshort 0 Grayscale, +>>4 uleshort 1 JPEG Compressed, +>>4 uleshort 2 RAW, +>>6 uleshort x version %d, +>>20 ulelong x %d frames, +>>48 ulelong x %dx +>>52 ulelong x \b%d # Type: ARRI Raw Image # Info: SMPTE RDD30:2014 # From: Harry Mallon <hjmallon at gmail.com> 0 string ARRI ARRI ARI image data, ->4 lelong 0x78563412 little-endian, ->4 lelong 0x12345678 big-endian, ->12 lelong x version %d, ->20 lelong x %dx ->24 lelong x \b%d +>4 ulelong 0x78563412 little-endian, +>4 ulelong 0x12345678 big-endian, +>12 ulelong x version %d, +>20 ulelong x %dx +>24 ulelong x \b%d # Type: Khronos KTX texture. # From: David Korth <gerbilsoft@gerbilsoft.com> @@ -2264,79 +2853,79 @@ # glEnum decoding. # NOTE: Only the most common formats are listed here. 0 name khronos-ktx-glEnum ->0 lelong 0x1907 \b, RGB ->0 lelong 0x1908 \b, RGBA ->0 lelong 0x1909 \b, LUMINANCE ->0 lelong 0x190A \b, LUMINANCE_ALPHA ->0 lelong 0x80E1 \b, BGR ->0 lelong 0x80E2 \b, BGRA ->0 lelong 0x83A0 \b, RGB_S3TC ->0 lelong 0x83A1 \b, RGB4_S3TC ->0 lelong 0x83A2 \b, RGBA_S3TC ->0 lelong 0x83A3 \b, RGBA4_S3TC ->0 lelong 0x83A4 \b, RGBA_DXT5_S3TC ->0 lelong 0x83A5 \b, RGBA4_DXT5_S3TC ->0 lelong 0x83F0 \b, COMPRESSED_RGB_S3TC_DXT1_EXT ->0 lelong 0x83F1 \b, COMPRESSED_RGBA_S3TC_DXT1_EXT ->0 lelong 0x83F2 \b, COMPRESSED_RGBA_S3TC_DXT3_EXT ->0 lelong 0x83F3 \b, COMPRESSED_RGBA_S3TC_DXT5_EXT ->0 lelong 0x8D64 \b, ETC1_RGB8_OES ->0 lelong 0x9270 \b, COMPRESSED_R11_EAC ->0 lelong 0x9271 \b, COMPRESSED_SIGNED_R11_EAC ->0 lelong 0x9272 \b, COMPRESSED_RG11_EAC ->0 lelong 0x9273 \b, COMPRESSED_SIGNED_RG11_EAC ->0 lelong 0x9274 \b, COMPRESSED_RGB8_ETC2 ->0 lelong 0x9275 \b, COMPRESSED_SRGB8_ETC2 ->0 lelong 0x9276 \b, COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 ->0 lelong 0x9277 \b, COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 ->0 lelong 0x9278 \b, COMPRESSED_RGBA2_ETC2_EAC ->0 lelong 0x9279 \b, COMPRESSED_SRGB8_ALPHA8_ETC2_EAC ->0 lelong 0x93B0 \b, COMPRESSED_RGBA_ASTC_4x4_KHR ->0 lelong 0x93B1 \b, COMPRESSED_RGBA_ASTC_5x4_KHR ->0 lelong 0x93B2 \b, COMPRESSED_RGBA_ASTC_5x5_KHR ->0 lelong 0x93B3 \b, COMPRESSED_RGBA_ASTC_6x5_KHR ->0 lelong 0x93B4 \b, COMPRESSED_RGBA_ASTC_6x6_KHR ->0 lelong 0x93B5 \b, COMPRESSED_RGBA_ASTC_8x5_KHR ->0 lelong 0x93B6 \b, COMPRESSED_RGBA_ASTC_8x6_KHR ->0 lelong 0x93B7 \b, COMPRESSED_RGBA_ASTC_8x8_KHR ->0 lelong 0x93B8 \b, COMPRESSED_RGBA_ASTC_10x5_KHR ->0 lelong 0x93B9 \b, COMPRESSED_RGBA_ASTC_10x6_KHR ->0 lelong 0x93BA \b, COMPRESSED_RGBA_ASTC_10x8_KHR ->0 lelong 0x93BB \b, COMPRESSED_RGBA_ASTC_10x10_KHR ->0 lelong 0x93BC \b, COMPRESSED_RGBA_ASTC_12x10_KHR ->0 lelong 0x93BD \b, COMPRESSED_RGBA_ASTC_12x12_KHR ->0 lelong 0x93D0 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR ->0 lelong 0x93D1 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR ->0 lelong 0x93D2 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR ->0 lelong 0x93D3 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR ->0 lelong 0x93D4 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR ->0 lelong 0x93D5 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR ->0 lelong 0x93D6 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR ->0 lelong 0x93D7 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR ->0 lelong 0x93D8 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR ->0 lelong 0x93D9 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR ->0 lelong 0x93DA \b, COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR ->0 lelong 0x93DB \b, COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR ->0 lelong 0x93DC \b, COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR ->0 lelong 0x93DD \b, COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR +>0 ulelong 0x1907 \b, RGB +>0 ulelong 0x1908 \b, RGBA +>0 ulelong 0x1909 \b, LUMINANCE +>0 ulelong 0x190A \b, LUMINANCE_ALPHA +>0 ulelong 0x80E1 \b, BGR +>0 ulelong 0x80E2 \b, BGRA +>0 ulelong 0x83A0 \b, RGB_S3TC +>0 ulelong 0x83A1 \b, RGB4_S3TC +>0 ulelong 0x83A2 \b, RGBA_S3TC +>0 ulelong 0x83A3 \b, RGBA4_S3TC +>0 ulelong 0x83A4 \b, RGBA_DXT5_S3TC +>0 ulelong 0x83A5 \b, RGBA4_DXT5_S3TC +>0 ulelong 0x83F0 \b, COMPRESSED_RGB_S3TC_DXT1_EXT +>0 ulelong 0x83F1 \b, COMPRESSED_RGBA_S3TC_DXT1_EXT +>0 ulelong 0x83F2 \b, COMPRESSED_RGBA_S3TC_DXT3_EXT +>0 ulelong 0x83F3 \b, COMPRESSED_RGBA_S3TC_DXT5_EXT +>0 ulelong 0x8D64 \b, ETC1_RGB8_OES +>0 ulelong 0x9270 \b, COMPRESSED_R11_EAC +>0 ulelong 0x9271 \b, COMPRESSED_SIGNED_R11_EAC +>0 ulelong 0x9272 \b, COMPRESSED_RG11_EAC +>0 ulelong 0x9273 \b, COMPRESSED_SIGNED_RG11_EAC +>0 ulelong 0x9274 \b, COMPRESSED_RGB8_ETC2 +>0 ulelong 0x9275 \b, COMPRESSED_SRGB8_ETC2 +>0 ulelong 0x9276 \b, COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 +>0 ulelong 0x9277 \b, COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 +>0 ulelong 0x9278 \b, COMPRESSED_RGBA2_ETC2_EAC +>0 ulelong 0x9279 \b, COMPRESSED_SRGB8_ALPHA8_ETC2_EAC +>0 ulelong 0x93B0 \b, COMPRESSED_RGBA_ASTC_4x4_KHR +>0 ulelong 0x93B1 \b, COMPRESSED_RGBA_ASTC_5x4_KHR +>0 ulelong 0x93B2 \b, COMPRESSED_RGBA_ASTC_5x5_KHR +>0 ulelong 0x93B3 \b, COMPRESSED_RGBA_ASTC_6x5_KHR +>0 ulelong 0x93B4 \b, COMPRESSED_RGBA_ASTC_6x6_KHR +>0 ulelong 0x93B5 \b, COMPRESSED_RGBA_ASTC_8x5_KHR +>0 ulelong 0x93B6 \b, COMPRESSED_RGBA_ASTC_8x6_KHR +>0 ulelong 0x93B7 \b, COMPRESSED_RGBA_ASTC_8x8_KHR +>0 ulelong 0x93B8 \b, COMPRESSED_RGBA_ASTC_10x5_KHR +>0 ulelong 0x93B9 \b, COMPRESSED_RGBA_ASTC_10x6_KHR +>0 ulelong 0x93BA \b, COMPRESSED_RGBA_ASTC_10x8_KHR +>0 ulelong 0x93BB \b, COMPRESSED_RGBA_ASTC_10x10_KHR +>0 ulelong 0x93BC \b, COMPRESSED_RGBA_ASTC_12x10_KHR +>0 ulelong 0x93BD \b, COMPRESSED_RGBA_ASTC_12x12_KHR +>0 ulelong 0x93D0 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR +>0 ulelong 0x93D1 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR +>0 ulelong 0x93D2 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR +>0 ulelong 0x93D3 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR +>0 ulelong 0x93D4 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR +>0 ulelong 0x93D5 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR +>0 ulelong 0x93D6 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR +>0 ulelong 0x93D7 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR +>0 ulelong 0x93D8 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR +>0 ulelong 0x93D9 \b, COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR +>0 ulelong 0x93DA \b, COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR +>0 ulelong 0x93DB \b, COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR +>0 ulelong 0x93DC \b, COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR +>0 ulelong 0x93DD \b, COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR # Endian-specific KTX header. # TODO: glType (all textures I've seen so far are GL_UNSIGNED_BYTE) 0 name khronos-ktx-endian-header ->20 lelong x \b, %u ->24 lelong >1 x %u ->28 lelong >1 x %u ->8 lelong >0 +>20 ulelong x \b, %u +>24 ulelong >1 x %u +>28 ulelong >1 x %u +>8 ulelong >0 >>8 use khronos-ktx-glEnum ->8 lelong 0 +>8 ulelong 0 >>12 use khronos-ktx-glEnum # Main KTX header. # Determine endianness, then check the rest of the header. 0 string \xABKTX\ 11\xBB\r\n\x1A\n Khronos KTX texture ->12 lelong 0x04030201 (little-endian) +>12 ulelong 0x04030201 (little-endian) >>16 use khronos-ktx-endian-header ->12 belong 0x04030201 (big-endian) +>12 ubelong 0x04030201 (big-endian) >>16 use \^khronos-ktx-endian-header # Type: Khronos KTX2 texture. @@ -2346,273 +2935,273 @@ # Supercompression enum. 0 name khronos-ktx2-supercompression ->0 lelong 1 BasisLZ ->0 lelong 2 Zstandard ->0 lelong 3 ZLIB +>0 ulelong 1 BasisLZ +>0 ulelong 2 Zstandard +>0 ulelong 3 ZLIB # Vulkan format identifier. # NOTE: Formats prohibited from KTX2 are commented out. 0 name khronos-ktx2-vkFormat ->0 lelong 0 UNDEFINED ->0 lelong 1 R4G4_UNORM_PACK8 ->0 lelong 2 R4G4B4A4_UNORM_PACK16 ->0 lelong 3 B4G4R4A4_UNORM_PACK16 ->0 lelong 4 R5G6B5_UNORM_PACK16 ->0 lelong 5 B5G6R5_UNORM_PACK16 ->0 lelong 6 R5G5B5A1_UNORM_PACK16 ->0 lelong 7 B5G5R5A1_UNORM_PACK16 ->0 lelong 8 A1R5G5B5_UNORM_PACK16 ->0 lelong 9 R8_UNORM ->0 lelong 10 R8_SNORM -#>0 lelong 11 R8_USCALED -#>0 lelong 12 R8_SSCALED ->0 lelong 13 R8_UINT ->0 lelong 14 R8_SINT ->0 lelong 15 R8_SRGB ->0 lelong 16 R8G8_UNORM ->0 lelong 17 R8G8_SNORM -#>0 lelong 18 R8G8_USCALED -#>0 lelong 19 R8G8_SSCALED ->0 lelong 20 R8G8_UINT ->0 lelong 21 R8G8_SINT ->0 lelong 22 R8G8_SRGB ->0 lelong 23 R8G8B8_UNORM ->0 lelong 24 R8G8B8_SNORM -#>0 lelong 25 R8G8B8_USCALED -#>0 lelong 26 R8G8B8_SSCALED ->0 lelong 27 R8G8B8_UINT ->0 lelong 28 R8G8B8_SINT ->0 lelong 29 R8G8B8_SRGB ->0 lelong 30 B8G8R8_UNORM ->0 lelong 31 B8G8R8_SNORM -#>0 lelong 32 B8G8R8_USCALED -#>0 lelong 33 B8G8R8_SSCALED ->0 lelong 34 B8G8R8_UINT ->0 lelong 35 B8G8R8_SINT ->0 lelong 36 B8G8R8_SRGB ->0 lelong 37 R8G8B8A8_UNORM ->0 lelong 38 R8G8B8A8_SNORM -#>0 lelong 39 R8G8B8A8_USCALED -#>0 lelong 40 R8G8B8A8_SSCALED ->0 lelong 41 R8G8B8A8_UINT ->0 lelong 42 R8G8B8A8_SINT ->0 lelong 43 R8G8B8A8_SRGB ->0 lelong 44 B8G8R8A8_UNORM ->0 lelong 45 B8G8R8A8_SNORM -#>0 lelong 46 B8G8R8A8_USCALED -#>0 lelong 47 B8G8R8A8_SSCALED ->0 lelong 48 B8G8R8A8_UINT ->0 lelong 49 B8G8R8A8_SINT ->0 lelong 50 B8G8R8A8_SRGB -#>0 lelong 51 A8B8G8R8_UNORM_PACK32 -#>0 lelong 52 A8B8G8R8_SNORM_PACK32 -#>0 lelong 53 A8B8G8R8_USCALED_PACK32 -#>0 lelong 54 A8B8G8R8_SSCALED_PACK32 -#>0 lelong 55 A8B8G8R8_UINT_PACK32 -#>0 lelong 56 A8B8G8R8_SINT_PACK32 -#>0 lelong 57 A8B8G8R8_SRGB_PACK32 ->0 lelong 58 A2R10G10B10_UNORM_PACK32 ->0 lelong 59 A2R10G10B10_SNORM_PACK32 -#>0 lelong 60 A2R10G10B10_USCALED_PACK32 -#>0 lelong 61 A2R10G10B10_SSCALED_PACK32 ->0 lelong 62 A2R10G10B10_UINT_PACK32 ->0 lelong 63 A2R10G10B10_SINT_PACK32 ->0 lelong 64 A2B10G10R10_UNORM_PACK32 ->0 lelong 65 A2B10G10R10_SNORM_PACK32 -#>0 lelong 66 A2B10G10R10_USCALED_PACK32 -#>0 lelong 67 A2B10G10R10_SSCALED_PACK32 ->0 lelong 68 A2B10G10R10_UINT_PACK32 ->0 lelong 69 A2B10G10R10_SINT_PACK32 ->0 lelong 70 R16_UNORM ->0 lelong 71 R16_SNORM -#>0 lelong 72 R16_USCALED -#>0 lelong 73 R16_SSCALED ->0 lelong 74 R16_UINT ->0 lelong 75 R16_SINT ->0 lelong 76 R16_SFLOAT ->0 lelong 77 R16G16_UNORM ->0 lelong 78 R16G16_SNORM -#>0 lelong 79 R16G16_USCALED -#>0 lelong 80 R16G16_SSCALED ->0 lelong 81 R16G16_UINT ->0 lelong 82 R16G16_SINT ->0 lelong 83 R16G16_SFLOAT ->0 lelong 84 R16G16B16_UNORM ->0 lelong 85 R16G16B16_SNORM -#>0 lelong 86 R16G16B16_USCALED -#>0 lelong 87 R16G16B16_SSCALED ->0 lelong 88 R16G16B16_UINT ->0 lelong 89 R16G16B16_SINT ->0 lelong 90 R16G16B16_SFLOAT ->0 lelong 91 R16G16B16A16_UNORM ->0 lelong 92 R16G16B16A16_SNORM -#>0 lelong 93 R16G16B16A16_USCALED -#>0 lelong 94 R16G16B16A16_SSCALED ->0 lelong 95 R16G16B16A16_UINT ->0 lelong 96 R16G16B16A16_SINT ->0 lelong 97 R16G16B16A16_SFLOAT ->0 lelong 98 R32_UINT ->0 lelong 99 R32_SINT ->0 lelong 100 R32_SFLOAT ->0 lelong 101 R32G32_UINT ->0 lelong 102 R32G32_SINT ->0 lelong 103 R32G32_SFLOAT ->0 lelong 104 R32G32B32_UINT ->0 lelong 105 R32G32B32_SINT ->0 lelong 106 R32G32B32_SFLOAT ->0 lelong 107 R32G32B32A32_UINT ->0 lelong 108 R32G32B32A32_SINT ->0 lelong 109 R32G32B32A32_SFLOAT ->0 lelong 110 R64_UINT ->0 lelong 111 R64_SINT ->0 lelong 112 R64_SFLOAT ->0 lelong 113 R64G64_UINT ->0 lelong 114 R64G64_SINT ->0 lelong 115 R64G64_SFLOAT ->0 lelong 116 R64G64B64_UINT ->0 lelong 117 R64G64B64_SINT ->0 lelong 118 R64G64B64_SFLOAT ->0 lelong 119 R64G64B64A64_UINT ->0 lelong 120 R64G64B64A64_SINT ->0 lelong 121 R64G64B64A64_SFLOAT ->0 lelong 122 B10G11R11_UFLOAT_PACK32 ->0 lelong 123 E5B9G9R9_UFLOAT_PACK32 ->0 lelong 124 D16_UNORM ->0 lelong 125 X8_D24_UNORM_PACK32 ->0 lelong 126 D32_SFLOAT ->0 lelong 127 S8_UINT ->0 lelong 128 D16_UNORM_S8_UINT ->0 lelong 129 D24_UNORM_S8_UINT ->0 lelong 130 D32_SFLOAT_S8_UINT - ->0 lelong 131 BC1_RGB_UNORM_BLOCK ->0 lelong 132 BC1_RGB_SRGB_BLOCK ->0 lelong 133 BC1_RGBA_UNORM_BLOCK ->0 lelong 134 BC1_RGBA_SRGB_BLOCK ->0 lelong 135 BC2_UNORM_BLOCK ->0 lelong 136 BC2_SRGB_BLOCK ->0 lelong 137 BC3_UNORM_BLOCK ->0 lelong 138 BC3_SRGB_BLOCK ->0 lelong 139 BC4_UNORM_BLOCK ->0 lelong 140 BC4_SNORM_BLOCK ->0 lelong 141 BC5_UNORM_BLOCK ->0 lelong 142 BC5_SNORM_BLOCK ->0 lelong 143 BC6H_UFLOAT_BLOCK ->0 lelong 144 BC6H_SFLOAT_BLOCK ->0 lelong 145 BC7_UNORM_BLOCK ->0 lelong 146 BC7_SRGB_BLOCK - ->0 lelong 147 ETC2_R8G8B8_UNORM_BLOCK ->0 lelong 148 ETC2_R8G8B8_SRGB_BLOCK ->0 lelong 149 ETC2_R8G8B8A1_UNORM_BLOCK ->0 lelong 150 ETC2_R8G8B8A1_SRGB_BLOCK ->0 lelong 151 ETC2_R8G8B8A8_UNORM_BLOCK ->0 lelong 152 ETC2_R8G8B8A8_SRGB_BLOCK - ->0 lelong 153 EAC_R11_UNORM_BLOCK ->0 lelong 154 EAC_R11_SNORM_BLOCK ->0 lelong 155 EAC_R11G11_UNORM_BLOCK ->0 lelong 156 EAC_R11G11_SNORM_BLOCK - ->0 lelong 157 ASTC_4x4_UNORM_BLOCK ->0 lelong 158 ASTC_4x4_SRGB_BLOCK ->0 lelong 159 ASTC_5x4_UNORM_BLOCK ->0 lelong 160 ASTC_5x4_SRGB_BLOCK ->0 lelong 161 ASTC_5x5_UNORM_BLOCK ->0 lelong 162 ASTC_5x5_SRGB_BLOCK ->0 lelong 163 ASTC_6x5_UNORM_BLOCK ->0 lelong 164 ASTC_6x5_SRGB_BLOCK ->0 lelong 165 ASTC_6x6_UNORM_BLOCK ->0 lelong 166 ASTC_6x6_SRGB_BLOCK ->0 lelong 167 ASTC_8x5_UNORM_BLOCK ->0 lelong 168 ASTC_8x5_SRGB_BLOCK ->0 lelong 169 ASTC_8x6_UNORM_BLOCK ->0 lelong 170 ASTC_8x6_SRGB_BLOCK ->0 lelong 171 ASTC_8x8_UNORM_BLOCK ->0 lelong 172 ASTC_8x8_SRGB_BLOCK ->0 lelong 173 ASTC_10x5_UNORM_BLOCK ->0 lelong 174 ASTC_10x5_SRGB_BLOCK ->0 lelong 175 ASTC_10x6_UNORM_BLOCK ->0 lelong 176 ASTC_10x6_SRGB_BLOCK ->0 lelong 177 ASTC_10x8_UNORM_BLOCK ->0 lelong 178 ASTC_10x8_SRGB_BLOCK ->0 lelong 179 ASTC_10x10_UNORM_BLOCK ->0 lelong 180 ASTC_10x10_SRGB_BLOCK ->0 lelong 181 ASTC_12x10_UNORM_BLOCK ->0 lelong 182 ASTC_12x10_SRGB_BLOCK ->0 lelong 183 ASTC_12x12_UNORM_BLOCK ->0 lelong 184 ASTC_12x12_SRGB_BLOCK - ->0 lelong 1000156000 G8B8G8R8_422_UNORM ->0 lelong 1000156001 B8G8R8G8_422_UNORM ->0 lelong 1000156002 G8_B8_R8_3PLANE_420_UNORM ->0 lelong 1000156003 G8_B8R8_2PLANE_420_UNORM ->0 lelong 1000156004 G8_B8_R8_3PLANE_422_UNORM ->0 lelong 1000156005 G8_B8R8_2PLANE_422_UNORM ->0 lelong 1000156006 G8_B8_R8_3PLANE_444_UNORM ->0 lelong 1000156007 R10X6_UNORM_PACK16 ->0 lelong 1000156008 R10X6G10X6_UNORM_2PACK16 ->0 lelong 1000156009 R10X6G10X6B10X6A10X6_UNORM_4PACK16 ->0 lelong 1000156010 G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 ->0 lelong 1000156011 B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 ->0 lelong 1000156012 G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 ->0 lelong 1000156013 G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 ->0 lelong 1000156014 G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 ->0 lelong 1000156015 G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 ->0 lelong 1000156016 G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 ->0 lelong 1000156017 R12X4_UNORM_PACK16 ->0 lelong 1000156018 R12X4G12X4_UNORM_2PACK16 ->0 lelong 1000156019 R12X4G12X4B12X4A12X4_UNORM_4PACK16 ->0 lelong 1000156020 G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 ->0 lelong 1000156021 B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 ->0 lelong 1000156022 G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 ->0 lelong 1000156023 G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 ->0 lelong 1000156024 G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 ->0 lelong 1000156025 G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 ->0 lelong 1000156026 G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 ->0 lelong 1000156027 G16B16G16R16_422_UNORM ->0 lelong 1000156028 B16G16R16G16_422_UNORM ->0 lelong 1000156029 G16_B16_R16_3PLANE_420_UNORM ->0 lelong 1000156030 G16_B16R16_2PLANE_420_UNORM ->0 lelong 1000156031 G16_B16_R16_3PLANE_422_UNORM ->0 lelong 1000156032 G16_B16R16_2PLANE_422_UNORM ->0 lelong 1000156033 G16_B16_R16_3PLANE_444_UNORM - ->0 lelong 1000054000 PVRTC1_2BPP_UNORM_BLOCK_IMG ->0 lelong 1000054001 PVRTC1_4BPP_UNORM_BLOCK_IMG ->0 lelong 1000054002 PVRTC2_2BPP_UNORM_BLOCK_IMG ->0 lelong 1000054003 PVRTC2_4BPP_UNORM_BLOCK_IMG ->0 lelong 1000054004 PVRTC1_2BPP_SRGB_BLOCK_IMG ->0 lelong 1000054005 PVRTC1_4BPP_SRGB_BLOCK_IMG ->0 lelong 1000054006 PVRTC2_2BPP_SRGB_BLOCK_IMG ->0 lelong 1000054007 PVRTC2_4BPP_SRGB_BLOCK_IMG - ->0 lelong 1000066000 ASTC_4x4_SFLOAT_BLOCK_EXT ->0 lelong 1000066001 ASTC_5x4_SFLOAT_BLOCK_EXT ->0 lelong 1000066002 ASTC_5x5_SFLOAT_BLOCK_EXT ->0 lelong 1000066003 ASTC_6x5_SFLOAT_BLOCK_EXT ->0 lelong 1000066004 ASTC_6x6_SFLOAT_BLOCK_EXT ->0 lelong 1000066005 ASTC_8x5_SFLOAT_BLOCK_EXT ->0 lelong 1000066006 ASTC_8x6_SFLOAT_BLOCK_EXT ->0 lelong 1000066007 ASTC_8x8_SFLOAT_BLOCK_EXT ->0 lelong 1000066008 ASTC_10x5_SFLOAT_BLOCK_EXT ->0 lelong 1000066009 ASTC_10x6_SFLOAT_BLOCK_EXT ->0 lelong 1000066010 ASTC_10x8_SFLOAT_BLOCK_EXT ->0 lelong 1000066011 ASTC_10x10_SFLOAT_BLOCK_EXT ->0 lelong 1000066012 ASTC_12x10_SFLOAT_BLOCK_EXT ->0 lelong 1000066013 ASTC_12x12_SFLOAT_BLOCK_EXT +>0 ulelong 0 UNDEFINED +>0 ulelong 1 R4G4_UNORM_PACK8 +>0 ulelong 2 R4G4B4A4_UNORM_PACK16 +>0 ulelong 3 B4G4R4A4_UNORM_PACK16 +>0 ulelong 4 R5G6B5_UNORM_PACK16 +>0 ulelong 5 B5G6R5_UNORM_PACK16 +>0 ulelong 6 R5G5B5A1_UNORM_PACK16 +>0 ulelong 7 B5G5R5A1_UNORM_PACK16 +>0 ulelong 8 A1R5G5B5_UNORM_PACK16 +>0 ulelong 9 R8_UNORM +>0 ulelong 10 R8_SNORM +#>0 ulelong 11 R8_USCALED +#>0 ulelong 12 R8_SSCALED +>0 ulelong 13 R8_UINT +>0 ulelong 14 R8_SINT +>0 ulelong 15 R8_SRGB +>0 ulelong 16 R8G8_UNORM +>0 ulelong 17 R8G8_SNORM +#>0 ulelong 18 R8G8_USCALED +#>0 ulelong 19 R8G8_SSCALED +>0 ulelong 20 R8G8_UINT +>0 ulelong 21 R8G8_SINT +>0 ulelong 22 R8G8_SRGB +>0 ulelong 23 R8G8B8_UNORM +>0 ulelong 24 R8G8B8_SNORM +#>0 ulelong 25 R8G8B8_USCALED +#>0 ulelong 26 R8G8B8_SSCALED +>0 ulelong 27 R8G8B8_UINT +>0 ulelong 28 R8G8B8_SINT +>0 ulelong 29 R8G8B8_SRGB +>0 ulelong 30 B8G8R8_UNORM +>0 ulelong 31 B8G8R8_SNORM +#>0 ulelong 32 B8G8R8_USCALED +#>0 ulelong 33 B8G8R8_SSCALED +>0 ulelong 34 B8G8R8_UINT +>0 ulelong 35 B8G8R8_SINT +>0 ulelong 36 B8G8R8_SRGB +>0 ulelong 37 R8G8B8A8_UNORM +>0 ulelong 38 R8G8B8A8_SNORM +#>0 ulelong 39 R8G8B8A8_USCALED +#>0 ulelong 40 R8G8B8A8_SSCALED +>0 ulelong 41 R8G8B8A8_UINT +>0 ulelong 42 R8G8B8A8_SINT +>0 ulelong 43 R8G8B8A8_SRGB +>0 ulelong 44 B8G8R8A8_UNORM +>0 ulelong 45 B8G8R8A8_SNORM +#>0 ulelong 46 B8G8R8A8_USCALED +#>0 ulelong 47 B8G8R8A8_SSCALED +>0 ulelong 48 B8G8R8A8_UINT +>0 ulelong 49 B8G8R8A8_SINT +>0 ulelong 50 B8G8R8A8_SRGB +#>0 ulelong 51 A8B8G8R8_UNORM_PACK32 +#>0 ulelong 52 A8B8G8R8_SNORM_PACK32 +#>0 ulelong 53 A8B8G8R8_USCALED_PACK32 +#>0 ulelong 54 A8B8G8R8_SSCALED_PACK32 +#>0 ulelong 55 A8B8G8R8_UINT_PACK32 +#>0 ulelong 56 A8B8G8R8_SINT_PACK32 +#>0 ulelong 57 A8B8G8R8_SRGB_PACK32 +>0 ulelong 58 A2R10G10B10_UNORM_PACK32 +>0 ulelong 59 A2R10G10B10_SNORM_PACK32 +#>0 ulelong 60 A2R10G10B10_USCALED_PACK32 +#>0 ulelong 61 A2R10G10B10_SSCALED_PACK32 +>0 ulelong 62 A2R10G10B10_UINT_PACK32 +>0 ulelong 63 A2R10G10B10_SINT_PACK32 +>0 ulelong 64 A2B10G10R10_UNORM_PACK32 +>0 ulelong 65 A2B10G10R10_SNORM_PACK32 +#>0 ulelong 66 A2B10G10R10_USCALED_PACK32 +#>0 ulelong 67 A2B10G10R10_SSCALED_PACK32 +>0 ulelong 68 A2B10G10R10_UINT_PACK32 +>0 ulelong 69 A2B10G10R10_SINT_PACK32 +>0 ulelong 70 R16_UNORM +>0 ulelong 71 R16_SNORM +#>0 ulelong 72 R16_USCALED +#>0 ulelong 73 R16_SSCALED +>0 ulelong 74 R16_UINT +>0 ulelong 75 R16_SINT +>0 ulelong 76 R16_SFLOAT +>0 ulelong 77 R16G16_UNORM +>0 ulelong 78 R16G16_SNORM +#>0 ulelong 79 R16G16_USCALED +#>0 ulelong 80 R16G16_SSCALED +>0 ulelong 81 R16G16_UINT +>0 ulelong 82 R16G16_SINT +>0 ulelong 83 R16G16_SFLOAT +>0 ulelong 84 R16G16B16_UNORM +>0 ulelong 85 R16G16B16_SNORM +#>0 ulelong 86 R16G16B16_USCALED +#>0 ulelong 87 R16G16B16_SSCALED +>0 ulelong 88 R16G16B16_UINT +>0 ulelong 89 R16G16B16_SINT +>0 ulelong 90 R16G16B16_SFLOAT +>0 ulelong 91 R16G16B16A16_UNORM +>0 ulelong 92 R16G16B16A16_SNORM +#>0 ulelong 93 R16G16B16A16_USCALED +#>0 ulelong 94 R16G16B16A16_SSCALED +>0 ulelong 95 R16G16B16A16_UINT +>0 ulelong 96 R16G16B16A16_SINT +>0 ulelong 97 R16G16B16A16_SFLOAT +>0 ulelong 98 R32_UINT +>0 ulelong 99 R32_SINT +>0 ulelong 100 R32_SFLOAT +>0 ulelong 101 R32G32_UINT +>0 ulelong 102 R32G32_SINT +>0 ulelong 103 R32G32_SFLOAT +>0 ulelong 104 R32G32B32_UINT +>0 ulelong 105 R32G32B32_SINT +>0 ulelong 106 R32G32B32_SFLOAT +>0 ulelong 107 R32G32B32A32_UINT +>0 ulelong 108 R32G32B32A32_SINT +>0 ulelong 109 R32G32B32A32_SFLOAT +>0 ulelong 110 R64_UINT +>0 ulelong 111 R64_SINT +>0 ulelong 112 R64_SFLOAT +>0 ulelong 113 R64G64_UINT +>0 ulelong 114 R64G64_SINT +>0 ulelong 115 R64G64_SFLOAT +>0 ulelong 116 R64G64B64_UINT +>0 ulelong 117 R64G64B64_SINT +>0 ulelong 118 R64G64B64_SFLOAT +>0 ulelong 119 R64G64B64A64_UINT +>0 ulelong 120 R64G64B64A64_SINT +>0 ulelong 121 R64G64B64A64_SFLOAT +>0 ulelong 122 B10G11R11_UFLOAT_PACK32 +>0 ulelong 123 E5B9G9R9_UFLOAT_PACK32 +>0 ulelong 124 D16_UNORM +>0 ulelong 125 X8_D24_UNORM_PACK32 +>0 ulelong 126 D32_SFLOAT +>0 ulelong 127 S8_UINT +>0 ulelong 128 D16_UNORM_S8_UINT +>0 ulelong 129 D24_UNORM_S8_UINT +>0 ulelong 130 D32_SFLOAT_S8_UINT + +>0 ulelong 131 BC1_RGB_UNORM_BLOCK +>0 ulelong 132 BC1_RGB_SRGB_BLOCK +>0 ulelong 133 BC1_RGBA_UNORM_BLOCK +>0 ulelong 134 BC1_RGBA_SRGB_BLOCK +>0 ulelong 135 BC2_UNORM_BLOCK +>0 ulelong 136 BC2_SRGB_BLOCK +>0 ulelong 137 BC3_UNORM_BLOCK +>0 ulelong 138 BC3_SRGB_BLOCK +>0 ulelong 139 BC4_UNORM_BLOCK +>0 ulelong 140 BC4_SNORM_BLOCK +>0 ulelong 141 BC5_UNORM_BLOCK +>0 ulelong 142 BC5_SNORM_BLOCK +>0 ulelong 143 BC6H_UFLOAT_BLOCK +>0 ulelong 144 BC6H_SFLOAT_BLOCK +>0 ulelong 145 BC7_UNORM_BLOCK +>0 ulelong 146 BC7_SRGB_BLOCK + +>0 ulelong 147 ETC2_R8G8B8_UNORM_BLOCK +>0 ulelong 148 ETC2_R8G8B8_SRGB_BLOCK +>0 ulelong 149 ETC2_R8G8B8A1_UNORM_BLOCK +>0 ulelong 150 ETC2_R8G8B8A1_SRGB_BLOCK +>0 ulelong 151 ETC2_R8G8B8A8_UNORM_BLOCK +>0 ulelong 152 ETC2_R8G8B8A8_SRGB_BLOCK + +>0 ulelong 153 EAC_R11_UNORM_BLOCK +>0 ulelong 154 EAC_R11_SNORM_BLOCK +>0 ulelong 155 EAC_R11G11_UNORM_BLOCK +>0 ulelong 156 EAC_R11G11_SNORM_BLOCK + +>0 ulelong 157 ASTC_4x4_UNORM_BLOCK +>0 ulelong 158 ASTC_4x4_SRGB_BLOCK +>0 ulelong 159 ASTC_5x4_UNORM_BLOCK +>0 ulelong 160 ASTC_5x4_SRGB_BLOCK +>0 ulelong 161 ASTC_5x5_UNORM_BLOCK +>0 ulelong 162 ASTC_5x5_SRGB_BLOCK +>0 ulelong 163 ASTC_6x5_UNORM_BLOCK +>0 ulelong 164 ASTC_6x5_SRGB_BLOCK +>0 ulelong 165 ASTC_6x6_UNORM_BLOCK +>0 ulelong 166 ASTC_6x6_SRGB_BLOCK +>0 ulelong 167 ASTC_8x5_UNORM_BLOCK +>0 ulelong 168 ASTC_8x5_SRGB_BLOCK +>0 ulelong 169 ASTC_8x6_UNORM_BLOCK +>0 ulelong 170 ASTC_8x6_SRGB_BLOCK +>0 ulelong 171 ASTC_8x8_UNORM_BLOCK +>0 ulelong 172 ASTC_8x8_SRGB_BLOCK +>0 ulelong 173 ASTC_10x5_UNORM_BLOCK +>0 ulelong 174 ASTC_10x5_SRGB_BLOCK +>0 ulelong 175 ASTC_10x6_UNORM_BLOCK +>0 ulelong 176 ASTC_10x6_SRGB_BLOCK +>0 ulelong 177 ASTC_10x8_UNORM_BLOCK +>0 ulelong 178 ASTC_10x8_SRGB_BLOCK +>0 ulelong 179 ASTC_10x10_UNORM_BLOCK +>0 ulelong 180 ASTC_10x10_SRGB_BLOCK +>0 ulelong 181 ASTC_12x10_UNORM_BLOCK +>0 ulelong 182 ASTC_12x10_SRGB_BLOCK +>0 ulelong 183 ASTC_12x12_UNORM_BLOCK +>0 ulelong 184 ASTC_12x12_SRGB_BLOCK + +>0 ulelong 1000156000 G8B8G8R8_422_UNORM +>0 ulelong 1000156001 B8G8R8G8_422_UNORM +>0 ulelong 1000156002 G8_B8_R8_3PLANE_420_UNORM +>0 ulelong 1000156003 G8_B8R8_2PLANE_420_UNORM +>0 ulelong 1000156004 G8_B8_R8_3PLANE_422_UNORM +>0 ulelong 1000156005 G8_B8R8_2PLANE_422_UNORM +>0 ulelong 1000156006 G8_B8_R8_3PLANE_444_UNORM +>0 ulelong 1000156007 R10X6_UNORM_PACK16 +>0 ulelong 1000156008 R10X6G10X6_UNORM_2PACK16 +>0 ulelong 1000156009 R10X6G10X6B10X6A10X6_UNORM_4PACK16 +>0 ulelong 1000156010 G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 +>0 ulelong 1000156011 B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 +>0 ulelong 1000156012 G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 +>0 ulelong 1000156013 G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 +>0 ulelong 1000156014 G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 +>0 ulelong 1000156015 G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 +>0 ulelong 1000156016 G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 +>0 ulelong 1000156017 R12X4_UNORM_PACK16 +>0 ulelong 1000156018 R12X4G12X4_UNORM_2PACK16 +>0 ulelong 1000156019 R12X4G12X4B12X4A12X4_UNORM_4PACK16 +>0 ulelong 1000156020 G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 +>0 ulelong 1000156021 B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 +>0 ulelong 1000156022 G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 +>0 ulelong 1000156023 G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 +>0 ulelong 1000156024 G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 +>0 ulelong 1000156025 G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 +>0 ulelong 1000156026 G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 +>0 ulelong 1000156027 G16B16G16R16_422_UNORM +>0 ulelong 1000156028 B16G16R16G16_422_UNORM +>0 ulelong 1000156029 G16_B16_R16_3PLANE_420_UNORM +>0 ulelong 1000156030 G16_B16R16_2PLANE_420_UNORM +>0 ulelong 1000156031 G16_B16_R16_3PLANE_422_UNORM +>0 ulelong 1000156032 G16_B16R16_2PLANE_422_UNORM +>0 ulelong 1000156033 G16_B16_R16_3PLANE_444_UNORM + +>0 ulelong 1000054000 PVRTC1_2BPP_UNORM_BLOCK_IMG +>0 ulelong 1000054001 PVRTC1_4BPP_UNORM_BLOCK_IMG +>0 ulelong 1000054002 PVRTC2_2BPP_UNORM_BLOCK_IMG +>0 ulelong 1000054003 PVRTC2_4BPP_UNORM_BLOCK_IMG +>0 ulelong 1000054004 PVRTC1_2BPP_SRGB_BLOCK_IMG +>0 ulelong 1000054005 PVRTC1_4BPP_SRGB_BLOCK_IMG +>0 ulelong 1000054006 PVRTC2_2BPP_SRGB_BLOCK_IMG +>0 ulelong 1000054007 PVRTC2_4BPP_SRGB_BLOCK_IMG + +>0 ulelong 1000066000 ASTC_4x4_SFLOAT_BLOCK_EXT +>0 ulelong 1000066001 ASTC_5x4_SFLOAT_BLOCK_EXT +>0 ulelong 1000066002 ASTC_5x5_SFLOAT_BLOCK_EXT +>0 ulelong 1000066003 ASTC_6x5_SFLOAT_BLOCK_EXT +>0 ulelong 1000066004 ASTC_6x6_SFLOAT_BLOCK_EXT +>0 ulelong 1000066005 ASTC_8x5_SFLOAT_BLOCK_EXT +>0 ulelong 1000066006 ASTC_8x6_SFLOAT_BLOCK_EXT +>0 ulelong 1000066007 ASTC_8x8_SFLOAT_BLOCK_EXT +>0 ulelong 1000066008 ASTC_10x5_SFLOAT_BLOCK_EXT +>0 ulelong 1000066009 ASTC_10x6_SFLOAT_BLOCK_EXT +>0 ulelong 1000066010 ASTC_10x8_SFLOAT_BLOCK_EXT +>0 ulelong 1000066011 ASTC_10x10_SFLOAT_BLOCK_EXT +>0 ulelong 1000066012 ASTC_12x10_SFLOAT_BLOCK_EXT +>0 ulelong 1000066013 ASTC_12x12_SFLOAT_BLOCK_EXT # Main KTX2 header. 0 string \xABKTX\ 20\xBB\r\n\x1A\n Khronos KTX2 texture ->20 lelong x \b, %u ->24 lelong >1 x %u ->28 lelong >1 x %u ->32 lelong >1 \b, %u layers ->36 lelong >1 \b, %u faces ->40 lelong >1 \b, %u mipmaps ->44 lelong >0 \b, +>20 ulelong x \b, %u +>24 ulelong >1 x %u +>28 ulelong >1 x %u +>32 ulelong >1 \b, %u layers +>36 ulelong >1 \b, %u faces +>40 ulelong >1 \b, %u mipmaps +>44 ulelong >0 \b, >>44 use khronos-ktx2-supercompression ->12 lelong >0 \b, +>12 ulelong >0 \b, >>12 use khronos-ktx2-vkFormat # Type: Valve VTF texture. @@ -2622,87 +3211,87 @@ # VTF image formats. 0 name vtf-image-format ->0 lelong 0 RGBA8888 ->0 lelong 1 ABGR8888 ->0 lelong 2 RGB888 ->0 lelong 3 BGR888 ->0 lelong 4 RGB565 ->0 lelong 5 I8 ->0 lelong 6 IA88 ->0 lelong 7 P8 ->0 lelong 8 A8 ->0 lelong 9 RGB888 (bluescreen) ->0 lelong 10 BGR888 (bluescreen) ->0 lelong 11 ARGB8888 ->0 lelong 12 BGRA8888 ->0 lelong 13 DXT1 ->0 lelong 14 DXT3 ->0 lelong 15 DXT5 ->0 lelong 16 BGRx8888 ->0 lelong 17 BGR565 ->0 lelong 18 BGRx5551 ->0 lelong 19 BGRA4444 ->0 lelong 20 DXT1+A1 ->0 lelong 21 BGRA5551 ->0 lelong 22 UV88 ->0 lelong 23 UVWQ8888 ->0 lelong 24 RGBA16161616F ->0 lelong 25 RGBA16161616 ->0 lelong 26 UVLX8888 +>0 ulelong 0 RGBA8888 +>0 ulelong 1 ABGR8888 +>0 ulelong 2 RGB888 +>0 ulelong 3 BGR888 +>0 ulelong 4 RGB565 +>0 ulelong 5 I8 +>0 ulelong 6 IA88 +>0 ulelong 7 P8 +>0 ulelong 8 A8 +>0 ulelong 9 RGB888 (bluescreen) +>0 ulelong 10 BGR888 (bluescreen) +>0 ulelong 11 ARGB8888 +>0 ulelong 12 BGRA8888 +>0 ulelong 13 DXT1 +>0 ulelong 14 DXT3 +>0 ulelong 15 DXT5 +>0 ulelong 16 BGRx8888 +>0 ulelong 17 BGR565 +>0 ulelong 18 BGRx5551 +>0 ulelong 19 BGRA4444 +>0 ulelong 20 DXT1+A1 +>0 ulelong 21 BGRA5551 +>0 ulelong 22 UV88 +>0 ulelong 23 UVWQ8888 +>0 ulelong 24 RGBA16161616F +>0 ulelong 25 RGBA16161616 +>0 ulelong 26 UVLX8888 # Main VTF header. 0 string VTF\0 Valve Texture Format ->4 lelong x v%u ->8 lelong x \b.%u ->0x10 leshort x \b, %u ->0x12 leshort >1 x %u +>4 ulelong x v%u +>8 ulelong x \b.%u +>0x10 uleshort x \b, %u +>0x12 uleshort >1 x %u >4 lequad 0x0000000700000002 ->>0x3F leshort >1 x %u ->0x18 leshort >1 \b, %u frames ->0x38 byte x \b, mipmaps: %u ->0x34 lelong >-1 \b, +>>0x3F uleshort >1 x %u +>0x18 uleshort >1 \b, %u frames +>0x38 ubyte x \b, mipmaps: %u +>0x34 ulelong >-1 \b, >>0x34 use vtf-image-format # Type: Valve VTF3 (PS3) texture. # From: David Korth <gerbilsoft@gerbilsoft.com> 0 string VTF3 Valve Texture Format (PS3) ->0x14 beshort x \b, %u ->0x16 beshort x \b x %u ->0x10 belong&0x2000 0 \b, DXT1 ->0x10 belong&0x2000 0x2000 \b, DXT5 +>0x14 ubeshort x \b, %u +>0x16 ubeshort x \b x %u +>0x10 ubelong&0x2000 0 \b, DXT1 +>0x10 ubelong&0x2000 0x2000 \b, DXT5 # Type: ASTC texture. # From: David Korth <gerbilsoft@gerbilsoft.com> # References: # - https://stackoverflow.com/questions/22600678/determine-internal-format-of-given-astc-compressed-image-through-its-header # - https://stackoverflow.com/a/22682244 -0 lelong 0x5ca1ab13 ASTC ->4 byte x %u ->5 byte x \bx%u ->6 byte >1 \bx%u +0 ulelong 0x5ca1ab13 ASTC +>4 ubyte x %u +>5 ubyte x \bx%u +>6 ubyte >1 \bx%u # X, Y, and Z dimensions are stored as 24-bit LE. # Pretend it's 32-bit and mask off the high byte. ->7 lelong&0x00FFFFFF x texture, %u ->10 lelong&0x00FFFFFF x x %u ->13 lelong&0x00FFFFFF >1 x %u +>7 ulelong&0x00FFFFFF x texture, %u +>10 ulelong&0x00FFFFFF x x %u +>13 ulelong&0x00FFFFFF >1 x %u # Zebra Metafile graphic # http://www.fileformat.info/format/zbr/egff.htm -0 beshort 0x9a02 Zebra Metafile graphic ->2 leshort 1 (version 1.x) ->2 leshort 2 (version 1.1x or 1.2x) ->2 leshort 3 (version 1.49) ->2 leshort 4 (version 1.50) +0 ubeshort 0x9a02 Zebra Metafile graphic +>2 uleshort 1 (version 1.x) +>2 uleshort 2 (version 1.1x or 1.2x) +>2 uleshort 3 (version 1.49) +>2 uleshort 4 (version 1.50) >4 string x (comment = %s) # Microsoft Paint graphic # http://www.fileformat.info/format/mspaint/egff.htm 0 string DanM icrosoft Paint image data (version 1.x) ->4 leshort x (%d ->>6 leshort x x %d) +>4 uleshort x (%d +>>6 uleshort x x %d) 0 string LinS Microsoft Paint image data (version 2.0) ->4 leshort x (%d ->>6 leshort x x %d) +>4 uleshort x (%d +>>6 uleshort x x %d) # reMarkable tablet internal file format (https://www.remarkable.com/) # https://github.com/ax3l/lines-are-beautiful @@ -2715,15 +3304,15 @@ >>>22 string selections >>>>33 string and >>>>>37 string layers ->>>>>>43 lelong x reMarkable tablet notebook lines, 1404 x 1872, %x page(s) +>>>>>>43 ulelong x reMarkable tablet notebook lines, 1404 x 1872, %x page(s) # newer per-page files for the reMarkable 0 string reMarkable >11 string .lines >>18 string file, >>>24 string version= ->>>>32 byte x reMarkable tablet page (v%c), 1404 x 1872, ->>>>>43 lelong x %d layer(s) +>>>>32 ubyte x reMarkable tablet page (v%c), 1404 x 1872, +>>>>>43 ulelong x %d layer(s) # Type: PVR3 texture. # From: David Korth <gerbilsoft@gerbilsoft.com> @@ -2788,18 +3377,18 @@ >0x18 ulelong x %u x >0x1C ulelong x %u >0x20 ulelong >1 x %u ->0x08 byte x \b, +>0x08 ubyte x \b, >0x0C ulelong 0 >>0x08 use pvr3-pixel-format >0x0C ulelong !0 ->>0x08 byte !0 %c ->>>0x0C byte !0 \b%u ->>0x09 byte !0 \b%c ->>>0x0D byte !0 \b%u ->>0x0A byte !0 \b%c ->>>0x0E byte !0 \b%u ->>0x0B byte !0 \b%c ->>>0x0F byte !0 \b%u +>>0x08 ubyte !0 %c +>>>0x0C ubyte !0 \b%u +>>0x09 ubyte !0 \b%c +>>>0x0D ubyte !0 \b%u +>>0x0A ubyte !0 \b%c +>>>0x0E ubyte !0 \b%u +>>0x0B ubyte !0 \b%c +>>>0x0F ubyte !0 \b%u >0x10 ulelong 1 \b, sRGB >0x04 ulelong&0x02 0x02 \b, premultiplied alpha @@ -2807,18 +3396,18 @@ >0x18 ubelong x %u x >0x1C ubelong x %u >0x20 ubelong >1 x %u ->0x08 byte x \b, +>0x08 ubyte x \b, >0x0C ubelong 0 >>0x08 use pvr3-pixel-format >0x0C ubelong !0 ->>0x0B byte !0 %c ->>>0x0F byte !0 \b%u ->>0x0A byte !0 \b%c ->>>0x0E byte !0 \b%u ->>0x09 byte !0 \b%c ->>>0x0D byte !0 \b%u ->>0x08 byte !0 \b%c ->>>0x0C byte !0 \b%u +>>0x0B ubyte !0 %c +>>>0x0F ubyte !0 \b%u +>>0x0A ubyte !0 \b%c +>>>0x0E ubyte !0 \b%u +>>0x09 ubyte !0 \b%c +>>>0x0D ubyte !0 \b%u +>>0x08 ubyte !0 \b%c +>>>0x0C ubyte !0 \b%u >0x10 ubelong 1 \b, sRGB >0x04 ubelong&0x02 0x02 \b, premultiplied alpha @@ -2829,64 +3418,64 @@ # XPR pixel formats. 0 name xbox-xpr-pixel-format ->0 byte 0x00 L8 ->0 byte 0x01 AL8 ->0 byte 0x02 ARGB1555 ->0 byte 0x03 RGB555 ->0 byte 0x04 ARGB4444 ->0 byte 0x05 RGB565 ->0 byte 0x06 ARGB8888 ->0 byte 0x07 xRGB8888 ->0 byte 0x0B P8 ->0 byte 0x0C DXT1 ->0 byte 0x0E DXT2 ->0 byte 0x0F DXT4 ->0 byte 0x10 Linear ARGB1555 ->0 byte 0x11 Linear RGB565 ->0 byte 0x12 Linear ARGB8888 ->0 byte 0x13 Linear L8 ->0 byte 0x16 Linear R8B8 ->0 byte 0x17 Linear G8B8 ->0 byte 0x19 A8 ->0 byte 0x1A A8L8 ->0 byte 0x1B Linear AL8 ->0 byte 0x1C Linear RGB555 ->0 byte 0x1D Linear ARGB4444 ->0 byte 0x1E Linear xRGB8888 ->0 byte 0x1F Linear A8 ->0 byte 0x20 Linear A8L8 ->0 byte 0x24 YUY2 ->0 byte 0x25 UYVY ->0 byte 0x27 L6V5U5 ->0 byte 0x28 V8U8 ->0 byte 0x29 R8B8 ->0 byte 0x2A D24S8 ->0 byte 0x2B F24S8 ->0 byte 0x2C D16 ->0 byte 0x2D F16 ->0 byte 0x2E Linear D24S8 ->0 byte 0x2F Linear F24S8 ->0 byte 0x30 Linear D16 ->0 byte 0x31 Linear F16 ->0 byte 0x32 L16 ->0 byte 0x33 V16U16 ->0 byte 0x35 Linear L16 ->0 byte 0x36 Linear V16U16 ->0 byte 0x37 Linear L6V5U5 ->0 byte 0x38 RGBA5551 ->0 byte 0x39 RGBA4444 ->0 byte 0x3A QWVU8888 ->0 byte 0x3B BGRA8888 ->0 byte 0x3C RGBA8888 ->0 byte 0x3D Linear RGBA5551 ->0 byte 0x3E Linear RGBA4444 ->0 byte 0x3F Linear ABGR8888 ->0 byte 0x40 Linear BGRA8888 ->0 byte 0x41 Linear RGBA8888 ->0 byte 0x64 Vertex Data +>0 ubyte 0x00 L8 +>0 ubyte 0x01 AL8 +>0 ubyte 0x02 ARGB1555 +>0 ubyte 0x03 RGB555 +>0 ubyte 0x04 ARGB4444 +>0 ubyte 0x05 RGB565 +>0 ubyte 0x06 ARGB8888 +>0 ubyte 0x07 xRGB8888 +>0 ubyte 0x0B P8 +>0 ubyte 0x0C DXT1 +>0 ubyte 0x0E DXT2 +>0 ubyte 0x0F DXT4 +>0 ubyte 0x10 Linear ARGB1555 +>0 ubyte 0x11 Linear RGB565 +>0 ubyte 0x12 Linear ARGB8888 +>0 ubyte 0x13 Linear L8 +>0 ubyte 0x16 Linear R8B8 +>0 ubyte 0x17 Linear G8B8 +>0 ubyte 0x19 A8 +>0 ubyte 0x1A A8L8 +>0 ubyte 0x1B Linear AL8 +>0 ubyte 0x1C Linear RGB555 +>0 ubyte 0x1D Linear ARGB4444 +>0 ubyte 0x1E Linear xRGB8888 +>0 ubyte 0x1F Linear A8 +>0 ubyte 0x20 Linear A8L8 +>0 ubyte 0x24 YUY2 +>0 ubyte 0x25 UYVY +>0 ubyte 0x27 L6V5U5 +>0 ubyte 0x28 V8U8 +>0 ubyte 0x29 R8B8 +>0 ubyte 0x2A D24S8 +>0 ubyte 0x2B F24S8 +>0 ubyte 0x2C D16 +>0 ubyte 0x2D F16 +>0 ubyte 0x2E Linear D24S8 +>0 ubyte 0x2F Linear F24S8 +>0 ubyte 0x30 Linear D16 +>0 ubyte 0x31 Linear F16 +>0 ubyte 0x32 L16 +>0 ubyte 0x33 V16U16 +>0 ubyte 0x35 Linear L16 +>0 ubyte 0x36 Linear V16U16 +>0 ubyte 0x37 Linear L6V5U5 +>0 ubyte 0x38 RGBA5551 +>0 ubyte 0x39 RGBA4444 +>0 ubyte 0x3A QWVU8888 +>0 ubyte 0x3B BGRA8888 +>0 ubyte 0x3C RGBA8888 +>0 ubyte 0x3D Linear RGBA5551 +>0 ubyte 0x3E Linear RGBA4444 +>0 ubyte 0x3F Linear ABGR8888 +>0 ubyte 0x40 Linear BGRA8888 +>0 ubyte 0x41 Linear RGBA8888 +>0 ubyte 0x64 Vertex Data 0 string XPR0 Microsoft Xbox XPR0 texture ->0x19 byte x \b, format: +>0x19 ubyte x \b, format: >>0x19 use xbox-xpr-pixel-format # ILDA Image Data Transfer Format @@ -2894,41 +3483,41 @@ # # Updated by Chuck Hein (laser@geekdude.com) # -0 string ILDA ILDA Image Data Transfer Format ->7 byte 0x00 3D Coordinates with Indexed Color ->7 byte 0x01 2D Coordinates with Indexed Color ->7 byte 0x02 Color Palette ->7 byte 0x04 3D Coordinates with True Color ->7 byte 0x05 2D Coordinates with True Color ->8 string >0 \b, palette %s ->16 string >0 \b, company %s ->24 beshort >0 \b, number of records %d ->>26 beshort x \b, palette number %d ->>28 beshort >0 \b, number of frames %d ->>30 byte >0 \b, projector number %d +0 string ILDA ILDA Image Data Transfer Format +>7 ubyte 0x00 3D Coordinates with Indexed Color +>7 ubyte 0x01 2D Coordinates with Indexed Color +>7 ubyte 0x02 Color Palette +>7 ubyte 0x04 3D Coordinates with True Color +>7 ubyte 0x05 2D Coordinates with True Color +>8 string >0 \b, palette %s +>16 string >0 \b, company %s +>24 ubeshort >0 \b, number of records %d +>>26 ubeshort x \b, palette number %d +>>28 ubeshort >0 \b, number of frames %d +>>30 ubyte >0 \b, projector number %d # Dropbox "lepton" compressed jpeg format # https://github.com/dropbox/lepton -0 belong&0xfffff0ff 0xcf84005a Lepton image file ->2 byte x (version %d) +0 ubelong&0xfffff0ff 0xcf84005a Lepton image file +>2 ubyte x (version %d) # Apple QuickTake camera raw images # https://en.wikipedia.org/wiki/Apple_QuickTake # dcraw can decode them 0 name quicktake ->4 belong 8 ->>544 beshort x \b, %dx ->>546 beshort x \b%d ->4 belong 4 ->>546 beshort x \b, %dx ->>544 beshort x \b%d +>4 ubelong 8 +>>544 ubeshort x \b, %dx +>>546 ubeshort x \b%d +>4 ubelong 4 +>>546 ubeshort x \b, %dx +>>544 ubeshort x \b%d 0 string qktk Apple QuickTake 100 Raw Image >0 use quicktake 0 string qktn ->4 byte 0 Apple QuickTake 150 Raw Image ->4 byte >0 Apple QuickTake 200 Raw Image +>4 ubyte 0 Apple QuickTake 150 Raw Image +>4 ubyte >0 Apple QuickTake 200 Raw Image >0 use quicktake # From: Joerg Jenderek @@ -3061,3 +3650,167 @@ 0 string ASTM-E57 ASTM E57 three-dimensional model !:mime model/e57 !:ext e57 + +# QOI [Quite OK Image Format] images +# (Horia Mihai David, mihaidavid@posteo.net) +# +# QOI format by Dominic Szablewski <http://phoboslab.org/> +# <https://qoiformat.org/> +# +# Based on spec v1.0 (2022.01.05) <https://qoiformat.org/qoi-specification.pdf> + +0 string qoif QOI image data +!:ext qoi +!:mime image/x-qoi +# See <https://github.com/phoboslab/qoi/issues/167> +>4 ubelong x %ux +>8 ubelong x \b%u, +>>13 ubyte 0 s +>>>12 ubyte 3 \bRGB +>>>12 ubyte 4 \bRGBA +>>>12 default x +>>>>12 ubyte x \b*bad channels %u* +>>>13 ubyte 0 (linear alpha) +>>13 ubyte 1 +>>>12 ubyte 3 RGB +>>>12 ubyte 4 RGBA +>>>13 ubyte 1 (all channels linear) +>>13 default x +>>>13 ubyte x *bad colorspace %u* + + +# Type: Godot 3, 4 texture (pixel format) +# From: David Korth <gerbilsoft@gerbilsoft.com> +0 name godot-pixel-format +>0 ulelong&0xFFFFF 0 L8 +>0 ulelong&0xFFFFF 1 LA8 +>0 ulelong&0xFFFFF 2 R8 +>0 ulelong&0xFFFFF 3 RG8 +>0 ulelong&0xFFFFF 4 RGB8 +>0 ulelong&0xFFFFF 5 RGBA8 +>0 ulelong&0xFFFFF 6 RGBA4444 +>0 ulelong&0xFFFFF 7 RGB565 +>0 ulelong&0xFFFFF 8 RF +>0 ulelong&0xFFFFF 9 RGF +>0 ulelong&0xFFFFF 10 RGBF +>0 ulelong&0xFFFFF 11 RGBAF +>0 ulelong&0xFFFFF 12 RH +>0 ulelong&0xFFFFF 13 RGH +>0 ulelong&0xFFFFF 14 RGBH +>0 ulelong&0xFFFFF 15 RGBAH +>0 ulelong&0xFFFFF 16 RGBE9995 +>0 ulelong&0xFFFFF 17 DXT1 +>0 ulelong&0xFFFFF 18 DXT3 +>0 ulelong&0xFFFFF 19 DXT5 +>0 ulelong&0xFFFFF 20 RGTC_R +>0 ulelong&0xFFFFF 21 RGTC_RG +>0 ulelong&0xFFFFF 22 BPTC_RGBA +>0 ulelong&0xFFFFF 23 BPTC_RGBF +>0 ulelong&0xFFFFF 24 BPTC_RGBFU +>0 ulelong&0xFFFFF 25 PVRTC1_2 +>0 ulelong&0xFFFFF 26 PVRTC1_2A +>0 ulelong&0xFFFFF 27 PVRTC1_4 +>0 ulelong&0xFFFFF 28 PVRTC1_4A +>0 ulelong&0xFFFFF 29 ETC +>0 ulelong&0xFFFFF 30 ETC2_R11 +>0 ulelong&0xFFFFF 31 ETC2_R11S +>0 ulelong&0xFFFFF 32 ETC2_RG11 +>0 ulelong&0xFFFFF 33 ETC2_RG11S +>0 ulelong&0xFFFFF 34 ETC2_RGB8 +>0 ulelong&0xFFFFF 35 ETC2_RGBA8 +>0 ulelong&0xFFFFF 36 ETC2_RGB8A1 +>0 ulelong&0xFFFFF 37 ASTC_8x8 + +# Type: Godot 3, 4 texture (rescale display, width) +# From: David Korth <gerbilsoft@gerbilsoft.com> +# Shows rescale value if it's not a power of 2. +0 name godot-rescale-display-w +>0 uleshort 0 +>0 uleshort 1 +>0 uleshort 2 +>0 uleshort 4 +>0 uleshort 8 +>0 uleshort 16 +>0 uleshort 32 +>0 uleshort 64 +>0 uleshort 128 +>0 uleshort 256 +>0 uleshort 512 +>0 uleshort 1024 +>0 uleshort 2048 +>0 uleshort 4096 +>0 uleshort 8192 +>0 uleshort 16384 +>0 uleshort 32768 +>0 default x +>>0 uleshort x (rescale to %u x + +# Type: Godot 3, 4 texture (rescale display, height) +# From: David Korth <gerbilsoft@gerbilsoft.com> +# Shows rescale value if it's not a power of 2. +0 name godot-rescale-display-h +>0 clear x +>0 uleshort 0 +>0 uleshort 1 +>0 uleshort 2 +>0 uleshort 4 +>0 uleshort 8 +>0 uleshort 16 +>0 uleshort 32 +>0 uleshort 64 +>0 uleshort 128 +>0 uleshort 256 +>0 uleshort 512 +>0 uleshort 1024 +>0 uleshort 2048 +>0 uleshort 4096 +>0 uleshort 8192 +>0 uleshort 16384 +>0 uleshort 32768 +>0 default x +>>0 uleshort x %u) + +# Type: Godot 3 texture +# From: David Korth <gerbilsoft@gerbilsoft.com> +# References: +# - https://github.com/godotengine/godot/blob/3.3/core/image.h +# - https://github.com/godotengine/godot/blob/3.3/scene/resources/texture.cpp +# - https://github.com/godotengine/godot/blob/3.3/scene/resources/texture.h +# TODO: Don't show "rescale to" if it matches the image size. +0 string GDST Godot 3 texture: +!:ext stex +!:mime image/x-godot-stex +>4 uleshort x %u x +>8 uleshort x %u +>6 uleshort 0 \b, +>6 uleshort !0 +>>6 use godot-rescale-display-w +>>10 use godot-rescale-display-h +>>10 uleshort x \b, +>16 ulelong&0x800000 !0 has mipmaps, +>16 ulelong&0x100000 0x100000 lossless encoding +>16 ulelong&0x200000 0x200000 lossy encoding +>16 ulelong&0x300000 0 +>>16 use godot-pixel-format + +# Type: Godot 4 texture +# From: David Korth <gerbilsoft@gerbilsoft.com> +# References: +# - https://github.com/godotengine/godot/blob/master/core/io/image.h +# - https://github.com/godotengine/godot/blob/master/scene/resources/texture.cpp +# - https://github.com/godotengine/godot/blob/master/scene/resources/texture.h +# TODO: Don't show "rescale to" if it matches the image size. +0 string GST2 Godot 4 texture +!:ext stex +!:mime image/x-godot-stex +>4 ulelong x v%u: +>0x28 uleshort x %u x +>0x2A uleshort x %u +>8 use godot-rescale-display-w +>12 use godot-rescale-display-h +>12 uleshort x \b, +>0x2C ulelong >1 %u mipmaps, +>0x30 use godot-pixel-format +>0x24 ulelong 1 \b, embedded PNG image +>0x24 ulelong 2 \b, embedded WebP image +>0x24 ulelong 3 \b, Basis Universal diff --git a/magic/Magdir/intel b/magic/Magdir/intel index 531dd6548ddb..2b57fd1b246a 100644 --- a/magic/Magdir/intel +++ b/magic/Magdir/intel @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: intel,v 1.20 2021/04/26 15:56:00 christos Exp $ +# $File: intel,v 1.22 2022/04/02 14:47:42 christos Exp $ # intel: file(1) magic for x86 Unix # # Various flavors of x86 UNIX executable/object (other than Xenix, which @@ -43,7 +43,16 @@ # no hint found, that at offset 22 is version #>22 leshort >0 - version %d 0 leshort 0x0200 ->0 use display-coff +# no F_EXEC flag bit implies Intel ia64 COFF object file without optional header +>18 leshort ^0x0002 +# skip some DEGAS high-res uncompressed bitmap *.pi3 handled by ./images like +# GEMINI03.PI3 MODEM2.PI3 POWERFIX.PI3 sigirl1.pi3 vanna5.pi3 +# by test for valid starting character (often point 0x2E) of 1st section name +>>20 ubyte >0x1F +>>>0 use display-coff +# F_EXEC flag bit implies Intel ia64 COFF executable +>18 leshort &0x0002 +>>0 use display-coff 0 leshort 0x8664 >0 use display-coff @@ -52,16 +61,191 @@ # From: Alex Myczko <alex@aiei.ch> # updated by Joerg Jenderek # https://en.wikipedia.org/wiki/Option_ROM -0 beshort 0x55AA BIOS (ia32) ROM Ext. -!:mime application/octet-stream +# URL: http://fileformats.archiveteam.org/wiki/BIOS +# Reference: http://www.lejabeach.com/sisubb/BIOS_Disassembly_Ninjutsu_Uncovered.pdf +0 beshort 0x55AA +# skip misidentified raspberry pi pieeprom-*.bin by check for +# unlikely high ROM size (0xF0*512=240*512) and not observed start instruction 0x0F +>2 ubeshort !0xF00F +# skip 2 byte sized eof.bin with start magic +>>0 use rom-x86 +0 name rom-x86 +>0 beshort x BIOS (ia32) ROM Ext. +#!:mime application/octet-stream +!:mime application/x-ibm-rom !:ext rom/bin ->5 string USB USB ->7 string LDR UNDI image +################################################################################ +# not Plug aNd Play ($PnP) like 00000000 (ide_xtp.bin kvmvapic.bin V7VGA.ROM) 000000fc (MCT-VGA.bin) +# 55aaf00f (pieeprom-*.bin) 55aa40e9 (Trm3x5.bin) 24506f4f (sgabios-bin.rom) +# 55aa4be9 (vgabios-stdvga.rom vgabios-cirrus-bin.rom vgabios-vmware-bin.rom) +>(26.s) ubelong !0x24506e50 +#>(26.s) ubelong !0x24506e50 NOT PNP=%8.8x +# also not PCI (PCIR) implies "old" ISA cards or foo like: 8a168404 (MCT-VGA.bin) +# 55aaf00f (pieeprom*.bin) +>>(24.s) ubelong !0x50434952 +#>>(24.s) ubelong !0x50434952 ISA CARD=%8.8x +# "old" identification strings used in file version 5.41 and earlier +# probably an USB controller +>>>5 string USB USB +# probably https://en.wikipedia.org/wiki/Preboot_Execution_Environment +>>>7 string LDR UNDI image +# probably another Adaptec SCSI controller +>>>26 string Adaptec Adaptec +# http://minuszerodegrees.net/rom/bin/adaptec_aha1542cp_bios_908501-00.bin +# already done by PNP variant +#>>>28 string Adaptec Adaptec +# probably Promise SCSI controller +>>>42 string PROMISE Promise +# old test for IBM compatible Video cards; INTERNAL FACTS WHY IS THIS WORKING? >30 string IBM IBM comp. Video ->26 string Adaptec Adaptec ->28 string Adaptec Adaptec ->42 string PROMISE Promise ->2 byte x (%d*512) +# display exact text for IBM compatible Video cards with longer text +>>33 ubyte !0 +>>>30 string x "%s" +# http://minuszerodegrees.net/rom/bin/unknown/MCT-VGA-16%20-%20TDVGA%203588%20BIOS%20Version%20V1.04A.zip +# "IBM COMPATIBLETDVGA 3588 BIOS Version V1.04A2+" "MCT-VGA-16 - TDVGA 3588 BIOS Version V1.04A.bin" +# "IBM VGA Compatible\001" NVidia44.bin +# "IBM EGA ROM Video Seven BIOS Code, Version 1.04" V7VGA.ROM +# "IBM" vgabios-stdvga.rom +# "IBM" vgabios-vmware-bin.rom: +# "IBM" vgabios-cirrus-bin.rom +# "IBM" vgabios-virtio-bin.rom +################################################################################ +# ROM size in 512B blocks must be interpreted as unsigned for ROM of network cards +# like: efi-eepro100.rom efi-rtl8139.rom pxe-e1000.rom +>2 ubyte x (%u*512) +# file name file size calculated size remark +# eof.bin 2 - with start magic nothing is shown here +# orchid.bin 188 0 =0*512 on window 95 CD in Drivers\audio\orchid3d +# multiboot.bin 1024 1024 =2*512 QEMU emulator +# loader1.bin 512 2048 =4*512 +# ide_xtp.bin 8192 8192 =16*512 +# kvmvapic.bin 9216 9216 =18*512 +# V7VGA.ROM 18832 16384 =32*512 +# adaptec1542.bin 32768 16384 =32*512 +# MCT-VGA.bin 32768 24576 =48*512 +# 2975BIOS.BIN 32768 32256 =63*512 +# efi-e1000.rom 196608 64000 =125*512 +# efi-rtl8139.rom 176640 66048 =129*512 +# pieeprom*.bin 524288 122880 =240*512 +################################################################################ +# initialization vector with executable code; often near JuMP instruction E9 yy zz +>3 ubyte =0xE9 jmp +# jmp offset like: 008fh 0093h 009fh 00afh 0143h 3ad7h 5417h 54ech 594dh 895fh +>>4 uleshort x %#4.4x +# for initialization vector samples without 3 byte jump instruction +>3 ubyte !0xE9 instruction +# eb4b3734h NVidia44.bin +# 00003234h V7VGA.ROM +# 060e0731h kvmvapic.bin +# cb000000h linuxboot-bin.rom +# e80d0fcbh PXE-Intel.rom +# b8004875h orchid.bin +>>3 ubelong x %#8.8x +# For misidetified raspberry pi pieeprom-*.bin like: 0xf00f +#>2 ubeshort x \b, AT 2 %#4.4x +################################################################################ +# new sections for BIOS (ia32) ROM Extension +# 4 bytes ASCII Signature "$PnP" for Plug aNd Play expansion header +>(26.s) string =$PnP \b; +#>(26.s) string =$PnP FOUND $PnP +# at 1Ah possible offset to expansion header structure; new for Plug aNd Play +>>26 uleshort x at %#x PNP +# Plug and Play vendor+device ID like: 0 0x000f1000 (2975BIOS.BIN) 0x31121095 (4243.bin) 0x04904215 (adaptec1542.bin) +#>>(26.s+0x0A) ulelong !0 NOT-nullID=%8.8x +>>(26.s+0x0A) uleshort !0 +# show PnP Vendor identification in human readable text form instead of numeric +# For adaptec_ava1515_bios_585201-00.bin reverted endian! BUT IS THIS ALWAYS TRUE? +>>>(26.s+0x0C) use \^PCI-vendor +>>>(26.s+0x0A) ubeshort x device=%#4.4x +# 3 byte Device type code; probably the same meaning as in PCI section? +# OK for storage controller SCSI (2975BIOS.BIN adaptec1542.bin) +# and network controller ethernet (efi-e1000.rom efi-rtl8139.rom) +>>(26.s+0x12) use PCI-class +# structure revision like: 01h +>>(26.s+4) ubyte !1 \b, revision %u +# PnP Header structure length in multiple of 16 bytes like: 2 +>>(26.s+5) uleshort !2 \b, length %u*16 +# offset to next header; 0 if none +>>(26.s+7) uleshort !0 \b, at %#x next header +# reserved byte; seems to be zero +>>(26.s+8) ubyte !0 \b, reserved %#x +# 8-bit checksum for this header; calculated and patched by patch2pnprom +>>(26.s+9) ubyte !0 \b, CRC %#x +# pointer to optional manufacturer string; like: 0 (4243.bin) 59h 5ch 60h c7h 14eh 27ch 296h 324h 3662h +>>(26.s+0x0E) uleshort >0 \b, at %#x +>>>(26.s+0x0C) uleshort x +# manufacturer ASCII-Z string like "http://ipxe.org" "Plop - Elmar Hanlhofer www.plop.at" "QEMU" +>>>>(&0.s) string x "%s" +# pointer to optional product string; like: 0 (2975BIOS.BIN) 6ch 70h 7ch d9h 160h 281h 29bh 329h +>>(26.s+0x10) uleshort >0 \b, at %#x +>>>(26.s+0x0E) uleshort x +# often human readable product ASCII-Z string like "iPXE" "Plop Boot Manager" +# "multiboot loader" "Intel UNDI, PXE-2.0 (build 082)" +>>>>(&0.s) string x "%s" +# PnP Device indicators; contains bits that identify the device as being capable of bootable +#>>(26.s+0x15) ubyte x \b, INDICATORS %#x +# device is a display device +>>(26.s+0x15) ubyte &0x01 \b, display +# device is an input device +>>(26.s+0x15) ubyte &0x02 \b, input +# device is an IPL device +>>(26.s+0x15) ubyte &0x04 \b, IPL +#>>(26.s+0x15) ubyte &0x08 reserved +# ROM is only required if this device is selected as a boot device +>>(26.s+0x15) ubyte &0x10 \b, bootable +# indicates ROM is read cacheable +>>(26.s+0x15) ubyte &0x20 \b, cacheable +# ROM may be shadowed in RAM +>>(26.s+0x15) ubyte &0x40 \b, shadowable +# ROM supports the device driver initialization model +>>(26.s+0x15) ubyte &0x80 \b, InitialModel +# boot connection vector; an offset to a routine that hook into INT 9h, INT 10h, or INT 13h +# 0 means disabled 0x0429 (4650_sr5.bin) 0x0072 (adaptec1542.bin) +>>(26.s+0x16) uleshort !0 \b, boot vector offset %#x +# disconnect vector; offset to routine that do cleanup from an unsuccessful boot attempt +>>(26.s+0x18) uleshort !0 \b, disconnect offset %#x +# bootstrap entry point/vector (BEV); offset to a routine (like RPL) that hook into INT 19h +# 0 means disabled 0x3c (multiboot.bin) 0x358 (efi-rtl8139.rom) 0xae7 (PXE-Intel.rom) +>>(26.s+0x1A) uleshort !0 \b, bootstrap offset %#x +# 2nd reserved area; seems to be zero +>>(26.s+0x1C) uleshort !0 \b, 2nd reserved %#x +# static resource information vector; 0 means disabled +>>(26.s+0x1E) uleshort !0 \b, static offset %#4.4x +################################################################################ +# 4 bytes ASCII Signature "PCIR" for PCI Data Structure +#>(24.s) string =PCIR FOUND PCIR +>(24.s) string =PCIR \b; +# pointer to PCI data structure like: 1Ch 38h 104h 8E44h +>>24 uleshort x at %#x PCI +# Vendor identification (ID) https://pci-ids.ucw.cz/v2.2/pci.ids +#>>(24.s+4) uleshort x ID=%4.4x +# show Vendor identification in human readable text form instead of numeric +>>(24.s+4) use PCI-vendor +# device identification (ID) +>>(24.s+6) uleshort x device=%#4.4x +# Base+sub class code https://wiki.osdev.org/PCI +>>(24.s+0x0D) use PCI-class +# pointer to vital product data (VPD); 0 indicates no VPD; WHAT EXACTLY iS VPD? +>>(24.s+8) uleshort !0 \b, at %#x VPD +# PCI data structure length like: 24h 28h +>>(24.s+0xA) uleshort >0x28 \b, length %u +# PCI data structure revision like: 0 3 +>>(24.s+0xC) ubyte >0 \b, revison %u +# image length (hexadecimal) in multiple of 512 bytes like: 54 56 68 6a 76 78 7c 7d 7e 7f 80 81 83 +# Apparently this gives the same information as given by byte at offset 2 but as 16-bit +#>>(24.s+0x10) uleshort x \b, length %u*512 +# revision level of code/data like: 0 1 201h 502h +>>(24.s+0xC) ubyte >1 \b, code revison %#x +# code type: 0~Intel x86/PC-AT compatible 1~Open firmware standard for PCI42 FF~Reserved +>>(24.s+0x14) ubyte >0 \b, code type %#x +# last image indicator; bit 7 indicates "last image"; bits 0-6 are reserved +>>(24.s+0x15) ubyte >0 +>>>(24.s+0x15) ubyte =0x80 \b, last ROM +# THIS SHOULD NOT HAPPEN! +>>>(24.s+0x15) ubyte !0x80 \b, indicator %x +# 3rd reserved area; seems to be zero in most cases but not for +# efi-e1000.rom efi-rtl8139.rom +>>(24.s+0x16) ubeshort !0 \b, 3rd reserved %#x # Flash descriptors for Intel SPI flash roms. # From Dr. Jesus <j@hug.gs> diff --git a/magic/Magdir/javascript b/magic/Magdir/javascript index 7fa9d9d404ca..1e29c5e8e875 100644 --- a/magic/Magdir/javascript +++ b/magic/Magdir/javascript @@ -1,19 +1,19 @@ #------------------------------------------------------------------------------ -# $File: javascript,v 1.2 2019/08/05 10:34:26 christos Exp $ +# $File: javascript,v 1.3 2021/12/08 13:42:00 christos Exp $ # javascript: magic for javascript and node.js scripts. # -0 search/1/w #!/bin/node Node.js script text executable +0 string/w #!/bin/node Node.js script text executable !:mime application/javascript -0 search/1/w #!/usr/bin/node Node.js script text executable +0 string/w #!/usr/bin/node Node.js script text executable !:mime application/javascript -0 search/1/w #!/bin/nodejs Node.js script text executable +0 string/w #!/bin/nodejs Node.js script text executable !:mime application/javascript -0 search/1/w #!/usr/bin/nodejs Node.js script text executable +0 string/w #!/usr/bin/nodejs Node.js script text executable !:mime application/javascript -0 search/1 #!/usr/bin/env\ node Node.js script text executable +0 string #!/usr/bin/env\ node Node.js script text executable !:mime application/javascript -0 search/1 #!/usr/bin/env\ nodejs Node.js script text executable +0 string #!/usr/bin/env\ nodejs Node.js script text executable !:mime application/javascript # Hermes by Facebook https://hermesengine.dev/ # https://github.com/facebook/hermes/blob/master/include/hermes/\ diff --git a/magic/Magdir/linux b/magic/Magdir/linux index f5216087f0cf..0405f778aa35 100644 --- a/magic/Magdir/linux +++ b/magic/Magdir/linux @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: linux,v 1.79 2021/04/26 15:56:00 christos Exp $ +# $File: linux,v 1.80 2022/03/24 15:48:58 christos Exp $ # linux: file(1) magic for Linux files # # Values for Linux/i386 binaries, from Daniel Quinlan <quinlan@yggdrasil.com> @@ -532,6 +532,6 @@ # ansible vault (does not really belong here) 0 string $ANSIBLE_VAULT; Ansible Vault ->&0 regex [0-9]*\.[0-9]* \b, version %s +>&0 regex [0-9]+\\.[0-9]+ \b, version %s >>&0 string ; ->>>&0 regex [A-Z0-9]* \b, encryption %s +>>>&0 regex [A-Z0-9]+ \b, encryption %s diff --git a/magic/Magdir/make b/magic/Magdir/make index f522b4f18b11..1abdf7a3ee2e 100644 --- a/magic/Magdir/make +++ b/magic/Magdir/make @@ -1,36 +1,21 @@ #------------------------------------------------------------------------------ -# $File: make,v 1.4 2018/05/29 17:26:02 christos Exp $ +# $File: make,v 1.5 2022/03/12 15:09:47 christos Exp $ # make: file(1) magic for makefiles # # URL: https://en.wikipedia.org/wiki/Make_(software) -0 regex/100l \^CFLAGS makefile script text -!:mime text/x-makefile -0 regex/100l \^VPATH makefile script text -!:mime text/x-makefile -0 regex/100l \^LDFLAGS makefile script text -!:mime text/x-makefile -0 regex/100l \^all: makefile script text -!:mime text/x-makefile -0 regex/100l \^\\.PRECIOUS makefile script text +0 regex/100l \^(CFLAGS|VPATH|LDFLAGS|all:|\\.PRECIOUS) makefile script text !:mime text/x-makefile +!:strength -15 # Update: Joerg Jenderek # Reference: https://www.freebsd.org/cgi/man.cgi?make(1) # exclude grub-core\lib\libgcrypt\mpi\Makefile.am with "#BEGIN_ASM_LIST" # by additional escaping point character -0 regex/100l \^\\.BEGIN BSD makefile script text -!:mime text/x-makefile -!:ext /mk -!:strength +10 # exclude MS Windows help file CoNtenT with ":include FOOBAR.CNT" # and NSIS script with "!include" by additional escaping point character -0 regex/100l \^\\.include BSD makefile script text -!:mime text/x-makefile -!:ext /mk -!:strength +10 -0 regex/100l \^\\.endif BSD makefile script text +0 regex/100l \^\\.(BEGIN|endif|include) BSD makefile script text !:mime text/x-makefile !:ext /mk -!:strength +10 -0 regex/100l \^SUBDIRS automake makefile script text +!:strength -10 +0 regex/100l \^SUBDIRS[[:space:]]+= automake makefile script text !:mime text/x-makefile -!:strength +10 +!:strength -15 diff --git a/magic/Magdir/mathematica b/magic/Magdir/mathematica index 77903b5fe8c3..1563e34ba21a 100644 --- a/magic/Magdir/mathematica +++ b/magic/Magdir/mathematica @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: mathematica,v 1.13 2021/07/14 09:06:24 christos Exp $ +# $File: mathematica,v 1.14 2021/11/07 16:27:36 christos Exp $ # mathematica: file(1) magic for mathematica files # "H. Nanosecond" <aldomel@ix.netcom.com> # Mathematica a multi-purpose math program @@ -117,16 +117,29 @@ 13 ushort 0 # check for valid ASCII matrix name >20 ubyte >0x1F +# skip PreviousEntries.dat with "invalid high" name \304P\344@\001 +>>20 ubyte <0304 +# skip some Netwfw*.dat and $I3KREPH.dat by checking for non zero number of rows +>>>4 ulong !0 # skip some CD-ROM filesystem like test-hfs.iso by looking for valid big endian type flag ->>0 ubelong&0xFFffFF00 0x00000300 ->>>0 use matlab4 +>>>>0 ubelong&0xFFffFF00 0x00000300 +>>>>>0 use matlab4 # no example for 8-bit and 16-bit integers matrix ->>0 ubelong&0xFFffFF00 0x00000400 ->>>0 use matlab4 ->>0 ulelong x +>>>>0 ubelong&0xFFffFF00 0x00000400 +>>>>>0 use matlab4 +# branch for Little-Endian variant of Matlab MATrix version 4 # skip big endian variant by looking for valid low lttle endian type flag ->>0 ulelong <53 ->>>0 use \^matlab4 +>>>>0 ulelong <53 +# skip tokens.dat and some Netwfw*.dat by check for valid imaginary flag value of MAT version 4 +>>>>>12 ulelong <2 +# no misidentfied little endian MATrix example with "short" matrix name +>>>>>>16 ulelong <3 +>>>>>>>0 use \^matlab4 +# little endian MATrix with "long" matrix name or some misidentified samples +>>>>>>16 ulelong >2 +# skip TileCacheLogo-*.dat with invalid 2nd character \001 of matrix name with length 96 +>>>>>>>21 ubyte >0x1F +>>>>>>>>0 use \^matlab4 # display information of Matlab v4 mat-file 0 name matlab4 Matlab v4 mat-file #!:mime application/octet-stream @@ -145,8 +158,10 @@ >0 ubelong/1000 4 (Cray) # namlen; the length of the matrix name #>16 ubelong x \b, name length %u +#>(16.L+19) ubyte x \b, TERMINATING NAME CHARACTER=%#x # nul terminated matrix name like: fit_params testmatrix testsparsecomplex teststringarray #>20 string x \b, MATRIX NAME="%s" +#>21 ubyte x \b, MAYBE 2ND CHAR=%c >16 pstring/L x %s # T indicates the matrix type: 0~numeric 1~text 2~sparse #>0 ubelong%10 x \b, T=%u @@ -158,5 +173,5 @@ # ncols; number of columns in the matrix like: 1 3 4 5 9 43 >8 ubelong x \b, columns %u # imagf; imaginary flag; 1~matrix has an imaginary part 0~only real data ->12 ubelong !0 \b, imaginary +>12 ubelong !0 \b, imaginary (%u) # real; Real part of the matrix consists of mrows * ncols numbers diff --git a/magic/Magdir/mcrypt b/magic/Magdir/mcrypt index 9c66af48b2a2..f2edd08912dd 100644 --- a/magic/Magdir/mcrypt +++ b/magic/Magdir/mcrypt @@ -1,14 +1,28 @@ #------------------------------------------------------------------------------ -# $File: mcrypt,v 1.5 2009/09/19 16:28:10 christos Exp $ +# $File: mcrypt,v 1.6 2022/02/08 18:51:45 christos Exp $ # Mavroyanopoulos Nikos <nmav@hellug.gr> # mcrypt: file(1) magic for mcrypt 2.2.x; +# URL: https://en.wikipedia.org/wiki/Mcrypt +# http://fileformats.archiveteam.org/wiki/MCrypt +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/n/nc-mcrypt.trid.xml +# Update: Joerg Jenderek +# Note: called by TrID "mcrypt encrypted (v2.5)" 0 string \0m\3 mcrypt 2.5 encrypted data, +#!:mime application/octet-stream +!:mime application/x-crypt-nc +!:ext nc >4 string >\0 algorithm: %s, >>&1 leshort >0 keysize: %d bytes, >>>&0 string >\0 mode: %s, +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/n/nc-mcrypt-22.trid.xml +# Note: called by TrID "mcrypt encrypted (v2.2)" 0 string \0m\2 mcrypt 2.2 encrypted data, +#!:mime application/octet-stream +!:mime application/x-crypt-nc +# no example +!:ext nc >3 byte 0 algorithm: blowfish-448, >3 byte 1 algorithm: DES, >3 byte 2 algorithm: 3DES, diff --git a/magic/Magdir/msdos b/magic/Magdir/msdos index c586210218bf..a8d6d0f43e3e 100644 --- a/magic/Magdir/msdos +++ b/magic/Magdir/msdos @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: msdos,v 1.152 2021/10/12 18:26:10 christos Exp $ +# $File: msdos,v 1.154 2022/03/21 21:25:50 christos Exp $ # msdos: file(1) magic for MS-DOS files # @@ -1367,6 +1367,8 @@ # HtmlHelp files (.chm) 0 string/b ITSF\003\000\000\000\x60\000\000\000 MS Windows HtmlHelp Data +!:mime application/vnd.ms-htmlhelp +!:ext chm # GFA-BASIC (Wolfram Kleff) 2 string/b GFA-BASIC3 GFA-BASIC 3 data @@ -1765,3 +1767,37 @@ # NB: The BACKUP.nnn files consist of the files backed up, # concatenated. + +# From: Joerg Jenderek +# URL: http://fileformats.archiveteam.org/wiki/MS-DOS_date/time +# Reference: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-dosdatetimetofiletime +# Note: DOS date+time format is different from formats such as Unix epoch +# bit encoded; uses year values relative to 1980 and 2 second precision +0 name dos-date +# HHHHHMMMMMMSSSSS bit encoded Hour (0-23) Minute (0-59) SecondPart (*2) +#>0 uleshort x RAW TIME [%#4.4x] +# hour part +#>0 uleshort/2048 x hour [%u] +# YYYYYMMMMDDDDD bit encoded YearPart (+1980) Month (1-12) Day (1-31) +#>2 uleshort x RAW DATE [%#4.4x] +# day part +>2 uleshort&0x001F x %u +#>2 uleshort/16 x MONTH PART [%#x] +# GRR: not working +#>2 uleshort/16 &0x000F MONTH [%u] +#>2 uleshort&0x01E0 x MONTH PART [%#4.4x] +>2 uleshort&0x01E0 =0x0020 jan +>2 uleshort&0x01E0 =0x0040 feb +>2 uleshort&0x01E0 =0x0060 mar +>2 uleshort&0x01E0 =0x0080 apr +>2 uleshort&0x01E0 =0x00A0 may +>2 uleshort&0x01E0 =0x00C0 jun +>2 uleshort&0x01E0 =0x00E0 jul +>2 uleshort&0x01E0 =0x0100 aug +>2 uleshort&0x01E0 =0x0120 sep +>2 uleshort&0x01E0 =0x0140 oct +>2 uleshort&0x01E0 =0x0160 nov +>2 uleshort&0x01E0 =0x0180 dec +# year part +>2 uleshort/512 x 1980+%u +# diff --git a/magic/Magdir/msooxml b/magic/Magdir/msooxml index 06f244fa132c..9303411f6356 100644 --- a/magic/Magdir/msooxml +++ b/magic/Magdir/msooxml @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: msooxml,v 1.16 2021/08/16 10:06:55 christos Exp $ +# $File: msooxml,v 1.17 2021/11/08 13:53:43 christos Exp $ # msooxml: file(1) magic for Microsoft Office XML # From: Ralf Brown <ralf.brown@gmail.com> @@ -30,7 +30,7 @@ # make sure the first file is correct >0x1E use msooxml >0x1E default x ->>0x1E regex \\[Content_Types\\]\\.xml|_rels/\\.rels|docProps +>>0x1E regex \\[Content_Types\\]\\.xml|_rels/\\.rels|docProps|customXml # skip to the second local file header # since some documents include a 520-byte extra field following the file # header, we need to scan for the next header @@ -46,5 +46,10 @@ # OpenOffice/Libreoffice orders ZIP entry differently, so check the 4th file >>>>>>&26 search/6000 PK\003\004 >>>>>>>&26 use msooxml +# Some OOXML generators add an extra customXml directory. Check another file. +>>>>>>>&26 default x +>>>>>>>>&26 search/6000 PK\003\004 +>>>>>>>>>&26 use msooxml +>>>>>>>>>&26 default x Microsoft OOXML >>>>>>>&26 default x Microsoft OOXML >>>>>&26 default x Microsoft OOXML diff --git a/magic/Magdir/msvc b/magic/Magdir/msvc index 8cf5c166d3f1..fbfa4f266f9b 100644 --- a/magic/Magdir/msvc +++ b/magic/Magdir/msvc @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: msvc,v 1.10 2018/10/01 19:14:03 christos Exp $ +# $File: msvc,v 1.11 2022/01/17 17:17:30 christos Exp $ # msvc: file(1) magic for msvc # "H. Nanosecond" <aldomel@ix.netcom.com> # Microsoft visual C @@ -20,9 +20,162 @@ 0 string \377\003\000\377\001\000\060\020\350 MSVC .res #.lib -0 string \360\015\000\000 Microsoft Visual C library -0 string \360\075\000\000 Microsoft Visual C library -0 string \360\175\000\000 Microsoft Visual C library +# URL: https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B +# http://fileformats.archiveteam.org/wiki/Microsoft_Library +# http://fileformats.archiveteam.org/wiki/OMF +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/l/lib-msvc.trid.xml +# https://pierrelib.pagesperso-orange.fr/exec_formats/OMF_v1.1.pdf +# Update: Joerg Jenderek +#0 string \360\015\000\000 Microsoft Visual C library +#0 string \360\075\000\000 Microsoft Visual C library +#0 string \360\175\000\000 Microsoft Visual C library +# test for RecordType~LibraryHeaderRecord=0xF0 + RecordLength=???Dh + dictionary offset is multiple of 0x200 +0 ubelong&0xFF0f80ff =0xF00d0000 +# Microsoft Visual C library (strength=70) before MIDI SysEx messages (strength=50) handled by ./sysex +#!:strength +0 +# test for valid 2nd RecordType~Translator Header Record=THEADR=80h or LHEADR=82h +>(1.s+3) ubyte&0xFD =0x80 +>>0 use omf-lib +# display information about Microsoft Visual C/OMF library +0 name omf-lib +# RecordType~LibraryHeaderRecord=0xF0 +#>0 byte 0xF0 Microsoft Visual C library +# the above description was used in file version 5.41 +>0 byte 0xF0 Microsoft Visual C/OMF library +#>0 byte 0xF0 relocatable Object Module Format (OMF) libray +#!:mime application/octet-stream +!:mime application/x-omf-lib +!:ext lib +# 1st record data length like 13=0Dh 29=1Dh 61=3Dh 125=7Dh 509=01FDh ... 32765=7FFDh +#>1 uleshort x \b, 1st record data length %u +#>1 uleshort x \b, 1st record data length %#x +# 2**4=16 <= RecordLength+3 = PageSize = 2**n {16 32 512 no examples 64 128 256 1024 2048 ...32768} <= 2**15=32768 +>1 uleshort+3 x \b, page size %u +# dictionary offset like: 400h 600h a00h c00h 1200h 1800h 2400h 5600h 12800h 19200h 28a00h +>3 ulelong x \b, at %#x dictionary +# dictionary block a 512 bytes; the first 37 bytes correspond to the 37 buckets +#>(3.l) ubequad x (%#16.16llx...) +# dictionary size; length in 512-byte blocks; a prime number? like: +# 1 2 3 4 5 6 7 9 11 13 15 16 18 21 22 23 24 25 31 50 53 89 101 117 277 +>7 uleshort x with %u block +# plurals s +>7 uleshort >1 \bs +# If dictionary byte 38 (FFLAG) has the value 255, there is no space left +>(3.l+37) ubyte <0xFF (FFLAG=%#x) +>(3.l+37) ubyte =0xFF (FFLAG=full) +# dictionary entry; length byte of following symbol, the following text bytes of symbol, two bytes specifies the page number +# like: dbfntx1! DBFNTX.LIB zlibCompileFlags_ ZLIB.LIB atoi! mwlibc.lib +>(3.l+38) pstring x 1st entry %s +# like: 1 33 41 47 458 8783 +>>&0 uleshort x in page %u +# library flags; 0 or 1, but WHAT IS 0x4d in MOUSE.LIB ? +>9 ubyte >1 \b, flags %#x +>9 ubyte =1 case sensitive +# In the library after header comes first object module with a Library Module Header Record (LHEADR=82h) +# but in examples Translator Header Record (THEADR=80h) which is handled identically +>(1.s+3) ubyte x \b, 2nd record +>(1.s+3) ubyte !0x80 (type %#x) +#>(1.s+4) uleshort x \b, 2nd record data length %u +# Module name often source name like "dos\crt0.asm" in mlibce.lib or "QB4UTIL.ASM" in QB4UTIL.LIB +# or "C:\Documents and Settings\Allan Campbell\My Documents\FDOSBoot\zlib\zutil.c" in ZLIB.LIB +# or title like "87INIT" in FP87.LIB or "ACOSASIN" in MATHC.LIB or "Copyright" in calc-bcc.lib +>(1.s+6) pstring x "%s" +# 2nd record checksum +#>>&0 ubyte x checksum %#x +# 3rd RecordType: 96h~LNAMES 88h~COMENT +>>&1 ubyte x \b, 3rd record +>>&1 ubyte !0x88 +>>>&-1 ubyte !0x96 +# 3rd unusual record type +>>>>&-1 ubyte x (type %#x) +# 3rd record is a List of Names Record (LNAMES=96h) +>>&1 ubyte =0x96 LNAMES +# LNAMES record length like: 2 15 19 +#>>>&0 uleshort x \b, LNAMES record length %u +>>>&0 uleshort >2 +# 1st LNAME string length; null is valid; maximal 255 +#>>>>&0 ubyte x 1st LNAME length %u +>>>>&0 ubyte =0 +# 2nd LNAME length like: 4 7 8 17 31 +#>>>>>&0 ubyte x 2nd LNAME length %u +# name used for segment, class, group, overlay, etc like: +# CODE (mwlibc.lib) _TEXT32 (JMPPM32.LIB) _OVLCODE (WOVL.LIB) +>>>>>&0 pstring x %s +# 3rd LNAME length like: 4 5 +#>>>>>>&0 ubyte x 3rd LNAME length %u +# like: DATA (mwlibc.lib) CODE (JMPPM32.LIB) _TEXT (EMU87.LIB) +>>>>>>&0 pstring x %s +# maybe 4th LNAME length like: 4 6 +>>>>>>>&0 ubyte <44 +# like: DATA (DEBUG.LIB) DGROUP (mwlibc.lib MOUSE.LIB) +>>>>>>>>&-1 pstring x %s +# 3rd record is a COMMENT (Including all comment class extensions) +>>&1 ubyte =0x88 COMMENT +# comment record length like: 3 FLIB7M.LIB 1Bh 1Eh 23h 27h 2Bh 30h freetype-bcc.lib +#>>>&0 uleshort x \b, record length %#x +# real comment length = record length - 1 (comment type) - 1 (comment Class) - 1 (checksum) -1 (char count) +# like: 2 LIBFL.LIB 4 "UUID" 5 "dscap" 6 "int386" 7 "qb4util" 8 "AMSGEXIT" 16 REXX.LIB 20 27 35 44 freetype-bcc.lib +#>>>>&-2 uleshort-4 >0 \b, comment length %u +# check that record contain at least comment type (1 byte), comment class (1 byte), checksum (1 byte) +# probably always true +>>>&0 uleshort >2 +# comment type: 80h~NP~no purge bit 40h~NL~no list bit +#>>>>&0 ubyte !0 Type %#x +>>>>&0 ubyte &0x80 Preserved +# no example +>>>>&0 ubyte &0x40 NoList +# comment class like: 0~Translator A0~OMF extensions A3~LIBMOD A1~New OMF extensions AA~UNKNOWN +>>>>&1 ubyte x class=%#x +# check that comment record contains at least real content +>>>>&-2 uleshort >3 +# Translator comment record (0); it may name the source language or translator +>>>>>&1 ubyte =0 Translator +#>>>>>>&0 ubyte x Translator length %u +# like: "TC86 Borland Turbo C 2.01 " (GEMS.LIB) "TC86 Borland Turbo C++ 3.00" (CATDB.LIB) +>>>>>>&0 pstring x "%s" +# OMF extensions comment record (A0); first byte of commentary string identifies subtype +>>>>>&1 ubyte =0xA0 OMF extensions +# A0 subtype like: 1~IMPDEF +>>>>>>&0 ubyte !1 subtype %#x +# Import Definition Record (Comment Class A0, Subtype 01~IMPDEF) +>>>>>>&0 ubyte 1 IMPDEF +# ordinal flag; determines form of Entry Ident field. If nonzero (seems to be 1) Entry is ordinal +>>>>>>>&0 ubyte !0 ordinal +# like: IMPORT.LIB DOSCALLS.LIB mlibw.lib mwinlibc.lib REXX.LIB +>>>>>>>>&-1 ubyte >1 %u +# Internal Name in count, char string format; module name for the imported symbol +# like: 7 "REXXSAA" 9 11 13 14 15 16 20 21 26 "_Z10_clip_linePdS_S_S_dddd" +#>>>>>>>&1 ubyte x internal name length %u +# internal module name like: _DllGetVersion DllGetVersion BezierTerminationTest Copyright +>>>>>>>&1 pstring x %s +# module name in count, char string format; DLL name that supplies a matching export symbol +# like: jpeg62.dll (jpeg-bcc.lib) unrar3.dll (unrar-bcc.lib) REXX (REXX.LIB) +>>>>>>>>&0 pstring x exported by %s +# Entry Ident; 16-bit if ordinal flag != 0 or imported name in count, char string format if ordinal flag = 0 +# like: \0 (calc-bcc.lib) DllGetVersion (libtiff-bcc.lib) UTF8ToHtml (libxml2-bcc.lib) xslAddCall (libxslt-bcc.lib) +#>>>>>>>>>&0 pstring >\0 entry ident %s +# "New OMF" extensions comment (A1); indicate version of symbolic debug information +# like: LIBFL.LIB +>>>>>&1 ubyte =0xA1 New OMF extensions +# symbolic debug information version n +>>>>>>&0 ubyte x n=%u +# symbolic debug information style like: HL~IBM PM Debugger style (LIBFL.LIB) DX~AIX style CV~Microsoft symbol and type style +>>>>>>>&0 string HL IBM style +>>>>>>>&0 string DX AIX style +>>>>>>>&0 string CV Microsoft style +# LIBMOD comment record (A3) used only by the librarian +# Microsoft extension added for LIB version 3.07 in macro assembler (MASM 5.0) +>>>>>&1 ubyte =0xA3 LIBMOD +# The A3 LIBMOD record contains only the ASCII string of the module name in count char format +#>>>>>>&0 ubyte x LIBMOD length %u +# LIBMOD comment record module name without path and extension like: +# qb4util (QB4UTIL.LIB) affaldiv (libh.lib) crt0 (slibc.lib) clipper (DDDRAWS.LIB) dinpdev (DINPUTS.LIB) UUID (UUID.LIB) +>>>>>>&0 pstring x %s +# GRR: WHAT iS THAT? AA foo comment record +#>>>>>&1 ubyte =0xAA AA-comment +# like: OS220 +#>>>>>>&0 string x what=%-5.5s +# #.pch 0 string DTJPCH0\000\022\103\006\200 Microsoft Visual C .pch diff --git a/magic/Magdir/nifty b/magic/Magdir/nifty new file mode 100644 index 000000000000..151d869872d4 --- /dev/null +++ b/magic/Magdir/nifty @@ -0,0 +1,202 @@ + +#------------------------------------------------------------------------------ +# $File: nifty,v 1.1 2022/02/14 16:51:15 christos Exp $ +# file(1) magic for the NIfTI file format + +# Type: NIfTI, Neuroimaging file format +# URL: https://nifti.nimh.nih.gov/ +# From: Yann Leprince <yann.leprince@cea.fr>, 2022 + +344 string n+1\0 NIfTI-1 neuroimaging data, +!:mime image/x.nifti +!:ext nii +>0 use nifti1 +344 string ni1\0 NIfTI-1 neuroimaging data header, +!:mime image/x.nifti +!:ext hdr +>0 use nifti1 + +4 string n+2\0\r\n\032\n NIfTI-2 neuroimaging data, +!:mime image/x.nifti +!:ext nii +>0 use nifti2 +4 string ni2\0\r\n\032\n NIfTI-2 neuroimaging data header, +!:mime image/x.nifti +!:ext hdr +>0 use nifti2 + +# Main subroutine for NIfTI-1 +0 name nifti1 +>0 clear x +>0 lelong =348 little endian +>>70 use nifti-datatype-le +>>112 lefloat !0 with scaling +>>0 use nifti1-dim-le +>>252 leshort >0 \b, with qform +>>>252 use xform-code-nifti1-le +>>254 leshort >0 \b, with sform +>>>254 use xform-code-nifti1-le +>>136 string >\0 \b, description: %s +>0 belong =348 big endian +>>70 use \^nifti-datatype-le +>>112 befloat !0 with scaling +>>0 use \^nifti1-dim-le +>>252 beshort >0 \b, with qform +>>>252 use \^xform-code-nifti1-le +>>254 beshort >0 \b, with sform +>>>254 use \^xform-code-nifti1-le +>>136 string >\0 \b, description: %s +>0 default x +>>0 long x invalid sizeof_hdr=%d + +# Main subroutine for NIfTI-2 +0 name nifti2 +>0 clear x +>0 lelong =540 little endian +>>12 use nifti-datatype-le +>>176 lefloat !0 with scaling +>>0 use nifti2-dim-le +>>344 lelong >0 \b, with qform +>>>344 use xform-code-nifti2-le +>>348 lelong >0 \b, with sform +>>>348 use xform-code-nifti2-le +>>240 string >\0 \b, description: %s +>0 belong =540 big endian +>>12 use \^nifti-datatype-le +>>176 befloat !0 with scaling +>>0 use \^nifti2-dim-le +>>344 lelong >0 \b, with qform +>>>344 use \^xform-code-nifti2-le +>>348 lelong >0 \b, with sform +>>>348 use \^xform-code-nifti2-le +>>240 string >\0 \b, description: %s +>0 default x +>>0 long x invalid sizeof_hdr=%d + + +# Other subroutines for details of NIfTI files + +0 name nifti-datatype-le +>0 clear x +>0 leshort =1 \b, binary datatype +>0 leshort =2 \b, uint8 datatype +>0 leshort =4 \b, int16 datatype +>0 leshort =8 \b, int32 datatype +>0 leshort =16 \b, float32 datatype +>0 leshort =32 \b, complex64 datatype +>0 leshort =64 \b, float64 datatype +>0 leshort =128 \b, RGB24 datatype +>0 leshort =256 \b, int8 datatype +>0 leshort =512 \b, uint16 datatype +>0 leshort =768 \b, uint32 datatype +>0 leshort =1024 \b, int64 datatype +>0 leshort =1280 \b, uint64 datatype +>0 leshort =1536 \b, float128 datatype +>0 leshort =1792 \b, complex128 datatype +>0 leshort =2048 \b, complex256 datatype +>0 leshort =2304 \b, RGBA32 datatype +>0 default x +>>0 leshort x \b, unknown datatype 0x%x +>>2 leshort x (%d bits/pixel) + +0 name nifti1-dim-le +>0 clear x +>40 leshort <0 \b, INVALID dim[0]=%d +>40 leshort >7 \b, INVALID dim[0]=%d +>0 default x +>>40 leshort x \b, %d-dimensional (size +>>42 leshort x %d +>>40 leshort >1 +>>>44 leshort x \bx%d +>>40 leshort >2 +>>>46 leshort x \bx%d +>>40 leshort >3 +>>>48 leshort x \bx%d +>>40 leshort >4 +>>>50 leshort x \bx%d +>>40 leshort >5 +>>>52 leshort x \bx%d +>>40 leshort >6 +>>>54 leshort x \bx%d +>>80 lefloat x \b, voxel size %f +>>40 leshort >1 +>>>84 lefloat x x %f +>>40 leshort >2 +>>>88 lefloat x x %f +>>123 use nifti1-xyz-unit +>>40 leshort >3 +>>>92 lefloat x x %f +>>>123 use nifti1-t-unit +>>40 leshort x \b) + +0 name nifti2-dim-le +>0 clear x +>16 lequad <0 \b, INVALID dim[0]=%lld +>16 lequad >7 \b, INVALID dim[0]=%lld +>0 default x +>>16 lequad x \b, %lld-dimensional (size +>>24 lequad x %lld +>>16 lequad >1 +>>>32 lequad x \bx%lld +>>16 lequad >2 +>>>40 lequad x \bx%lld +>>16 lequad >3 +>>>48 lequad x \bx%lld +>>16 lequad >4 +>>>56 lequad x \bx%lld +>>16 lequad >5 +>>>64 lequad x \bx%lld +>>16 lequad >6 +>>>72 lequad x \bx%lld, +>>112 ledouble x \b, voxel size %f +>>16 lequad >1 +>>>120 ledouble x x %f +>>16 lequad >2 +>>>128 ledouble x x %f +>>500 use nifti2-xyz-unit +>>16 lequad >3 +>>>136 ledouble x x %f +>>>500 use nifti2-t-unit +>>16 lequad x \b) + +0 name xform-code-nifti1-le +>0 leshort =1 to scanner-based coordinates +>0 leshort =2 to aligned coordinates +>0 leshort =3 to Talairach coordinates +>0 leshort =4 to MNI152 coordinates +>0 leshort =5 to template coordinates + +0 name xform-code-nifti2-le +>0 lelong =1 to scanner-based coordinates +>0 lelong =2 to aligned coordinates +>0 lelong =3 to Talairach coordinates +>0 lelong =4 to MNI152 coordinates +>0 lelong =5 to template coordinates + +0 name nifti1-xyz-unit +>0 byte &0x01 +>>0 byte ^0x02 m +>>0 byte &0x02 micron +>0 byte ^0x01 +>>0 byte &0x02 mm + +0 name nifti1-t-unit +>0 byte &0x08 +>>0 byte ^0x10 s +>>0 byte &0x10 ms +>0 byte ^0x08 +>>0 byte &0x10 microsecond + +0 name nifti2-xyz-unit +>0 lelong &0x01 +>>0 lelong ^0x02 m +>>0 lelong &0x02 micron +>0 lelong ^0x01 +>>0 lelong &0x02 mm + +0 name nifti2-t-unit +>0 lelong &0x08 +>>0 lelong ^0x10 s +>>0 lelong &0x10 ms +>0 lelong ^0x08 +>>0 lelong &0x10 microsecond diff --git a/magic/Magdir/ole2compounddocs b/magic/Magdir/ole2compounddocs index a5e60a821b5e..1379e569e122 100644 --- a/magic/Magdir/ole2compounddocs +++ b/magic/Magdir/ole2compounddocs @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: ole2compounddocs,v 1.12 2021/09/04 16:00:38 christos Exp $ +# $File: ole2compounddocs,v 1.18 2022/05/31 17:38:36 christos Exp $ # Microsoft OLE 2 Compound Documents : file(1) magic for Microsoft Structured # storage (https://en.wikipedia.org/wiki/Compound_File_Binary_Format) # Additional tests for OLE 2 Compound Documents should be under this recipe. @@ -200,6 +200,22 @@ !:mime application/x-ms-info !:ext nfo # +# From: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/Microsoft_Access +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/m/mdz.trid.xml +# http://fileformats.archiveteam.org/wiki/Microsoft_Compound_File +# Note: only version foo tested and called "Microsoft Access Wizard template" by TrID +# Fourth directory entry name TemplateID +>>>>384 lestring16 TemplateID : Microsoft Access wizard template +# Second directory entry name like \005SummaryInformation and 3rd name like \005DocumentSummaryInformation +#!:mime application/x-ole-storage +#!:mime application/vnd.ms-office +#!:mime application/vnd.ms-access +#!:mime application/msaccess +!:mime application/x-ms-mdz +# http://extension.nirsoft.net/mdz +!:ext mdz +# # URL: http://fileformats.archiveteam.org/wiki/Corel_Print_House # Second directory entry name Thumbnail >>>>128 lestring16 Thumbnail : Corel PrintHouse image @@ -258,6 +274,24 @@ !:ext prd/prv # 2nd directory entry name Pictures >>>>>>128 lestring16 Pictures with pictures +# +# URL: http://fileformats.archiveteam.org/wiki/PageMaker +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/p +# pagemaker-generic.trid.xml +# pagemaker-pm6.trid.xml +# pagemaker-pm65.trid.xml +# pmd-pm7.trid.xml +# From: Joerg Jenderek +# Note: since version 6 embedd as stream with PageMaker name the "old" format handled by ./wordprocessors +# verified by Michal Mutl Structured Storage Viewer `SSView.exe brochus.pt6` +# Second directory entry name PageMaker +>>>>128 lestring16 PageMaker : +# look for magic of "old" PageMaker like in 02TEMPLT.T65 +>>>>>0 search/0xa900/s \0\0\0\0\0\0\xff\x99 +# GRR: jump to PageMaker stream and inspect it by sub routine PageMaker of ./wordprocessors failed with wrong version! +#>>>>>>&0 use PageMaker +# THIS WORKS PARTLY! +>>>>>>&0 indirect x # remaining null clsid >>>>128 default x : UNKNOWN # second directory entry name like VisioDocument Control000 @@ -267,6 +301,9 @@ # forth >>>>>384 lestring16 x %.20s !:mime application/x-ole-storage +# according to file version 5.41 with -e soft option +#!:mime application/CDFV2 +#!:ext ??? # look for known clsid GUID # - Visio documents # URL: http://fileformats.archiveteam.org/wiki/Visio @@ -417,6 +454,28 @@ !:apple ????PPT3 # /autostart/template !:ext ppt/pps/pot +# From: Joerg Jenderek +# URL: https://www.file-extensions.org/ppa-file-extension +# https://en.wikipedia.org/wiki/Microsoft_PowerPoint#cite_note-231 +# Reference: http://fileformats.archiveteam.org/wiki/Microsoft_Compound_File +>>88 ubequad 0x871800aa0060263b : Microsoft +# only version 8 (97) tested; PowerPoint 4.0 to 11.0 (2004) (Wikipedia); 97 to 2003 (file-extensions.org) +>>>80 ubequad 0xf04672810a72cf11 PowerPoint Addin or Wizard +# second, third and fourth directory entry name like VBA PROJECT PROJECTwm +# http://extension.nirsoft.net/pwz +!:mime application/vnd.ms-powerpoint +# like: BSHPPT97.PPA "AutoContent Wizard.pwz" +!:ext ppa/pwz +# +# From: Joerg Jenderek +# URL: http://fileformats.archiveteam.org/wiki/AWD_(At_Work_Document) +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/a/awd-fax.trid.xml +# Note: called "Microsoft At Work Fax document" by TrID +>>88 ubequad 0xb29400dd010f2bf9 : Microsoft +>>>80 ubequad 0x801cb0023de01a10 At Work fax Document +#!:mime application/x-ole-storage +!:mime image/x-ms-awd +!:ext awd # # URL: https://en.wikipedia.org/wiki/Microsoft_Project #?? @@ -424,6 +483,20 @@ >>>80 ubequad 0x3a8fb774c8c8d111 Project !:mime application/vnd.ms-project !:ext mpp +# From: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/Microsoft_Office_shared_tools#Binder +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/o/obd.trid.xml +# http://fileformats.archiveteam.org/wiki/Microsoft_Compound_File +# Note: only version 8 tested and called "Office Binder Document" by TrID and +# "Microsoft Office Binder File for Windows" version 97-2000 by DROID fmt/240 +>>88 ubequad 0xb21c00aa004ba90b : Microsoft +>>>80 ubequad 0x0004855964661b10 Office Binder Document, Template or wizard +# second directory entry name like Binder +# https://www.file-extensions.org/obd-file-extension +#!:mime application/vnd.ms-binder +!:mime application/x-msbinder +# obt for template; obz for Microsoft Office Binder wizard +!:ext obd/obt/obz # # URL: http://fileformats.archiveteam.org/wiki/WordPerfect # Reference: http://fileformats.archiveteam.org/wiki/Microsoft_Compound_File @@ -560,9 +633,29 @@ !:mime application/vnd.softmaker.planmaker # pmv for template https://www.file-extensions.org/pmv-file-extension !:ext pmd/pmv +# URL: http://fileformats.archiveteam.org/wiki/MAX_(3ds_Max) +# https://en.wikipedia.org/wiki/Autodesk_3ds_Max +# Reference: http://fileformats.archiveteam.org/wiki/Microsoft_Compound_File +# Note: called "3D Studio Max Scene" by TrID and "3DS Max" by DROID and +# "3DSMax thumbnail" by XnView and verfied by `nconvert -info A380.max` +# applies only to "newer" versions (about 2008-2020) +>>88 ubequad 0x9fed04143144cc1e : Autodesk +>>>80 ubequad 0x7b8cdd1cc081a045 3ds Max +#!:mime application/x-ole-storage +!:mime model/x-autodesk-max +# like: https://static.free3d.com/models/dropbox/dropbox/sq/A380.7z/A380.max +!:ext max +# also chr for character file according to DROID https://www.nationalarchives.gov.uk/PRONOM/fmt/978 +#!:ext max/chr # remaining non null clsid ->>88 default x : UNKNOWN +>>88 default x +# GRR: check again for non null clsid because wrong when called by indirect directive +>>>88 ubequad !0 : UNKNOWN +# https://reposcope.com/mimetype/application/x-ole-storage !:mime application/x-ole-storage ->>>80 ubequad !0 \b, clsid %#16.16llx ->>>88 ubequad x \b%16.16llx +# according to file version 5.41 with -e soft option +#!:mime application/CDFV2 +#!:ext ??? +>>>>80 ubequad !0 \b, clsid %#16.16llx +>>>>88 ubequad x \b%16.16llx diff --git a/magic/Magdir/oric b/magic/Magdir/oric new file mode 100644 index 000000000000..38c02c5751d3 --- /dev/null +++ b/magic/Magdir/oric @@ -0,0 +1,16 @@ + +#------------------------------------------------------------------------------ +# $File: oric,v 1.2 2022/04/25 17:28:20 christos Exp $ +# Oric tape files +# From: Stefan A. Haubenthal <polluks@sdf.lonestar.org> +# References: +# http://fileformats.archiveteam.org/wiki/TAP_(Oric) +# http://fileformats.archiveteam.org/wiki/DSK_(Oric) +0 string \x16\x16\x16\x24 Oric tape, +>6 byte =0x00 BASIC, +>6 byte =0x80 memory block, +>7 byte >0x00 autorun, +>13 string x "%.15s" + +0 string ORICDISK Oric Image +0 string MFM_DISK Oric Image diff --git a/magic/Magdir/os2 b/magic/Magdir/os2 index 02f27fa6b075..cb43e999f6f6 100644 --- a/magic/Magdir/os2 +++ b/magic/Magdir/os2 @@ -1,12 +1,14 @@ #------------------------------------------------------------------------------ -# $File: os2,v 1.13 2021/04/26 15:56:00 christos Exp $ +# $File: os2,v 1.14 2022/03/21 21:25:50 christos Exp $ # os2: file(1) magic for OS/2 files # # Provided 1998/08/22 by # David Mediavilla <davidme.news@REMOVEIFNOTSPAMusa.net> 1 search/100 InternetShortcut MS Windows 95 Internet shortcut text +!:mime application/x-mswinurl +!:ext url >17 search/100 URL= (URL=< >>&0 string x \b%s>) diff --git a/magic/Magdir/palm b/magic/Magdir/palm index 8cec9df20db1..5d2b913c35fe 100644 --- a/magic/Magdir/palm +++ b/magic/Magdir/palm @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: palm,v 1.14 2019/04/19 00:42:27 christos Exp $ +# $File: palm,v 1.15 2021/12/16 21:50:06 christos Exp $ # palm: file(1) magic for PalmOS {.prc,.pdb}: applications, docfiles, and hacks # # Brian Lalor <blalor@hcirisc.cs.binghamton.edu> @@ -55,6 +55,7 @@ # Mobipocket (www.mobipocket.com), donated by Carl Witty # expanded by Ralf Brown 60 string BOOKMOBI Mobipocket E-book +!:mime application/x-mobipocket-ebook # MobiPocket stores a full title, pointed at by the belong at offset # 0x54 in its header at (78.L), with length given by the belong at # offset 0x58. diff --git a/magic/Magdir/pci_ids b/magic/Magdir/pci_ids new file mode 100644 index 000000000000..34bc2e2f8afc --- /dev/null +++ b/magic/Magdir/pci_ids @@ -0,0 +1,116 @@ + +#------------------------------------------------------------------------------ +# $File: pci_ids,v 1.1 2022/04/02 14:47:42 christos Exp $ +# pci.ids: file(1) magic for PCI specific informations +# + +# Vendor identification (ID) https://pci-ids.ucw.cz/v2.2/pci.ids +# show hexadecimal PCI vendor identification in human readable text form +0 name PCI-vendor +# ID vendor name +#>0 uleshort =0x0f00 fOO +>0 uleshort =0x1000 Broadcom +>0 uleshort =0x1002 AMD/ATI +>0 uleshort =0x1013 Cirrus Logic +>0 uleshort =0x1014 IBM +>0 uleshort =0x1022 AMD +>0 uleshort =0x1050 Winbond +>0 uleshort =0x105a Promise +>0 uleshort =0x1095 Silicon +>0 uleshort =0x10EC Realtek +>0 uleshort =0x10de NVIDIA +>0 uleshort =0x1106 VIA +# Woodward McCoach, Inc. +>0 uleshort =0x1231 Woodward +# +>0 uleshort =0x1234 Bochs +>0 uleshort =0x15ad VMware +>0 uleshort =0x1af4 Virtio +>0 uleshort =0x1b36 QEMU +>0 uleshort =0x1de1 Tekram +# maybe also Promise? +#>0 uleshort =0x4289 Promise +#>0 uleshort =0x66a1 FOO +>0 uleshort =0x8086 Intel +>0 uleshort =0x9004 Adaptec +# also Adaptec; but no example +>0 uleshort =0x9005 Adaptec +# for unknown/missing manufactors +>0 default x UNKNOWN +>>0 uleshort x (%#4.4x) + +# https://blog.ladsai.com/pci-configuration-space-class-code.html +# Base class code https://wiki.osdev.org/PCI +# show hexadecimal PCI class+sub+ProgIF identification in human readable text form +0 name PCI-class +#>0 ubyte x CLASS=%x +>0 ubyte x +# Device was built prior definition of the class code field +>>0 ubyte 0x00 PRIOR +# Any device except for VGA-Compatible devices like: 2975BIOS.BIN Trm3x5.bin +# BUT also NVidia44.bin vgabios-stdvga-bin.rom +#>>>0 ubyte 0x00 NOT VGA +# VGA-Compatible Device; NO EXAMPLE found here!! +#>>>0 ubyte 0x01 VGA +# like 4243.bin +#>>>0 ubyte 0x04 SUB_CLASS_4 +>>0 ubyte 0x01 storage controller +# device sub-type and its definition is dependent upon the base-type code +>>>1 ubyte 0x00 SCSI +>>>1 ubyte 0x01 IDE +>>>1 ubyte 0x02 Floppy +>>>1 ubyte 0x03 IPI +>>>0 ubyte 0x04 RAID +>>>1 ubyte 0x05 ATA +>>>1 ubyte 0x06 SATA +>>>1 ubyte 0x07 SAS +>>>1 ubyte 0x08 NVM +# 4650_sr5.bin "PROMISE" "FT TX4650 Ary X" +>>>1 ubyte 0x80 OTHER +>>0 ubyte 0x02 network controller +>>>1 ubyte 0x00 ethernet +>>>1 ubyte 0x01 token ring +>>>1 ubyte 0x02 FDDI +>>>1 ubyte 0x03 ATM +>>>1 ubyte 0x04 ISDN +>>>1 ubyte 0x05 WorldFip +# PICMG 2.14 Multi Computing +>>>1 ubyte 0x06 PICMG +>>>1 ubyte 0x80 OTHER +>>0 ubyte 0x03 display controller +>>0 ubyte 0x04 multimedia controller +>>0 ubyte 0x05 memory controller +>>0 ubyte 0x06 bridge device +# Simple Communication Controllers +>>0 ubyte 0x07 communication controller +# Base System Peripherals +>>0 ubyte 0x08 base peripheral +# Input Devices +>>0 ubyte 0x09 input device +# Docking Stations +>>0 ubyte 0x0A docking station +>>0 ubyte 0x0B processor +>>0 ubyte 0x0C serial bus controller +>>0 ubyte 0x0D wireless controller +# Intelligent I/O Controllers +>>0 ubyte 0x0E I/O controller +# Satellite Communication Controllers +>>0 ubyte 0x0F satellite controller +# Encryption/Decryption Controllers +>>0 ubyte 0x10 encryption controller +# Data Acquisition and Signal Processing Controllers +>>0 ubyte 0x11 signal controller +# Processing Accelerator +>>0 ubyte 0x12 processing accelerator +# Non-Essential Instrumentation +>>0 ubyte 0x13 non-essential +# reserved or unassigned +>>0 default x +# device does not fit any defined class; Unassigned Class (Vendor specific) +>>>0 ubyte 0xFF UNASSIGNED +# THIS SHOULD NOT HAPPEN! BUT CLASS=8f for Promise 4650_sr5.bin 8660_sr5.bin +>>>0 default x RESERVED +>>>>0 ubyte x (%#x) +# Prog IF of PCI class code? +# defines the specific device programming interface +>2 ubyte >0 \b, ProgIF=%u diff --git a/magic/Magdir/python b/magic/Magdir/python index 80a59959bea2..ed5888591aae 100644 --- a/magic/Magdir/python +++ b/magic/Magdir/python @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: python,v 1.43 2021/05/25 15:12:03 christos Exp $ +# $File: python,v 1.44 2021/10/20 11:15:35 christos Exp $ # python: file(1) magic for python # # Outlook puts """ too for urgent messages @@ -8,6 +8,7 @@ # often the module starts with a multiline string 0 string/t """ Python script text executable # MAGIC as specified in Python/import.c (1.0 to 3.7) +# and in Lib/importlib/_bootstrap_external.py (3.5+) # two bytes of magic followed by "\r\n" in little endian order 0 belong 0x02099900 python 1.0 byte-compiled !:mime application/x-bytecode.python @@ -215,6 +216,50 @@ !:mime application/x-bytecode.python 0 belong 0x610d0d0a python 3.9 byte-compiled !:mime application/x-bytecode.python +0 belong 0x660d0d0a python 3.10 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x670d0d0a python 3.10 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x680d0d0a python 3.10 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x690d0d0a python 3.10 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x6a0d0d0a python 3.10 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x6b0d0d0a python 3.10 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x6c0d0d0a python 3.10 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x6d0d0d0a python 3.10 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x6e0d0d0a python 3.10 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x6f0d0d0a python 3.10 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x7a0d0d0a python 3.11 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x7b0d0d0a python 3.11 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x7c0d0d0a python 3.11 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x7d0d0d0a python 3.11 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x7e0d0d0a python 3.11 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x7f0d0d0a python 3.11 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x800d0d0a python 3.11 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x810d0d0a python 3.11 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x820d0d0a python 3.11 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x830d0d0a python 3.11 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x840d0d0a python 3.11 byte-compiled +!:mime application/x-bytecode.python +0 belong 0x850d0d0a python 3.11 byte-compiled +!:mime application/x-bytecode.python 0 search/1/w #!\040/usr/bin/python Python script text executable !:strength + 15 diff --git a/magic/Magdir/riff b/magic/Magdir/riff index 39a5acbe23b9..6421bcb6747d 100644 --- a/magic/Magdir/riff +++ b/magic/Magdir/riff @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: riff,v 1.43 2021/04/26 15:56:00 christos Exp $ +# $File: riff,v 1.44 2022/05/14 19:42:47 christos Exp $ # riff: file(1) magic for RIFF format # See # @@ -161,6 +161,64 @@ #>0 string x we got %s #>>&(4.l+4) use riff-walk +# RecorderGear TR500 call recorder digits (BCD) +0 name tr500-call-recorder-digits +>0 byte&0xF0 0x00 \b0 +>0 byte&0xF0 0x10 \b1 +>0 byte&0xF0 0x20 \b2 +>0 byte&0xF0 0x30 \b3 +>0 byte&0xF0 0x40 \b4 +>0 byte&0xF0 0x50 \b5 +>0 byte&0xF0 0x60 \b6 +>0 byte&0xF0 0x70 \b7 +>0 byte&0xF0 0x80 \b8 +>0 byte&0xF0 0x90 \b9 +>0 byte&0xF0 0xb0 \b* +>0 byte&0xF0 0xc0 \b# +>0 byte&0x0F 0 \b0 +>0 byte&0x0F 1 \b1 +>0 byte&0x0F 2 \b2 +>0 byte&0x0F 3 \b3 +>0 byte&0x0F 4 \b4 +>0 byte&0x0F 5 \b5 +>0 byte&0x0F 6 \b6 +>0 byte&0x0F 7 \b7 +>0 byte&0x0F 8 \b8 +>0 byte&0x0F 9 \b9 +>0 byte&0x0F 0xb \b* +>0 byte&0x0F 0xc \b# + +# TR500 call recorder extended header +# From: David Korth <gerbilsoft@gerbilsoft.com> +# Contains dialed/incoming phone number and timestamp. +# TODO: Verify byte 15. +0 name tr500-call-recorder-header +>15 byte 2 (outgoing call: +>15 byte 4 (incoming call: +>1 byte 0xFF \bno number +>1 byte !0xFF +>>1 use tr500-call-recorder-digits +>>2 byte !0xFF +>>>2 use tr500-call-recorder-digits +>>3 byte !0xFF +>>>3 use tr500-call-recorder-digits +>>4 byte !0xFF +>>>4 use tr500-call-recorder-digits +>>5 byte !0xFF +>>>5 use tr500-call-recorder-digits +>>6 byte !0xFF +>>>6 use tr500-call-recorder-digits +>>7 byte !0xFF +>>>7 use tr500-call-recorder-digits +>>8 byte !0xFF +>>>8 use tr500-call-recorder-digits +>9 byte x \b, 20%02x +>10 byte x \b/%02x +>11 byte x \b/%02x +>12 byte x %02x +>13 byte x \b:%02x +>14 byte x \b:%02x) + # AVI section extended by Patrik Radman <patrik+file-magic@iki.fi> # 0 string RIFF RIFF (little-endian) data @@ -231,6 +289,11 @@ !:ext wav/wave >>12 string >\0 >>>12 use riff-walk +# TR500 call recorder extended header +>>16 ulelong 0x1E4 +>>>20 leshort 0x11 +>>>>256 byte 4 +>>>>>256 use tr500-call-recorder-header # Update: Joerg Jenderek # lower case for Corel Draw version 8 Bidi >8 string/c cdr @@ -676,6 +739,7 @@ # for debugging purpose display 5th chunk like: LIST osfp #>>(26.l+30) string x \b, 5th "%-4.4s" >4 ulelong+8 x \b, %u bytes + # # XXX - some of the below may only appear in little-endian form. # diff --git a/magic/Magdir/rpi b/magic/Magdir/rpi index 58e6dfde70a5..0d213b5357e7 100644 --- a/magic/Magdir/rpi +++ b/magic/Magdir/rpi @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: rpi,v 1.2 2019/10/02 02:07:30 christos Exp $ +# $File: rpi,v 1.3 2022/04/02 14:39:34 christos Exp $ # rpi: file(1) magic for Raspberry Pi images -44 lelong 0 >4 lelong 0 @@ -27,3 +27,26 @@ >>>>>>>>>40 string DDTK8 >>>>>>>>>>48 lelong 4 >>>>>>>>>>>52 string RPTL Raspberry PI kernel image + +# From: Joerg Jenderek +# URL: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html +# #raspberry-pi-4-boot-eeprom +# Reference: https://github.com/raspberrypi/rpi-eeprom/blob/master/rpi-eeprom-config +# Note: start with same magic as for BIOS (ia32) ROM Extension handled by ./intel +# masked with MAGIC_MASK and then compared with MAGIC +0 belong&0xFFffF00F 0x55aaF00F Raspberry PI EEPROM +#!:mime application/octet-stream +!:mime application/x-raspberry-eeprom +# like: pieeprom-2020-09-03.bin +!:ext bin +# a 32 bit offset to the next section like: 000184d4 000184c8 00018534 ... 0000bb84 0000bbd4 0000bbd4 +>4 ubelong x \b, offset %8.8x +#>(4.L) ubelong x NEXT=%8.8x +# self.length +>8 ubelong !0 \b, length %x +# self.filename +>12 string >0 \b, "%s" +# length is zero +>8 ubelong =0 +# if length is zero then 2nd section magic here can be zero; this means sections parsing done +>>8 ubelong !0 \b, 2nd MAGIC=%8.8x diff --git a/magic/Magdir/sgml b/magic/Magdir/sgml index a1c0484ce4dd..a191c3015fa4 100644 --- a/magic/Magdir/sgml +++ b/magic/Magdir/sgml @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: sgml,v 1.42 2020/12/12 20:01:47 christos Exp $ +# $File: sgml,v 1.45 2022/03/21 21:36:55 christos Exp $ # Type: SVG Vectorial Graphics # From: Noel Torres <tecnico@ejerciciosresueltos.com> 0 string \<?xml\ version= @@ -52,66 +52,66 @@ # https://www.w3.org/TR/SVG/single-page.html 0 search/4096/cWbt \<!doctype\ svg SVG XML document !:mime image/svg+xml -!:strength + 5 +!:strength + 15 0 search/4096/cwt \<head\> HTML document text !:mime text/html -!:strength + 5 +!:strength + 15 0 search/4096/cWt \<head\ HTML document text !:mime text/html -!:strength + 5 +!:strength + 15 0 search/4096/cwt \<title\> HTML document text !:mime text/html -!:strength + 5 +!:strength + 15 0 search/4096/cWt \<title\ HTML document text !:mime text/html -!:strength + 5 +!:strength + 15 0 search/4096/cwt \<html\> HTML document text !:mime text/html -!:strength + 5 +!:strength + 15 0 search/4096/cWt \<html\ HTML document text !:mime text/html -!:strength + 5 +!:strength + 15 0 search/4096/cwt \<script\> HTML document text !:mime text/html -!:strength + 5 +!:strength + 15 0 search/4096/cWt \<script\ HTML document text !:mime text/html -!:strength + 5 +!:strength + 15 0 search/4096/cwt \<style\> HTML document text !:mime text/html -!:strength + 5 +!:strength + 15 0 search/4096/cWt \<style\ HTML document text !:mime text/html -!:strength + 5 +!:strength + 15 0 search/4096/cwt \<table\> HTML document text !:mime text/html -!:strength + 5 +!:strength + 15 0 search/4096/cWt \<table\ HTML document text !:mime text/html -!:strength + 5 +!:strength + 15 0 search/4096/cwt \<a\ href= HTML document text !:mime text/html -!:strength + 5 +!:strength + 15 # Extensible markup language (XML), a subset of SGML # from Marc Prud'hommeaux (marc@apocalypse.org) 0 search/1/cwt \<?xml XML document text !:mime text/xml -!:strength + 5 +!:strength + 15 0 string/t \<?xml\ version\ " XML !:mime text/xml -!:strength + 5 +!:strength + 15 0 string/t \<?xml\ version=" XML !:mime text/xml -!:strength + 5 +!:strength + 15 >15 string/t >\0 %.3s document text >>23 search/1 \<xsl:stylesheet (XSL stylesheet) >>24 search/1 \<xsl:stylesheet (XSL stylesheet) 0 string/t \<?xml\ version=' XML !:mime text/xml -!:strength + 5 +!:strength + 15 >15 string/t >\0 %.3s document text >>23 search/1 \<xsl:stylesheet (XSL stylesheet) >>24 search/1 \<xsl:stylesheet (XSL stylesheet) @@ -139,7 +139,10 @@ # http://files.pef-format.org/specifications/pef-2008-1/pef-specification.html # # Simon Aittamaa <simon.aittamaa@gmail.com> -0 string \<?xml\ version= ->14 regex ['"\ \t]*[0-9.]+['"\ \t]* ->>19 search/4096 \<pef Portable Embosser Format +0 string \<?xml\ version= +>14 regex ['"\ \t]*[0-9.]+['"\ \t]* +>>19 search/4096 \<pef Portable Embosser Format !:mime application/x-pef+xml + +# https://www.qgis.org/en/site/ +0 string \<!DOCTYPE\040qgis QGIS XML document diff --git a/magic/Magdir/sniffer b/magic/Magdir/sniffer index 816ecb907a3e..87bff6b03e6c 100644 --- a/magic/Magdir/sniffer +++ b/magic/Magdir/sniffer @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: sniffer,v 1.30 2021/07/03 13:51:56 christos Exp $ +# $File: sniffer,v 1.31 2022/03/20 22:45:43 christos Exp $ # sniffer: file(1) magic for packet capture files # # From: guy@alum.mit.edu (Guy Harris) @@ -362,4 +362,51 @@ # # Files from Accellent Group's 5View products. # -0 string \xaa\xaa\xaa\xaa 5View capture file +# URL: http://www.infovista.com +# Reference: http://mark0.net/download/triddefs_xml.7z +# defs/0/5vw.trid.xml +# https://2.na.dl.wireshark.org/src/wireshark-3.6.2.tar.xz +# wireshark-3.6.2/wiretap/5views.c +# Update: Joerg Jenderek +# Note: called "5View capture" by TrID and +# "Wireshark capture file" on Windows or +# "Packet Capture (Accellent/InfoVista 5view)" by shared MIME-info database +# verified/falsified by `wireshark *.5vw` +0 string \xaa\xaa\xaa\xaa +# skip misidentified boot/x86_64/loader/kroete.dat on Suse LEAP DVD +# by check for valid record version +>8 ulelong =0x00010000 +>>0 use 5view-le +0 name 5view-le +# t_5VW_Info_Header.Signature = CST_5VW_INFO_HEADER_KEY = 0xAAAAAAAAU +>0 ulelong x 5View capture file +# https://reposcope.com/mimetype/application/x-5view +!:mime application/x-5view +!:ext 5vw +# size of header in bytes (included signature and reserved fields); probably always 20h +>4 ulelong !0x00000020 \b, header size %#x +# version of header record; apparently always CST_5VW_INFO_RECORD_VERSION=0x00010000U +>8 ulelong !0x00010000 \b, record version %#x +# DataSize; total size of data without header like: 18h +>12 ulelong x \b, record size %#x +# filetype; type of the capture file like: 18001000h +>16 ulelong x \b, file type %#8.8x +# Reserved[3]; reserved for future use; apparently zero +>20 quad !0 \b, Reserved %#llx +# look for record header key CST_5VW_RECORDS_HEADER_KEY of structure t_5VW_TimeStamped_Header +>0x20 search/0xB8/b \xEE\xEE\x33\x33 \b; record +# HeaderSize; actual size of this header in bytes like: 32 24h +>>&0 uleshort x size %#x +# HeaderType; exact type of this header; probably always 0x4000 +>>&2 uleshort !0x4000 \b, header type %#x +# RecType; type of record like: 80000000h +>>&4 ulelong x \b, record type %#x +# RecSubType; subtype of record like: 0 +>>&8 ulelong !0 \b, subtype %#x +# RecSize; Size of one record like: 5Ch +>>&12 ulelong x \b, RecSize %#x +# RecNb; Number of records like: 1 +>>&16 ulelong >1 \b, %#x records +# Timestamp Utc +#>>&20 ulelong x \b, RAW TIME %#8.8x +>>&20 date x \b, Time-stamp %s diff --git a/magic/Magdir/statistics b/magic/Magdir/statistics index 0ceb82cd272f..ca9f8591b68e 100644 --- a/magic/Magdir/statistics +++ b/magic/Magdir/statistics @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: statistics,v 1.2 2020/10/08 17:51:53 christos Exp $ +# $File: statistics,v 1.3 2022/03/24 15:48:58 christos Exp $ # statistics: file(1) magic for statistics related software # @@ -42,4 +42,4 @@ # Example of those files can be found on Zenodo: # https://zenodo.org/search?page=1&size=20&q=&file_type=dta 0 string \<stata_dta\>\<header\>\<release\> Stata Data File ->&0 regex [0-9]* (Release %s) +>&0 regex [0-9]+ (Release %s) diff --git a/magic/Magdir/sysex b/magic/Magdir/sysex index 967ac0ce30c1..0065ad17e432 100644 --- a/magic/Magdir/sysex +++ b/magic/Magdir/sysex @@ -1,20 +1,42 @@ #------------------------------------------------------------------------ -# $File: sysex,v 1.10 2019/04/19 00:42:27 christos Exp $ +# $File: sysex,v 1.11 2022/01/17 17:16:51 christos Exp $ # sysex: file(1) magic for MIDI sysex files # # GRR: original 1 byte test at offset was too general as it catches also many FATs of DOS filesystems # where real SYStem EXclusive messages at offset 1 are limited to seven bits # https://en.wikipedia.org/wiki/MIDI -0 ubeshort&0xFF80 0xF000 SysEx File - - +# test for StartSysEx byte and upper unsed bit of vendor ID +0 ubeshort&0xFF80 0xF000 +# MIDI System Exclusive (SysEx) messages (strength=50) after Microsoft Visual C library (strength=70) +#!:strength +0 +# skip Microsoft Visual C library with page size 16 misidentifed as ADA and +# page size 32 misidentifed as Inventronics by looking for terminating End Of eXclusive byte (EOX) +>2 search/12 \xF7 +>>0 use midi-sysex +# display information about MIDI System Exclusive (SysEx) messages +0 name midi-sysex +# https://fileinfo.com/extension/syx +>1 ubyte x MIDI audio System Exclusive (SysEx) message - +# Note: file (version 5.41) labeled the above entry as "SysEx File" +#!:mime application/octet-stream +!:mime audio/x-syx +# https://onsongapp.com/docs/features/formats/sysex +!:ext syx/sysex +# https://www.midi.org/specifications-old/item/manufacturer-id-numbers +# https://raw.githubusercontent.com/insolace/MIDI-Sysex-MFG-IDs/master/Sysex%20ID%20Tables/MIDI%20Sysex%20MFG%20IDs.csv +# SysEx manufacturer ID; originally one byte, but now 0 is used as an escapement to reach the next two # North American Group ->1 byte 0x01 Sequential +#>1 byte 0x01 Sequential +>1 byte 0x01 Sequential Circuits >1 byte 0x02 IDP ->1 byte 0x03 OctavePlateau +#>1 byte 0x03 OctavePlateau +>1 byte 0x03 Voyetra Turtle Beach >1 byte 0x04 Moog ->1 byte 0x05 Passport ->1 byte 0x06 Lexicon +#>1 byte 0x05 Passport +>1 byte 0x05 Passport Designs +#>1 byte 0x06 Lexicon +>1 byte 0x06 Lexicon Inc. >1 byte 0x07 Kurzweil/Future Retro >>3 byte 0x77 777 >>4 byte 0x00 Bank @@ -38,12 +60,17 @@ >>5 byte 0x10 (ALL) >>2 byte x \b, Channel %d >1 byte 0x08 Fender ->1 byte 0x09 Gulbransen ->1 byte 0x0a AKG +#>1 byte 0x09 Gulbransen +>1 byte 0x09 MIDI9 +#>1 byte 0x0a AKG +>1 byte 0x0a AKG Acoustics >1 byte 0x0b Voyce >1 byte 0x0c Waveframe ->1 byte 0x0d ADA ->1 byte 0x0e Garfield +# not ADA programming language +#>1 byte 0x0d ADA +>1 byte 0x0d ADA Signal Processors Inc. +#>1 byte 0x0e Garfield +>1 byte 0x0e Garfield Electronics >1 byte 0x0f Ensoniq >1 byte 0x10 Oberheim >>2 byte 0x06 Matrix 6 series @@ -59,7 +86,8 @@ >1 byte 0x16 Lowrey >1 byte 0x17 AdamsSmith >1 byte 0x18 E-mu ->1 byte 0x19 Harmony +#>1 byte 0x19 Harmony +>1 byte 0x19 Harmony Systems >1 byte 0x1a ART >1 byte 0x1b Baldwin >1 byte 0x1c Eventide @@ -67,23 +95,28 @@ >1 byte 0x1f Clarity # European Group ->1 byte 0x21 SIEL +#>1 byte 0x21 SIEL +>1 byte 0x21 Proel Labs (SIEL) >1 byte 0x22 Synthaxe >1 byte 0x24 Hohner >1 byte 0x25 Twister ->1 byte 0x26 Solton +#>1 byte 0x26 Solton +>1 byte 0x26 Ketron s.r.l. >1 byte 0x27 Jellinghaus >1 byte 0x28 Southworth >1 byte 0x29 PPG >1 byte 0x2a JEN ->1 byte 0x2b SSL ->1 byte 0x2c AudioVertrieb +#>1 byte 0x2b SSL +>1 byte 0x2b Solid State Logic Organ Systems +#>1 byte 0x2c AudioVertrieb +>1 byte 0x2c Audio Veritrieb-P. Struven >1 byte 0x2f ELKA >>3 byte 0x09 EK-44 >1 byte 0x30 Dynacord ->1 byte 0x31 Jomox +#>1 byte 0x31 Jomox +>1 byte 0x31 Viscount International Spa >1 byte 0x33 Clavia >1 byte 0x39 Soundcraft # Some Waldorf info from http://Stromeko.Synth.net/Downloads#WaldorfDocs @@ -202,14 +235,16 @@ >1 byte 0x44 Casio >1 byte 0x46 Kamiya >1 byte 0x47 Akai ->1 byte 0x48 Victor +#>1 byte 0x48 Victor +>1 byte 0x48 Victor Company of Japan. Ltd. >1 byte 0x49 Mesosha >1 byte 0x4b Fujitsu >1 byte 0x4c Sony >1 byte 0x4e Teac >1 byte 0x50 Matsushita >1 byte 0x51 Fostex ->1 byte 0x52 Zoom +#>1 byte 0x52 Zoom +>1 byte 0x52 Zoom Corporation >1 byte 0x54 Matsushita >1 byte 0x57 Acoustic tech. lab. # https://www.midi.org/techspecs/manid.php @@ -317,4 +352,78 @@ >1 belong&0xffffff00 0x00204700 Klavis Tech. >1 belong&0xffffff00 0x00204800 Noteheads AB +# Update: Joerg Jenderek; January 2022 +>1 byte 0x00 ID EXTENSIONS +>1 byte 0x13 Digidesign Inc. +>1 byte 0x1e Key Concepts +>1 byte 0x20 Passac +>1 byte 0x23 Stepp +>1 byte 0x2d Neve +>1 byte 0x2e Soundtracs Ltd. +>1 byte 0x32 Drawmer +>1 byte 0x34 Audio Architecture +>1 byte 0x35 Generalmusic Corp SpA +>1 byte 0x36 Cheetah Marketing +>1 byte 0x37 C.T.M. +>1 byte 0x38 Simmons UK +>1 byte 0x3a Steinberg +>1 byte 0x3b Wersi GmbH +>1 byte 0x3c AVAB Niethammer AB +>1 byte 0x3d Digigram +>1 byte 0x3f Quasimidi +# +>1 byte 0x40 Kawai Musical Instruments MFG. CO. Ltd +#>1 byte 0x45 foo +#>1 byte 0x4a foo +#>1 byte 0x4d foo +#>1 byte 0x4f foo +#>1 byte 0x53 foo +>1 byte 0x55 Suzuki Musical Instruments MFG. Co. Ltd. +>1 byte 0x56 Fuji Sound Corporation Ltd. +#>1 byte 0x58 foo +>1 byte 0x59 Faith. Inc. +>1 byte 0x5a Internet Corporation +#>1 byte 0x5b foo +>1 byte 0x5c Seekers Co. Ltd. +#>1 byte 0x5d foo +#>1 byte 0x5e foo +>1 byte 0x5f SD Card Association +# Reserved for other uses for 60H to 7FH +# URL: https://www.philscomputerlab.com/roland-midi-emulator-project-20.html +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/s/syx--midiemu.trid.xml +# Note: called by TrID "MIDI Emulator Project SysEx preset command" +>1 byte 0x66 MIDI Emulator +# https://electronicmusic.fandom.com/wiki/List_of_MIDI_Manufacturer_IDs +# Educational, prototyping, test, private use and experimentation +>1 byte 0x7D PROTOTYPING +# universal non-real-time (sample dump, tuning table, etc.) +>1 byte 0x7E UNIVERSAL +# universal real time (MIDI time code, MIDI Machine control, etc.) +>1 byte 0x7F universal real time +# display information about End Of eXclusive byte (EOX=F7) +#>2 ubyte 0xF7 \b, at 2 EOX +#>3 ubyte 0xF7 \b, at 3 EOX +# https://tttapa.github.io/Control-Surface-doc/new-input/Doxygen/d2/d93/SysEx-Send-Receive_8ino-example.html +>4 ubyte 0xF7 \b, at 4 EOX +# http://www.1manband.nl/tutorials2/sysex.htm +>5 ubyte 0xF7 \b, at 5 EOX +# http://www.somascape.org/midi/tech/mfile.html#sysex +>6 ubyte 0xF7 \b, at 6 EOX +# +>7 ubyte 0xF7 \b, at 7 EOX +# https://webmidijs.org/forum/discussion/34/how-to-send-or-receive-system-exclusive-messages +>8 ubyte 0xF7 \b, at 8 EOX +# +>9 ubyte 0xF7 \b, at 9 EOX +# https://www.chd-el.cz/wp-content/uploads/845010_syxcom.pdf +>10 ubyte 0xF7 \b, at 10 EOX +# https://stackoverflow.com/questions/52906076/handling-midi-the-input-of-multiple-system-exclusive-messages-in-vb +>11 ubyte 0xF7 \b, at 11 EOX +# https://www.2writers.com/eddie/TutSysEx.htm +>12 ubyte 0xF7 \b, at 12 EOX +>13 ubyte 0xF7 \b, at 13 EOX +# http://www.chromakinetics.com/handsonic/rolSysEx.htm +>14 ubyte 0xF7 \b, at 14 EOX +#>15 ubyte 0xF7 \b, at 15 EOX + 0 string T707 Roland TR-707 Data diff --git a/magic/Magdir/uuencode b/magic/Magdir/uuencode index 7844468484c2..df70dc5319a5 100644 --- a/magic/Magdir/uuencode +++ b/magic/Magdir/uuencode @@ -1,16 +1,18 @@ #------------------------------------------------------------------------------ -# $File: uuencode,v 1.8 2019/12/14 20:40:26 christos Exp $ +# $File: uuencode,v 1.9 2021/11/13 17:48:10 christos Exp $ # uuencode: file(1) magic for ASCII-encoded files # -# GRR: the first line of xxencoded files is identical to that in uuencoded -# files, but the first character in most subsequent lines is 'h' instead of -# 'M'. (xxencoding uses lowercase letters in place of most of uuencode's -# punctuation and survives BITNET gateways better.) If regular expressions -# were supported, this entry could possibly be split into two with -# "begin\040\.\*\012M" or "begin\040\.\*\012h" (where \. and \* are REs). -0 search/1 begin\ uuencoded or xxencoded text +# The first line of xxencoded files is identical to that in uuencoded files, +# but the first character in most subsequent lines is 'h' instead of 'M'. +# (xxencoding uses lowercase letters in place of most of uuencode's +# punctuation and survives BITNET gateways better.) +0 regex/1024 \^begin\040[0-7]{3}\040 +>&0 regex/256 [\012\015]+M[\040-\140]{60}[\012\015]+ uuencoded text +>&0 regex/256 [\012\015]+h[0-9A-Za-z\053\055]{60}[\012\015]+ xxencoded text +>&0 default x uuencoded or xxencoded text +>&0 string >\0 \b, file name "%s" # btoa(1) is an alternative to uuencode that requires less space. 0 search/1 xbtoa\ Begin btoa'd text diff --git a/magic/Magdir/virtual b/magic/Magdir/virtual index 86fe9fcd36d0..7872e32483ba 100644 --- a/magic/Magdir/virtual +++ b/magic/Magdir/virtual @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: virtual,v 1.14 2021/04/26 15:56:00 christos Exp $ +# $File: virtual,v 1.16 2022/01/18 14:08:15 christos Exp $ # From: James Nobis <quel@quelrod.net> # Microsoft hard disk images for: # Virtual Server @@ -219,7 +219,8 @@ # Updated by Adam Buchbinder (adam.buchbinder@gmail.com) # Made by reading sources, reading documentation, and doing trial and error # on existing QCOW files -0 string/b QFI\xFB +0 string/b QFI\xFB QEMU QCOW Image +!:mime application/x-qemu-disk # Uncomment the following line to display Magic (only used for debugging # this magic number) @@ -227,8 +228,7 @@ # There are currently 2 Versions: "1" and "2". # https://www.gnome.org/~markmc/qcow-image-format-version-1.html ->4 belong !1 QEMU QCOW2 Image ->4 belong 1 QEMU QCOW Image (v1) +>4 belong x (v%d) # Using the existence of the Backing File Offset to determine whether # to read Backing File Information diff --git a/magic/Magdir/windows b/magic/Magdir/windows index 4ec0af3e32d6..c98708ae1bae 100644 --- a/magic/Magdir/windows +++ b/magic/Magdir/windows @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: windows,v 1.37 2021/04/26 15:56:00 christos Exp $ +# $File: windows,v 1.44 2022/05/31 17:39:08 christos Exp $ # windows: file(1) magic for Microsoft Windows # # This file is mainly reserved for files where programs @@ -358,7 +358,7 @@ # skip space at beginning >0 string \040 # name without extension and greater character or name with hlp extension ->>1 regex/c \^([^\xd>]*|.*\.hlp) MS Windows help file Content, based "%s" +>>1 regex/c \^([^\xd>]*|.*\\.hlp) MS Windows help file Content, based "%s" !:mime text/plain !:apple ????TEXT !:ext cnt @@ -382,6 +382,8 @@ # Created by: unknown # 'L' + GUUID 0 string \114\0\0\0\001\024\002\0\0\0\0\0\300\0\0\0\0\0\0\106 MS Windows shortcut +!:mime application/x-ms-shortcut +!:ext lnk >20 lelong&1 1 \b, Item id list present >20 lelong&2 2 \b, Points to a file or directory >20 lelong&4 4 \b, Has Description string @@ -495,10 +497,16 @@ # empty line CRLF 0 ubeshort 0x0D0A >0 use ini-file -# comment line +# comment line starting with semicolon 0 string ; ->0 use ini-file -# section line +# look for phrase of Windows policy ADMinistrative template (with starting remark) +# like: WINDOW_95_CD/TOOLS/RESKIT/netadmin/poledit/conf.adm +>1 search/3548 END\040CATEGORY +# ADM with remark (by adm-rem.trid.xml) already done by generic ASCII variant +# if no Windows policy ADMinistrative template then Windows INItialization +>1 default x +>>0 use ini-file +# section line starting with left bracket 0 string [ >0 use ini-file # check and then display Windows INItialization configuration @@ -510,7 +518,7 @@ # space after right bracket # or AutoRun.Amd64 for 64 bit systems # or only NL separator ->>&0 regex/c \^(autorun) +>>&0 regex/c \^autorun # but sometimes total commander directory tree file "treeinfo.wc" with lines like # [AUTORUN] # [boot] @@ -535,11 +543,11 @@ # http://www.winfaq.de/faq_html/Content/tip2500/onlinefaq.php?h=tip2653.htm # https://msdn.microsoft.com/en-us/library/windows/desktop/cc144102.aspx # .ShellClassInfo DeleteOnCopy LocalizedFileNames ASCII coded case-independent ->>&0 regex/c \^(\.ShellClassInfo|DeleteOnCopy|LocalizedFileNames)] Windows desktop.ini +>>&0 regex/1024c \^(\\.ShellClassInfo|DeleteOnCopy|LocalizedFileNames)] Windows desktop.ini !:mime application/x-wine-extension-ini #!:mime text/plain # https://support.microsoft.com/kb/84709/ ->>&0 regex/c \^(don't\ load)] Windows CONTROL.INI +>>&0 regex/c \^don't\ load] Windows CONTROL.INI !:mime application/x-wine-extension-ini !:ext ini >>&0 regex/c \^(ndishlp\\$|protman\\$|NETBEUI\\$)] Windows PROTOCOL.INI @@ -555,34 +563,57 @@ !:mime application/x-wine-extension-ini !:ext ini # http://www.mdgx.com/newtip6.htm ->>&0 regex/c \^(SafeList)] Windows IOS.INI +>>&0 regex/c \^SafeList] Windows IOS.INI !:mime application/x-wine-extension-ini !:ext ini # https://en.wikipedia.org/wiki/NTLDR Windows Boot Loader information ->>&0 regex/c \^(boot\x20loader)] Windows boot.ini +>>&0 regex/c \^boot\x20loader] Windows boot.ini !:mime application/x-wine-extension-ini !:ext ini # https://en.wikipedia.org/wiki/CONFIG.SYS ->>&0 regex/c \^(menu)] MS-DOS CONFIG.SYS +>>&0 regex/c \^menu] MS-DOS CONFIG.SYS # @CONFIG.UI configuration file of previous DOS version saved by Caldera OPENDOS INSTALL.EXE # CONFIG.PSS saved version of file CONFIG.SYS created by %WINDIR%\SYSTEM\MSCONFIG.EXE # CONFIG.TSH renamed file CONFIG.SYS.BAT by %WINDIR%\SYSTEM\MSCONFIG.EXE # dos and w40 used in dual booting scene !:ext sys/dos/w40 # https://support.microsoft.com/kb/118579/ ->>&0 regex/c \^(Paths)]\r\n MS-DOS MSDOS.SYS +>>&0 regex/c \^Paths]\r\n MS-DOS MSDOS.SYS !:ext sys/dos # http://chmspec.nongnu.org/latest/INI.html#HHP ->>&0 regex/c \^(options)]\r\n Microsoft HTML Help Project +>>&0 regex/c \^options]\r\n Microsoft HTML Help Project !:mime text/plain !:ext hhp # From: Joerg Jenderek -# URL: https://documentation.basis.com/BASISHelp/WebHelp/b3odbc/obdcdriv_character_translation.htm +# URL: https://documentation.basis.com/BASISHelp/WebHelp/b3odbc/ODBC_Driver/obdcdriv_character_translation.htm # Reference: https://www.garykessler.net/library/file_sigs.html +# http://mark0.net/download/triddefs_xml.7z/defs/c/cpx.trid.xml # Note: stored in directory %WINDIR%\SysWOW64 or %WINDIR%\system ->>&0 regex/c \^(Windows\ Latin) Windows codepage translator -!:mime text/plain +# second word often Latin but sometimes Cyrillic like in 12510866.CPX +>>&0 regex/c \^Windows\ (Latin|Cyrillic) Windows codepage translator +#!:mime text/plain +!:mime text/x-ms-cpx +# like: 12510866.CPX !:ext cpx +# From: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/InstallShield +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/l/lid-is.trid.xml +# Note: contain also 3 keywords like: count Default key0 +>>&0 regex/c \^Languages] InstallShield Language Identifier +#!:mime text/plain +!:mime text/x-installshield-lid +# like: SETUP.LID +!:ext lid +# From: Joerg Jenderek +# URL: https://www.file-extensions.org/tag-file-extension +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/t/taginfo.trid.xml +# Note: contain also keywords like: Application Category Company Misc Version +>>&0 regex/c \^TagInfo] TagInfo +#!:mime text/plain +#!:mime text/prs.lines.tag +!:mime text/x-ms-tag +# like: DATA.TAG +!:ext tag # unknown keyword after opening bracket >>&0 default x #>>>&0 string/c x UNKNOWN [%s @@ -603,28 +634,73 @@ !:mime application/x-wine-extension-ini #!:mime text/plain !:ext ini/inf +# UTF-16 BOM +0 ubeshort =0xFFFE +# look for phrase of Windows policy ADMinistrative template (UTF-16 by adm-uni.trid.xml) +# like: wuau.adm +>2 search/0x384A E\0N\0D\0\040\0C\0A\0T\0E\0G\0O\0R\0Y\0 +>>0 use windows-adm +# if no Windows policy ADMinistrative template then Windows INFormation +>2 default x # UTF-16 BOM followed by CR~0D00 , comment~semicolon~3B00 , section~bracket~5B00 -0 ubelong&0xFFff89FF =0xFFFE0900 +>>0 ubelong&0xFFff89FF =0xFFFE0900 # look for left bracket in section line ->2 search/8192 [ +>>>2 search/8192 [ # keyword without 1st letter which is maybe up-/down-case ->>&3 lestring16 ersion] Windows setup INFormation +>>>>&3 lestring16 ersion] Windows setup INFormation !:mime application/x-setupscript +# like: hdaudio.inf iscsi.inf spaceport.inf tpm.inf usbhub3.inf UVncVirtualDisplay.inf !:ext inf ->>&3 lestring16 trings] Windows setup INFormation +>>>>&3 lestring16 trings] Windows setup INFormation !:mime application/x-setupscript +# like: arduino_gemma.inf iis.inf MSM8960.inf !:ext inf ->>&3 lestring16 ourceDisksNames] Windows setup INFormation +>>>>&3 lestring16 ourceDisksNames] Windows setup INFormation !:mime application/x-setupscript +# like: atiixpag.inf mdmnokia.inf netefe32.inf rdpbus.inf !:ext inf # netnwcli.inf start with ;---[ NetNWCli.INX ] ->>&3 default x +>>>>&3 default x # look for NL followed by left bracket ->>>&0 search/8192 \x0A\x00\x5b ->>>>&3 lestring16 ersion] Windows setup INFormation +>>>>>&0 search/8192 \x0A\x00\x5b +# like: defltwk.inf netvwifibus.inf WSDPrint.inf +>>>>>>&3 lestring16 ersion] Windows setup INFormation !:mime application/x-setupscript !:ext inf +# Summary: Windows Policy ADMinistrative template +# From: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/Administrative_Template +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/a/adm.trid.xml +# Note: typically stored in directory like: %WINDIR%\system32\GroupPolicy\ADM +# worst case ASCII variant starting with remark line like: inetset.adm +0 search/0x4E CLASS\040 +>&0 string MACHINE +>>0 use windows-adm +>&0 string USER +>>0 use windows-adm +# display information about Windows policy ADMinistrative template +0 name windows-adm Windows Policy Administrative Template +!:mime text/x-ms-adm +!:ext adm +# UTF-16 BOM implies UTF-16 encoded ADM (by adm-uni.trid.xml) +>0 ubeshort =0xFFFE +>>2 lestring16 x \b, 1st line "%s" +# look for UTF-16 encoded CarriageReturn LineFeed +>>>2 search/0x3A \r\0\n\0 +>>>>&0 lestring16 x \b, 2nd line "%s" +# no UTF-16 BOM implies "ASCII" encoded ADM (by adm.trid.xml) +>0 ubeshort !0xFFFE +>>0 string x \b, 1st line "%s" +#>>>&0 ubequad x \b, 2ND %16.16llx +# 2nd line empty +>>>&2 beshort =0x0D0A +>>>>&0 beshort !0x0D0A \b, 3th line +>>>>>&-2 string x "%s" +# 2nd line with content +>>>&2 beshort !0x0D0A \b, 2nd line +>>>>&-2 string x "%s" + # Windows Precompiled INF files *.PNF added by Joerg Jenderek at Mar 2013 of _PNF_HEADER inf.h # http://read.pudn.com/downloads3/sourcecode/windows/248345/win2k/private/windows/setup/setupapi/inf.h__.htm # URL: http://fileformats.archiveteam.org/wiki/INF_(Windows) @@ -1080,3 +1156,61 @@ 0 string ID;P Microsoft SYLK program >4 string >0 \b, created by %s !:ext slk/sylk + +# Summary: Windows Performance Monitor Alert +# From: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/Performance_Monitor +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/p/pma.trid.xml +# Note: called "Windows Performance Monitor Alert" by TrID +0 ubelong =0xDC058340 +>4 ubyte =0 Windows Performance Monitor Alert +#!:mime application/octet-stream +# https://www.thoughtco.com/mime-types-by-content-type-3469108 +# https://filext.com/file-extension/PAM +!:mime application/x-perfmon +#!:mime application/x-ms-pma +!:ext pma +# metric type like: "BrowserMetrics" "CrashpadMetrics" "SetupMetrics" +>>80 string x \b, "%s" + +# From: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/InstallShield +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/i/ins.trid.xml +# Note: contain also keywords like: BATCH_INSTALL ISVERSION LOGHANDLE SRCDIR SRCDISK WINDIR WINSYSDISK +0 ubelong 0xB8C90C00 InstallShield Script +#!:mime application/octet-stream +!:mime application/x-installshield-ins +# like test.ins Setup.ins +!:ext ins +# UNKNOWN like: 160034121de07e00 1600341260befe00 16003412e0783700 +# 5000010021083f00 50000100b0335600 50000100cbfdf800 50000100dfbc4700 +#>4 ubequad x \b, at 4 %#16.16llx +# copyright text like: "Stirling Technologies, Inc. (c) 1990-1994" +# "InstallSHIELD Software Coporation (c) 1990-1997" +>13 pstring/h x "%s" +# look for specific ASCII variable names +>1 search/0x121/s SRCDIR \b, variable names: +# 1st like: SRCDIR +>>&-4 leshort x #%u +>>&-2 pstring/h x %s +# 2nd like: SRCDISK +>>>&0 leshort x #%u +>>>&2 pstring/h x %s +# 3rd like: TARGETDISK +>>>>&0 leshort x #%u +>>>>&2 pstring/h x %s +# 4th like: TARGETDIR +#>>>>>&0 leshort x #%u +#>>>>>&2 pstring/h x %s +# 5th like: WINDIR +#>>>>>>&0 leshort x #%u +#>>>>>>&2 pstring/h x %s +# 6th like: WINDISK +#>>>>>>>&0 leshort x #%u +#>>>>>>>&2 pstring/h x %s +# 7th like: WINSYSDIR +#>>>>>>>>&0 leshort x #%u +#>>>>>>>>&2 pstring/h x %s +# ... LOGHANDLE +>0 ubelong x ... +# diff --git a/magic/Magdir/wordprocessors b/magic/Magdir/wordprocessors index 297addfb114c..8032053d06c3 100644 --- a/magic/Magdir/wordprocessors +++ b/magic/Magdir/wordprocessors @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: wordprocessors,v 1.26 2021/08/21 12:45:34 christos Exp $ +# $File: wordprocessors,v 1.27 2021/12/06 15:05:16 christos Exp $ # wordprocessors: file(1) magic fo word processors. # ####### PWP file format used on Smith Corona Personal Word Processors: @@ -229,6 +229,68 @@ !:mime application/x-quark-xpress-3 2 string MMXPRa Motorola Quark Express Document (Korean) +# From: Joerg Jenderek +# URL: http://fileformats.archiveteam.org/wiki/PageMaker +# https://en.wikipedia.org/wiki/Adobe_PageMaker +# Reference: http://mark0.net/download/triddefs_xml.7z/defs/p +# pm4-pagemaker.trid.xml +# pm5-pagemaker.trid.xml +# Note: since version 6 in 1995 called Adobe PageMaker and +# embedded in Compound Document handled by ./ole2compounddocs +# mainly tested little endian variant +4 ubelong =0x0000FF99 +>0 use PageMaker +# big endian variant +4 ubelong =0x000099FF +>0 use \^PageMaker +# display information of Aldus/Adobe PageMaker document/publication +0 name PageMaker +>110 uleshort <0x0600 Aldus +>110 uleshort >0x05FF Adobe +>110 uleshort x PageMaker +# "MP" marker for newer version 4 and above according to TrID +#>108 string x \b, MARKER "%.2s" +# http://www.nationalarchives.gov.uk/pronom/fmt/876 +!:mime application/vnd.pagemaker +#!:mime application/x-pagemaker +# different file name extensions are used depending on version +# older version like 3 +>110 uleshort/256 =0 document +# https://www.macdisk.com/macsigen.php +!:apple ALB3ALD3 +# PT3 for template and no example for PageMaker document/publiction with PM3 extension +!:ext pm3/pt3 +>110 uleshort/256 =4 document +!:apple ALD4ALB4 +# no example for PT4 template +!:ext pm4/pt4 +>110 uleshort/256 =5 document +!:apple ALD5ALB5 +# no example for PT5 template +!:ext pm5/pt5 +>110 uleshort =0x0600 document +!:apple ALD6ALB6 +# PT6 for template +!:ext pm6/pt6 +# HOWTO to distinguish version 7 from 6.5 ? +>110 uleshort =0x0632 document +!:apple AD65AB65 +# no example for T65 template +!:ext p65/t65/pmd/pmt +# version 7 with PMT extension for template +#!:ext pmd/pmt +#!:apple ????PUBF +# endian marker FF 99 for little endian +>6 ubyte =0xFF \b, little-endian +>6 ubyte =0x99 \b, big-endian +# newer numeric version like: 4 5 6 6.50 +#>110 uleshort x \b, VERSION=%#x +>110 uleshort >0x03FF +>>110 uleshort/256 x \b, version %u +>>110 uleshort%256 >0 \b.%u +# older version like 3 +>110 uleshort <0x0400 \b, maybe version 3 + # adobe indesign (document, whatever...) from querkan 0 belong 0x0606edf5 Adobe InDesign >16 string DOCUMENT Document diff --git a/magic/Magdir/xwindows b/magic/Magdir/xwindows index 37ed8744c5b8..d8c08c8702e7 100644 --- a/magic/Magdir/xwindows +++ b/magic/Magdir/xwindows @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: xwindows,v 1.12 2021/08/24 08:31:10 christos Exp $ +# $File: xwindows,v 1.13 2022/03/24 15:48:58 christos Exp $ # xwindows: file(1) magic for various X/Window system file formats. # Compiled X Keymap @@ -37,7 +37,7 @@ # X bitmap https://en.wikipedia.org/wiki/X_BitMap 0 search/2048 #define\040 >&0 regex [a-zA-Z0-9]+_width\040 xbm image ->>&0 regex [0-9]* (%sx +>>&0 regex [0-9]+ (%sx >>>&0 string \n#define\040 >>>>&0 regex [a-zA-Z0-9]+_height\040 ->>>>>&0 regex [0-9]* \b%s) +>>>>>&0 regex [0-9]+ \b%s) diff --git a/magic/Magdir/zip b/magic/Magdir/zip index d70434db0f29..abf5284776d4 100644 --- a/magic/Magdir/zip +++ b/magic/Magdir/zip @@ -1,20 +1,28 @@ #------------------------------------------------------------------------------ -# $File: zip,v 1.7 2021/04/26 15:56:00 christos Exp $ +# $File: zip,v 1.8 2021/10/24 15:53:56 christos Exp $ # zip: file(1) magic for zip files; this is not use # Note the version of magic in archive is currently stronger, this is # just an example until negative offsets are supported better +# Note: All fields unless otherwise noted are unsigned! # Zip Central Directory record 0 name zipcd >0 string PK\001\002 Zip archive data !:mime application/zip +# no "made by" in local file header with PK\3\4 magic >>4 leshort x \b, made by >>4 use zipversion >>4 use ziphost +# inside ./archive 1.151 called "at least" zipversion "to extract" >>6 leshort x \b, extract using at least >>6 use zipversion ->>12 ledate x \b, last modified %s ->>24 lelong >0 \b, uncompressed size %d +# This is DOS date like: ledate 21:00:48 19 Dec 2001 != DOS 00:00 1 Jan 2010 ~ 0000213C +>>12 ulelong x \b, last modified +>>14 lemsdosdate x \b, last modified %s +>>12 lemsdostime x %s +# uncompressed size of 1st entry; FFffFFff means real value stored in ZIP64 record +>>24 ulelong !0xFFffFFff \b, uncompressed size %u +# inside ./archive 1.151 called "compression method="zipcompression >>10 leshort x \b, method= >>10 use zipcompression @@ -102,11 +110,17 @@ #>1 ubyte >19 unused %#x # Zip End Of Central Directory record +# GRR: wrong for ZIP with comment archive -22 string PK\005\006 -#>4 leshort >1 \b, %d disks -#>6 leshort >1 \b, central directory disk %d -#>8 leshort >1 \b, %d central directories on this disk -#>10 leshort >1 \b, %d central directories -#>12 lelong x \b, %d central directory bytes +#>4 uleshort !0xFFff \b, %u disks +#>6 uleshort !0xFFff \b, central directory disk %u +#>8 uleshort !0xFFff \b, %u central directories on this disk +#>10 uleshort !0xFFff \b, %u central directories +#>12 ulelong !0xFFffFFff \b, %u central directory bytes +# offset of central directory +#>16 ulelong x \b, central directory offset %#x >(16.l) use zipcd +# archive comment length n +#>>20 uleshort >0 \b, comment length %u +# archive comment >>20 pstring/l >0 \b, %s diff --git a/magic/Makefile.am b/magic/Makefile.am index ab8c43287ef8..fafa9b7d0fb1 100644 --- a/magic/Makefile.am +++ b/magic/Makefile.am @@ -1,5 +1,5 @@ # -# $File: Makefile.am,v 1.172 2021/10/07 15:41:22 christos Exp $ +# $File: Makefile.am,v 1.178 2022/04/02 14:47:42 christos Exp $ # MAGIC_FRAGMENT_BASE = Magdir MAGIC_DIR = $(top_srcdir)/magic @@ -29,6 +29,7 @@ $(MAGIC_FRAGMENT_DIR)/application \ $(MAGIC_FRAGMENT_DIR)/applix \ $(MAGIC_FRAGMENT_DIR)/apt \ $(MAGIC_FRAGMENT_DIR)/archive \ +$(MAGIC_FRAGMENT_DIR)/aria \ $(MAGIC_FRAGMENT_DIR)/arm \ $(MAGIC_FRAGMENT_DIR)/asf \ $(MAGIC_FRAGMENT_DIR)/assembler \ @@ -58,6 +59,7 @@ $(MAGIC_FRAGMENT_DIR)/c64 \ $(MAGIC_FRAGMENT_DIR)/cad \ $(MAGIC_FRAGMENT_DIR)/cafebabe \ $(MAGIC_FRAGMENT_DIR)/cbor \ +$(MAGIC_FRAGMENT_DIR)/ccf \ $(MAGIC_FRAGMENT_DIR)/cddb \ $(MAGIC_FRAGMENT_DIR)/chord \ $(MAGIC_FRAGMENT_DIR)/cisco \ @@ -89,6 +91,7 @@ $(MAGIC_FRAGMENT_DIR)/dif \ $(MAGIC_FRAGMENT_DIR)/diff \ $(MAGIC_FRAGMENT_DIR)/digital \ $(MAGIC_FRAGMENT_DIR)/dolby \ +$(MAGIC_FRAGMENT_DIR)/dsf \ $(MAGIC_FRAGMENT_DIR)/dump \ $(MAGIC_FRAGMENT_DIR)/dyadic \ $(MAGIC_FRAGMENT_DIR)/ebml \ @@ -206,6 +209,7 @@ $(MAGIC_FRAGMENT_DIR)/netbsd \ $(MAGIC_FRAGMENT_DIR)/netscape \ $(MAGIC_FRAGMENT_DIR)/netware \ $(MAGIC_FRAGMENT_DIR)/news \ +$(MAGIC_FRAGMENT_DIR)/nifty \ $(MAGIC_FRAGMENT_DIR)/nim-lang \ $(MAGIC_FRAGMENT_DIR)/nitpicker \ $(MAGIC_FRAGMENT_DIR)/numpy \ @@ -216,6 +220,7 @@ $(MAGIC_FRAGMENT_DIR)/ole2compounddocs \ $(MAGIC_FRAGMENT_DIR)/olf \ $(MAGIC_FRAGMENT_DIR)/openfst \ $(MAGIC_FRAGMENT_DIR)/opentimestamps \ +$(MAGIC_FRAGMENT_DIR)/oric \ $(MAGIC_FRAGMENT_DIR)/os2 \ $(MAGIC_FRAGMENT_DIR)/os400 \ $(MAGIC_FRAGMENT_DIR)/os9 \ @@ -228,6 +233,7 @@ $(MAGIC_FRAGMENT_DIR)/pbf \ $(MAGIC_FRAGMENT_DIR)/pbm \ $(MAGIC_FRAGMENT_DIR)/pc88 \ $(MAGIC_FRAGMENT_DIR)/pc98 \ +$(MAGIC_FRAGMENT_DIR)/pci_ids \ $(MAGIC_FRAGMENT_DIR)/pcjr \ $(MAGIC_FRAGMENT_DIR)/pdf \ $(MAGIC_FRAGMENT_DIR)/pdp \ diff --git a/magic/Makefile.in b/magic/Makefile.in index 71eb168d0a2e..2b1b3f1842de 100644 --- a/magic/Makefile.in +++ b/magic/Makefile.in @@ -275,7 +275,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # -# $File: Makefile.am,v 1.172 2021/10/07 15:41:22 christos Exp $ +# $File: Makefile.am,v 1.178 2022/04/02 14:47:42 christos Exp $ # MAGIC_FRAGMENT_BASE = Magdir MAGIC_DIR = $(top_srcdir)/magic @@ -303,6 +303,7 @@ $(MAGIC_FRAGMENT_DIR)/application \ $(MAGIC_FRAGMENT_DIR)/applix \ $(MAGIC_FRAGMENT_DIR)/apt \ $(MAGIC_FRAGMENT_DIR)/archive \ +$(MAGIC_FRAGMENT_DIR)/aria \ $(MAGIC_FRAGMENT_DIR)/arm \ $(MAGIC_FRAGMENT_DIR)/asf \ $(MAGIC_FRAGMENT_DIR)/assembler \ @@ -332,6 +333,7 @@ $(MAGIC_FRAGMENT_DIR)/c64 \ $(MAGIC_FRAGMENT_DIR)/cad \ $(MAGIC_FRAGMENT_DIR)/cafebabe \ $(MAGIC_FRAGMENT_DIR)/cbor \ +$(MAGIC_FRAGMENT_DIR)/ccf \ $(MAGIC_FRAGMENT_DIR)/cddb \ $(MAGIC_FRAGMENT_DIR)/chord \ $(MAGIC_FRAGMENT_DIR)/cisco \ @@ -363,6 +365,7 @@ $(MAGIC_FRAGMENT_DIR)/dif \ $(MAGIC_FRAGMENT_DIR)/diff \ $(MAGIC_FRAGMENT_DIR)/digital \ $(MAGIC_FRAGMENT_DIR)/dolby \ +$(MAGIC_FRAGMENT_DIR)/dsf \ $(MAGIC_FRAGMENT_DIR)/dump \ $(MAGIC_FRAGMENT_DIR)/dyadic \ $(MAGIC_FRAGMENT_DIR)/ebml \ @@ -480,6 +483,7 @@ $(MAGIC_FRAGMENT_DIR)/netbsd \ $(MAGIC_FRAGMENT_DIR)/netscape \ $(MAGIC_FRAGMENT_DIR)/netware \ $(MAGIC_FRAGMENT_DIR)/news \ +$(MAGIC_FRAGMENT_DIR)/nifty \ $(MAGIC_FRAGMENT_DIR)/nim-lang \ $(MAGIC_FRAGMENT_DIR)/nitpicker \ $(MAGIC_FRAGMENT_DIR)/numpy \ @@ -490,6 +494,7 @@ $(MAGIC_FRAGMENT_DIR)/ole2compounddocs \ $(MAGIC_FRAGMENT_DIR)/olf \ $(MAGIC_FRAGMENT_DIR)/openfst \ $(MAGIC_FRAGMENT_DIR)/opentimestamps \ +$(MAGIC_FRAGMENT_DIR)/oric \ $(MAGIC_FRAGMENT_DIR)/os2 \ $(MAGIC_FRAGMENT_DIR)/os400 \ $(MAGIC_FRAGMENT_DIR)/os9 \ @@ -502,6 +507,7 @@ $(MAGIC_FRAGMENT_DIR)/pbf \ $(MAGIC_FRAGMENT_DIR)/pbm \ $(MAGIC_FRAGMENT_DIR)/pc88 \ $(MAGIC_FRAGMENT_DIR)/pc98 \ +$(MAGIC_FRAGMENT_DIR)/pci_ids \ $(MAGIC_FRAGMENT_DIR)/pcjr \ $(MAGIC_FRAGMENT_DIR)/pdf \ $(MAGIC_FRAGMENT_DIR)/pdp \ diff --git a/src/apprentice.c b/src/apprentice.c index eb3b4a594e75..9dbe52eeb440 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: apprentice.c,v 1.309 2021/09/24 13:59:19 christos Exp $") +FILE_RCSID("@(#)$File: apprentice.c,v 1.324 2022/05/31 18:54:25 christos Exp $") #endif /* lint */ #include "magic.h" @@ -50,6 +50,12 @@ FILE_RCSID("@(#)$File: apprentice.c,v 1.309 2021/09/24 13:59:19 christos Exp $") #endif #include <dirent.h> #include <limits.h> +#ifdef HAVE_BYTESWAP_H +#include <byteswap.h> +#endif +#ifdef HAVE_SYS_BSWAP_H +#include <sys/bswap.h> +#endif #define EATAB {while (isascii(CAST(unsigned char, *l)) && \ @@ -114,7 +120,8 @@ private int parse(struct magic_set *, struct magic_entry *, const char *, size_t, int); private void eatsize(const char **); private int apprentice_1(struct magic_set *, const char *, int); -private size_t apprentice_magic_strength(const struct magic *); +private ssize_t apprentice_magic_strength_1(const struct magic *); +private size_t apprentice_magic_strength(const struct magic *, size_t); private int apprentice_sort(const void *, const void *); private void apprentice_list(struct mlist *, int ); private struct magic_map *apprentice_load(struct magic_set *, @@ -124,9 +131,21 @@ private void mlist_free_all(struct magic_set *); private void mlist_free(struct mlist *); private void byteswap(struct magic *, uint32_t); private void bs1(struct magic *); + +#if defined(HAVE_BYTESWAP_H) +#define swap2(x) bswap_16(x) +#define swap4(x) bswap_32(x) +#define swap8(x) bswap_64(x) +#elif defined(HAVE_SYS_BSWAP_H) +#define swap2(x) bswap16(x) +#define swap4(x) bswap32(x) +#define swap8(x) bswap64(x) +#else private uint16_t swap2(uint16_t); private uint32_t swap4(uint32_t); private uint64_t swap8(uint64_t); +#endif + private char *mkdbname(struct magic_set *, const char *, int); private struct magic_map *apprentice_buf(struct magic_set *, struct magic *, size_t); @@ -270,6 +289,12 @@ static const struct type_tbl_s type_tbl[] = { { XX("offset"), FILE_OFFSET, FILE_FMT_QUAD }, { XX("bevarint"), FILE_BEVARINT, FILE_FMT_STR }, { XX("levarint"), FILE_LEVARINT, FILE_FMT_STR }, + { XX("msdosdate"), FILE_MSDOSDATE, FILE_FMT_STR }, + { XX("lemsdosdate"), FILE_LEMSDOSDATE, FILE_FMT_STR }, + { XX("bemsdosdate"), FILE_BEMSDOSDATE, FILE_FMT_STR }, + { XX("msdostime"), FILE_MSDOSTIME, FILE_FMT_STR }, + { XX("lemsdostime"), FILE_LEMSDOSTIME, FILE_FMT_STR }, + { XX("bemsdostime"), FILE_BEMSDOSTIME, FILE_FMT_STR }, { XX_NULL, FILE_INVALID, FILE_FMT_NONE }, }; @@ -425,7 +450,15 @@ add_mlist(struct mlist *mlp, struct magic_map *map, size_t idx) ml->map = idx == 0 ? map : NULL; ml->magic = map->magic[idx]; ml->nmagic = map->nmagic[idx]; - + if (ml->nmagic) { + ml->magic_rxcomp = CAST(file_regex_t **, + calloc(ml->nmagic, sizeof(*ml->magic_rxcomp))); + if (ml->magic_rxcomp == NULL) { + free(ml); + return -1; + } + } else + ml->magic_rxcomp = NULL; mlp->prev->next = ml; ml->prev = mlp->prev; ml->next = mlp; @@ -507,6 +540,9 @@ file_ms_free(struct magic_set *ms) free(ms->o.pbuf); free(ms->o.buf); free(ms->c.li); +#ifdef USE_C_LOCALE + freelocale(ms->c_lc_ctype); +#endif free(ms); } @@ -546,6 +582,10 @@ file_ms_alloc(int flags) ms->regex_max = FILE_REGEX_MAX; ms->bytes_max = FILE_BYTES_MAX; ms->encoding_max = FILE_ENCODING_MAX; +#ifdef USE_C_LOCALE + ms->c_lc_ctype = newlocale(LC_CTYPE_MASK, "C", 0); + assert(ms->c_lc_ctype != NULL); +#endif return ms; free: free(ms); @@ -580,6 +620,7 @@ apprentice_unmap(struct magic_map *map) break; #endif default: + fprintf(stderr, "Bad map type %d", map->type); abort(); } free(map); @@ -610,8 +651,20 @@ mlist_free_all(struct magic_set *ms) private void mlist_free_one(struct mlist *ml) { + size_t i; + if (ml->map) apprentice_unmap(CAST(struct magic_map *, ml->map)); + + for (i = 0; i < ml->nmagic; ++i) { + if (ml->magic_rxcomp[i]) { + file_regfree(ml->magic_rxcomp[i]); + free(ml->magic_rxcomp[i]); + ml->magic_rxcomp[i] = NULL; + } + } + free(ml->magic_rxcomp); + ml->magic_rxcomp = NULL; free(ml); } @@ -711,7 +764,7 @@ file_apprentice(struct magic_set *ms, const char *fn, int action) fn = mfn; while (fn) { - p = strchr(fn, PATHSEP); + p = CCAST(char *, strchr(fn, PATHSEP)); if (p) *p++ = '\0'; if (*fn == '\0') @@ -817,6 +870,12 @@ typesize(int type) case FILE_SHORT: case FILE_LESHORT: case FILE_BESHORT: + case FILE_MSDOSDATE: + case FILE_BEMSDOSDATE: + case FILE_LEMSDOSDATE: + case FILE_MSDOSTIME: + case FILE_BEMSDOSTIME: + case FILE_LEMSDOSTIME: return 2; case FILE_LONG: @@ -836,6 +895,8 @@ typesize(int type) case FILE_FLOAT: case FILE_BEFLOAT: case FILE_LEFLOAT: + case FILE_BEID3: + case FILE_LEID3: return 4; case FILE_QUAD: @@ -869,8 +930,8 @@ typesize(int type) /* * Get weight of this magic entry, for sorting purposes. */ -private size_t -apprentice_magic_strength(const struct magic *m) +private ssize_t +apprentice_magic_strength_1(const struct magic *m) { #define MULT 10U size_t ts, v; @@ -878,8 +939,10 @@ apprentice_magic_strength(const struct magic *m) switch (m->type) { case FILE_DEFAULT: /* make sure this sorts last */ - if (m->factor_op != FILE_FACTOR_OP_NONE) + if (m->factor_op != FILE_FACTOR_OP_NONE) { + fprintf(stderr, "Bad factor_op %d", m->factor_op); abort(); + } return 0; case FILE_BYTE: @@ -919,10 +982,21 @@ apprentice_magic_strength(const struct magic *m) case FILE_BEVARINT: case FILE_LEVARINT: case FILE_GUID: + case FILE_BEID3: + case FILE_LEID3: case FILE_OFFSET: + case FILE_MSDOSDATE: + case FILE_BEMSDOSDATE: + case FILE_LEMSDOSDATE: + case FILE_MSDOSTIME: + case FILE_BEMSDOSTIME: + case FILE_LEMSDOSTIME: ts = typesize(m->type); - if (ts == FILE_BADSIZE) + if (ts == FILE_BADSIZE) { + (void)fprintf(stderr, "Bad size for type %d\n", + m->type); abort(); + } val += ts * MULT; break; @@ -950,6 +1024,7 @@ apprentice_magic_strength(const struct magic *m) case FILE_INDIRECT: case FILE_NAME: case FILE_USE: + case FILE_CLEAR: break; case FILE_DER: @@ -986,6 +1061,33 @@ apprentice_magic_strength(const struct magic *m) abort(); } + return val; +} + + +private size_t +apprentice_magic_strength(const struct magic *m, + size_t nmagic __attribute__((__unused__))) +{ + ssize_t val = apprentice_magic_strength_1(m); + +#ifdef notyet + if (m->desc[0] == '\0') { + size_t i; + /* + * Magic entries with no description get their continuations + * added + */ + for (i = 1; m[i].cont_level != 0 && i < MIN(nmagic, 3); i++) { + ssize_t v = apprentice_magic_strength_1(&m[i]) >> + (i + 1); + val += v; + if (m[i].desc[0] != '\0') + break; + } + } +#endif + switch (m->factor_op) { case FILE_FACTOR_OP_NONE: break; @@ -1002,18 +1104,22 @@ apprentice_magic_strength(const struct magic *m) val /= m->factor; break; default: + (void)fprintf(stderr, "Bad factor_op %u\n", m->factor_op); abort(); } if (val <= 0) /* ensure we only return 0 for FILE_DEFAULT */ val = 1; +#ifndef notyet /* * Magic entries with no description get a bonus because they depend * on subsequent magic entries to print something. */ if (m->desc[0] == '\0') val++; +#endif + return val; } @@ -1025,8 +1131,8 @@ apprentice_sort(const void *a, const void *b) { const struct magic_entry *ma = CAST(const struct magic_entry *, a); const struct magic_entry *mb = CAST(const struct magic_entry *, b); - size_t sa = apprentice_magic_strength(ma->mp); - size_t sb = apprentice_magic_strength(mb->mp); + size_t sa = apprentice_magic_strength(ma->mp, ma->cont_count); + size_t sb = apprentice_magic_strength(mb->mp, mb->cont_count); if (sa == sb) return 0; else if (sa > sb) @@ -1041,7 +1147,7 @@ apprentice_sort(const void *a, const void *b) private void apprentice_list(struct mlist *mlist, int mode) { - uint32_t magindex = 0; + uint32_t magindex, descindex, mimeindex, lineindex; struct mlist *ml; for (ml = mlist->next; ml != mlist; ml = ml->next) { for (magindex = 0; magindex < ml->nmagic; magindex++) { @@ -1058,17 +1164,22 @@ apprentice_list(struct mlist *mlist, int mode) * Try to iterate over the tree until we find item with * description/mimetype. */ - while (magindex + 1 < ml->nmagic && - ml->magic[magindex + 1].cont_level != 0 && - *ml->magic[magindex].desc == '\0' && - *ml->magic[magindex].mimetype == '\0') - magindex++; + lineindex = descindex = mimeindex = magindex; + for (magindex++; magindex < ml->nmagic && + ml->magic[magindex].cont_level != 0; magindex++) { + if (*ml->magic[descindex].desc == '\0' + && *ml->magic[magindex].desc) + descindex = magindex; + if (*ml->magic[mimeindex].mimetype == '\0' + && *ml->magic[magindex].mimetype) + mimeindex = magindex; + } printf("Strength = %3" SIZE_T_FORMAT "u@%u: %s [%s]\n", - apprentice_magic_strength(m), - ml->magic[magindex].lineno, - ml->magic[magindex].desc, - ml->magic[magindex].mimetype); + apprentice_magic_strength(m, ml->nmagic - magindex), + ml->magic[lineindex].lineno, + ml->magic[descindex].desc, + ml->magic[mimeindex].mimetype); } } } @@ -1116,6 +1227,12 @@ set_test_type(struct magic *mstart, struct magic *m) case FILE_DER: case FILE_GUID: case FILE_OFFSET: + case FILE_MSDOSDATE: + case FILE_BEMSDOSDATE: + case FILE_LEMSDOSDATE: + case FILE_MSDOSTIME: + case FILE_BEMSDOSTIME: + case FILE_LEMSDOSTIME: mstart->flag |= BINTEST; break; case FILE_STRING: @@ -1162,19 +1279,20 @@ addentry(struct magic_set *ms, struct magic_entry *me, struct magic_entry_set *mset) { size_t i = me->mp->type == FILE_NAME ? 1 : 0; - if (mset[i].count == mset[i].max) { + if (mset[i].me == NULL || mset[i].count == mset[i].max) { struct magic_entry *mp; - mset[i].max += ALLOC_INCR; + size_t incr = mset[i].max + ALLOC_INCR; if ((mp = CAST(struct magic_entry *, - realloc(mset[i].me, sizeof(*mp) * mset[i].max))) == + realloc(mset[i].me, sizeof(*mp) * incr))) == NULL) { - file_oomem(ms, sizeof(*mp) * mset[i].max); + file_oomem(ms, sizeof(*mp) * incr); return -1; } (void)memset(&mp[mset[i].count], 0, sizeof(*mp) * ALLOC_INCR); mset[i].me = mp; + mset[i].max = incr; } mset[i].me[mset[i].count++] = *me; memset(me, 0, sizeof(*me)); @@ -1535,6 +1653,12 @@ file_signextend(struct magic_set *ms, struct magic *m, uint64_t v) case FILE_FLOAT: case FILE_BEFLOAT: case FILE_LEFLOAT: + case FILE_MSDOSDATE: + case FILE_BEMSDOSDATE: + case FILE_LEMSDOSDATE: + case FILE_MSDOSTIME: + case FILE_BEMSDOSTIME: + case FILE_LEMSDOSTIME: v = CAST(int32_t, v); break; case FILE_QUAD: @@ -2413,11 +2537,9 @@ private int parse_apple(struct magic_set *ms, struct magic_entry *me, const char *line, size_t len) { - struct magic *m = &me->mp[0]; - return parse_extra(ms, me, line, len, CAST(off_t, offsetof(struct magic, apple)), - sizeof(m->apple), "APPLE", "!+-./?", 0); + sizeof(me->mp[0].apple), "APPLE", "!+-./?", 0); } /* @@ -2427,11 +2549,9 @@ private int parse_ext(struct magic_set *ms, struct magic_entry *me, const char *line, size_t len) { - struct magic *m = &me->mp[0]; - return parse_extra(ms, me, line, len, CAST(off_t, offsetof(struct magic, ext)), - sizeof(m->ext), "EXTENSION", ",!+-/@?_$&", 0); /* & for b&w */ + sizeof(me->mp[0].ext), "EXTENSION", ",!+-/@?_$&", 0); /* & for b&w */ } /* @@ -2442,11 +2562,9 @@ private int parse_mime(struct magic_set *ms, struct magic_entry *me, const char *line, size_t len) { - struct magic *m = &me->mp[0]; - return parse_extra(ms, me, line, len, CAST(off_t, offsetof(struct magic, mimetype)), - sizeof(m->mimetype), "MIME", "+-/.$?:{}", 1); + sizeof(me->mp[0].mimetype), "MIME", "+-/.$?:{}", 1); } private int @@ -2485,6 +2603,7 @@ check_format_type(const char *ptr, int type, const char **estr) h = 0; break; default: + fprintf(stderr, "Bad number format %d", type); abort(); } } else @@ -2627,6 +2746,7 @@ check_format_type(const char *ptr, int type, const char **estr) default: /* internal error */ + fprintf(stderr, "Bad file format %d", type); abort(); } invalid: @@ -2721,12 +2841,11 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action) } if (m->type == FILE_REGEX) { file_regex_t rx; - int rc = file_regcomp(&rx, m->value.s, REG_EXTENDED); - if (rc) { - if (ms->flags & MAGIC_CHECK) - file_regerror(&rx, rc, ms); + int rc = file_regcomp(ms, &rx, m->value.s, + REG_EXTENDED); + if (rc == 0) { + file_regfree(&rx); } - file_regfree(&rx); return rc ? -1 : 0; } return 0; @@ -2796,6 +2915,7 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action) x = 0; break; default: + fprintf(stderr, "Bad width %zu", ts); abort(); } if (x) { @@ -2828,6 +2948,7 @@ getstr(struct magic_set *ms, struct magic *m, const char *s, int warn) char *pmax = p + plen - 1; int c; int val; + size_t bracket_nesting = 0; while ((c = *s++) != '\0') { if (isspace(CAST(unsigned char, c))) @@ -2836,135 +2957,149 @@ getstr(struct magic_set *ms, struct magic *m, const char *s, int warn) file_error(ms, 0, "string too long: `%s'", origs); return NULL; } - if (c == '\\') { - switch(c = *s++) { - - case '\0': - if (warn) - file_magwarn(ms, "incomplete escape"); - s--; - goto out; - - case '\t': - if (warn) { - file_magwarn(ms, - "escaped tab found, use \\t instead"); - warn = 0; /* already did */ - } - /*FALLTHROUGH*/ - default: - if (warn) { - if (isprint(CAST(unsigned char, c))) { - /* Allow escaping of - * ``relations'' */ - if (strchr("<>&^=!", c) == NULL - && (m->type != FILE_REGEX || - strchr("[]().*?^$|{}", c) - == NULL)) { - file_magwarn(ms, "no " - "need to escape " - "`%c'", c); - } - } else { - file_magwarn(ms, - "unknown escape sequence: " - "\\%03o", c); + if (c != '\\') { + if (c == '[') { + bracket_nesting++; + } + if (c == ']' && bracket_nesting > 0) { + bracket_nesting--; + } + *p++ = CAST(char, c); + continue; + } + switch(c = *s++) { + + case '\0': + if (warn) + file_magwarn(ms, "incomplete escape"); + s--; + goto out; + case '.': + if (m->type == FILE_REGEX && + bracket_nesting == 0 && warn) { + file_magwarn(ms, "escaped dot ('.') found, " + "use \\\\. instead"); + } + warn = 0; /* already did */ + /*FALLTHROUGH*/ + case '\t': + if (warn) { + file_magwarn(ms, + "escaped tab found, use \\\\t instead"); + warn = 0; /* already did */ + } + /*FALLTHROUGH*/ + default: + if (warn) { + if (isprint(CAST(unsigned char, c))) { + /* Allow escaping of + * ``relations'' */ + if (strchr("<>&^=!", c) == NULL + && (m->type != FILE_REGEX || + strchr("[]().*?^$|{}", c) + == NULL)) { + file_magwarn(ms, "no " + "need to escape " + "`%c'", c); } + } else { + file_magwarn(ms, + "unknown escape sequence: " + "\\%03o", c); } - /*FALLTHROUGH*/ - /* space, perhaps force people to use \040? */ - case ' ': + } + /*FALLTHROUGH*/ + /* space, perhaps force people to use \040? */ + case ' ': #if 0 - /* - * Other things people escape, but shouldn't need to, - * so we disallow them - */ - case '\'': - case '"': - case '?': + /* + * Other things people escape, but shouldn't need to, + * so we disallow them + */ + case '\'': + case '"': + case '?': #endif - /* Relations */ - case '>': - case '<': - case '&': - case '^': - case '=': - case '!': - /* and baskslash itself */ - case '\\': - *p++ = CAST(char, c); - break; + /* Relations */ + case '>': + case '<': + case '&': + case '^': + case '=': + case '!': + /* and backslash itself */ + case '\\': + *p++ = CAST(char, c); + break; - case 'a': - *p++ = '\a'; - break; + case 'a': + *p++ = '\a'; + break; - case 'b': - *p++ = '\b'; - break; + case 'b': + *p++ = '\b'; + break; - case 'f': - *p++ = '\f'; - break; + case 'f': + *p++ = '\f'; + break; - case 'n': - *p++ = '\n'; - break; + case 'n': + *p++ = '\n'; + break; - case 'r': - *p++ = '\r'; - break; + case 'r': + *p++ = '\r'; + break; - case 't': - *p++ = '\t'; - break; + case 't': + *p++ = '\t'; + break; - case 'v': - *p++ = '\v'; - break; + case 'v': + *p++ = '\v'; + break; - /* \ and up to 3 octal digits */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - val = c - '0'; - c = *s++; /* try for 2 */ - if (c >= '0' && c <= '7') { - val = (val << 3) | (c - '0'); - c = *s++; /* try for 3 */ - if (c >= '0' && c <= '7') - val = (val << 3) | (c-'0'); - else - --s; - } + /* \ and up to 3 octal digits */ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + val = c - '0'; + c = *s++; /* try for 2 */ + if (c >= '0' && c <= '7') { + val = (val << 3) | (c - '0'); + c = *s++; /* try for 3 */ + if (c >= '0' && c <= '7') + val = (val << 3) | (c-'0'); else --s; - *p++ = CAST(char, val); - break; + } + else + --s; + *p++ = CAST(char, val); + break; - /* \x and up to 2 hex digits */ - case 'x': - val = 'x'; /* Default if no digits */ - c = hextoint(*s++); /* Get next char */ - if (c >= 0) { - val = c; - c = hextoint(*s++); - if (c >= 0) - val = (val << 4) + c; - else - --s; - } else + /* \x and up to 2 hex digits */ + case 'x': + val = 'x'; /* Default if no digits */ + c = hextoint(*s++); /* Get next char */ + if (c >= 0) { + val = c; + c = hextoint(*s++); + if (c >= 0) + val = (val << 4) + c; + else --s; - *p++ = CAST(char, val); - break; - } - } else - *p++ = CAST(char, c); + } else + --s; + *p++ = CAST(char, val); + break; + } } --s; out: @@ -3355,6 +3490,7 @@ byteswap(struct magic *magic, uint32_t nmagic) bs1(&magic[i]); } +#if !defined(HAVE_BYTESWAP_H) && !defined(HAVE_SYS_BSWAP_H) /* * swap a short */ @@ -3394,7 +3530,7 @@ swap8(uint64_t sv) uint64_t rv; uint8_t *s = RCAST(uint8_t *, RCAST(void *, &sv)); uint8_t *d = RCAST(uint8_t *, RCAST(void *, &rv)); -#if 0 +# if 0 d[0] = s[3]; d[1] = s[2]; d[2] = s[1]; @@ -3403,7 +3539,7 @@ swap8(uint64_t sv) d[5] = s[6]; d[6] = s[5]; d[7] = s[4]; -#else +# else d[0] = s[7]; d[1] = s[6]; d[2] = s[5]; @@ -3412,9 +3548,10 @@ swap8(uint64_t sv) d[5] = s[2]; d[6] = s[1]; d[7] = s[0]; -#endif +# endif return rv; } +#endif protected uintmax_t file_varint2uintmax_t(const unsigned char *us, int t, size_t *l) @@ -3548,13 +3685,13 @@ file_magicfind(struct magic_set *ms, const char *name, struct mlist *v) for (ml = mlist->next; ml != mlist; ml = ml->next) { struct magic *ma = ml->magic; - uint32_t nma = ml->nmagic; - for (i = 0; i < nma; i++) { + for (i = 0; i < ml->nmagic; i++) { if (ma[i].type != FILE_NAME) continue; if (strcmp(ma[i].value.s, name) == 0) { v->magic = &ma[i]; - for (j = i + 1; j < nma; j++) + v->magic_rxcomp = &(ml->magic_rxcomp[i]); + for (j = i + 1; j < ml->nmagic; j++) if (ma[j].cont_level == 0) break; v->nmagic = j - i; diff --git a/src/ascmagic.c b/src/ascmagic.c index 9e64e7c3ff76..c9a2f348ef0e 100644 --- a/src/ascmagic.c +++ b/src/ascmagic.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: ascmagic.c,v 1.109 2021/02/05 23:01:40 christos Exp $") +FILE_RCSID("@(#)$File: ascmagic.c,v 1.110 2021/12/06 15:33:00 christos Exp $") #endif /* lint */ #include "magic.h" @@ -273,8 +273,8 @@ file_ascmagic_with_encoding(struct magic_set *ms, const struct buffer *b, goto done; if (has_long_lines) - if (file_printf(ms, ", with very long lines (%zu)", - has_long_lines) == -1) + if (file_printf(ms, ", with very long lines (%" + SIZE_T_FORMAT "u)", has_long_lines) == -1) goto done; /* diff --git a/src/cdf.c b/src/cdf.c index b5ad2f6adb6c..874a6ed33036 100644 --- a/src/cdf.c +++ b/src/cdf.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: cdf.c,v 1.120 2021/09/24 13:59:19 christos Exp $") +FILE_RCSID("@(#)$File: cdf.c,v 1.121 2021/10/20 13:56:15 christos Exp $") #endif #include <assert.h> @@ -48,6 +48,12 @@ FILE_RCSID("@(#)$File: cdf.c,v 1.120 2021/09/24 13:59:19 christos Exp $") #include <time.h> #include <ctype.h> #include <limits.h> +#ifdef HAVE_BYTESWAP_H +#include <byteswap.h> +#endif +#ifdef HAVE_SYS_BSWAP_H +#include <sys/bswap.h> +#endif #ifndef EFTYPE #define EFTYPE EINVAL @@ -124,6 +130,15 @@ cdf_calloc(const char *file __attribute__((__unused__)), return calloc(n, u); } +#if defined(HAVE_BYTESWAP_H) +# define _cdf_tole2(x) bswap_16(x) +# define _cdf_tole4(x) bswap_32(x) +# define _cdf_tole8(x) bswap_64(x) +#elif defined(HAVE_SYS_BSWAP_H) +# define _cdf_tole2(x) bswap16(x) +# define _cdf_tole4(x) bswap32(x) +# define _cdf_tole8(x) bswap64(x) +#else /* * swap a short */ @@ -173,6 +188,7 @@ _cdf_tole8(uint64_t sv) d[7] = s[0]; return rv; } +#endif /* * grab a uint32_t from a possibly unaligned address, and return it in diff --git a/src/cdf_time.c b/src/cdf_time.c index e4eea4c737f3..68388f114122 100644 --- a/src/cdf_time.c +++ b/src/cdf_time.c @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: cdf_time.c,v 1.19 2019/03/12 20:43:05 christos Exp $") +FILE_RCSID("@(#)$File: cdf_time.c,v 1.20 2021/12/06 15:33:00 christos Exp $") #endif #include <time.h> @@ -171,8 +171,13 @@ cdf_ctime(const time_t *sec, char *buf) char *ptr = ctime_r(sec, buf); if (ptr != NULL) return buf; +#ifdef WIN32 + (void)snprintf(buf, 26, "*Bad* 0x%16.16I64x\n", + CAST(long long, *sec)); +#else (void)snprintf(buf, 26, "*Bad* %#16.16" INT64_T_FORMAT "x\n", CAST(long long, *sec)); +#endif return buf; } diff --git a/src/compress.c b/src/compress.c index 9f65e4fa19e0..113077ae1aa7 100644 --- a/src/compress.c +++ b/src/compress.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: compress.c,v 1.129 2020/12/08 21:26:00 christos Exp $") +FILE_RCSID("@(#)$File: compress.c,v 1.135 2022/04/11 18:14:41 christos Exp $") #endif #include "magic.h" @@ -43,6 +43,9 @@ FILE_RCSID("@(#)$File: compress.c,v 1.129 2020/12/08 21:26:00 christos Exp $") #ifdef HAVE_UNISTD_H #include <unistd.h> #endif +#ifdef HAVE_SPAWN_H +#include <spawn.h> +#endif #include <string.h> #include <errno.h> #include <ctype.h> @@ -51,7 +54,7 @@ FILE_RCSID("@(#)$File: compress.c,v 1.129 2020/12/08 21:26:00 christos Exp $") #ifndef HAVE_SIG_T typedef void (*sig_t)(int); #endif /* HAVE_SIG_T */ -#if !defined(__MINGW32__) && !defined(WIN32) && !defined(__MINGW64__) +#ifdef HAVE_SYS_IOCTL_H #include <sys/ioctl.h> #endif #ifdef HAVE_SYS_WAIT_H @@ -449,7 +452,21 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf, ssize_t r; int tfd; - (void)strlcpy(buf, "/tmp/file.XXXXXX", sizeof buf); +#ifdef WIN32 + const char *t; + buf[0] = '\0'; + if ((t = getenv("TEMP")) != NULL) + (void)strlcpy(buf, t, sizeof(buf)); + else if ((t = getenv("TMP")) != NULL) + (void)strlcpy(buf, t, sizeof(buf)); + else if ((t = getenv("TMPDIR")) != NULL) + (void)strlcpy(buf, t, sizeof(buf)); + if (buf[0] != '\0') + (void)strlcat(buf, "/", sizeof(buf)); + (void)strlcat(buf, "file.XXXXXX", sizeof(buf)); +#else + (void)strlcpy(buf, "/tmp/file.XXXXXX", sizeof(buf)); +#endif #ifndef HAVE_MKSTEMP { char *ptr = mktemp(buf); @@ -718,16 +735,61 @@ closep(int *fd) closefd(fd, i); } -static int -copydesc(int i, int fd) +static void +movedesc(void *v, int i, int fd) { if (fd == i) - return 0; /* "no dup was necessary" */ + return; /* "no dup was necessary" */ +#ifdef HAVE_POSIX_SPAWNP + posix_spawn_file_actions_t *fa = RCAST(posix_spawn_file_actions_t *, v); + posix_spawn_file_actions_adddup2(fa, fd, i); + posix_spawn_file_actions_addclose(fa, fd); +#else if (dup2(fd, i) == -1) { DPRINTF("dup(%d, %d) failed (%s)\n", fd, i, strerror(errno)); exit(1); } - return 1; + close(v ? fd : fd); +#endif +} + +static void +closedesc(void *v, int fd) +{ +#ifdef HAVE_POSIX_SPAWNP + posix_spawn_file_actions_t *fa = RCAST(posix_spawn_file_actions_t *, v); + posix_spawn_file_actions_addclose(fa, fd); +#else + close(v ? fd : fd); +#endif +} + +static void +handledesc(void *v, int fd, int fdp[3][2]) +{ + if (fd != -1) { + (void) lseek(fd, CAST(off_t, 0), SEEK_SET); + movedesc(v, STDIN_FILENO, fd); + } else { + movedesc(v, STDIN_FILENO, fdp[STDIN_FILENO][0]); + if (fdp[STDIN_FILENO][1] > 2) + closedesc(v, fdp[STDIN_FILENO][1]); + } + + file_clear_closexec(STDIN_FILENO); + +///FIXME: if one of the fdp[i][j] is 0 or 1, this can bomb spectacularly + movedesc(v, STDOUT_FILENO, fdp[STDOUT_FILENO][1]); + if (fdp[STDOUT_FILENO][0] > 2) + closedesc(v, fdp[STDOUT_FILENO][0]); + + file_clear_closexec(STDOUT_FILENO); + + movedesc(v, STDERR_FILENO, fdp[STDERR_FILENO][1]); + if (fdp[STDERR_FILENO][0] > 2) + closedesc(v, fdp[STDERR_FILENO][0]); + + file_clear_closexec(STDERR_FILENO); } static pid_t @@ -817,6 +879,10 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, const unsigned char *old, pid_t writepid = -1; size_t i; ssize_t r; + char *const *args; +#ifdef HAVE_POSIX_SPAWNP + posix_spawn_file_actions_t fa; +#endif switch (method) { #ifdef BUILTIN_DECOMPRESS @@ -867,6 +933,22 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, const unsigned char *old, strerror(errno)); } + args = RCAST(char *const *, RCAST(intptr_t, compr[method].argv)); +#ifdef HAVE_POSIX_SPAWNP + posix_spawn_file_actions_init(&fa); + + handledesc(&fa, fd, fdp); + + status = posix_spawnp(&pid, compr[method].argv[0], &fa, NULL, + args, NULL); + + posix_spawn_file_actions_destroy(&fa); + + if (status == -1) { + return makeerror(newch, n, "Cannot posix_spawn `%s', %s", + compr[method].argv[0], strerror(errno)); + } +#else /* For processes with large mapped virtual sizes, vfork * may be _much_ faster (10-100 times) than fork. */ @@ -881,37 +963,14 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, const unsigned char *old, * in a way which confuses parent. In particular, * do not modify fdp[i][j]. */ - if (fd != -1) { - (void) lseek(fd, CAST(off_t, 0), SEEK_SET); - if (copydesc(STDIN_FILENO, fd)) - (void) close(fd); - } else { - if (copydesc(STDIN_FILENO, fdp[STDIN_FILENO][0])) - (void) close(fdp[STDIN_FILENO][0]); - if (fdp[STDIN_FILENO][1] > 2) - (void) close(fdp[STDIN_FILENO][1]); - } - file_clear_closexec(STDIN_FILENO); + handledesc(NULL, fd, fdp); -///FIXME: if one of the fdp[i][j] is 0 or 1, this can bomb spectacularly - if (copydesc(STDOUT_FILENO, fdp[STDOUT_FILENO][1])) - (void) close(fdp[STDOUT_FILENO][1]); - if (fdp[STDOUT_FILENO][0] > 2) - (void) close(fdp[STDOUT_FILENO][0]); - file_clear_closexec(STDOUT_FILENO); - - if (copydesc(STDERR_FILENO, fdp[STDERR_FILENO][1])) - (void) close(fdp[STDERR_FILENO][1]); - if (fdp[STDERR_FILENO][0] > 2) - (void) close(fdp[STDERR_FILENO][0]); - file_clear_closexec(STDERR_FILENO); - - (void)execvp(compr[method].argv[0], - RCAST(char *const *, RCAST(intptr_t, compr[method].argv))); + (void)execvp(compr[method].argv[0], args); dprintf(STDERR_FILENO, "exec `%s' failed, %s", compr[method].argv[0], strerror(errno)); _exit(1); /* _exit(), not exit(), because of vfork */ } +#endif /* parent */ /* Close write sides of child stdout/err pipes */ for (i = 1; i < __arraycount(fdp); i++) diff --git a/src/der.c b/src/der.c index 4bee9f169ebc..220ad93584d9 100644 --- a/src/der.c +++ b/src/der.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: der.c,v 1.21 2020/06/15 00:58:10 christos Exp $") +FILE_RCSID("@(#)$File: der.c,v 1.22 2022/01/10 14:15:08 christos Exp $") #endif #else #define SIZE_T_FORMAT "z" @@ -235,6 +235,7 @@ der_tag(char *buf, size_t len, uint32_t tag) static int der_data(char *buf, size_t blen, uint32_t tag, const void *q, uint32_t len) { + uint32_t i; const uint8_t *d = CAST(const uint8_t *, q); switch (tag) { case DER_TAG_PRINTABLE_STRING: @@ -251,7 +252,7 @@ der_data(char *buf, size_t blen, uint32_t tag, const void *q, uint32_t len) break; } - for (uint32_t i = 0; i < len; i++) { + for (i = 0; i < len; i++) { uint32_t z = i << 1; if (z < blen - 2) snprintf(buf + z, blen - z, "%.2x", d[i]); @@ -283,7 +284,8 @@ der_offs(struct magic_set *ms, struct magic *m, size_t nbytes) offs += ms->offset + m->offset; DPRINTF(("cont_level = %d\n", m->cont_level)); #ifdef DEBUG_DER - for (size_t i = 0; i < m->cont_level; i++) + size_t i; + for (i = 0; i < m->cont_level; i++) printf("cont_level[%" SIZE_T_FORMAT "u] = %u\n", i, ms->c.li[i].off); #endif diff --git a/src/encoding.c b/src/encoding.c index 3647a481d47d..e40cb62c916a 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: encoding.c,v 1.32 2021/04/27 19:37:14 christos Exp $") +FILE_RCSID("@(#)$File: encoding.c,v 1.38 2022/06/10 13:40:17 christos Exp $") #endif /* lint */ #include "magic.h" @@ -80,7 +80,6 @@ file_encoding(struct magic_set *ms, const struct buffer *b, size_t nbytes = b->flen; size_t mlen; int rv = 1, ucs_type; - unsigned char *nbuf = NULL; file_unichar_t *udefbuf; size_t udeflen; @@ -103,13 +102,6 @@ file_encoding(struct magic_set *ms, const struct buffer *b, file_oomem(ms, mlen); goto done; } - mlen = (nbytes + 1) * sizeof(nbuf[0]); - if ((nbuf = CAST(unsigned char *, - calloc(CAST(size_t, 1), mlen))) == NULL) { - file_oomem(ms, mlen); - goto done; - } - if (looks_ascii(buf, nbytes, *ubuf, ulen)) { if (looks_utf7(buf, nbytes, *ubuf, ulen) > 0) { DPRINTF(("utf-7 %" SIZE_T_FORMAT "u\n", *ulen)); @@ -155,6 +147,13 @@ file_encoding(struct magic_set *ms, const struct buffer *b, *code = "Non-ISO extended-ASCII"; *code_mime = "unknown-8bit"; } else { + unsigned char *nbuf; + + mlen = (nbytes + 1) * sizeof(nbuf[0]); + if ((nbuf = CAST(unsigned char *, malloc(mlen))) == NULL) { + file_oomem(ms, mlen); + goto done; + } from_ebcdic(buf, nbytes, nbuf); if (looks_ascii(nbuf, nbytes, *ubuf, ulen)) { @@ -171,10 +170,10 @@ file_encoding(struct magic_set *ms, const struct buffer *b, rv = 0; *type = "binary"; } + free(nbuf); } done: - free(nbuf); if (ubuf == &udefbuf) free(udefbuf); @@ -458,11 +457,16 @@ looks_utf7(const unsigned char *buf, size_t nbytes, file_unichar_t *ubuf, return -1; } +#define UCS16_NOCHAR(c) ((c) >= 0xfdd0 && (c) <= 0xfdef) +#define UCS16_HISURR(c) ((c) >= 0xd800 && (c) <= 0xdbff) +#define UCS16_LOSURR(c) ((c) >= 0xdc00 && (c) <= 0xdfff) + private int looks_ucs16(const unsigned char *bf, size_t nbytes, file_unichar_t *ubf, size_t *ulen) { int bigend; + uint32_t hi; size_t i; if (nbytes < 2) @@ -476,21 +480,39 @@ looks_ucs16(const unsigned char *bf, size_t nbytes, file_unichar_t *ubf, return 0; *ulen = 0; + hi = 0; for (i = 2; i + 1 < nbytes; i += 2) { - /* XXX fix to properly handle chars > 65536 */ + uint32_t uc; if (bigend) - ubf[(*ulen)++] = bf[i + 1] - | (CAST(file_unichar_t, bf[i]) << 8); + uc = bf[i + 1] | (CAST(file_unichar_t, bf[i]) << 8); else - ubf[(*ulen)++] = bf[i] - | (CAST(file_unichar_t, bf[i + 1]) << 8); + uc = bf[i] | (CAST(file_unichar_t, bf[i + 1]) << 8); - if (ubf[*ulen - 1] == 0xfffe) + uc &= 0xffff; + + switch (uc) { + case 0xfffe: + case 0xffff: return 0; - if (ubf[*ulen - 1] < 128 && - text_chars[CAST(size_t, ubf[*ulen - 1])] != T) + default: + if (UCS16_NOCHAR(uc)) + return 0; + break; + } + if (hi) { + if (!UCS16_LOSURR(uc)) + return 0; + uc = 0x10000 + 0x400 * (hi - 1) + (uc - 0xdc00); + hi = 0; + } + if (uc < 128 && text_chars[CAST(size_t, uc)] != T) + return 0; + ubf[(*ulen)++] = uc; + if (UCS16_HISURR(uc)) + hi = uc - 0xd800 + 1; + if (UCS16_LOSURR(uc)) return 0; } diff --git a/src/file.c b/src/file.c index 2f4f7a6d6337..5300e5af8edf 100644 --- a/src/file.c +++ b/src/file.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: file.c,v 1.190 2021/09/24 14:14:26 christos Exp $") +FILE_RCSID("@(#)$File: file.c,v 1.195 2022/06/02 15:45:43 christos Exp $") #endif /* lint */ #include "magic.h" @@ -57,6 +57,9 @@ FILE_RCSID("@(#)$File: file.c,v 1.190 2021/09/24 14:14:26 christos Exp $") #ifdef HAVE_WCHAR_H #include <wchar.h> #endif +#ifdef HAVE_WCTYPE_H +#include <wctype.h> +#endif #if defined(HAVE_GETOPT_H) && defined(HAVE_STRUCT_OPTION) # include <getopt.h> @@ -182,7 +185,7 @@ int main(int argc, char *argv[]) { int c; - size_t i; + size_t i, j, wid, nw; int action = 0, didsomefiles = 0, errflg = 0; int flags = 0, e = 0; #ifdef HAVE_LIBSECCOMP @@ -408,27 +411,30 @@ main(int argc, char *argv[]) if (optind == argc) { if (!didsomefiles) usage(); + goto out; } - else { - size_t j, wid, nw; - for (wid = 0, j = CAST(size_t, optind); j < CAST(size_t, argc); - j++) { - nw = file_mbswidth(argv[j]); - if (nw > wid) - wid = nw; - } - /* - * If bflag is only set twice, set it depending on - * number of files [this is undocumented, and subject to change] - */ - if (bflag == 2) { - bflag = optind >= argc - 1; - } - for (; optind < argc; optind++) - e |= process(magic, argv[optind], wid); + + for (wid = 0, j = CAST(size_t, optind); j < CAST(size_t, argc); + j++) { + nw = file_mbswidth(magic, argv[j]); + if (nw > wid) + wid = nw; } + /* + * If bflag is only set twice, set it depending on + * number of files [this is undocumented, and subject to change] + */ + if (bflag == 2) { + bflag = optind >= argc - 1; + } + for (; optind < argc; optind++) + e |= process(magic, argv[optind], wid); + out: + if (!nobuffer) + e |= fflush(stdout) != 0; + if (magic) magic_close(magic); return e; @@ -453,7 +459,7 @@ setparam(const char *p) size_t i; char *s; - if ((s = strchr(p, '=')) == NULL) + if ((s = CCAST(char *, strchr(p, '='))) == NULL) goto badparm; for (i = 0; i < __arraycount(pm); i++) { @@ -513,7 +519,7 @@ unwrap(struct magic_set *ms, const char *fn) while ((len = getline(&line, &llen, f)) > 0) { if (line[len - 1] == '\n') line[len - 1] = '\0'; - cwid = file_mbswidth(line); + cwid = file_mbswidth(ms, line); if (cwid > wid) wid = cwid; } @@ -540,35 +546,45 @@ process(struct magic_set *ms, const char *inname, int wid) { const char *type, c = nulsep > 1 ? '\0' : '\n'; int std_in = strcmp(inname, "-") == 0; + int haderror = 0; + size_t plen = 4 * wid + 1; + char *pbuf, *pname; + + if ((pbuf = CAST(char *, malloc(plen))) == NULL) + file_err(EXIT_FAILURE, "Can't allocate %zu bytes", plen); if (wid > 0 && !bflag) { - (void)printf("%s", std_in ? "/dev/stdin" : inname); + pname = file_printable(ms, pbuf, plen, inname, wid); + (void)printf("%s", std_in ? "/dev/stdin" : pname); if (nulsep) (void)putc('\0', stdout); if (nulsep < 2) { (void)printf("%s", separator); (void)printf("%*s ", CAST(int, nopad ? 0 - : (wid - file_mbswidth(inname))), ""); + : (wid - file_mbswidth(ms, inname))), ""); } } type = magic_file(ms, std_in ? NULL : inname); if (type == NULL) { - (void)printf("ERROR: %s%c", magic_error(ms), c); + haderror |= printf("ERROR: %s%c", magic_error(ms), c); } else { - (void)printf("%s%c", type, c); + haderror |= printf("%s%c", type, c) < 0; } if (nobuffer) - (void)fflush(stdout); - return type == NULL; + haderror |= fflush(stdout) != 0; + free(pbuf); + return haderror || type == NULL; } protected size_t -file_mbswidth(const char *s) +file_mbswidth(struct magic_set *ms, const char *s) { -#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH) - size_t bytesconsumed, old_n, n, width = 0; + size_t width = 0; +#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH) && \ + defined(HAVE_WCTYPE_H) + size_t bytesconsumed, old_n, n; mbstate_t state; wchar_t nextchar; (void)memset(&state, 0, sizeof(mbstate_t)); @@ -581,22 +597,18 @@ file_mbswidth(const char *s) /* Something went wrong, return something reasonable */ return old_n; } - if (s[0] == '\n') { - /* - * do what strlen() would do, so that caller - * is always right - */ - width++; - } else { - int w = wcwidth(nextchar); - if (w > 0) - width += w; - } + width += ((ms->flags & MAGIC_RAW) != 0 + || iswprint(nextchar)) ? wcwidth(nextchar) : 4; s += bytesconsumed, n -= bytesconsumed; } return width; #else + while (*s) { + width += (ms->flags & MAGIC_RAW) != 0 + || isprint(CAST(unsigned char, *s)) ? 1 : 4; + } + return strlen(s); #endif } @@ -626,7 +638,7 @@ docprint(const char *opts, int def) int comma, pad; char *sp, *p; - p = strchr(opts, '%'); + p = CCAST(char *, strchr(opts, '%')); if (p == NULL) { fprintf(stdout, "%s", opts); defprint(def); diff --git a/src/file.h b/src/file.h index 28a05e17a6ff..343f62ea9595 100644 --- a/src/file.h +++ b/src/file.h @@ -27,7 +27,7 @@ */ /* * file.h - definitions for file(1) program - * @(#)$File: file.h,v 1.227 2021/06/30 10:08:48 christos Exp $ + * @(#)$File: file.h,v 1.234 2022/05/28 20:24:09 christos Exp $ */ #ifndef __file_h__ @@ -88,6 +88,10 @@ /* Do this here and now, because struct stat gets re-defined on solaris */ #include <sys/stat.h> #include <stdarg.h> +#include <locale.h> +#if defined(HAVE_XLOCALE_H) +#include <xlocale.h> +#endif #define ENABLE_CONDITIONALS @@ -157,7 +161,7 @@ #define MAXstring 128 /* max len of "string" types */ #define MAGICNO 0xF11E041C -#define VERSIONNO 16 +#define VERSIONNO 17 #define FILE_MAGICSIZE 376 #define FILE_GUID_SIZE sizeof("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX") @@ -167,6 +171,8 @@ #define FILE_COMPILE 2 #define FILE_LIST 3 +typedef regex_t file_regex_t; + struct buffer { int fd; struct stat st; @@ -213,60 +219,66 @@ struct magic { uint8_t vallen; /* length of string value, if any */ uint8_t type; /* comparison type (FILE_*) */ uint8_t in_type; /* type of indirection */ -#define FILE_INVALID 0 -#define FILE_BYTE 1 -#define FILE_SHORT 2 -#define FILE_DEFAULT 3 -#define FILE_LONG 4 -#define FILE_STRING 5 -#define FILE_DATE 6 -#define FILE_BESHORT 7 -#define FILE_BELONG 8 -#define FILE_BEDATE 9 -#define FILE_LESHORT 10 -#define FILE_LELONG 11 -#define FILE_LEDATE 12 -#define FILE_PSTRING 13 -#define FILE_LDATE 14 -#define FILE_BELDATE 15 -#define FILE_LELDATE 16 -#define FILE_REGEX 17 -#define FILE_BESTRING16 18 -#define FILE_LESTRING16 19 -#define FILE_SEARCH 20 -#define FILE_MEDATE 21 -#define FILE_MELDATE 22 -#define FILE_MELONG 23 -#define FILE_QUAD 24 -#define FILE_LEQUAD 25 -#define FILE_BEQUAD 26 -#define FILE_QDATE 27 -#define FILE_LEQDATE 28 -#define FILE_BEQDATE 29 -#define FILE_QLDATE 30 -#define FILE_LEQLDATE 31 -#define FILE_BEQLDATE 32 -#define FILE_FLOAT 33 -#define FILE_BEFLOAT 34 -#define FILE_LEFLOAT 35 -#define FILE_DOUBLE 36 -#define FILE_BEDOUBLE 37 -#define FILE_LEDOUBLE 38 -#define FILE_BEID3 39 -#define FILE_LEID3 40 -#define FILE_INDIRECT 41 -#define FILE_QWDATE 42 -#define FILE_LEQWDATE 43 -#define FILE_BEQWDATE 44 -#define FILE_NAME 45 -#define FILE_USE 46 -#define FILE_CLEAR 47 -#define FILE_DER 48 -#define FILE_GUID 49 -#define FILE_OFFSET 50 -#define FILE_BEVARINT 51 -#define FILE_LEVARINT 52 -#define FILE_NAMES_SIZE 53 /* size of array to contain all names */ +#define FILE_INVALID 0 +#define FILE_BYTE 1 +#define FILE_SHORT 2 +#define FILE_DEFAULT 3 +#define FILE_LONG 4 +#define FILE_STRING 5 +#define FILE_DATE 6 +#define FILE_BESHORT 7 +#define FILE_BELONG 8 +#define FILE_BEDATE 9 +#define FILE_LESHORT 10 +#define FILE_LELONG 11 +#define FILE_LEDATE 12 +#define FILE_PSTRING 13 +#define FILE_LDATE 14 +#define FILE_BELDATE 15 +#define FILE_LELDATE 16 +#define FILE_REGEX 17 +#define FILE_BESTRING16 18 +#define FILE_LESTRING16 19 +#define FILE_SEARCH 20 +#define FILE_MEDATE 21 +#define FILE_MELDATE 22 +#define FILE_MELONG 23 +#define FILE_QUAD 24 +#define FILE_LEQUAD 25 +#define FILE_BEQUAD 26 +#define FILE_QDATE 27 +#define FILE_LEQDATE 28 +#define FILE_BEQDATE 29 +#define FILE_QLDATE 30 +#define FILE_LEQLDATE 31 +#define FILE_BEQLDATE 32 +#define FILE_FLOAT 33 +#define FILE_BEFLOAT 34 +#define FILE_LEFLOAT 35 +#define FILE_DOUBLE 36 +#define FILE_BEDOUBLE 37 +#define FILE_LEDOUBLE 38 +#define FILE_BEID3 39 +#define FILE_LEID3 40 +#define FILE_INDIRECT 41 +#define FILE_QWDATE 42 +#define FILE_LEQWDATE 43 +#define FILE_BEQWDATE 44 +#define FILE_NAME 45 +#define FILE_USE 46 +#define FILE_CLEAR 47 +#define FILE_DER 48 +#define FILE_GUID 49 +#define FILE_OFFSET 50 +#define FILE_BEVARINT 51 +#define FILE_LEVARINT 52 +#define FILE_MSDOSDATE 53 +#define FILE_LEMSDOSDATE 54 +#define FILE_BEMSDOSDATE 55 +#define FILE_MSDOSTIME 56 +#define FILE_LEMSDOSTIME 57 +#define FILE_BEMSDOSTIME 58 +#define FILE_NAMES_SIZE 59 /* size of array to contain all names */ #define IS_STRING(t) \ ((t) == FILE_STRING || \ @@ -398,7 +410,8 @@ struct magic { /* list of magic entries */ struct mlist { struct magic *magic; /* array of magic entries */ - uint32_t nmagic; /* number of entries in array */ + file_regex_t **magic_rxcomp; /* array of compiled regexps */ + size_t nmagic; /* number of entries in array */ void *map; /* internal resources used by entry */ struct mlist *next, *prev; }; @@ -477,6 +490,13 @@ struct magic_set { #define FILE_NAME_MAX 50 #define FILE_REGEX_MAX 8192 #define FILE_ENCODING_MAX (64 * 1024) +#if defined(HAVE_NEWLOCALE) && defined(HAVE_USELOCALE) && defined(HAVE_FREELOCALE) +#define USE_C_LOCALE + locale_t c_lc_ctype; +#define file_locale_used +#else +#define file_locale_used __attribute__((__unused__)) +#endif }; /* Type for Unicode characters */ @@ -485,7 +505,9 @@ typedef unsigned long file_unichar_t; struct stat; #define FILE_T_LOCAL 1 #define FILE_T_WINDOWS 2 -protected const char *file_fmttime(char *, size_t, uint64_t, int); +protected const char *file_fmtdatetime(char *, size_t, uint64_t, int); +protected const char *file_fmtdate(char *, size_t, uint16_t); +protected const char *file_fmttime(char *, size_t, uint16_t); protected const char *file_fmtvarint(const unsigned char *, int, char *, size_t); protected struct magic_set *file_ms_alloc(int); @@ -543,7 +565,7 @@ protected void file_magwarn(struct magic_set *, const char *, ...) __attribute__((__format__(__printf__, 2, 3))); protected void file_mdump(struct magic *); protected void file_showstr(FILE *, const char *, size_t); -protected size_t file_mbswidth(const char *); +protected size_t file_mbswidth(struct magic_set *, const char *); protected const char *file_getbuffer(struct magic_set *); protected ssize_t sread(int, void *, size_t, int); protected int file_check_mem(struct magic_set *, unsigned int); @@ -553,7 +575,7 @@ protected size_t file_pstring_length_size(struct magic_set *, const struct magic *); protected size_t file_pstring_get_length(struct magic_set *, const struct magic *, const char *); -protected char * file_printable(struct magic_set *, char *, size_t, +public char * file_printable(struct magic_set *, char *, size_t, const char *, size_t); #ifdef __EMX__ protected int file_os2_apptype(struct magic_set *, const char *, const void *, @@ -568,29 +590,13 @@ protected void buffer_init(struct buffer *, int, const struct stat *, protected void buffer_fini(struct buffer *); protected int buffer_fill(const struct buffer *); -#include <locale.h> -#if defined(HAVE_XLOCALE_H) -#include <xlocale.h> -#endif -typedef struct { - const char *pat; -#if defined(HAVE_NEWLOCALE) && defined(HAVE_USELOCALE) && defined(HAVE_FREELOCALE) -#define USE_C_LOCALE - locale_t old_lc_ctype; - locale_t c_lc_ctype; -#else - char *old_lc_ctype; -#endif - int rc; - regex_t rx; -} file_regex_t; -protected int file_regcomp(file_regex_t *, const char *, int); -protected int file_regexec(file_regex_t *, const char *, size_t, regmatch_t *, +protected int file_regcomp(struct magic_set *, file_regex_t *, const char *, int); +protected int file_regexec(struct magic_set *, file_regex_t *, const char *, + size_t, regmatch_t *, int); protected void file_regfree(file_regex_t *); -protected void file_regerror(file_regex_t *, int, struct magic_set *); typedef struct { char *buf; diff --git a/src/fsmagic.c b/src/fsmagic.c index 5204f20d0cdb..f01d374f1838 100644 --- a/src/fsmagic.c +++ b/src/fsmagic.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: fsmagic.c,v 1.81 2019/07/16 13:30:32 christos Exp $") +FILE_RCSID("@(#)$File: fsmagic.c,v 1.82 2022/04/11 18:14:41 christos Exp $") #endif /* lint */ #include "magic.h" @@ -327,7 +327,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) char *tmp; char buf2[BUFSIZ+BUFSIZ+4]; - if ((tmp = strrchr(fn, '/')) == NULL) { + if ((tmp = CCAST(char *, strrchr(fn, '/'))) == NULL) { tmp = buf; /* in current directory anyway */ } else { if (tmp - fn + 1 > BUFSIZ) { diff --git a/src/funcs.c b/src/funcs.c index 33c3f85a71a7..71041441e290 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: funcs.c,v 1.122 2021/06/30 10:08:48 christos Exp $") +FILE_RCSID("@(#)$File: funcs.c,v 1.129 2022/05/28 20:24:09 christos Exp $") #endif /* lint */ #include "magic.h" @@ -54,9 +54,12 @@ FILE_RCSID("@(#)$File: funcs.c,v 1.122 2021/06/30 10:08:48 christos Exp $") protected char * file_copystr(char *buf, size_t blen, size_t width, const char *str) { - if (++width > blen) - width = blen; - strlcpy(buf, str, width); + if (blen == 0) + return buf; + if (width >= blen) + width = blen - 1; + memcpy(buf, str, width); + buf[width] = '\0'; return buf; } @@ -90,7 +93,8 @@ file_checkfield(char *msg, size_t mlen, const char *what, const char **pp) protected int file_checkfmt(char *msg, size_t mlen, const char *fmt) { - for (const char *p = fmt; *p; p++) { + const char *p; + for (p = fmt; *p; p++) { if (*p != '%') continue; if (*++p == '%') @@ -146,8 +150,8 @@ file_vprintf(struct magic_set *ms, const char *fmt, va_list ap) size_t blen = ms->o.blen; free(buf); file_clearbuf(ms); - file_error(ms, 0, "Output buffer space exceeded %d+%zu", len, - blen); + file_error(ms, 0, "Output buffer space exceeded %d+%" + SIZE_T_FORMAT "u", len, blen); return -1; } @@ -634,13 +638,11 @@ file_replace(struct magic_set *ms, const char *pat, const char *rep) file_regex_t rx; int rc, rv = -1; - rc = file_regcomp(&rx, pat, REG_EXTENDED); - if (rc) { - file_regerror(&rx, rc, ms); - } else { + rc = file_regcomp(ms, &rx, pat, REG_EXTENDED); + if (rc == 0) { regmatch_t rm; int nm = 0; - while (file_regexec(&rx, ms->o.buf, 1, &rm, 0) == 0) { + while (file_regexec(ms, &rx, ms->o.buf, 1, &rm, 0) == 0) { ms->o.buf[rm.rm_so] = '\0'; if (file_printf(ms, "%s%s", rep, rm.rm_eo != 0 ? ms->o.buf + rm.rm_eo : "") == -1) @@ -655,58 +657,64 @@ out: } protected int -file_regcomp(file_regex_t *rx, const char *pat, int flags) +file_regcomp(struct magic_set *ms file_locale_used, file_regex_t *rx, + const char *pat, int flags) { #ifdef USE_C_LOCALE - rx->c_lc_ctype = newlocale(LC_CTYPE_MASK, "C", 0); - assert(rx->c_lc_ctype != NULL); - rx->old_lc_ctype = uselocale(rx->c_lc_ctype); - assert(rx->old_lc_ctype != NULL); + locale_t old = uselocale(ms->c_lc_ctype); + assert(old != NULL); #else - rx->old_lc_ctype = setlocale(LC_CTYPE, NULL); - assert(rx->old_lc_ctype != NULL); - rx->old_lc_ctype = strdup(rx->old_lc_ctype); - assert(rx->old_lc_ctype != NULL); + char old[1024]; + strlcpy(old, setlocale(LC_CTYPE, NULL), sizeof(old)); (void)setlocale(LC_CTYPE, "C"); #endif - rx->pat = pat; + int rc; + rc = regcomp(rx, pat, flags); - return rx->rc = regcomp(&rx->rx, pat, flags); +#ifdef USE_C_LOCALE + uselocale(old); +#else + (void)setlocale(LC_CTYPE, old); +#endif + if (rc > 0 && (ms->flags & MAGIC_CHECK)) { + char errmsg[512]; + + (void)regerror(rc, rx, errmsg, sizeof(errmsg)); + file_magerror(ms, "regex error %d for `%s', (%s)", rc, pat, + errmsg); + } + return rc; } protected int -file_regexec(file_regex_t *rx, const char *str, size_t nmatch, - regmatch_t* pmatch, int eflags) +file_regexec(struct magic_set *ms file_locale_used, file_regex_t *rx, + const char *str, size_t nmatch, regmatch_t* pmatch, int eflags) { - assert(rx->rc == 0); +#ifdef USE_C_LOCALE + locale_t old = uselocale(ms->c_lc_ctype); + assert(old != NULL); +#else + char old[1024]; + strlcpy(old, setlocale(LC_CTYPE, NULL), sizeof(old)); + (void)setlocale(LC_CTYPE, "C"); +#endif + int rc; /* XXX: force initialization because glibc does not always do this */ if (nmatch != 0) memset(pmatch, 0, nmatch * sizeof(*pmatch)); - return regexec(&rx->rx, str, nmatch, pmatch, eflags); -} - -protected void -file_regfree(file_regex_t *rx) -{ - if (rx->rc == 0) - regfree(&rx->rx); + rc = regexec(rx, str, nmatch, pmatch, eflags); #ifdef USE_C_LOCALE - (void)uselocale(rx->old_lc_ctype); - freelocale(rx->c_lc_ctype); + uselocale(old); #else - (void)setlocale(LC_CTYPE, rx->old_lc_ctype); - free(rx->old_lc_ctype); + (void)setlocale(LC_CTYPE, old); #endif + return rc; } protected void -file_regerror(file_regex_t *rx, int rc, struct magic_set *ms) +file_regfree(file_regex_t *rx) { - char errmsg[512]; - - (void)regerror(rc, &rx->rx, errmsg, sizeof(errmsg)); - file_magerror(ms, "regex error %d for `%s', (%s)", rc, rx->pat, - errmsg); + regfree(rx); } protected file_pushbuf_t * @@ -755,7 +763,7 @@ file_pop_buffer(struct magic_set *ms, file_pushbuf_t *pb) /* * convert string to ascii printable format. */ -protected char * +public char * file_printable(struct magic_set *ms, char *buf, size_t bufsiz, const char *str, size_t slen) { @@ -790,11 +798,25 @@ protected int file_parse_guid(const char *s, uint64_t *guid) { struct guid *g = CAST(struct guid *, CAST(void *, guid)); +#ifndef WIN32 return sscanf(s, "%8x-%4hx-%4hx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", &g->data1, &g->data2, &g->data3, &g->data4[0], &g->data4[1], &g->data4[2], &g->data4[3], &g->data4[4], &g->data4[5], &g->data4[6], &g->data4[7]) == 11 ? 0 : -1; +#else + /* MS-Windows runtime doesn't support %hhx, except under + non-default __USE_MINGW_ANSI_STDIO. */ + uint16_t data16[8]; + int rv = sscanf(s, "%8x-%4hx-%4hx-%2hx%2hx-%2hx%2hx%2hx%2hx%2hx%2hx", + &g->data1, &g->data2, &g->data3, &data16[0], &data16[1], + &data16[2], &data16[3], &data16[4], &data16[5], + &data16[6], &data16[7]) == 11 ? 0 : -1; + int i; + for (i = 0; i < 8; i++) + g->data4[i] = data16[i]; + return rv; +#endif } protected int @@ -803,11 +825,19 @@ file_print_guid(char *str, size_t len, const uint64_t *guid) const struct guid *g = CAST(const struct guid *, CAST(const void *, guid)); +#ifndef WIN32 return snprintf(str, len, "%.8X-%.4hX-%.4hX-%.2hhX%.2hhX-" "%.2hhX%.2hhX%.2hhX%.2hhX%.2hhX%.2hhX", g->data1, g->data2, g->data3, g->data4[0], g->data4[1], g->data4[2], g->data4[3], g->data4[4], g->data4[5], g->data4[6], g->data4[7]); +#else + return snprintf(str, len, "%.8X-%.4hX-%.4hX-%.2hX%.2hX-" + "%.2hX%.2hX%.2hX%.2hX%.2hX%.2hX", + g->data1, g->data2, g->data3, g->data4[0], g->data4[1], + g->data4[2], g->data4[3], g->data4[4], g->data4[5], + g->data4[6], g->data4[7]); +#endif } protected int @@ -818,15 +848,21 @@ file_pipe_closexec(int *fds) #else if (pipe(fds) == -1) return -1; +# ifdef F_SETFD (void)fcntl(fds[0], F_SETFD, FD_CLOEXEC); (void)fcntl(fds[1], F_SETFD, FD_CLOEXEC); +# endif return 0; #endif } protected int file_clear_closexec(int fd) { +#ifdef F_SETFD return fcntl(fd, F_SETFD, 0); +#else + return 0; +#endif } protected char * diff --git a/src/is_csv.c b/src/is_csv.c index 937ab5f401ff..841317c6aeb0 100644 --- a/src/is_csv.c +++ b/src/is_csv.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: is_csv.c,v 1.6 2020/08/09 16:43:36 christos Exp $") +FILE_RCSID("@(#)$File: is_csv.c,v 1.7 2022/05/28 00:44:22 christos Exp $") #endif #include <string.h> @@ -184,7 +184,7 @@ main(int argc, char *argv[]) if (fstat(fd, &st) == -1) err(EXIT_FAILURE, "Can't stat `%s'", argv[1]); - if ((p = malloc(st.st_size)) == NULL) + if ((p = CAST(char *, malloc(st.st_size))) == NULL) err(EXIT_FAILURE, "Can't allocate %jd bytes", (intmax_t)st.st_size); if (read(fd, p, st.st_size) != st.st_size) diff --git a/src/is_json.c b/src/is_json.c index 0b12438ff2a9..c276b7be5984 100644 --- a/src/is_json.c +++ b/src/is_json.c @@ -32,19 +32,25 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: is_json.c,v 1.15 2020/06/07 19:05:47 christos Exp $") +FILE_RCSID("@(#)$File: is_json.c,v 1.20 2022/05/28 00:44:22 christos Exp $") #endif -#include <string.h> #include "magic.h" +#else +#include <stdio.h> +#include <stddef.h> #endif +#include <string.h> #ifdef DEBUG #include <stdio.h> #define DPRINTF(a, b, c) \ - printf("%s [%.2x/%c] %.20s\n", (a), *(b), *(b), (const char *)(c)) + printf("%*s%s [%.2x/%c] %.*s\n", (int)lvl, "", (a), *(b), *(b), \ + (int)(b - c), (const char *)(c)) +#define __file_debugused #else #define DPRINTF(a, b, c) do { } while (/*CONSTCOND*/0) +#define __file_debugused __attribute__((__unused__)) #endif #define JSON_ARRAY 0 @@ -117,7 +123,8 @@ json_skip_space(const unsigned char *uc, const unsigned char *ue) } static int -json_parse_string(const unsigned char **ucp, const unsigned char *ue) +json_parse_string(const unsigned char **ucp, const unsigned char *ue, + size_t lvl __file_debugused) { const unsigned char *uc = *ucp; size_t i; @@ -155,8 +162,8 @@ json_parse_string(const unsigned char **ucp, const unsigned char *ue) goto out; } case '"': - *ucp = uc; DPRINTF("Good string: ", uc, *ucp); + *ucp = uc; return 1; default: continue; @@ -189,8 +196,8 @@ json_parse_array(const unsigned char **ucp, const unsigned char *ue, case ']': done: st[JSON_ARRAYN]++; - *ucp = uc + 1; DPRINTF("Good array: ", uc, *ucp); + *ucp = uc + 1; return 1; default: goto out; @@ -221,7 +228,7 @@ json_parse_object(const unsigned char **ucp, const unsigned char *ue, goto out; } DPRINTF("next field", uc, *ucp); - if (!json_parse_string(&uc, ue)) { + if (!json_parse_string(&uc, ue, lvl)) { DPRINTF("not string", uc, *ucp); goto out; } @@ -243,12 +250,12 @@ json_parse_object(const unsigned char **ucp, const unsigned char *ue, continue; case '}': /* { */ done: - *ucp = uc; DPRINTF("Good object: ", uc, *ucp); + *ucp = uc; return 1; default: - *ucp = uc - 1; DPRINTF("not more", uc, *ucp); + *ucp = uc - 1; goto out; } } @@ -259,7 +266,8 @@ out: } static int -json_parse_number(const unsigned char **ucp, const unsigned char *ue) +json_parse_number(const unsigned char **ucp, const unsigned char *ue, + size_t lvl __file_debugused) { const unsigned char *uc = *ucp; int got = 0; @@ -310,7 +318,7 @@ out: static int json_parse_const(const unsigned char **ucp, const unsigned char *ue, - const char *str, size_t len) + const char *str, size_t len, size_t lvl __file_debugused) { const unsigned char *uc = *ucp; @@ -338,8 +346,10 @@ json_parse(const unsigned char **ucp, const unsigned char *ue, goto out; // Avoid recursion - if (lvl > 20) + if (lvl > 500) { + DPRINTF("Too many levels", uc, *ucp); return 0; + } #if JSON_COUNT /* bail quickly if not counting */ if (lvl > 1 && (st[JSON_OBJECT] || st[JSON_ARRAYN])) @@ -349,7 +359,7 @@ json_parse(const unsigned char **ucp, const unsigned char *ue, DPRINTF("Parse general: ", uc, *ucp); switch (*uc++) { case '"': - rv = json_parse_string(&uc, ue); + rv = json_parse_string(&uc, ue, lvl + 1); t = JSON_STRING; break; case '[': @@ -361,20 +371,21 @@ json_parse(const unsigned char **ucp, const unsigned char *ue, t = JSON_OBJECT; break; case 't': - rv = json_parse_const(&uc, ue, "true", sizeof("true")); + rv = json_parse_const(&uc, ue, "true", sizeof("true"), lvl + 1); t = JSON_CONSTANT; break; case 'f': - rv = json_parse_const(&uc, ue, "false", sizeof("false")); + rv = json_parse_const(&uc, ue, "false", sizeof("false"), + lvl + 1); t = JSON_CONSTANT; break; case 'n': - rv = json_parse_const(&uc, ue, "null", sizeof("null")); + rv = json_parse_const(&uc, ue, "null", sizeof("null"), lvl + 1); t = JSON_CONSTANT; break; default: --uc; - rv = json_parse_number(&uc, ue); + rv = json_parse_number(&uc, ue, lvl + 1); t = JSON_NUMBER; break; } @@ -382,10 +393,10 @@ json_parse(const unsigned char **ucp, const unsigned char *ue, st[t]++; uc = json_skip_space(uc, ue); out: - *ucp = uc; DPRINTF("End general: ", uc, *ucp); + *ucp = uc; if (lvl == 0) - return rv && (st[JSON_ARRAYN] || st[JSON_OBJECT]); + return rv && uc == ue && (st[JSON_ARRAYN] || st[JSON_OBJECT]); return rv; } @@ -414,7 +425,7 @@ file_is_json(struct magic_set *ms, const struct buffer *b) return -1; return 1; } - if (file_printf(ms, "JSON data") == -1) + if (file_printf(ms, "JSON text data") == -1) return -1; #if JSON_COUNT #define P(n) st[n], st[n] > 1 ? "s" : "" @@ -455,7 +466,7 @@ main(int argc, char *argv[]) if (fstat(fd, &st) == -1) err(EXIT_FAILURE, "Can't stat `%s'", argv[1]); - if ((p = malloc(st.st_size)) == NULL) + if ((p = CAST(char *, malloc(st.st_size))) == NULL) err(EXIT_FAILURE, "Can't allocate %jd bytes", (intmax_t)st.st_size); if (read(fd, p, st.st_size) != st.st_size) diff --git a/src/magic.c b/src/magic.c index 03a456bc9a0d..7768497ae079 100644 --- a/src/magic.c +++ b/src/magic.c @@ -33,7 +33,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: magic.c,v 1.115 2021/09/20 17:45:41 christos Exp $") +FILE_RCSID("@(#)$File: magic.c,v 1.117 2021/12/06 15:33:00 christos Exp $") #endif /* lint */ #include "magic.h" @@ -221,6 +221,10 @@ out: default_magic = NULL; } + /* Before anything else, try to get a magic file from user HOME */ + if ((home = getenv("HOME")) != NULL) + _w32_append_path(&hmagicpath, "%s%s", home, hmagic); + /* First, try to get a magic file from user-application data */ if ((home = getenv("LOCALAPPDATA")) != NULL) _w32_append_path(&hmagicpath, "%s%s", home, hmagic); @@ -273,9 +277,22 @@ unreadable_info(struct magic_set *ms, mode_t md, const char *file) if (access(file, W_OK) == 0) if (file_printf(ms, "writable, ") == -1) return -1; +#ifndef WIN32 if (access(file, X_OK) == 0) if (file_printf(ms, "executable, ") == -1) return -1; +#else + /* X_OK doesn't work well on MS-Windows */ + { + const char *p = strrchr(file, '.'); + if (p && (stricmp(p, ".exe") + || stricmp(p, ".dll") + || stricmp(p, ".bat") + || stricmp(p, ".cmd"))) + if (file_printf(ms, "writable, ") == -1) + return -1; + } +#endif } if (S_ISREG(md)) if (file_printf(ms, "regular file, ") == -1) @@ -442,8 +459,6 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd) errno = 0; if ((fd = open(inname, flags)) < 0) { okstat = stat(inname, &sb) == 0; - if (okstat && S_ISFIFO(sb.st_mode)) - ispipe = 1; #ifdef WIN32 /* * Can't stat, can't open. It may have been opened in @@ -462,7 +477,7 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd) rv = 0; goto done; } -#if O_CLOEXEC == 0 +#if O_CLOEXEC == 0 && defined(F_SETFD) (void)fcntl(fd, F_SETFD, FD_CLOEXEC); #endif } @@ -500,7 +515,7 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd) } else if (fd != -1) { /* Windows refuses to read from a big console buffer. */ size_t howmany = -#if defined(WIN32) +#ifdef WIN32 _isatty(fd) ? 8 * 1024 : #endif ms->bytes_max; diff --git a/src/print.c b/src/print.c index 6d9816ad5f56..ee8cb5af4a4e 100644 --- a/src/print.c +++ b/src/print.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: print.c,v 1.89 2021/06/30 10:08:48 christos Exp $") +FILE_RCSID("@(#)$File: print.c,v 1.90 2021/10/24 15:52:18 christos Exp $") #endif /* lint */ #include <string.h> @@ -157,34 +157,34 @@ file_mdump(struct magic *m) case FILE_BEDATE: case FILE_MEDATE: (void)fprintf(stderr, "%s,", - file_fmttime(tbuf, sizeof(tbuf), m->value.l, 0)); + file_fmtdatetime(tbuf, sizeof(tbuf), m->value.l, 0)); break; case FILE_LDATE: case FILE_LELDATE: case FILE_BELDATE: case FILE_MELDATE: (void)fprintf(stderr, "%s,", - file_fmttime(tbuf, sizeof(tbuf), m->value.l, + file_fmtdatetime(tbuf, sizeof(tbuf), m->value.l, FILE_T_LOCAL)); break; case FILE_QDATE: case FILE_LEQDATE: case FILE_BEQDATE: (void)fprintf(stderr, "%s,", - file_fmttime(tbuf, sizeof(tbuf), m->value.q, 0)); + file_fmtdatetime(tbuf, sizeof(tbuf), m->value.q, 0)); break; case FILE_QLDATE: case FILE_LEQLDATE: case FILE_BEQLDATE: (void)fprintf(stderr, "%s,", - file_fmttime(tbuf, sizeof(tbuf), m->value.q, + file_fmtdatetime(tbuf, sizeof(tbuf), m->value.q, FILE_T_LOCAL)); break; case FILE_QWDATE: case FILE_LEQWDATE: case FILE_BEQWDATE: (void)fprintf(stderr, "%s,", - file_fmttime(tbuf, sizeof(tbuf), m->value.q, + file_fmtdatetime(tbuf, sizeof(tbuf), m->value.q, FILE_T_WINDOWS)); break; case FILE_FLOAT: @@ -202,6 +202,18 @@ file_mdump(struct magic *m) (void)fprintf(stderr, "%s", file_fmtvarint( m->value.us, m->type, tbuf, sizeof(tbuf))); break; + case FILE_MSDOSDATE: + case FILE_BEMSDOSDATE: + case FILE_LEMSDOSDATE: + (void)fprintf(stderr, "%s,", + file_fmtdate(tbuf, sizeof(tbuf), m->value.h)); + break; + case FILE_MSDOSTIME: + case FILE_BEMSDOSTIME: + case FILE_LEMSDOSTIME: + (void)fprintf(stderr, "%s,", + file_fmttime(tbuf, sizeof(tbuf), m->value.h)); + break; case FILE_DEFAULT: /* XXX - do anything here? */ break; @@ -252,7 +264,7 @@ file_fmtvarint(const unsigned char *us, int t, char *buf, size_t blen) } protected const char * -file_fmttime(char *buf, size_t bsize, uint64_t v, int flags) +file_fmtdatetime(char *buf, size_t bsize, uint64_t v, int flags) { char *pp; time_t t; @@ -282,6 +294,49 @@ file_fmttime(char *buf, size_t bsize, uint64_t v, int flags) pp[strcspn(pp, "\n")] = '\0'; return pp; out: + strlcpy(buf, "*Invalid datetime*", bsize); + return buf; +} + +/* + * https://docs.microsoft.com/en-us/windows/win32/api/winbase/\ + * nf-winbase-dosdatetimetofiletime?redirectedfrom=MSDN + */ +protected const char * +file_fmtdate(char *buf, size_t bsize, uint16_t v) +{ + struct tm tm; + + memset(&tm, 0, sizeof(tm)); + tm.tm_mday = v & 0x1f; + tm.tm_mon = ((v >> 5) & 0xf) - 1; + tm.tm_year = (v >> 9) + 80; + + if (strftime(buf, bsize, "%a, %b %d %Y", &tm) == 0) + goto out; + + return buf; +out: + strlcpy(buf, "*Invalid date*", bsize); + return buf; +} + +protected const char * +file_fmttime(char *buf, size_t bsize, uint16_t v) +{ + struct tm tm; + + memset(&tm, 0, sizeof(tm)); + tm.tm_sec = (v & 0x1f) * 2; + tm.tm_min = ((v >> 5) & 0x3f); + tm.tm_hour = (v >> 11); + + if (strftime(buf, bsize, "%T", &tm) == 0) + goto out; + + return buf; +out: strlcpy(buf, "*Invalid time*", bsize); return buf; + } diff --git a/src/readcdf.c b/src/readcdf.c index 7622c7b08aaa..0b06b421eb96 100644 --- a/src/readcdf.c +++ b/src/readcdf.c @@ -26,7 +26,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: readcdf.c,v 1.74 2019/09/11 15:46:30 christos Exp $") +FILE_RCSID("@(#)$File: readcdf.c,v 1.76 2022/01/17 16:59:01 christos Exp $") #endif #include <assert.h> @@ -605,8 +605,8 @@ file_trycdf(struct magic_set *ms, const struct buffer *b) } #endif - if ((i = cdf_read_user_stream(&info, &h, &sat, &ssat, &sst, &dir, - "FileHeader", &scn)) != -1) { + if (cdf_read_user_stream(&info, &h, &sat, &ssat, &sst, &dir, + "FileHeader", &scn) != -1) { #define HWP5_SIGNATURE "HWP Document File" if (scn.sst_len * scn.sst_ss >= sizeof(HWP5_SIGNATURE) - 1 && memcmp(scn.sst_tab, HWP5_SIGNATURE, @@ -674,7 +674,8 @@ out0: if (file_printf(ms, ", %s", expn) == -1) return -1; } else if (ms->flags & MAGIC_MIME_TYPE) { - if (file_printf(ms, "application/CDFV2") == -1) + /* https://reposcope.com/mimetype/application/x-ole-storage */ + if (file_printf(ms, "application/x-ole-storage") == -1) return -1; } return 1; diff --git a/src/readelf.c b/src/readelf.c index 7dbef58af804..08c7233e9bdc 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: readelf.c,v 1.178 2021/06/30 10:08:48 christos Exp $") +FILE_RCSID("@(#)$File: readelf.c,v 1.180 2022/01/10 14:15:08 christos Exp $") #endif #ifdef BUILTIN_ELF @@ -1015,7 +1015,7 @@ do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, size_t elsize = xauxv_sizeof; const char *tag; int is_string; - size_t nval; + size_t nval, off; if ((*flags & (FLAGS_IS_CORE|FLAGS_DID_CORE_STYLE)) != (FLAGS_IS_CORE|FLAGS_DID_CORE_STYLE)) @@ -1043,7 +1043,7 @@ do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, *flags |= FLAGS_DID_AUXV; nval = 0; - for (size_t off = 0; off + elsize <= descsz; off += elsize) { + for (off = 0; off + elsize <= descsz; off += elsize) { memcpy(xauxv_addr, &nbuf[doff + off], xauxv_sizeof); /* Limit processing to 50 vector entries to prevent DoS */ if (nval++ >= 50) { @@ -1649,7 +1649,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, char ibuf[BUFSIZ]; char interp[BUFSIZ]; ssize_t bufsize; - size_t offset, align, len, need = 0; + size_t offset, align, need = 0; int pie = 0, dynamic = 0; if (num == 0) { @@ -1709,7 +1709,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, } if (doread) { - len = xph_filesz < sizeof(nbuf) ? xph_filesz + size_t len = xph_filesz < sizeof(nbuf) ? xph_filesz : sizeof(nbuf); off_t offs = xph_offset; bufsize = pread(fd, nbuf, len, offs); @@ -1720,8 +1720,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, return -1; return 0; } - } else - len = 0; + } /* Things we can determine when we seek */ switch (xph_type) { diff --git a/src/softmagic.c b/src/softmagic.c index 8d2d7b725cad..5e49afb7dbbc 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: softmagic.c,v 1.315 2021/09/03 13:17:52 christos Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.323 2022/05/28 00:44:22 christos Exp $") #endif /* lint */ #include "magic.h" @@ -43,7 +43,7 @@ FILE_RCSID("@(#)$File: softmagic.c,v 1.315 2021/09/03 13:17:52 christos Exp $") #include <time.h> #include "der.h" -private int match(struct magic_set *, struct magic *, uint32_t, +private int match(struct magic_set *, struct magic *, file_regex_t **, uint32_t, const struct buffer *, size_t, int, int, int, uint16_t *, uint16_t *, int *, int *, int *, int *); private int mget(struct magic_set *, struct magic *, const struct buffer *, @@ -52,8 +52,8 @@ private int mget(struct magic_set *, struct magic *, const struct buffer *, uint16_t *, int *, int *, int *, int *); private int msetoffset(struct magic_set *, struct magic *, struct buffer *, const struct buffer *, size_t, unsigned int); -private int magiccheck(struct magic_set *, struct magic *); -private int32_t mprint(struct magic_set *, struct magic *); +private int magiccheck(struct magic_set *, struct magic *, file_regex_t **); +private int mprint(struct magic_set *, struct magic *); private int moffset(struct magic_set *, struct magic *, const struct buffer *, int32_t *); private void mdebug(uint32_t, const char *, size_t); @@ -131,8 +131,8 @@ file_softmagic(struct magic_set *ms, const struct buffer *b, } for (ml = ms->mlist[0]->next; ml != ms->mlist[0]; ml = ml->next) - if ((rv = match(ms, ml->magic, ml->nmagic, b, 0, mode, - text, 0, indir_count, name_count, + if ((rv = match(ms, ml->magic, ml->magic_rxcomp, ml->nmagic, b, + 0, mode, text, 0, indir_count, name_count, &printed_something, &need_separator, NULL, NULL)) != 0) return rv; @@ -191,8 +191,8 @@ file_fmtcheck(struct magic_set *ms, const char *desc, const char *def, * so that higher-level continuations are processed. */ private int -match(struct magic_set *ms, struct magic *magic, uint32_t nmagic, - const struct buffer *b, size_t offset, int mode, int text, +match(struct magic_set *ms, struct magic *magic, file_regex_t **magic_rxcomp, + uint32_t nmagic, const struct buffer *b, size_t offset, int mode, int text, int flip, uint16_t *indir_count, uint16_t *name_count, int *printed_something, int *need_separator, int *returnval, int *found_match) @@ -220,6 +220,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic, for (magindex = 0; magindex < nmagic; magindex++) { int flush = 0; struct magic *m = &magic[magindex]; + file_regex_t **m_rxcomp = &magic_rxcomp[magindex]; if (m->type != FILE_NAME) if ((IS_STRING(m->type) && @@ -257,7 +258,7 @@ flush: *returnval = 1; } - switch (magiccheck(ms, m)) { + switch (magiccheck(ms, m, m_rxcomp)) { case -1: return -1; case 0: @@ -318,6 +319,7 @@ flush: while (magindex + 1 < nmagic && magic[magindex + 1].cont_level != 0) { m = &magic[++magindex]; + m_rxcomp = &magic_rxcomp[magindex]; ms->line = m->lineno; /* for messages */ if (cont_level < m->cont_level) @@ -371,7 +373,7 @@ flush: break; } - switch (flush ? 1 : magiccheck(ms, m)) { + switch (flush ? 1 : magiccheck(ms, m, m_rxcomp)) { case -1: return -1; case 0: @@ -436,7 +438,6 @@ flush: &ms->c.li[cont_level].off)) { case -1: case 0: - flush = 1; cont_level--; break; default: @@ -473,15 +474,14 @@ check_fmt(struct magic_set *ms, const char *fmt) { file_regex_t rx; int rc, rv = -1; + const char* pat = "%[-0-9\\.]*s"; if (strchr(fmt, '%') == NULL) return 0; - rc = file_regcomp(&rx, "%[-0-9\\.]*s", REG_EXTENDED|REG_NOSUB); - if (rc) { - file_regerror(&rx, rc, ms); - } else { - rc = file_regexec(&rx, fmt, 0, 0, 0); + rc = file_regcomp(ms, &rx, pat, REG_EXTENDED|REG_NOSUB); + if (rc == 0) { + rc = file_regexec(ms, &rx, fmt, 0, 0, 0); rv = !rc; } file_regfree(&rx); @@ -502,7 +502,7 @@ strndup(const char *str, size_t n) for (len = 0; len < n && str[len]; len++) continue; - if ((copy = malloc(len + 1)) == NULL) + if ((copy = CAST(char *, malloc(len + 1))) == NULL) return NULL; (void)memcpy(copy, str, len); copy[len] = '\0'; @@ -565,13 +565,12 @@ varexpand(struct magic_set *ms, char *buf, size_t len, const char *str) } -private int32_t +private int mprint(struct magic_set *ms, struct magic *m) { uint64_t v; float vf; double vd; - int64_t t = 0; char buf[128], tbuf[26], sbuf[512], ebuf[512]; const char *desc; union VALUETYPE *p = &ms->ms_value; @@ -609,7 +608,6 @@ mprint(struct magic_set *ms, struct magic *m) } \ break; \ } \ - t = ms->offset + sizeof(stype); \ break switch (m->type) { @@ -642,20 +640,18 @@ mprint(struct magic_set *ms, struct magic *m) file_printable(ms, sbuf, sizeof(sbuf), m->value.s, sizeof(m->value.s))) == -1) return -1; - t = ms->offset + m->vallen; } else { char *str = p->s; /* compute t before we mangle the string? */ - t = ms->offset + strlen(str); if (*m->value.s == '\0') str[strcspn(str, "\r\n")] = '\0'; if (m->str_flags & STRING_TRIM) str = file_strtrim(str); - + if (file_printf(ms, F(ms, desc, "%s"), file_printable(ms, sbuf, sizeof(sbuf), str, sizeof(p->s) - (str - p->s))) == -1) @@ -665,7 +661,6 @@ mprint(struct magic_set *ms, struct magic *m) size_t l = file_pstring_length_size(ms, m); if (l == FILE_BADSIZE) return -1; - t += l; } } break; @@ -675,9 +670,8 @@ mprint(struct magic_set *ms, struct magic *m) case FILE_LEDATE: case FILE_MEDATE: if (file_printf(ms, F(ms, desc, "%s"), - file_fmttime(tbuf, sizeof(tbuf), p->l, 0)) == -1) + file_fmtdatetime(tbuf, sizeof(tbuf), p->l, 0)) == -1) return -1; - t = ms->offset + sizeof(uint32_t); break; case FILE_LDATE: @@ -685,37 +679,34 @@ mprint(struct magic_set *ms, struct magic *m) case FILE_LELDATE: case FILE_MELDATE: if (file_printf(ms, F(ms, desc, "%s"), - file_fmttime(tbuf, sizeof(tbuf), p->l, FILE_T_LOCAL)) == -1) + file_fmtdatetime(tbuf, sizeof(tbuf), p->l, FILE_T_LOCAL)) + == -1) return -1; - t = ms->offset + sizeof(uint32_t); break; case FILE_QDATE: case FILE_BEQDATE: case FILE_LEQDATE: if (file_printf(ms, F(ms, desc, "%s"), - file_fmttime(tbuf, sizeof(tbuf), p->q, 0)) == -1) + file_fmtdatetime(tbuf, sizeof(tbuf), p->q, 0)) == -1) return -1; - t = ms->offset + sizeof(uint64_t); break; case FILE_QLDATE: case FILE_BEQLDATE: case FILE_LEQLDATE: if (file_printf(ms, F(ms, desc, "%s"), - file_fmttime(tbuf, sizeof(tbuf), p->q, FILE_T_LOCAL)) == -1) + file_fmtdatetime(tbuf, sizeof(tbuf), p->q, FILE_T_LOCAL)) == -1) return -1; - t = ms->offset + sizeof(uint64_t); break; case FILE_QWDATE: case FILE_BEQWDATE: case FILE_LEQWDATE: if (file_printf(ms, F(ms, desc, "%s"), - file_fmttime(tbuf, sizeof(tbuf), p->q, FILE_T_WINDOWS)) + file_fmtdatetime(tbuf, sizeof(tbuf), p->q, FILE_T_WINDOWS)) == -1) return -1; - t = ms->offset + sizeof(uint64_t); break; case FILE_FLOAT: @@ -735,7 +726,6 @@ mprint(struct magic_set *ms, struct magic *m) return -1; break; } - t = ms->offset + sizeof(float); break; case FILE_DOUBLE: @@ -755,7 +745,6 @@ mprint(struct magic_set *ms, struct magic *m) return -1; break; } - t = ms->offset + sizeof(double); break; case FILE_SEARCH: @@ -770,18 +759,13 @@ mprint(struct magic_set *ms, struct magic *m) return -1; } scp = (m->str_flags & STRING_TRIM) ? file_strtrim(cp) : cp; - + rval = file_printf(ms, F(ms, desc, "%s"), file_printable(ms, sbuf, sizeof(sbuf), scp, ms->search.rm_len)); free(cp); if (rval == -1) return -1; - - if ((m->str_flags & REGEX_OFFSET_START)) - t = ms->search.offset; - else - t = ms->search.offset + ms->search.rm_len; break; } @@ -789,32 +773,42 @@ mprint(struct magic_set *ms, struct magic *m) case FILE_CLEAR: if (file_printf(ms, "%s", m->desc) == -1) return -1; - t = ms->offset; break; case FILE_INDIRECT: case FILE_USE: case FILE_NAME: - t = ms->offset; break; case FILE_DER: if (file_printf(ms, F(ms, desc, "%s"), file_printable(ms, sbuf, sizeof(sbuf), ms->ms_value.s, sizeof(ms->ms_value.s))) == -1) return -1; - t = ms->offset; break; case FILE_GUID: (void) file_print_guid(buf, sizeof(buf), ms->ms_value.guid); if (file_printf(ms, F(ms, desc, "%s"), buf) == -1) return -1; - t = ms->offset; + break; + case FILE_MSDOSDATE: + case FILE_BEMSDOSDATE: + case FILE_LEMSDOSDATE: + if (file_printf(ms, F(ms, desc, "%s"), + file_fmtdate(tbuf, sizeof(tbuf), p->h)) == -1) + return -1; + break; + case FILE_MSDOSTIME: + case FILE_BEMSDOSTIME: + case FILE_LEMSDOSTIME: + if (file_printf(ms, F(ms, desc, "%s"), + file_fmttime(tbuf, sizeof(tbuf), p->h)) == -1) + return -1; break; default: file_magerror(ms, "invalid m->type (%d) in mprint()", m->type); return -1; } - return CAST(int32_t, t); + return 0; } private int @@ -832,6 +826,12 @@ moffset(struct magic_set *ms, struct magic *m, const struct buffer *b, case FILE_SHORT: case FILE_BESHORT: case FILE_LESHORT: + case FILE_MSDOSDATE: + case FILE_LEMSDOSDATE: + case FILE_BEMSDOSDATE: + case FILE_MSDOSTIME: + case FILE_LEMSDOSTIME: + case FILE_BEMSDOSTIME: o = CAST(int32_t, (ms->offset + sizeof(short))); break; @@ -1137,6 +1137,12 @@ mconvert(struct magic_set *ms, struct magic *m, int flip) goto out; return 1; case FILE_SHORT: + case FILE_MSDOSDATE: + case FILE_LEMSDOSDATE: + case FILE_BEMSDOSDATE: + case FILE_MSDOSTIME: + case FILE_LEMSDOSTIME: + case FILE_BEMSDOSTIME: if (cvt_16(p, m) == -1) goto out; return 1; @@ -1819,12 +1825,13 @@ mget(struct magic_set *ms, struct magic *m, const struct buffer *b, bb = *b; bb.fbuf = s + offset; bb.flen = nbytes - offset; + rv = -1; for (mlp = ms->mlist[0]->next; mlp != ms->mlist[0]; mlp = mlp->next) { - if ((rv = match(ms, mlp->magic, mlp->nmagic, &bb, 0, - BINTEST, text, 0, indir_count, name_count, - printed_something, need_separator, NULL, + if ((rv = match(ms, mlp->magic, mlp->magic_rxcomp, + mlp->nmagic, &bb, 0, BINTEST, text, 0, indir_count, + name_count, printed_something, need_separator, NULL, NULL)) != 0) break; } @@ -1875,8 +1882,8 @@ mget(struct magic_set *ms, struct magic *m, const struct buffer *b, nfound_match = 0; (*name_count)++; eoffset = ms->eoffset; - rv = match(ms, ml.magic, ml.nmagic, b, offset + o, - mode, text, flip, indir_count, name_count, + rv = match(ms, ml.magic, ml.magic_rxcomp, ml.nmagic, b, + offset + o, mode, text, flip, indir_count, name_count, printed_something, need_separator, returnval, &nfound_match); ms->ms_value.q = nfound_match; @@ -1998,8 +2005,29 @@ file_strncmp16(const char *a, const char *b, size_t len, size_t maxlen, return file_strncmp(a, b, len, maxlen, flags); } +private file_regex_t * +alloc_regex(struct magic_set *ms, struct magic *m) +{ + int rc; + file_regex_t *rx = CAST(file_regex_t *, malloc(sizeof(*rx))); + + if (rx == NULL) { + file_error(ms, errno, "can't allocate %" SIZE_T_FORMAT + "u bytes", sizeof(*rx)); + return NULL; + } + + rc = file_regcomp(ms, rx, m->value.s, REG_EXTENDED | REG_NEWLINE | + ((m->str_flags & STRING_IGNORE_CASE) ? REG_ICASE : 0)); + if (rc == 0) + return rx; + + free(rx); + return NULL; +} + private int -magiccheck(struct magic_set *ms, struct magic *m) +magiccheck(struct magic_set *ms, struct magic *m, file_regex_t **m_cache) { uint64_t l = m->value.q; uint64_t v; @@ -2016,6 +2044,12 @@ magiccheck(struct magic_set *ms, struct magic *m) case FILE_SHORT: case FILE_BESHORT: case FILE_LESHORT: + case FILE_MSDOSDATE: + case FILE_LEMSDOSDATE: + case FILE_BEMSDOSDATE: + case FILE_MSDOSTIME: + case FILE_LEMSDOSTIME: + case FILE_BEMSDOSTIME: v = p->h; break; @@ -2077,8 +2111,8 @@ magiccheck(struct magic_set *ms, struct magic *m) break; default: - file_magerror(ms, "cannot happen with float: invalid relation `%c'", - m->reln); + file_magerror(ms, "cannot happen with float: " + "invalid relation `%c'", m->reln); return -1; } return matched; @@ -2110,7 +2144,8 @@ magiccheck(struct magic_set *ms, struct magic *m) break; default: - file_magerror(ms, "cannot happen with double: invalid relation `%c'", m->reln); + file_magerror(ms, "cannot happen with double: " + "invalid relation `%c'", m->reln); return -1; } return matched; @@ -2182,64 +2217,56 @@ magiccheck(struct magic_set *ms, struct magic *m) } case FILE_REGEX: { int rc; - file_regex_t rx; + file_regex_t *rx = *m_cache; const char *search; + regmatch_t pmatch; + size_t slen = ms->search.s_len; + char *copy; if (ms->search.s == NULL) return 0; + if (rx == NULL) { + rx = *m_cache = alloc_regex(ms, m); + if (rx == NULL) + return -1; + } l = 0; - rc = file_regcomp(&rx, m->value.s, - REG_EXTENDED|REG_NEWLINE| - ((m->str_flags & STRING_IGNORE_CASE) ? REG_ICASE : 0)); - if (rc) { - file_regerror(&rx, rc, ms); - v = CAST(uint64_t, -1); + if (slen != 0) { + copy = CAST(char *, malloc(slen)); + if (copy == NULL) { + file_error(ms, errno, + "can't allocate %" SIZE_T_FORMAT "u bytes", + slen); + return -1; + } + memcpy(copy, ms->search.s, slen); + copy[--slen] = '\0'; + search = copy; } else { - regmatch_t pmatch; - size_t slen = ms->search.s_len; - char *copy; - if (slen != 0) { - copy = CAST(char *, malloc(slen)); - if (copy == NULL) { - file_regfree(&rx); - file_error(ms, errno, - "can't allocate %" SIZE_T_FORMAT "u bytes", - slen); - return -1; - } - memcpy(copy, ms->search.s, slen); - copy[--slen] = '\0'; - search = copy; - } else { - search = CCAST(char *, ""); - copy = NULL; - } - rc = file_regexec(&rx, RCAST(const char *, search), - 1, &pmatch, 0); - free(copy); - switch (rc) { - case 0: - ms->search.s += CAST(int, pmatch.rm_so); - ms->search.offset += CAST(size_t, pmatch.rm_so); - ms->search.rm_len = CAST(size_t, - pmatch.rm_eo - pmatch.rm_so); - v = 0; - break; + search = CCAST(char *, ""); + copy = NULL; + } + rc = file_regexec(ms, rx, RCAST(const char *, search), + 1, &pmatch, 0); + free(copy); + switch (rc) { + case 0: + ms->search.s += CAST(int, pmatch.rm_so); + ms->search.offset += CAST(size_t, pmatch.rm_so); + ms->search.rm_len = CAST(size_t, + pmatch.rm_eo - pmatch.rm_so); + v = 0; + break; - case REG_NOMATCH: - v = 1; - break; + case REG_NOMATCH: + v = 1; + break; - default: - file_regerror(&rx, rc, ms); - v = CAST(uint64_t, -1); - break; - } - } - file_regfree(&rx); - if (v == CAST(uint64_t, -1)) + default: return -1; + break; + } break; } case FILE_USE: diff --git a/tests/Makefile.am b/tests/Makefile.am index b44944346c0c..b17dfb12bb06 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,6 +7,8 @@ android-vdex-1.result \ android-vdex-1.testfile \ android-vdex-2.result \ android-vdex-2.testfile \ +arj.result \ +arj.testfile \ CVE-2014-1943.result \ CVE-2014-1943.testfile \ JW07022A.mp3.result \ @@ -35,6 +37,10 @@ json2.result \ json2.testfile \ json3.result \ json3.testfile \ +json4.result \ +json4.testfile \ +json5.result \ +json5.testfile \ matilde.arm.result \ matilde.arm.testfile \ pcjr.result \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 99264d83f5e4..7a41d2227cae 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -299,6 +299,8 @@ android-vdex-1.result \ android-vdex-1.testfile \ android-vdex-2.result \ android-vdex-2.testfile \ +arj.result \ +arj.testfile \ CVE-2014-1943.result \ CVE-2014-1943.testfile \ JW07022A.mp3.result \ @@ -327,6 +329,10 @@ json2.result \ json2.testfile \ json3.result \ json3.testfile \ +json4.result \ +json4.testfile \ +json5.result \ +json5.testfile \ matilde.arm.result \ matilde.arm.testfile \ pcjr.result \ diff --git a/tests/arj.result b/tests/arj.result new file mode 100644 index 000000000000..8a32e67eb1c0 --- /dev/null +++ b/tests/arj.result @@ -0,0 +1 @@ +ARJ archive data, v11, slash-switched, created 5 1980+48, original name: example_m0.arj, os: Unix
\ No newline at end of file diff --git a/tests/arj.testfile b/tests/arj.testfile Binary files differnew file mode 100644 index 000000000000..e133f8a28477 --- /dev/null +++ b/tests/arj.testfile diff --git a/tests/json1.result b/tests/json1.result index 01442dc9c271..550d7ac2f9db 100644 --- a/tests/json1.result +++ b/tests/json1.result @@ -1 +1 @@ -JSON data
\ No newline at end of file +JSON text data
\ No newline at end of file diff --git a/tests/json2.result b/tests/json2.result index 01442dc9c271..550d7ac2f9db 100644 --- a/tests/json2.result +++ b/tests/json2.result @@ -1 +1 @@ -JSON data
\ No newline at end of file +JSON text data
\ No newline at end of file diff --git a/tests/json3.result b/tests/json3.result index 01442dc9c271..550d7ac2f9db 100644 --- a/tests/json3.result +++ b/tests/json3.result @@ -1 +1 @@ -JSON data
\ No newline at end of file +JSON text data
\ No newline at end of file diff --git a/tests/json4.result b/tests/json4.result new file mode 100644 index 000000000000..550d7ac2f9db --- /dev/null +++ b/tests/json4.result @@ -0,0 +1 @@ +JSON text data
\ No newline at end of file diff --git a/tests/json4.testfile b/tests/json4.testfile new file mode 100644 index 000000000000..7660873d1031 --- /dev/null +++ b/tests/json4.testfile @@ -0,0 +1 @@ +[1] diff --git a/tests/json5.result b/tests/json5.result new file mode 100644 index 000000000000..90965495a30f --- /dev/null +++ b/tests/json5.result @@ -0,0 +1 @@ +ASCII text
\ No newline at end of file diff --git a/tests/json5.testfile b/tests/json5.testfile new file mode 100644 index 000000000000..01bd52f288fe --- /dev/null +++ b/tests/json5.testfile @@ -0,0 +1 @@ +[1] 2 diff --git a/tests/test.c b/tests/test.c index 468c9847209e..a3b91ba10d25 100644 --- a/tests/test.c +++ b/tests/test.c @@ -86,7 +86,7 @@ main(int argc, char **argv) else prog = argv[0]; - ms = magic_open(MAGIC_NONE); + ms = magic_open(MAGIC_ERROR); if (ms == NULL) { (void)fprintf(stderr, "%s: ERROR opening MAGIC_NONE: %s\n", prog, strerror(errno)); @@ -105,7 +105,6 @@ main(int argc, char **argv) if (argc != 3) { (void)fprintf(stderr, "Usage: %s TEST-FILE RESULT\n", prog); - magic_close(ms); goto bad; } if ((result = magic_file(ms, argv[1])) == NULL) { |