msdos 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244
  1. #------------------------------------------------------------------------------
  2. # $File: msdos,v 1.164 2022/12/26 17:23:08 christos Exp $
  3. # msdos: file(1) magic for MS-DOS files
  4. #
  5. # .BAT files (Daniel Quinlan, quinlan@yggdrasil.com)
  6. # updated by Joerg Jenderek at Oct 2008,Apr 2011
  7. 0 string/t @
  8. >1 string/cW \ echo\ off DOS batch file text
  9. !:mime text/x-msdos-batch
  10. !:ext bat
  11. >1 string/cW echo\ off DOS batch file text
  12. !:mime text/x-msdos-batch
  13. !:ext bat
  14. >1 string/cW rem DOS batch file text
  15. !:mime text/x-msdos-batch
  16. !:ext bat
  17. >1 string/cW set\ DOS batch file text
  18. !:mime text/x-msdos-batch
  19. !:ext bat
  20. # OS/2 batch files are REXX. the second regex is a bit generic, oh well
  21. # the matched commands seem to be common in REXX and uncommon elsewhere
  22. 100 search/0xffff rxfuncadd
  23. >100 regex/c =^[\ \t]{0,10}call[\ \t]{1,10}rxfunc OS/2 REXX batch file text
  24. 100 search/0xffff say
  25. >100 regex/c =^[\ \t]{0,10}say\ ['"] OS/2 REXX batch file text
  26. # updated by Joerg Jenderek at Oct 2015
  27. # https://de.wikipedia.org/wiki/Common_Object_File_Format
  28. # http://www.delorie.com/djgpp/doc/coff/filhdr.html
  29. # ./intel already labeled COFF type 0x14c=0514 as "80386 COFF executable"
  30. #0 leshort 0x14c MS Windows COFF Intel 80386 object file
  31. #>4 ledate x stamp %s
  32. 0 leshort 0x166 MS Windows COFF MIPS R4000 object file
  33. #>4 ledate x stamp %s
  34. 0 leshort 0x184 MS Windows COFF Alpha object file
  35. #>4 ledate x stamp %s
  36. 0 leshort 0x268 MS Windows COFF Motorola 68000 object file
  37. #>4 ledate x stamp %s
  38. 0 leshort 0x1f0 MS Windows COFF PowerPC object file
  39. #>4 ledate x stamp %s
  40. 0 leshort 0x290 MS Windows COFF PA-RISC object file
  41. #>4 ledate x stamp %s
  42. # Tests for various EXE types.
  43. #
  44. # Many of the compressed formats were extracted from IDARC 1.23 source code.
  45. #
  46. # e_magic
  47. 0 string/b MZ
  48. # TODO
  49. # FLT: Syntrillium CoolEdit Filter https://en.wikipedia.org/wiki/Adobe_Audition
  50. # FMX64:FileMaker Pro 64-bit plug-in https://en.wikipedia.org/wiki/FileMaker
  51. # FMX: FileMaker Pro 32-bit plug-in https://en.wikipedia.org/wiki/FileMaker
  52. # FOD: WIFE Font Driver
  53. # GAU: MS Flight Simulator Gauge
  54. # IFS: OS/2 Installable File System https://en.wikipedia.org/wiki/OS/2
  55. # MEXW32:MATLAB Windows 32bit compiled function https://en.wikipedia.org/wiki/MATLAB
  56. # MEXW64:MATLAB Windows 64bit compiled function https://en.wikipedia.org/wiki/MATLAB
  57. # MLL: Maya plug-in (generic) http://en.wikipedia.org/wiki/Autodesk_Maya
  58. # PFL: PhotoFilter plugin http://photofiltre.free.fr
  59. # 8*: PhotoShop plug-in (generic) http://www.adobe.com/products/photoshop/main.html
  60. # PLG: Aston Shell plugin http://www.astonshell.com/
  61. # QLB: Microsoft Basic Quick library https://en.wikipedia.org/wiki/QuickBASIC
  62. # SKL: WinLIFT skin http://www.zapsolution.com/winlift/index.htm
  63. # TBK: Asymetrix ToolBook application http://www.toolbook.com
  64. # TBP: The Bat! plugin http://www.ritlabs.com
  65. # UPC: Ultimate Paint Graphics Editor plugin http://ultimatepaint.j-t-l.com
  66. # XFM: Syntrillium Cool Edit Transform Effect bad http://www.cooledit.com
  67. # XPL: X-Plane plugin http://www.xsquawkbox.net/xpsdk/
  68. # ZAP: ZoneLabs Zone Alarm data http://www.zonelabs.com
  69. #
  70. # NEXT LINES FOR DEBUGGING!
  71. # e_cblp; bytes on last page of file
  72. # e_cp; pages in file
  73. #>4 uleshort x \b, e_cp 0x%x
  74. # e_lfanew; file address of new exe header
  75. #>0x3c ulelong x \b, e_lfanew 0x%x
  76. # e_lfarlc; address of relocation table
  77. #>0x18 uleshort x \b, e_lfarlc=0x%x
  78. # e_ovno; overlay number. If zero, this is the main executable foo
  79. #>0x1a uleshort !0 \b, e_ovno 0x%x
  80. #>0x1C ubequad !0 \b, e_res 0x%16.16llx
  81. # e_oemid; often 0
  82. #>0x24 uleshort !0 \b, e_oemid 0x%x
  83. # e_oeminfo; typically zeroes, but 13Dh (WORDSTAR.CNV WPFT5.CNV) 143h (WRITWIN.CNV)
  84. # 1A3h (DBASE.CNV LOTUS123.CNV RFTDCA.CNV WORDDOS.CNV WORDMAC.CNV WORDWIN1.CNVXLBIFF.CNV)
  85. #>0x26 uleshort !0 \b, e_oeminfo 0x%x
  86. # e_res2; typically zeroes, but 000006006F082D2Ah SCSICFG.EXE 00009A0300007C03h de.exe
  87. # 0000CA0000000002h country.exe dosxmgr.exe 421E0A00421EA823h QMC.EXE
  88. #>0x28 ubequad !0 \b, e_res2 0x%16.16llx
  89. # https://web.archive.org/web/20171116024937/http://www.ctyme.com/intr/rb-2939.htm#table1593
  90. # https://github.com/uxmal/reko/blob/master/src/ImageLoaders/MzExe/ExeImageLoader.cs
  91. # new exe header magic like: PE NE LE LX W3 W4
  92. # no examples found for ZM DL MP P2 P3
  93. #>(0x3c.l) string x \b, at [0x3c] %.2s
  94. #>(0x3c.l) ubelong x \b, at [0x3c] %#8.8x
  95. #>(0x3c.l+4) ubelong x \b, at [0x3c+4] %#8.8x
  96. #
  97. # Most non-DOS MZ-executable extensions have the relocation table more than 0x40 bytes into the file.
  98. # http://www.mitec.cz/Downloads/EXE.zip/EXE64.exe e_lfarlc=0x8ead
  99. # OS/2 ECS\INSTALL\DETECTEI\PCISCAN.EXE e_lfarlc=0x1c
  100. # some EFI apps Shell_Full.efi ext4_x64_signed.efi e_lfarlc=0
  101. # Icon library WORD60.ICL e_lfarlc=0
  102. # Microsoft compiled help format 2.0 WINWORD.DEV.HXS e_lfarlc=0
  103. >0x18 uleshort <0x40
  104. # check magic of new second header
  105. # NE executable with low e_lfarlc like: WORD60.ICL
  106. # ICL: Icons Library 16-bit http://fileformats.archiveteam.org/wiki/Icon_library
  107. >>(0x3c.l) string NE Windows Icons Library 16-bit
  108. !:mime image/x-ms-icl
  109. !:ext icl
  110. # handle LX executable with low e_lfarlc like: PCISCAN.EXE
  111. >>(0x3c.l) string LX
  112. >>>(0x3c.l) use lx-executable
  113. # skip Portable Executable (PE) with low e_lfarlc here, because handled later
  114. # like: ext4_x64_signed.efi Shell_Full.efi WINWORD.DEV.HXS
  115. >>(0x3c.l) string PE
  116. # not New Executable (NE) and not PE with low e_lfarlc like:
  117. # MACCNV55.EXE WORK_RTF.EXE TELE200.EXE NDD.EXE iflash.exe
  118. >>(0x3c.l) default x MS-DOS executable, MZ for MS-DOS
  119. !:mime application/x-dosexec
  120. # Windows and later versions of DOS will allow .EXEs to be named with a .COM
  121. # extension, mostly for compatibility's sake.
  122. # like: EDIT.COM 4DOS.COM CMD8086.COM CMD-FR.COM SYSLINUX.COM
  123. # URL: https://en.wikipedia.org/wiki/Personal_NetWare#VLM
  124. # Reference: https://mark0.net/download/triddefs_xml.7z/defs/e/exe-vlm-msg.trid.xml
  125. # also like: BGISRV.DRV
  126. !:ext exe/com/vlm/drv
  127. # These traditional tests usually work but not always. When test quality support is
  128. # implemented these can be turned on.
  129. #>>0x18 leshort 0x1c (Borland compiler)
  130. #>>0x18 leshort 0x1e (MS compiler)
  131. # Maybe it's a PE?
  132. # URL: http://fileformats.archiveteam.org/wiki/Portable_Executable
  133. # Reference: https://docs.microsoft.com/de-de/windows/win32/debug/pe-format
  134. >(0x3c.l) string PE\0\0 PE
  135. !:mime application/vnd.microsoft.portable-executable
  136. # https://docs.microsoft.com/de-de/windows/win32/debug/pe-format#characteristics
  137. # DLL Characteristics
  138. #>>(0x3c.l+22) uleshort x \b, CHARACTERISTICS %#4.4x,
  139. # 0x0200~IMAGE_FILE_DEBUG_STRIPPED Debugging information is removed from the image file
  140. # 0x1000~IMAGE_FILE_SYSTEM The image file is a system file, not a user program.
  141. # 0x2000~IMAGE_FILE_DLL The image file is a dynamic-link library (DLL)
  142. >>(0x3c.l+24) leshort 0x010b \b32 executable
  143. # https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#windows-subsystem
  144. #>>>(0x3c.l+92) leshort x \b, SUBSYSTEM %u
  145. >>(0x3c.l+24) leshort 0x020b \b32+ executable
  146. #>>>(0x3c.l+92) leshort x \b, SUBSYSTEM %u
  147. >>(0x3c.l+24) leshort 0x0107 ROM image
  148. >>(0x3c.l+24) default x Unknown PE signature
  149. >>>&0 leshort x %#x
  150. >>(0x3c.l+22) leshort&0x2000 >0 (DLL)
  151. # 0~IMAGE_SUBSYSTEM_UNKNOWN An unknown subsystem
  152. >>(0x3c.l+92) leshort 0 (
  153. # Summary: Microsoft compiled help *.HXS format 2.0
  154. # URL: https://en.wikipedia.org/wiki/Microsoft_Help_2
  155. # Reference: http://www.russotto.net/chm/itolitlsformat.html
  156. # https://mark0.net/download/triddefs_xml.7z/defs/h/hxs.trid.xml
  157. # Note: 2 PE sections (.rsrc, .its) implies Microsoft compiled help format; the .its section contains the help content ITOLITLS
  158. # verified by command like `pelook.exe -d WINWORD.HXS & pelook.exe -h WINWORD.HXS`
  159. >>>(0x3c.l+6) uleshort =2 \bMicrosoft compiled help format 2.0)
  160. !:ext hxs
  161. # 3 PE sections (.text, .reloc, .rsrc) implies some Control Panel Item like:
  162. # CPL: Control Panel item for WINE 1.7.28 https://www.winehq.org/
  163. >>>(0x3c.l+6) uleshort !2 \bControl Panel Item)
  164. !:ext cpl
  165. # 1~IMAGE_SUBSYSTEM_NATIVE device drivers and native Windows processes
  166. >>(0x3c.l+92) leshort 1
  167. # Native PEs include ntoskrnl.exe, hal.dll, smss.exe, autochk.exe, and all the
  168. # drivers in Windows/System32/drivers/*.sys.
  169. >>>(0x3c.l+22) leshort&0x2000 >0 (native)
  170. !:ext dll/sys
  171. >>>(0x3c.l+22) leshort&0x2000 0 (native)
  172. !:ext exe/sys
  173. # 2~IMAGE_SUBSYSTEM_WINDOWS_GUI The Windows graphical user interface (GUI) subsystem
  174. >>(0x3c.l+92) leshort 2
  175. >>>(0x3c.l+22) leshort&0x2000 >0 (GUI)
  176. # These could probably be at least partially distinguished from one another by
  177. # looking for specific exported functions.
  178. # CPL: Control Panel item
  179. # TLB: Type library
  180. # OCX: OLE/ActiveX control
  181. # ACM: Audio compression manager codec
  182. # AX: DirectShow source filter
  183. # IME: Input method editor
  184. !:ext dll/cpl/tlb/ocx/acm/ax/ime
  185. >>>(0x3c.l+22) leshort&0x2000 0 (GUI)
  186. # Screen savers typically include code from the scrnsave.lib static library, but
  187. # that's not guaranteed.
  188. !:ext exe/scr
  189. # 3~IMAGE_SUBSYSTEM_WINDOWS_CUI The Windows character subsystem
  190. >>(0x3c.l+92) leshort 3
  191. >>>(0x3c.l+22) leshort&0x2000 >0 (console)
  192. !:ext dll/cpl/tlb/ocx/acm/ax/ime
  193. >>>(0x3c.l+22) leshort&0x2000 0 (console)
  194. !:ext exe/com
  195. # NO Windows Subsystem number 4!
  196. >>(0x3c.l+92) leshort 4 (Unknown subsystem 4)
  197. # 5~IMAGE_SUBSYSTEM_OS2_CUI The OS/2 character subsystem
  198. >>(0x3c.l+92) leshort 5 (OS/2)
  199. # GRR: No examples found by Joerg Jenderek
  200. #!:ext foo-exe-os2
  201. # NO Windows Subsystem number 6!
  202. >>(0x3c.l+92) leshort 6 (Unknown subsystem 6)
  203. # 7~IMAGE_SUBSYSTEM_POSIX_CUI The Posix character subsystem
  204. >>(0x3c.l+92) leshort 7 (POSIX
  205. >>>(0x3c.l+22) leshort&0x2000 >0 \b)
  206. # like: PSXDLL.DLL
  207. !:ext dll
  208. >>>(0x3c.l+22) leshort&0x2000 0 \b)
  209. # like: PAX.EXE
  210. !:ext exe
  211. # 8~IMAGE_SUBSYSTEM_NATIVE_WINDOWS Native Win9x driver
  212. >>(0x3c.l+92) leshort 8 (Win9x)
  213. # GRR: No examples found by Joerg Jenderek
  214. #!:ext foo-exe-win98
  215. # 9~IMAGE_SUBSYSTEM_WINDOWS_CE_GUI Windows CE
  216. >>(0x3c.l+92) leshort 9 (Windows CE
  217. >>>(0x3c.l+22) leshort&0x2000 >0 \b)
  218. # like: MCS9900Ce50.dll Mosiisr99x.dll TMCGPS.DLL
  219. !:ext dll
  220. >>>(0x3c.l+22) leshort&0x2000 0 \b)
  221. # like: NNGStart.exe navigator.exe
  222. !:ext exe
  223. # 10~IMAGE_SUBSYSTEM_EFI_APPLICATION An Extensible Firmware Interface (EFI) application
  224. >>(0x3c.l+92) leshort 10 (EFI application)
  225. # like: bootmgfw.efi grub.efi gdisk_x64.efi Shell_Full.efi shim.efi syslinux.efi
  226. !:ext efi
  227. # 11~IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER An EFI driver with boot services
  228. >>(0x3c.l+92) leshort 11 (EFI boot service driver)
  229. # like: ext2_x64_signed.efi Fat_x64.efi iso9660_x64_signed.efi
  230. !:ext efi
  231. >>(0x3c.l+92) leshort 12 (EFI runtime driver)
  232. # no sample found
  233. !:ext efi
  234. # 13~IMAGE_SUBSYSTEM_EFI_ROM An EFI ROM image
  235. >>(0x3c.l+92) leshort 13 (EFI ROM)
  236. # no sample found
  237. !:ext efi
  238. # 14~IMAGE_SUBSYSTEM_XBOX XBOX
  239. >>(0x3c.l+92) leshort 14 (XBOX)
  240. #!:ext foo-xbox
  241. # NO Windows Subsystem number 15!
  242. >>(0x3c.l+92) leshort 15 (Unknown subsystem 15)
  243. # 16~IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION Windows boot application
  244. >>(0x3c.l+92) leshort 16 (Windows boot application
  245. >>>(0x3c.l+22) leshort&0x2000 >0 \b)
  246. # like: bootvhd.dll bootuwf.dll hvloader.dll tcbloader.dll bootspaces.dll
  247. !:ext dll
  248. >>>(0x3c.l+22) leshort&0x2000 0 \b)
  249. # like: bootmgr.efi memtest.efi shellx64.efi memtest.exe winload.exe winresume.exe bootvhd.dll hvloader.dll
  250. !:ext efi/exe
  251. # GRR: the next 2 lines are not executed!
  252. #>>(0x3c.l+92) default x (Unknown subsystem
  253. #>>>&0 leshort x %#x)
  254. >>(0x3c.l+92) leshort >16 (Unknown subsystem
  255. >>>&0 leshort x %#x)
  256. >>(0x3c.l+4) leshort 0x14c Intel 80386
  257. >>(0x3c.l+4) leshort 0x166 MIPS R4000
  258. >>(0x3c.l+4) leshort 0x168 MIPS R10000
  259. >>(0x3c.l+4) leshort 0x184 Alpha
  260. >>(0x3c.l+4) leshort 0x1a2 Hitachi SH3
  261. >>(0x3c.l+4) leshort 0x1a3 Hitachi SH3 DSP
  262. >>(0x3c.l+4) leshort 0x1a8 Hitachi SH5
  263. >>(0x3c.l+4) leshort 0x169 MIPS WCE v2
  264. >>(0x3c.l+4) leshort 0x1a6 Hitachi SH4
  265. >>(0x3c.l+4) leshort 0x1c0 ARM
  266. >>(0x3c.l+4) leshort 0x1c2 ARM Thumb
  267. >>(0x3c.l+4) leshort 0x1c4 ARMv7 Thumb
  268. >>(0x3c.l+4) leshort 0x1d3 Matsushita AM33
  269. >>(0x3c.l+4) leshort 0x1f0 PowerPC
  270. >>(0x3c.l+4) leshort 0x1f1 PowerPC with FPU
  271. >>(0x3c.l+4) leshort 0x1f2 PowerPC (big-endian)
  272. >>(0x3c.l+4) leshort 0x200 Intel Itanium
  273. >>(0x3c.l+4) leshort 0x266 MIPS16
  274. >>(0x3c.l+4) leshort 0x268 Motorola 68000
  275. >>(0x3c.l+4) leshort 0x290 PA-RISC
  276. >>(0x3c.l+4) leshort 0x366 MIPSIV
  277. >>(0x3c.l+4) leshort 0x466 MIPS16 with FPU
  278. >>(0x3c.l+4) leshort 0xebc EFI byte code
  279. >>(0x3c.l+4) leshort 0x5032 RISC-V 32-bit
  280. >>(0x3c.l+4) leshort 0x5064 RISC-V 64-bit
  281. >>(0x3c.l+4) leshort 0x5128 RISC-V 128-bit
  282. >>(0x3c.l+4) leshort 0x9041 Mitsubishi M32R
  283. >>(0x3c.l+4) leshort 0x8664 x86-64
  284. >>(0x3c.l+4) leshort 0xaa64 Aarch64
  285. >>(0x3c.l+4) leshort 0xc0ee MSIL
  286. # GRR: the next 2 lines are not executed!
  287. >>(0x3c.l+4) default x Unknown processor type
  288. >>>&0 leshort x %#x
  289. >>(0x3c.l+22) leshort&0x0200 >0 (stripped to external PDB)
  290. >>(0x3c.l+22) leshort&0x1000 >0 system file
  291. >>(0x3c.l+24) leshort 0x010b
  292. >>>(0x3c.l+232) lelong >0 Mono/.Net assembly
  293. >>(0x3c.l+24) leshort 0x020b
  294. >>>(0x3c.l+248) lelong >0 Mono/.Net assembly
  295. # hooray, there's a DOS extender using the PE format, with a valid PE
  296. # executable inside (which just prints a message and exits if run in win)
  297. >>(8.s*16) string 32STUB \b, 32rtm DOS extender
  298. >>(8.s*16) string !32STUB \b, for MS Windows
  299. >>(0x3c.l+0xf8) string UPX0 \b, UPX compressed
  300. >>(0x3c.l+0xf8) search/0x140 PEC2 \b, PECompact2 compressed
  301. >>(0x3c.l+0xf8) search/0x140 UPX2
  302. >>>(&0x10.l+(-4)) string PK\3\4 \b, ZIP self-extracting archive (Info-Zip)
  303. >>(0x3c.l+0xf8) search/0x140 .idata
  304. >>>(&0xe.l+(-4)) string PK\3\4 \b, ZIP self-extracting archive (Info-Zip)
  305. >>>(&0xe.l+(-4)) string ZZ0 \b, ZZip self-extracting archive
  306. >>>(&0xe.l+(-4)) string ZZ1 \b, ZZip self-extracting archive
  307. >>(0x3c.l+0xf8) search/0x140 .rsrc
  308. >>>(&0x0f.l+(-4)) string a\\\4\5 \b, WinHKI self-extracting archive
  309. >>>(&0x0f.l+(-4)) string Rar! \b, RAR self-extracting archive
  310. >>>(&0x0f.l+(-4)) search/0x3000 MSCF \b, InstallShield self-extracting archive
  311. >>>(&0x0f.l+(-4)) search/32 Nullsoft \b, Nullsoft Installer self-extracting archive
  312. >>(0x3c.l+0xf8) search/0x140 .data
  313. >>>(&0x0f.l) string WEXTRACT \b, MS CAB-Installer self-extracting archive
  314. >>(0x3c.l+0xf8) search/0x140 .petite\0 \b, Petite compressed
  315. >>>(0x3c.l+0xf7) byte x
  316. >>>>(&0x104.l+(-4)) string =!sfx! \b, ACE self-extracting archive
  317. >>(0x3c.l+0xf8) search/0x140 .WISE \b, WISE installer self-extracting archive
  318. >>(0x3c.l+0xf8) search/0x140 .dz\0\0\0 \b, Dzip self-extracting archive
  319. >>&(0x3c.l+0xf8) search/0x100 _winzip_ \b, ZIP self-extracting archive (WinZip)
  320. >>&(0x3c.l+0xf8) search/0x100 SharedD \b, Microsoft Installer self-extracting archive
  321. >>0x30 string Inno \b, InnoSetup self-extracting archive
  322. # NumberOfSections; Normal Dynamic Link libraries have a few sections for code, data and resource etc.
  323. # PE used as container have less sections
  324. >>(0x3c.l+6) leshort >1 \b, %u sections
  325. # do not display for 1 section to get output like in version 5.43 and to keep output columns low
  326. #>>(0x3c.l+6) leshort =1 \b, %u section
  327. # If the relocation table is 0x40 or more bytes into the file, it's definitely
  328. # not a DOS EXE.
  329. >0x18 uleshort >0x3f
  330. # Hmm, not a PE but the relocation table is too high for a traditional DOS exe,
  331. # must be one of the unusual subformats.
  332. >>(0x3c.l) string !PE\0\0 MS-DOS executable
  333. #!:mime application/x-dosexec
  334. >>(0x3c.l) string NE \b, NE
  335. #!:mime application/x-dosexec
  336. !:mime application/x-ms-ne-executable
  337. # FOR DEBUGGING!
  338. # Reference: https://wiki.osdev.org/NE
  339. # ProgFlags; Program flags, bitmapped
  340. #>>>(0x3c.l+0x0C) ubyte x \b, ProgFlags 0x%2.2x
  341. # >>>(0x3c.l+0x0c) ubyte&0x03 =0 \b, none
  342. # >>>(0x3c.l+0x0c) ubyte&0x03 =1 \b, single shared
  343. # >>>(0x3c.l+0x0c) ubyte&0x03 =2 \b, multiple
  344. # >>>(0x3c.l+0x0c) ubyte&0x03 =3 \b, (null)
  345. # >>>(0x3c.l+0x0c) ubyte &0x04 \b, Global initialization
  346. # >>>(0x3c.l+0x0c) ubyte &0x08 \b, Protected mode only
  347. # >>>(0x3c.l+0x0c) ubyte &0x10 \b, 8086 instructions
  348. # >>>(0x3c.l+0x0c) ubyte &0x20 \b, 80286 instructions
  349. # >>>(0x3c.l+0x0c) ubyte &0x40 \b, 80386 instructions
  350. # >>>(0x3c.l+0x0c) ubyte &0x80 \b, 80x87 instructions
  351. # ApplFlags; Application flags, bitmapped
  352. # https://www.fileformat.info/format/exe/corion-ne.htm
  353. #>>>(0x3c.l+0x0D) ubyte x \b, ApplFlags 0x%2.2x
  354. # Application type (bits 0-2); 1~Full screen (not aware of Windows/P.M. API)
  355. # 2~Compatible with Windows/P.M. API 3~Uses Windows/P.M. API
  356. #>>>(0x3c.l+0x0D) ubyte&0x07 =1 \b, Full screen
  357. #>>>(0x3c.l+0x0D) ubyte&0x07 =2 \b, Compatible with Windows/P.M. API
  358. #>>>(0x3c.l+0x0D) ubyte&0x07 =3 \b, use Windows/P.M. API
  359. # bit 7; DLL or driver (SS:SP info invalid, CS:IP points at FAR init routine called with AX handle
  360. #>>>(0x3c.l+0x0D) ubyte &0x80 \b, DLL or driver
  361. # AutoDataSegIndex; automatic data segment index like: 0 2 3 22
  362. # zero if the SINGLEDATA and MULTIPLEDATA bits are cleared
  363. #>>>(0x3c.l+0x0e) uleshort x \b, AutoDataSegIndex %u
  364. # InitHeapSize; intial local heap size like; 0 400h 1400h
  365. # zero if there is no local allocation
  366. #>>>(0x3c.l+0x10) uleshort !0 \b, InitHeapSize 0x%x
  367. # InitStackSize; inital stack size like: 0 10h A00h 7D0h A8Ch FA0h 1000h 1388h
  368. # 1400h (CBT) 1800h 2000h 2800h 2EE0h 2F3Ch 3258h 3E80h 4000h 4E20h 5000h 6000h
  369. # 6D60h 8000h 40000h
  370. # zero if the SS register value does not equal the DS register value
  371. #>>>(0x3c.l+0x12) uleshort !0 \b, InitStackSize 0x%x
  372. # EntryPoint; segment offset value of CS:IP like: 0 10000h 18A84h 11C1Ah 307F1h
  373. #>>>(0x3c.l+0x14) ulelong !0 \b, EntryPoint 0x%x
  374. # InitStack; specifies the segment offset value of stack pointer SS:SP
  375. # like: 0 20000h 160000h
  376. #>>>(0x3c.l+0x18) ulelong !0 \b, InitStack 0x%x
  377. # SegCount; number of segments in segment table like: 0 1 2 3 16h
  378. #>>>(0x3c.l+0x1C) uleshort x \b, SegCount 0x%x
  379. # ModRefs; number of module references (DLLs) like; 0 1 3
  380. #>>>(0x3c.l+0x1E) uleshort !0 \b, ModRefs %u
  381. # NoResNamesTabSiz; size in bytes of non-resident names table
  382. # like: Bh 16h B4h B9h 2Ch 18Fh 16AAh
  383. #>>>(0x3c.l+0x20) uleshort x \b, NoResNamesTabSiz 0x%x
  384. # SegTableOffset; offset of Segment table like: 40h
  385. #>>>(0x3c.l+0x22) uleshort !0x40 \b, SegTableOffset 0x%x
  386. # ResTableOffset; offset of resources table like: 40h 50h 58h F0h
  387. # 40h for most fonts likedos737.fon FMFONT.FOT but 60h for L1WBASE.FON
  388. #>>>(0x3c.l+0x24) uleshort x \b, ResTableOffset 0x%x
  389. # ResidNamTable; offset of resident names table
  390. # like: 58h 5Ch 60h 68h 74h 98h 2E3h 2E7h 2F0h
  391. #>>>(0x3c.l+0x26) uleshort x \b, ResidNamTable 0x%x
  392. # ImportNameTable; offset of imported names table (array of counted strings, terminated with string of length 00h)
  393. # like: 77h 7Eh 80h C6h A7h ACh 2F8h 3FFh
  394. #>>>(0x3c.l+0x2a) uleshort x \b, ImportNameTable 0x%x
  395. # OffStartNonResTab; offset from start of file to non-resident names table
  396. # like: 110h 11Dh 19Bh 1A5h 3F5h 4C8h 4EEh D93h
  397. #>>>(0x3c.l+0x2c) ulelong x \b, OffStartNonResTab 0x%x
  398. # MovEntryCount; number of movable entry points like: 0 4 5 6 16 17 24 312 355 446
  399. #>>>(0x3c.l+0x30) uleshort !0 \b, MovEntryCount %u
  400. # FileAlnSzShftCnt; log2 of the segment sector size; 4~16 0~9~512 (default)
  401. #>>>(0x3c.l+0x32) uleshort !9 \b, FileAlnSzShftCnt %u
  402. # nResTabEntries; number of resource table entries like: 0 2
  403. #>>>(0x3c.l+0x34) uleshort !0 \b, nResTabEntries %u
  404. # targOS; Target OS; 0~unknown~OS/2 1.0 or MS Windows 1-2
  405. # OS/2 1.0 like: DTM.DLL SHELL11F.EXE HELPMSG.EXE CREATEDD.EXE
  406. # or Windows 1.03 - 2.1 like: MSDOSD.EXE KARTEI.EXE KALENDER.EXE
  407. #>>>(0x3c.l+0x36) byte x TARGOS %x
  408. >>>(0x3c.l+0x36) byte 0 for OS/2 1.0 or MS Windows 1-2
  409. >>>(0x3c.l+0x36) byte 1 for OS/2 1.x
  410. >>>(0x3c.l+0x36) byte 2 for MS Windows 3.x
  411. >>>(0x3c.l+0x36) byte 3 for MS-DOS
  412. >>>(0x3c.l+0x36) byte 4 for Windows 386
  413. >>>(0x3c.l+0x36) byte 5 for Borland Operating System Services
  414. # http://downloads.sourceforge.net/dfendreloaded/D-Fend-Reloaded-1.4.4.zip
  415. # D-Fend Reloaded/VirtualHD/FREEDOS/DPMILD32.EXE
  416. # GRR: WHAT OS is this?
  417. #>>>(0x3c.l+0x36) byte 6 for TARGET SIX
  418. # https://en.wikipedia.org/wiki/Phar_Lap_(company)
  419. >>>(0x3c.l+0x36) byte 0x81 for MS-DOS, Phar Lap DOS extender, OS/2
  420. # like: CVP7.EXE
  421. >>>(0x3c.l+0x36) byte 0x82 for MS-DOS, Phar Lap DOS extender, Windows
  422. >>>(0x3c.l+0x36) default x
  423. >>>>(0x3c.l+0x36) ubyte x (unknown OS %#x)
  424. # expctwinver; expected Windows version (minor first) like:
  425. # 0.0~DTM.DLL 203.4~Windows 1.03 GDI.EXE 2.1~TTY.DRV 3.0~dos737.fon FMFONT.FOT THREED.VBX 3.10~GDI.EXE 4.0~(ME) VGAFULL.3GR
  426. >>>(0x3c.l+0x3F) ubyte x (%u
  427. >>>(0x3c.l+0x3E) ubyte x \b.%u)
  428. # OS2EXEFlags; other EXE flags
  429. # 0~Long filename support 1~2.x protected mode 4~2.x proportional fonts 8~Executable has gangload area
  430. #>>>(0x3c.l+0x37) byte !0 \b, OS2EXEFlags 0x%x
  431. # retThunkOffset; offset to return thunks or start of gangload area like: 0 34h 58h 246h
  432. #>>>(0x3c.l+0x38) uleshort !0 \b, retThunkOffset 0x%x
  433. # segrefthunksoff; offset to segment reference thunks or size of gangload area
  434. # like: 0 33Eh 39Ah AEEh
  435. #>>>(0x3c.l+0x3A) uleshort !0 \b, segrefthunksoff 0x%x
  436. # mincodeswap; minimum code swap area size like 0 620Ch
  437. #>>>(0x3c.l+0x3C) uleshort !0 \b, mincodeswap 0x%x
  438. >>>(0x3c.l+0x0c) leshort&0x8000 0x8000 (DLL or font)
  439. # DRV: Driver
  440. # 3GR: Grabber device driver
  441. # CPL: Control Panel Item
  442. # VBX: Visual Basic Extension https://en.wikipedia.org/wiki/Visual_Basic
  443. # FON: Bitmap font http://fileformats.archiveteam.org/wiki/FON
  444. # FOT: Font resource file
  445. # EXE: WINSPOOL.EXE USER.EXE krnl386.exe GDI.EXE
  446. # CNV: Microsoft Word text conversion https://www.file-extensions.org/cnv-file-extension-microsoft-word-text-conversion-data
  447. !:ext dll/drv/3gr/cpl/vbx/fon/fot
  448. >>>(0x3c.l+0x0c) leshort&0x8000 0 (EXE)
  449. !:ext exe/scr
  450. >>>&(&0x24.s-1) string ARJSFX \b, ARJ self-extracting archive
  451. >>>(0x3c.l+0x70) search/0x80 WinZip(R)\ Self-Extractor \b, ZIP self-extracting archive (WinZip)
  452. >>(0x3c.l) string LX\0\0 \b, LX
  453. !:mime application/x-dosexec
  454. >>>(0x3c.l+0x0a) leshort <1 (unknown OS)
  455. >>>(0x3c.l+0x0a) leshort 1 for OS/2
  456. >>>(0x3c.l+0x0a) leshort 2 for MS Windows
  457. >>>(0x3c.l+0x0a) leshort 3 for DOS
  458. >>>(0x3c.l+0x0a) leshort >3 (unknown OS)
  459. >>>(0x3c.l+0x10) lelong&0x28000 =0x8000 (DLL)
  460. >>>(0x3c.l+0x10) lelong&0x20000 >0 (device driver)
  461. >>>(0x3c.l+0x10) lelong&0x300 0x300 (GUI)
  462. >>>(0x3c.l+0x10) lelong&0x28300 <0x300 (console)
  463. >>>(0x3c.l+0x08) leshort 1 i80286
  464. >>>(0x3c.l+0x08) leshort 2 i80386
  465. >>>(0x3c.l+0x08) leshort 3 i80486
  466. >>>(8.s*16) string emx \b, emx
  467. >>>>&1 string x %s
  468. >>>&(&0x54.l-3) string arjsfx \b, ARJ self-extracting archive
  469. # MS Windows system file, supposedly a collection of LE executables
  470. # like vmm32.vxd WIN386.EXE
  471. >>(0x3c.l) string W3 \b, W3 for MS Windows
  472. #!:mime application/x-dosexec
  473. !:mime application/x-ms-w3-executable
  474. !:ext vxd/exe
  475. # W4 executable
  476. >>(0x3c.l) string W4 \b, W4 for MS Windows
  477. #!:mime application/x-dosexec
  478. !:mime application/x-ms-w4-executable
  479. # windows 98 VMM32.VXD
  480. !:ext vxd
  481. >>(0x3c.l) string LE\0\0 \b, LE executable
  482. !:mime application/x-dosexec
  483. >>>(0x3c.l+0x0a) leshort 1
  484. # some DOS extenders use LE files with OS/2 header
  485. >>>>0x240 search/0x100 DOS/4G for MS-DOS, DOS4GW DOS extender
  486. >>>>0x240 search/0x200 WATCOM\ C/C++ for MS-DOS, DOS4GW DOS extender
  487. >>>>0x440 search/0x100 CauseWay\ DOS\ Extender for MS-DOS, CauseWay DOS extender
  488. >>>>0x40 search/0x40 PMODE/W for MS-DOS, PMODE/W DOS extender
  489. >>>>0x40 search/0x40 STUB/32A for MS-DOS, DOS/32A DOS extender (stub)
  490. >>>>0x40 search/0x80 STUB/32C for MS-DOS, DOS/32A DOS extender (configurable stub)
  491. >>>>0x40 search/0x80 DOS/32A for MS-DOS, DOS/32A DOS extender (embedded)
  492. # this is a wild guess; hopefully it is a specific signature
  493. >>>>&0x24 lelong <0x50
  494. >>>>>(&0x4c.l) string \xfc\xb8WATCOM
  495. >>>>>>&0 search/8 3\xdbf\xb9 \b, 32Lite compressed
  496. # another wild guess: if real OS/2 LE executables exist, they probably have higher start EIP
  497. #>>>>(0x3c.l+0x1c) lelong >0x10000 for OS/2
  498. # fails with DOS-Extenders.
  499. >>>(0x3c.l+0x0a) leshort 2 for MS Windows
  500. >>>(0x3c.l+0x0a) leshort 3 for DOS
  501. >>>(0x3c.l+0x0a) leshort 4 for MS Windows (VxD)
  502. # VXD: VxD for Windows 95/98/Me
  503. # 386: VxD for Windows 2.10, 3.0, 3.1x
  504. # PDR: Port driver
  505. # MPD: Miniport driver (?)
  506. !:ext vxd/386/pdr/mpd
  507. >>>(&0x7c.l+0x26) string UPX \b, UPX compressed
  508. >>>&(&0x54.l-3) string UNACE \b, ACE self-extracting archive
  509. # looks like ASCII, probably some embedded copyright message.
  510. # and definitely not NE/LE/LX/PE
  511. >>0x3c lelong >0x20000000
  512. >>>(4.s*512) leshort !0x014c \b, MZ for MS-DOS
  513. !:mime application/x-dosexec
  514. !:ext exe/com
  515. # header data too small for extended executable
  516. >2 long !0
  517. >>0x18 uleshort <0x40
  518. >>>(4.s*512) leshort !0x014c
  519. >>>>&(2.s-514) string !LE
  520. >>>>>&-2 string !BW
  521. #>>>>>>(0x3c.l) string x \b, 2ND MAGIC %.2s
  522. # but some LX executable appear here also like: PCISCAN.EXE
  523. >>>>>>(0x3c.l) string !LX
  524. # because Portable Executable (PE) already done skip many here like:
  525. # xcopy32.exe stinger64.exe WimUtil.exe
  526. # NO such DOS examples found and
  527. # DOS examples seems to be already handled by e_lfarlc <0x40 like: CMD8086.COM CMD-FR.COM
  528. >>>>>>>(0x3c.l) string !PE \b, MZ for MS-DOS
  529. !:mime application/x-dosexec
  530. >>>>&(2.s-514) string LE \b, LE
  531. >>>>>0x240 search/0x100 DOS/4G for MS-DOS, DOS4GW DOS extender
  532. # educated guess since indirection is still not capable enough for complex offset
  533. # calculations (next embedded executable would be at &(&2*512+&0-2)
  534. # I suspect there are only LE executables in these multi-exe files
  535. >>>>&(2.s-514) string BW
  536. >>>>>0x240 search/0x100 DOS/4G \b, LE for MS-DOS, DOS4GW DOS extender (embedded)
  537. >>>>>0x240 search/0x100 !DOS/4G \b, BW collection for MS-DOS
  538. # This sequence skips to the first COFF segment, usually .text
  539. >(4.s*512) leshort 0x014c \b, COFF
  540. !:mime application/x-dosexec
  541. >>(8.s*16) string go32stub for MS-DOS, DJGPP go32 DOS extender
  542. >>(8.s*16) string emx
  543. >>>&1 string x for DOS, Win or OS/2, emx %s
  544. >>&(&0x42.l-3) byte x
  545. >>>&0x26 string UPX \b, UPX compressed
  546. # and yet another guess: small .text, and after large .data is unusual, could be 32lite
  547. >>&0x2c search/0xa0 .text
  548. >>>&0x0b lelong <0x2000
  549. >>>>&0 lelong >0x6000 \b, 32lite compressed
  550. >(8.s*16) string $WdX \b, WDos/X DOS extender
  551. # By now an executable type should have been printed out. The executable
  552. # may be a self-uncompressing archive, so look for evidence of that and
  553. # print it out.
  554. #
  555. # Some signatures below from Greg Roelofs, newt@uchicago.edu.
  556. #
  557. >0x35 string \x8e\xc0\xb9\x08\x00\xf3\xa5\x4a\x75\xeb\x8e\xc3\x8e\xd8\x33\xff\xbe\x30\x00\x05 \b, aPack compressed
  558. >0xe7 string LH/2\ Self-Extract \b, %s
  559. >0x1c string UC2X \b, UCEXE compressed
  560. >0x1c string WWP\ \b, WWPACK compressed
  561. >0x1c string RJSX \b, ARJ self-extracting archive
  562. >0x1c string diet \b, diet compressed
  563. >0x1c string LZ09 \b, LZEXE v0.90 compressed
  564. >0x1c string LZ91 \b, LZEXE v0.91 compressed
  565. >0x1c string tz \b, TinyProg compressed
  566. >0x1e string Copyright\ 1989-1990\ PKWARE\ Inc. Self-extracting PKZIP archive
  567. !:mime application/zip
  568. # Yes, this really is "Copr", not "Corp."
  569. >0x1e string PKLITE\ Copr. Self-extracting PKZIP archive
  570. !:mime application/zip
  571. # winarj stores a message in the stub instead of the sig in the MZ header
  572. >0x20 search/0xe0 aRJsfX \b, ARJ self-extracting archive
  573. >0x20 string AIN
  574. >>0x23 string 2 \b, AIN 2.x compressed
  575. >>0x23 string <2 \b, AIN 1.x compressed
  576. >>0x23 string >2 \b, AIN 1.x compressed
  577. >0x24 string LHa's\ SFX \b, LHa self-extracting archive
  578. !:mime application/x-lha
  579. >0x24 string LHA's\ SFX \b, LHa self-extracting archive
  580. !:mime application/x-lha
  581. >0x24 string \ $ARX \b, ARX self-extracting archive
  582. >0x24 string \ $LHarc \b, LHarc self-extracting archive
  583. >0x20 string SFX\ by\ LARC \b, LARC self-extracting archive
  584. >0x40 string aPKG \b, aPackage self-extracting archive
  585. >0x64 string W\ Collis\0\0 \b, Compack compressed
  586. >0x7a string Windows\ self-extracting\ ZIP \b, ZIP self-extracting archive
  587. >>&0xf4 search/0x140 \x0\x40\x1\x0
  588. >>>(&0.l+(4)) string MSCF \b, WinHKI CAB self-extracting archive
  589. >1638 string -lh5- \b, LHa self-extracting archive v2.13S
  590. >0x17888 string Rar! \b, RAR self-extracting archive
  591. # Skip to the end of the EXE. This will usually work fine in the PE case
  592. # because the MZ image is hardcoded into the toolchain and almost certainly
  593. # won't match any of these signatures.
  594. >(4.s*512) long x
  595. >>&(2.s-517) byte x
  596. >>>&0 string PK\3\4 \b, ZIP self-extracting archive
  597. >>>&0 string Rar! \b, RAR self-extracting archive
  598. >>>&0 string =!\x11 \b, AIN 2.x self-extracting archive
  599. >>>&0 string =!\x12 \b, AIN 2.x self-extracting archive
  600. >>>&0 string =!\x17 \b, AIN 1.x self-extracting archive
  601. >>>&0 string =!\x18 \b, AIN 1.x self-extracting archive
  602. >>>&7 search/400 **ACE** \b, ACE self-extracting archive
  603. >>>&0 search/0x480 UC2SFX\ Header \b, UC2 self-extracting archive
  604. # a few unknown ZIP sfxes, no idea if they are needed or if they are
  605. # already captured by the generic patterns above
  606. >(8.s*16) search/0x20 PKSFX \b, ZIP self-extracting archive (PKZIP)
  607. # TODO: how to add this? >FileSize-34 string Windows\ Self-Installing\ Executable \b, ZIP self-extracting archive
  608. #
  609. # TELVOX Teleinformatica CODEC self-extractor for OS/2:
  610. >49801 string \x79\xff\x80\xff\x76\xff \b, CODEC archive v3.21
  611. >>49824 leshort =1 \b, 1 file
  612. >>49824 leshort >1 \b, %u files
  613. # Summary: OS/2 LX Library and device driver (no DOS stub)
  614. # From: Joerg Jenderek
  615. # URL: http://en.wikipedia.org/wiki/EXE
  616. # Reference: http://www.textfiles.com/programming/FORMATS/lxexe.txt
  617. # https://github.com/open-watcom/open-watcom-v2/blob/master/bld/watcom/h/exeflat.h
  618. # Note: by dll-os2-no-dos-stub.trid.xml called "OS/2 Dynamic Link Library (no DOS stub)"
  619. # TODO: unify with DOS stub variant (MZ magic)
  620. 0 string/b LX
  621. >2 ushort =0
  622. >>0 use lx-executable
  623. # no examples found for big endian variant
  624. >2 ushort =0x0101
  625. >>0 use \^lx-executable
  626. 0 name lx-executable
  627. # similar looking like variant with MS-DOS stub (MZ magic): "MS-DOS executable, LX"
  628. #>0x00 uleshort x executable,
  629. # signature OSF_FLAT_LX_SIGNATURE~0x584C~LX OSF_FLAT_SIGNATURE~0x454C~LE
  630. >0x00 uleshort =0x584c LX
  631. >0x00 uleshort =0x454C LE
  632. >0x00 uleshort x executable
  633. #!:mime application/x-msdownload
  634. !:mime application/x-lx-executable
  635. !:ext exe
  636. # byte order: 00h~little-endian non-zero=1~big-endian
  637. #>0x02 ubyte =0 (little-endian)
  638. >0x02 ubyte !0 (big-endian)
  639. # FOR DEBUGGING!
  640. # word order: 00h~little-endian non-zero=1~big-endian
  641. #>0x03 ubyte =0 \b, little-endian word order
  642. #>0x03 ubyte !0 \b, big-endian word order
  643. # cpu_type; CPU type like: 1~286 2~386 3~486 4 20h~i860 21h~Intel N11 40h~MIPS R2000,R3000 41h~MIPS R6000 42h~MIPS R4000
  644. #>0x08 uleshort x \b, CPU %u
  645. # os_type; target operating system like: 0~unknown 1~OS/2 2~Windows 3~DOS 4.x 4~Windows 386
  646. #>0x0A leshort x \b, OS %u
  647. # flags; module type flags
  648. #>0x10 ulelong x \b, FLAGS %#8.8x
  649. # 00000002h ~Reserved for system use
  650. #>0x10 ulelong &0x00000002 \b, 2h reserved
  651. # OSF_INIT_INSTANCE=00000004h ~Per-Process Library Initialization; setting this bit for EXE file is invalid
  652. #>0x10 ulelong &0x00000004 \b, per-process library Initialization
  653. # OSF_INTERNAL_FIXUPS_DONE=00000010h ~Internal fixups for the module have been applied
  654. #>0x10 ulelong &0x00000010 \b, int. fixup
  655. # OSF_EXTERNAL_FIXUPS_DONE=00000020h ~External fixups for the module have been applied
  656. #>0x10 ulelong &0x00000020 \b, ext. fixup
  657. # OSF_NOT_PM_COMPATIBLE=00000100h ~Incompatible with PM windowing
  658. #>0x10 ulelong&0x00000100 =0x00000100 \b, incompatible with PM windowing
  659. # OSF_PM_COMPATIBLE=00000200h ~Compatible with PM windowing
  660. #>0x10 ulelong&0x00000200 =0x00000200 \b, compatible with PM windowing
  661. # bit 17; device driver
  662. #>0x10 ulelong&0x00020000 >0 \b, device driver
  663. # Per-process Library Termination; setting this bit for EXE file is invalid
  664. #>0x10 ulelong&0x40000000 =0x40000000 \b, per-process library termination
  665. >0x0a leshort 1 for OS/2
  666. # no example found
  667. >0x0a leshort 3 for DOS
  668. # http://www.ctyme.com/intr/rb-2939.htm#Table1610
  669. # library by module type mask 00038000h (bits 15-17);
  670. # 0h ~executable Program module
  671. >0x10 ulelong&0x00038000 =0x00000000 (program)
  672. #!:ext exe
  673. # OSF_IS_DLL=8000h ~Library module (DLL)
  674. >0x10 ulelong&0x00038000 >0x00000000
  675. # OSF_PHYS_DEVICE=00020000h ~device driver
  676. >>0x10 ulelong&0x00020000 >0 (device driver)
  677. !:ext sys
  678. # if not device driver it is library (DLL)
  679. >>0x10 ulelong&0x00020000 =0 (library)
  680. !:ext dll
  681. # bits 8-10; OSF_PM_APP=300h in flags ~Uses PM windowing API; either it is GUI or console
  682. >0x10 ulelong&0x00000300 =0x00000300 (GUI)
  683. >0x10 ulelong&0x00000300 !0x00000300 (console)
  684. # CPU type
  685. >0x08 uleshort 1 i80286
  686. # all inspected examples
  687. >0x08 uleshort 2 i80386
  688. >0x08 uleshort 3 i80486
  689. >0x08 uleshort 4 i80586
  690. # 21h Intel "N11" or compatible
  691. # 40h MIPS Mark I ( R2000, R3000) or compatible
  692. # 41h MIPS Mark II ( R6000 ) or compatible
  693. # 42h MIPS Mark III ( R4000 ) or compatible
  694. # added by Joerg Jenderek of https://www.freedos.org/software/?prog=kc
  695. # and https://www.freedos.org/software/?prog=kpdos
  696. # for FreeDOS files like KEYBOARD.SYS, KEYBRD2.SYS, KEYBRD3.SYS, *.KBD
  697. 0 string/b KCF FreeDOS KEYBoard Layout collection
  698. # only version=0x100 found
  699. >3 uleshort x \b, version %#x
  700. # length of string containing author,info and special characters
  701. >6 ubyte >0
  702. #>>6 pstring x \b, name=%s
  703. >>7 string >\0 \b, author=%-.14s
  704. >>7 search/254 \xff \b, info=
  705. #>>>&0 string x \b%-s
  706. >>>&0 string x \b%-.15s
  707. # for FreeDOS *.KL files
  708. 0 string/b KLF FreeDOS KEYBoard Layout file
  709. # only version=0x100 or 0x101 found
  710. >3 uleshort x \b, version %#x
  711. # stringlength
  712. >5 ubyte >0
  713. >>8 string x \b, name=%-.2s
  714. 0 string \xffKEYB\ \ \ \0\0\0\0
  715. >12 string \0\0\0\0`\004\360 MS-DOS KEYBoard Layout file
  716. # DOS device driver updated by Joerg Jenderek at May 2011,Mar 2017,Aug 2020
  717. # URL: http://fileformats.archiveteam.org/wiki/DOS_device_driver
  718. # Reference: http://www.delorie.com/djgpp/doc/rbinter/it/46/16.html
  719. # https://amaus.net/static/S100/IBM/software/DOS/DOS%20techref/CHAPTER.009
  720. 0 ulequad&0x07a0ffffffff 0xffffffff
  721. # skip OS/2 INI ./os2
  722. >4 ubelong !0x14000000
  723. >>0 use msdos-driver
  724. 0 name msdos-driver DOS executable (
  725. #!:mime application/octet-stream
  726. !:mime application/x-dosdriver
  727. # also found FreeDOS print driver SPOOL.DEV and disc compression driver STACLOAD.BIN
  728. # and IBM Token-Ring adapter IBMTOK.DOS. Why and when DOS instead SYS is used?
  729. # PROTMAN.DOS ELNKPL.DOS
  730. !:ext sys/dev/bin/dos
  731. # 1 space char after "UPX compressed" to get phrase like "UPX compressed character device"
  732. >40 search/7 UPX! \bUPX compressed
  733. # DOS device driver attributes
  734. >4 uleshort&0x8000 0x0000 \bblock device driver
  735. # character device
  736. >4 uleshort&0x8000 0x8000 \b
  737. # 1 space char after "clock" to get phrase like "clock character device driver CLOCK$"
  738. >>4 uleshort&0x0008 0x0008 \bclock
  739. # fast video output by int 29h
  740. # 1 space char after "fast" to get phrase like "fast standard input/output character device driver"
  741. >>4 uleshort&0x0010 0x0010 \bfast
  742. # standard input/output device
  743. # 1 space char after "standard" to get phrase like "standard input/output character device driver"
  744. >>4 uleshort&0x0003 >0 \bstandard
  745. >>>4 uleshort&0x0001 0x0001 \binput
  746. >>>4 uleshort&0x0003 0x0003 \b/
  747. # 1 space char after "output" to get phrase like "input/output character device driver"
  748. >>>4 uleshort&0x0002 0x0002 \boutput
  749. >>4 uleshort&0x8000 0x8000 \bcharacter device driver
  750. >0 ubyte x
  751. # upx compressed device driver has garbage instead of real in name field of header
  752. >>40 search/7 UPX!
  753. >>40 default x
  754. # leading/trailing nulls, zeros or non ASCII characters in 8-byte name field at offset 10 are skipped
  755. # 1 space char before device driver name to get phrase like "device driver PROTMAN$"
  756. >>>12 ubyte >0x2E \b
  757. >>>>10 ubyte >0x20
  758. >>>>>10 ubyte !0x2E
  759. >>>>>>10 ubyte !0x2A \b%c
  760. >>>>11 ubyte >0x20
  761. >>>>>11 ubyte !0x2E \b%c
  762. >>>>12 ubyte >0x20
  763. >>>>>12 ubyte !0x39
  764. >>>>>>12 ubyte !0x2E \b%c
  765. >>>13 ubyte >0x20
  766. >>>>13 ubyte !0x2E \b%c
  767. >>>>14 ubyte >0x20
  768. >>>>>14 ubyte !0x2E \b%c
  769. >>>>15 ubyte >0x20
  770. >>>>>15 ubyte !0x2E \b%c
  771. >>>>16 ubyte >0x20
  772. >>>>>16 ubyte !0x2E
  773. >>>>>>16 ubyte <0xCB \b%c
  774. >>>>17 ubyte >0x20
  775. >>>>>17 ubyte !0x2E
  776. >>>>>>17 ubyte <0x90 \b%c
  777. # some character device drivers like ASPICD.SYS, btcdrom.sys and Cr_atapi.sys contain only spaces or points in name field
  778. >>>12 ubyte <0x2F
  779. # they have their real name at offset 22
  780. # also block device drivers like DUMBDRV.SYS
  781. >>>>22 string >\056 %-.6s
  782. >4 uleshort&0x8000 0x0000
  783. # 32 bit sector addressing ( > 32 MB) for block devices
  784. >>4 uleshort&0x0002 0x0002 \b,32-bit sector-
  785. # support by driver functions 13h, 17h, 18h
  786. >4 uleshort&0x0040 0x0040 \b,IOCTL-
  787. # open, close, removable media support by driver functions 0Dh, 0Eh, 0Fh
  788. >4 uleshort&0x0800 0x0800 \b,close media-
  789. # output until busy support by int 10h for character device driver
  790. >4 uleshort&0x8000 0x8000
  791. >>4 uleshort&0x2000 0x2000 \b,until busy-
  792. # direct read/write support by driver functions 03h,0Ch
  793. >4 uleshort&0x4000 0x4000 \b,control strings-
  794. >4 uleshort&0x8000 0x8000
  795. >>4 uleshort&0x6840 >0 \bsupport
  796. >4 uleshort&0x8000 0x0000
  797. >>4 uleshort&0x4842 >0 \bsupport
  798. >0 ubyte x \b)
  799. >0 ulelong !0xffffffff with pointer %#x
  800. # DOS driver cmd640x.sys has 0x12 instead of 0xffffffff for pointer field to next device header
  801. 0 ulequad 0x0513c00000000012
  802. >0 use msdos-driver
  803. # DOS drivers DC2975.SYS, DUMBDRV.SYS, ECHO.SYS has also none 0xffffffff for pointer field
  804. 0 ulequad 0x32f28000ffff0016
  805. >0 use msdos-driver
  806. 0 ulequad 0x007f00000000ffff
  807. >0 use msdos-driver
  808. # https://www.uwe-sieber.de/files/cfg_echo.zip
  809. 0 ulequad 0x001600000000ffff
  810. >0 use msdos-driver
  811. # DOS drivers LS120.SYS, MKELS120.SYS use reserved bits of attribute field
  812. 0 ulequad 0x0bf708c2ffffffff
  813. >0 use msdos-driver
  814. 0 ulequad 0x07bd08c2ffffffff
  815. >0 use msdos-driver
  816. # 3Com EtherLink 3C501 CID\SERVER\IBMLS\IBM500D1\DLSNETDR.ZIP\ELNK.DOS
  817. 0 ulequad 0x027ac0c0ffffffff
  818. >0 use msdos-driver
  819. # IBM Streamer CID\SERVER\IBMLS\IBM500D1\DLSNETDR.ZIP\IBMMPC.DOS
  820. 0 ulequad 0x00228880ffffffff
  821. >0 use msdos-driver
  822. # updated by Joerg Jenderek
  823. # GRR: line below too general as it catches also
  824. # rt.lib DYADISKS.PIC and many more
  825. # start with assembler instruction MOV
  826. 0 ubyte 0x8c
  827. # skip "AppleWorks word processor data" like ARTICLE.1 ./apple
  828. >4 string !O====
  829. # skip some unknown basic binaries like RocketRnger.SHR
  830. >>5 string !MAIN
  831. # skip "GPG symmetrically encrypted data" ./gnu
  832. # skip "PGP symmetric key encrypted data" ./pgp
  833. # openpgpdefs.h: fourth byte < 14 indicate cipher algorithm type
  834. >>>4 ubyte >13
  835. >>>>0 use msdos-com
  836. # the remaining files should be DOS *.COM executables
  837. # dosshell.COM 8cc0 2ea35f07 e85211 e88a11 b80058 cd
  838. # hmload.COM 8cc8 8ec0 bbc02b 89dc 83c30f c1eb04 b4
  839. # UNDELETE.COM 8cca 2e8916 6503 b430 cd21 8b 2e0200 8b
  840. # BOOTFIX.COM 8cca 2e8916 9603 b430 cd21 8b 2e0200 8b
  841. # RAWRITE3.COM 8cca 2e8916 d602 b430 cd21 8b 2e0200 8b
  842. # SHARE.COM 8cca 2e8916 d602 b430 cd21 8b 2e0200 8b
  843. # validchr.COM 8cca 2e8916 9603 b430 cd21 8b 2e028b1e
  844. # devload.COM 8cca 8916ad01 b430 cd21 8b2e0200 892e
  845. 0 name msdos-com
  846. # URL: http://fileformats.archiveteam.org/wiki/DOS_executable_(.com)
  847. >0 byte x DOS executable (
  848. # DOS executable with JuMP 16-bit instruction
  849. >0 byte =0xE9
  850. # check for probably nil padding til offset 64 of Lotus driver name
  851. >>56 quad =0
  852. # check for "long" alphabetic Lotus driver name like:
  853. # Diablo "COMPAQ Text Display" "IBM Monochrome Display" "Plantronics ColorPlus"
  854. >>>24 regex =^[A-Z][A-Za-z\040]{5,21} \bLotus driver) %s
  855. !:mime application/x-dosexec
  856. # like: CPQ0TD.DRV IBM0MONO.DRV (Lotus 123 10a) SDIAB4.DRV SPL0CPLS.DRV (Lotus Symphony 2)
  857. !:ext drv
  858. # COM with nils like MODE.COM IBMDOS.COM (pcdos 3.31 ru Compaq) RSSTUB.COM (PC-DOS 2000 de) ACCESS.COM (Lotus Symphony 1)
  859. >>>24 default x \bCOM)
  860. !:mime application/x-dosexec
  861. !:ext com
  862. # DOS executable with JuMP 16-bit and without nil padding
  863. >>56 quad !0
  864. # https://wiki.syslinux.org/wiki/index.php?title=Doc/comboot
  865. # TODO: HOWTO distinguish COMboot from pure DOS executables?
  866. # look for unreliable Syslinux specific api call INTerrupt 22h for 16-bit COMBOOT program
  867. >>>1 search/0xc088 \xcd\x22 \bCOM or COMBOOT 16-bit)
  868. !:mime application/x-dosexec
  869. # like: sbm.cbt command.com (Windows XP) UNI2ASCI.COM (FreeDOS 1.2)
  870. !:ext com/cbt
  871. >>>1 default x \bCOM)
  872. !:mime application/x-dosexec
  873. !:ext com
  874. # DOS executable without JuMP 16-bit instruction
  875. >0 byte !0xE9
  876. # SCREATE.SYS https://en.wikipedia.org/wiki/Stac_Electronics
  877. >>10 string =?STACVOL \bSCREATE.SYS)
  878. !:mime application/x-dosexec
  879. !:ext sys
  880. # COM executable without JuMP 16-bit instruction and not SCREATE.SYS
  881. >>10 string !?STACVOL \bCOM)
  882. !:mime application/x-dosexec
  883. !:ext com
  884. >6 string SFX\ of\ LHarc \b, %s
  885. >0x1FE leshort 0xAA55 \b, boot code
  886. >85 string UPX \b, UPX compressed
  887. >4 string \ $ARX \b, ARX self-extracting archive
  888. >4 string \ $LHarc \b, LHarc self-extracting archive
  889. >0x20e string SFX\ by\ LARC \b, LARC self-extracting archive
  890. # like: E30ODI.COM MADGEODI.COM UNI2ASCI.COM RECOVER.COM (DOS 2) COMMAND.COM (DOS 2)
  891. >1 search/0xc088 \xcd\x22 \b, maybe with interrupt 22h
  892. >0 ubelong x \b, start instruction %#8.8x
  893. # show more instructions but not in samples like: rem.com (DJGPP)
  894. >4 ubelong x %8.8x
  895. # JMP 8bit
  896. 0 byte 0xeb
  897. # byte 0xeb conflicts with magic leshort 0xn2eb of "SYMMETRY i386" handled by ./sequent
  898. # allow forward jumps only
  899. >1 byte >-1
  900. # that offset must be accessible
  901. # with hexadecimal values like: 0e 2e 50 8c 8d ba bc bd be e8 fb fc
  902. >>(1.b+2) byte x
  903. # if look like COM executable with x86 boot signature then this
  904. # implies FAT volume with x86 real mode code already handled by ./filesystems
  905. #
  906. # No x86 boot signature implies often DOS executable
  907. # check for unrealistic high number of FATs. Then it is an unusual disk image or often a DOS executable
  908. # like: FIXBIOS.COM (50 bytes)
  909. >>>16 ubyte >3
  910. # https://www.drivedroid.io/
  911. # skip MBR disk image drivedroid.img version 12 July 2013 by start message
  912. >>>>2 string !DriveDroid
  913. # ftp://old-dos.ru/OSCollect/OS/MS-DOS/Final Releases/
  914. # skip unusual floppy image disk1.img of MS-DOS 1.25 (Corona Data Systems OEM)
  915. # by check for characteristic message text near the beginning
  916. >>>>>15 string !Non\040System\040disk
  917. # "ftp://old-dos.ru/OSCollect/OS/BeOS/BeOS 4.0.rar"
  918. # skip BeOS 4 bootfloppy.img done as "Linux kernel x86 boot executable" by ./linux
  919. # by check for characteristic message text near the beginning
  920. >>>>>>6 string !read\040error\015
  921. # https://github.com/ventoy/Ventoy/releases/download/v1.0.78/ventoy-1.0.78-windows.zip
  922. # skip ventoy 1.0.78 boot_hybrid.img
  923. >>>>>>>24 string !\220\220\353I$\022\017
  924. # "ftp://old-dos.ru/OSCollect/OS/MS-DOS/Final Releases/PC-DOS 1.0 (5.25).rar"
  925. # skip unusual floppy image PCDOS100.IMG of DOS 1.0
  926. # by check for characteristic message text near the beginning
  927. >>>>>>>>9 string !7-May-81
  928. # "ftp://old-dos.ru/OSCollect/OS/BeOS/BeOS 5.0 Personal (BA).rar"
  929. # skip BeOS 5 floppy_1.44.00.ima done as "DOS/MBR boot sector" by ./filesystems
  930. # by check for characteristic message near the beginning
  931. >>>>>>>>>3 string !\370sdfS\270
  932. # like: FIXBIOS.COM (50 bytes)
  933. >>>>>>>>>>0 use msdos-com
  934. # check for unrealistic low number of FATs. Then it is an unusual FAT disk image or often a DOS executable
  935. # like: DEVICE.COM INSTALL.COM (GAG 4.10) WORD.COM (Word 1.15)
  936. >>>16 ubyte =0
  937. # if low FATs with x86 boot signature it can be unusual disk image like: boot.img (Ventoy 1.0.27) geodspms.img (Syslinux)
  938. >>>>0x1FE leshort =0xAA55
  939. >>>>0x1FE default x
  940. # https://thestarman.pcministry.com/tool/hxd/dimtut.htm
  941. # skip unusual floppy image TK-DOS11.img IBMDOS11.img of IBM DOS 1.10
  942. # by check for characteristic bootloader names near end of boot sector
  943. >>>>>395 string !ibmbio\040\040com
  944. >>>>>>0 use msdos-com
  945. # 8-bit jump with valid number of FAT implies FAT volume already handled by ./filesystems
  946. # like: balder.img
  947. >>>16 default x
  948. # skip disk images with boot signature at end of 1st sector
  949. # like: TDSK-64b.img
  950. >>>>(11.s-2) uleshort !0xAA55
  951. # skip unusual floppy image without boot signature like 360k-256.img (mtools 4.0.18)
  952. # by check for characteristic file system type text for FAT (12 bit or 16 bit)
  953. >>>>>54 string !FAT
  954. # "ftp://old-dos.ru/OSCollect/OS/MS-DOS/Final Releases/Microsoft MS-DOS 3.31 (Compaq OEM) (3.5).rar"
  955. # skip unusual floppy image Disk4.img without boot signature and file system type text
  956. # by check for characteristic OEM-ID text
  957. >>>>>>3 string !COMPAQ\040\040
  958. # no such DOS COM executables found
  959. >>>>>>>0 use msdos-com
  960. # JMP 16bit
  961. 0 byte 0xe9
  962. # 16-bit offset; for DEBUGGING!; can be negative like: USBDRIVE.COM
  963. #>1 leshort x \b, OFFSET %d
  964. # forward jumps
  965. >1 leshort >-1
  966. # that offset must be accessible
  967. # with hexadecimal values like: 06 1e 0e 2e 60 8c 8d b4 ba be e8 fc
  968. >>(1.s+3) byte x
  969. # check for unrealistic high number of FATs. Then it is not a disk image and it is a DOS executable
  970. # like: CALLVER.COM CPUCACHE.COM K437_EUR.COM SHSUCDX.COM UMBFILL.COM (183 bytes)
  971. >>>16 ubyte >3
  972. >>>>0 use msdos-com
  973. # check for unrealistic low number of FATs. Then it is not a disk image and it is a DOS executable
  974. # like: GAG.COM DRMOUSE.COM NDN.COM CPQ0TD.DRV
  975. >>>16 ubyte =0
  976. >>>>0 use msdos-com
  977. # maybe disc image with valid number of FATs or DOS executable
  978. # like: IPXODI.COM PERUSE.COM TASKID.COM
  979. >>>16 default x
  980. # invalid low media descriptor. Then it is not a disk image and it is a DOS executable
  981. >>>>21 ubyte <0xE5
  982. >>>>>0 use msdos-com
  983. # valid media descriptor. Then it is maybe disk image or DOS executable
  984. >>>>21 ubyte >0xE4
  985. # invalid sectorsize not a power of 2 from 32-32768. Then it is not a disk image and it must be DOS executable
  986. # like: LEARN.COM (Word 1.15)
  987. >>>>>11 uleshort&0x001f !0
  988. >>>>>>0 use msdos-com
  989. # negative offset, must not lead into PSP
  990. # like: BASICA.COM (PC dos 3.20) FORMAT.COM SMC8100.COM WORD.COM (word4)
  991. # HIDSUPT1.COM USBDRIVE.COM USBSUPT1.COM USBUHCI.COM (FreeDOS USBDOS)
  992. >1 leshort <-259
  993. # that offset must be accessible
  994. # add 10000h to jump at end of 64 KiB segment, add 1 for jump instruction and 2 for 16-bit offset
  995. >>(1,s+65539) byte x
  996. # after jump next instruction for DEBUGGING!
  997. #>>>&-1 ubelong x \b, NEXT instruction %#8.8x
  998. >>>0 use msdos-com
  999. # updated by Joerg Jenderek at Oct 2008,2015,2022
  1000. # following line is too general
  1001. 0 ubyte 0xb8
  1002. # skip 2 linux kernels like memtest.bin with "\xb8\xc0\x07\x8e" in ./linux
  1003. >0 string !\xb8\xc0\x07\x8e
  1004. # modified by Joerg Jenderek
  1005. # syslinux COM32 or COM32R executable
  1006. >>1 lelong&0xFFFFFFFe 0x21CD4CFe COM executable (32-bit COMBOOT
  1007. # https://www.syslinux.org/wiki/index.php/Comboot_API
  1008. # Since version 5.00 c32 modules switched from the COM32 object format to ELF
  1009. !:mime application/x-c32-comboot-syslinux-exec
  1010. !:ext c32
  1011. # https://syslinux.zytor.com/comboot.php
  1012. # older syslinux version ( <4 )
  1013. # (32-bit COMBOOT) programs *.C32 contain 32-bit code and run in flat-memory 32-bit protected mode
  1014. # start with assembler instructions mov eax,21cd4cffh
  1015. >>>1 lelong 0x21CD4CFf \b)
  1016. # syslinux:doc/comboot.txt
  1017. # A COM32R program must start with the byte sequence B8 FE 4C CD 21 (mov
  1018. # eax,21cd4cfeh) as a magic number.
  1019. # syslinux version (4.x)
  1020. # "COM executable (COM32R)" or "Syslinux COM32 module" by TrID
  1021. >>>1 lelong 0x21CD4CFe \b, relocatable)
  1022. >>1 default x
  1023. # look for interrupt instruction like in rem.com (DJGPP) LOADER.COM (DR-DOS 7.x)
  1024. >>>3 search/118 \xCD
  1025. # FOR DEBUGGING; possible hexadecimal interrupt number like: 10~BANNER.COM 13~bcdw_cl.com 15~poweroff.com (Syslinux)
  1026. # 1A~BERNDPCI.COM 20~SETENHKB.COM 21~mostly 22~gfxboot.com (Syslinux) 2F~SHUTDOWN.COM (GEMSYS)
  1027. #>>>>&0 ubyte x \b, INTERUPT %#x
  1028. # few examples with interrupt 0x13 instruction
  1029. >>>>&0 ubyte =0x13
  1030. # FOR DEBUGGING!
  1031. #>>>>>3 ubequad x \b, 2nd INSTRUCTION %#16.16llx
  1032. # skip Gpt.com Mbr.com (edk2-UDK2018 bootsector) described as "DOS/MBR boot sector" by ./filesystems
  1033. # by check for assembler instructions: mov es,ax ; mov ax,07c0h ; mov ds,ax
  1034. >>>>>3 ubequad !0x8ec0b8c0078ed88d
  1035. # few COM executables with interrupt 0x13 instruction like: Bootable CD Wizard executables bcdw_cl.com fdemuoff.com
  1036. # http://bootcd.narod.ru/bcdw150z_en.zip
  1037. >>>>>>0 use msdos-com
  1038. # few examples with interrupt 0x16 instruction like flashimg.img
  1039. >>>>&0 ubyte =0x16
  1040. # skip Syslinux 3.71 flashimg.img done as "DOS/MBR boot sector" by ./filesystems
  1041. # by check for assembler instructions: cmp ax 0xE4E4 (magic); jnz
  1042. >>>>>8 ubelong !0x3DE4E475
  1043. # no DOS executable with interrupt 0x16 found
  1044. >>>>>>0 use msdos-com
  1045. # most examples with interrupt instruction unequal 0x13 and 0x16
  1046. >>>>&0 default x
  1047. #>>>>>&-1 ubyte x \b, INTERUPT %#x
  1048. # like: LOADER.COM SETENHKB.COM banner.com copybs.com gif2raw.com poweroff.com rem.com
  1049. >>>>>0 use msdos-com
  1050. # few COM executables without interrupt instruction like RESTART.COM (DOS 7.10) REBOOT.COM
  1051. # or some EUC-KR text files or one Ulead Imaginfo thumbnail
  1052. >>>3 default x
  1053. # FOR DEBUGGING; 2nd instruction like 0x50 (RESTART.COM) 0x8e (REBOOT.COM)
  1054. # or random like: 0x0 (IMAGINFO.PE3 sky_snow) 0xb1 (euckr_.txt)
  1055. #>>>>3 ubyte x \b, 2nd INSTRUCTION %#x
  1056. # skip 1 Ulead Imaginfo thumbnail (IMAGINFO.PE3 sky_snow)
  1057. # inside SAMPLES/TEXTURES/SKY_SNOW
  1058. # from https://archive.org/download/PI3CANON/PI3CANON.iso
  1059. >>>>3 ubyte !0x0
  1060. # skip some EUC-KR text files like: euckr_falsepositive.txt
  1061. # https://bugs.astron.com/view.php?id=186
  1062. >>>>>3 ubyte !0xb1
  1063. # like: RESTART.COM (DOS 7.10) REBOOT.COM
  1064. >>>>>>0 use msdos-com
  1065. # URL: https://en.wikipedia.org/wiki/UPX
  1066. # Reference: https://github.com/upx/upx/archive/v3.96.zip/upx-3.96/
  1067. # src/stub/src/i086-dos16.com.S
  1068. # Update: Joerg Jenderek
  1069. # assembler instructions: cmp sp, offset sp_limit
  1070. 0 string/b \x81\xfc
  1071. #>2 uleshort x \b, sp_limit=%#x
  1072. # assembler instructions: jump above +2; int 0x20; mov cx, offset bytes_to_copy
  1073. >4 string \x77\x02\xcd\x20\xb9
  1074. #>9 uleshort x \b, [bytes_to_copy]=%#x
  1075. # at different offsets assembler instructions: push di; jump decomp_start_n2b
  1076. >0x1e search/3 \x57\xe9
  1077. #>>&0 uleshort x \b, decomp_start_n2b=%#x
  1078. # src/stub/src/include/header.S; UPX_MAGIC_LE32
  1079. >>&2 string UPX! FREE-DOS executable (COM), UPX
  1080. !:mime application/x-dosexec
  1081. # UPX compressed *.CPI; See ./fonts
  1082. >>>&21 string =FONT compressed DOS code page font
  1083. !:ext cpx
  1084. >>>&21 string !FONT compressed
  1085. !:ext com
  1086. # compressed size?
  1087. #>>>&14 uleshort+152 x \b, %u bytes
  1088. # uncompressed len
  1089. >>>&12 uleshort x \b, uncompressed %u bytes
  1090. 252 string Must\ have\ DOS\ version DR-DOS executable (COM)
  1091. !:mime application/x-dosexec
  1092. !:ext com
  1093. # GRR search is not working
  1094. #2 search/28 \xcd\x21 COM executable for MS-DOS
  1095. #WHICHFAT.cOM
  1096. 2 string \xcd\x21 COM executable for DOS
  1097. !:mime application/x-dosexec
  1098. !:ext com
  1099. #DELTREE.cOM DELTREE2.cOM
  1100. 4 string \xcd\x21 COM executable for DOS
  1101. !:mime application/x-dosexec
  1102. !:ext com
  1103. #IFMEMDSK.cOM ASSIGN.cOM COMP.cOM
  1104. 5 string \xcd\x21 COM executable for DOS
  1105. !:mime application/x-dosexec
  1106. !:ext com
  1107. #DELTMP.COm HASFAT32.cOM
  1108. 7 string \xcd\x21
  1109. >0 byte !0xb8 COM executable for DOS
  1110. !:mime application/x-dosexec
  1111. !:ext com
  1112. #COMP.cOM MORE.COm
  1113. 10 string \xcd\x21
  1114. >5 string !\xcd\x21 COM executable for DOS
  1115. !:mime application/x-dosexec
  1116. !:ext com
  1117. #comecho.com
  1118. 13 string \xcd\x21 COM executable for DOS
  1119. !:mime application/x-dosexec
  1120. !:ext com
  1121. #HELP.COm EDIT.coM
  1122. 18 string \xcd\x21
  1123. # not printable before it?
  1124. >17 byte >32
  1125. >>17 byte <126
  1126. >>17 default x COM executable for MS-DOS
  1127. !:mime application/x-dosexec
  1128. !:ext com
  1129. #NWRPLTRM.COm
  1130. 23 string \xcd\x21 COM executable for MS-DOS
  1131. !:mime application/x-dosexec
  1132. !:ext com
  1133. #LOADFIX.cOm LOADFIX.cOm
  1134. 30 string \xcd\x21 COM executable for MS-DOS
  1135. !:mime application/x-dosexec
  1136. !:ext com
  1137. #syslinux.com 3.11
  1138. 70 string \xcd\x21 COM executable for DOS
  1139. !:mime application/x-dosexec
  1140. !:ext com
  1141. # many compressed/converted COMs start with a copy loop instead of a jump
  1142. 0x6 search/0xa \xfc\x57\xf3\xa5\xc3 COM executable for MS-DOS
  1143. !:mime application/x-dosexec
  1144. !:ext com
  1145. 0x6 search/0xa \xfc\x57\xf3\xa4\xc3 COM executable for DOS
  1146. !:mime application/x-dosexec
  1147. !:ext com
  1148. >0x18 search/0x10 \x50\xa4\xff\xd5\x73 \b, aPack compressed
  1149. 0x3c string W\ Collis\0\0 COM executable for MS-DOS, Compack compressed
  1150. !:mime application/x-dosexec
  1151. !:ext com
  1152. # FIXME: missing diet .com compression
  1153. # miscellaneous formats
  1154. 0 string/b LZ MS-DOS executable (built-in)
  1155. #0 byte 0xf0 MS-DOS program library data
  1156. #
  1157. # AAF files:
  1158. # <stuartc@rd.bbc.co.uk> Stuart Cunningham
  1159. 0 string/b \320\317\021\340\241\261\032\341AAFB\015\000OM\006\016\053\064\001\001\001\377 AAF legacy file using MS Structured Storage
  1160. >30 byte 9 (512B sectors)
  1161. >30 byte 12 (4kB sectors)
  1162. 0 string/b \320\317\021\340\241\261\032\341\001\002\001\015\000\002\000\000\006\016\053\064\003\002\001\001 AAF file using MS Structured Storage
  1163. >30 byte 9 (512B sectors)
  1164. >30 byte 12 (4kB sectors)
  1165. # Popular applications
  1166. #
  1167. # Update: Joerg Jenderek
  1168. # URL: http://fileformats.archiveteam.org/wiki/DOC
  1169. # Reference: https://web.archive.org/web/20170206041048/
  1170. # http://www.msxnet.org/word2rtf/formats/ffh-dosword5
  1171. # wIdent+dty
  1172. 0 belong 0x31be0000
  1173. # skip droid skeleton like x-fmt-274-signature-id-488.doc
  1174. >128 ubyte >0 Microsoft
  1175. >>96 uleshort =0 Word
  1176. !:mime application/msword
  1177. !:apple MSWDWDBN
  1178. # DCX is used in the Unix version.
  1179. !:ext doc/dcx
  1180. >>>0x6E ulequad =0 1.0-4.0
  1181. >>>0x6E ulequad !0 5.0-6.0
  1182. >>>0x6E ulequad x (DOS) Document
  1183. # https://web.archive.org/web/20130831064118/http://msxnet.org/word2rtf/formats/write.txt
  1184. >>96 uleshort !0 Write 3.0 (Windows) Document
  1185. !:mime application/x-mswrite
  1186. !:apple MSWDWDBN
  1187. # sometimes also doc like in splitter.doc srchtest.doc
  1188. !:ext wri/doc
  1189. # wTool must be 0125400 octal
  1190. #>>4 uleshort !0xAB00 \b, wTool %o
  1191. # reserved; must be zero
  1192. #>>6 ulelong !0 \b, reserved %u
  1193. # block pointer to the block containing optional file manager information
  1194. #>>0x1C uleshort x \b, at %#x info block
  1195. # jump to File manager information block
  1196. >>(0x1C.s*128) uleshort x
  1197. # test for valid information start; maybe also 0012h
  1198. >>>&-2 uleshort =0x0014
  1199. # Document ASCIIZ name
  1200. >>>>&0x12 string x %s
  1201. # author name
  1202. >>>>>&1 string x \b, author %s
  1203. # reviser name
  1204. >>>>>>&1 string x \b, reviser %s
  1205. # keywords
  1206. >>>>>>>&1 string x \b, keywords %s
  1207. # comment
  1208. >>>>>>>>&1 string x \b, comment %s
  1209. # version number
  1210. >>>>>>>>>&1 string x \b, version %s
  1211. # date of last change MM/DD/YY
  1212. >>>>>>>>>>&1 string x \b, %-.8s
  1213. # creation date MM/DD/YY
  1214. >>>>>>>>>>&9 string x created %-.8s
  1215. # file name of print format like NORMAL.STY
  1216. >>0x1E string >0 \b, formatted by %-.66s
  1217. # count of pages in whole file for write variant; maybe some times wrong
  1218. >>96 uleshort >0 \b, %u pages
  1219. # name of the printer driver like HPLASMS
  1220. >>0x62 string >0 \b, %-.8s printer
  1221. # number of blocks used in the file; seems to be 0 for Word 4.0 and Write 3.0
  1222. >>0x6A uleshort >0 \b, %u blocks
  1223. # bit field for corrected text areas
  1224. #>>0x6C uleshort x \b, %#x bit field
  1225. # text of document; some times start with 4 non printable characters like CR LF
  1226. >>128 ubyte x \b,
  1227. >>>128 ubyte >0x1F
  1228. >>>>128 string x %s
  1229. >>>128 ubyte <0x20
  1230. >>>>129 ubyte >0x1F
  1231. >>>>>129 string x %s
  1232. >>>>129 ubyte <0x20
  1233. >>>>>130 ubyte >0x1F
  1234. >>>>>>130 string x %s
  1235. >>>>>130 ubyte <0x20
  1236. >>>>>>131 ubyte >0x1F
  1237. >>>>>>>131 string x %s
  1238. >>>>>>131 ubyte <0x20
  1239. >>>>>>>132 ubyte >0x1F
  1240. >>>>>>>>132 string x %s
  1241. >>>>>>>132 ubyte <0x20
  1242. >>>>>>>>133 ubyte >0x1F
  1243. >>>>>>>>>133 string x %s
  1244. #
  1245. 0 string/b PO^Q` Microsoft Word 6.0 Document
  1246. !:mime application/msword
  1247. #
  1248. 4 long 0
  1249. >0 belong 0xfe320000 Microsoft Word for Macintosh 1.0
  1250. !:mime application/msword
  1251. !:ext mcw
  1252. >0 belong 0xfe340000 Microsoft Word for Macintosh 3.0
  1253. !:mime application/msword
  1254. !:ext mcw
  1255. >0 belong 0xfe37001c Microsoft Word for Macintosh 4.0
  1256. !:mime application/msword
  1257. !:ext mcw
  1258. >0 belong 0xfe370023 Microsoft Word for Macintosh 5.0
  1259. !:mime application/msword
  1260. !:ext mcw
  1261. 0 string/b \333\245-\0\0\0 Microsoft Word 2.0 Document
  1262. !:mime application/msword
  1263. !:ext doc
  1264. # Note: seems already recognized as "OLE 2 Compound Document" in ./ole2compounddocs
  1265. #512 string/b \354\245\301 Microsoft Word Document
  1266. #!:mime application/msword
  1267. #
  1268. 0 string/b \xDB\xA5\x2D\x00 Microsoft WinWord 2.0 Document
  1269. !:mime application/msword
  1270. #
  1271. 0 string/b \xDB\xA5\x2D\x00 Microsoft WinWord 2.0 Document
  1272. !:mime application/msword
  1273. #
  1274. 0 string/b \x09\x04\x06\x00\x00\x00\x10\x00 Microsoft Excel Worksheet
  1275. !:mime application/vnd.ms-excel
  1276. # https://www.macdisk.com/macsigen.php
  1277. !:apple XCELXLS4
  1278. !:ext xls
  1279. #
  1280. # Update: Joerg Jenderek
  1281. # URL: https://en.wikipedia.org/wiki/Lotus_1-2-3
  1282. # Reference: http://www.aboutvb.de/bas/formate/pdf/wk3.pdf
  1283. # Note: newer Lotus versions >2 use longer BOF record
  1284. # record type (BeginningOfFile=0000h) + length (001Ah)
  1285. 0 belong 0x00001a00
  1286. # reserved should be 0h but 8c0dh for TUTMAC.WK3, 5h for SAMPADNS.WK3, 1h for a_readme.wk3, 1eh for K&G86.WK3
  1287. #>18 uleshort&0x73E0 0
  1288. # Lotus Multi Byte Character Set (LMBCS=1-31)
  1289. >20 ubyte >0
  1290. >>20 ubyte <32 Lotus 1-2-3
  1291. #!:mime application/x-123
  1292. !:mime application/vnd.lotus-1-2-3
  1293. !:apple ????L123
  1294. # (version 5.26) labeled the entry as "Lotus 1-2-3 wk3 document data"
  1295. >>>4 uleshort 0x1000 WorKsheet, version 3
  1296. !:ext wk3
  1297. # (version 5.26) labeled the entry as "Lotus 1-2-3 wk4 document data"
  1298. >>>4 uleshort 0x1002 WorKsheet, version 4
  1299. # also worksheet template 4 (.wt4)
  1300. !:ext wk4/wt4
  1301. # no example or documentation for wk5
  1302. #>>4 uleshort 0x???? WorKsheet, version 4
  1303. #!:ext wk5
  1304. # only MacrotoScript.123 example
  1305. >>>4 uleshort 0x1003 WorKsheet, version 97
  1306. # also worksheet template Smartmaster (.12M)?
  1307. !:ext 123
  1308. # only Set_Y2K.123 example
  1309. >>>4 uleshort 0x1005 WorKsheet, version 9.8 Millennium
  1310. !:ext 123
  1311. # no example for this version
  1312. >>>4 uleshort 0x8001 FoRMatting data
  1313. !:ext frm
  1314. # (version 5.26) labeled the entry as "Lotus 1-2-3 fm3 or fmb document data"
  1315. # TrID labeles the entry as "Formatting Data for Lotus 1-2-3 worksheet"
  1316. >>>4 uleshort 0x8007 ForMatting data, version 3
  1317. !:ext fm3
  1318. >>>4 default x unknown
  1319. # file revision sub code 0004h for worksheets
  1320. >>>>6 uleshort =0x0004 worksheet
  1321. !:ext wXX
  1322. >>>>6 uleshort !0x0004 formatting data
  1323. !:ext fXX
  1324. # main revision number
  1325. >>>>4 uleshort x \b, revision %#x
  1326. >>>6 uleshort =0x0004 \b, cell range
  1327. # active cellcoord range (start row, page,column ; end row, page, column)
  1328. # start values normally 0~1st sheet A1
  1329. >>>>8 ulelong !0
  1330. >>>>>10 ubyte >0 \b%d*
  1331. >>>>>8 uleshort x \b%d,
  1332. >>>>>11 ubyte x \b%d-
  1333. # end page mostly 0
  1334. >>>>14 ubyte >0 \b%d*
  1335. # end raw, column normally not 0
  1336. >>>>12 uleshort x \b%d,
  1337. >>>>15 ubyte x \b%d
  1338. # Lotus Multi Byte Character Set (1~cp850,2~cp851,...,16~japan,...,31~??)
  1339. >>>>20 ubyte >1 \b, character set %#x
  1340. # flags
  1341. >>>>21 ubyte x \b, flags %#x
  1342. >>>6 uleshort !0x0004
  1343. # record type (FONTNAME=00AEh)
  1344. >>>>30 search/29 \0\xAE
  1345. # variable length m (2) + entries (1) + ?? (1) + LCMBS string (n)
  1346. >>>>>&4 string >\0 \b, 1st font "%s"
  1347. #
  1348. # Update: Joerg Jenderek
  1349. # URL: http://fileformats.archiveteam.org/wiki/Lotus_1-2-3
  1350. # Reference: http://www.schnarff.com/file-formats/lotus-1-2-3/WSFF2.TXT
  1351. # Note: Used by both old Lotus 1-2-3 and Lotus Symphony (DOS) til version 2.x
  1352. # record type (BeginningOfFile=0000h) + length (0002h)
  1353. 0 belong 0x00000200
  1354. # GRR: line above is too general as it catches also MS Windows CURsor
  1355. # to display MS Windows cursor (strength=70) before Lotus 1-2-3 (strength=70-1)
  1356. !:strength -1
  1357. # skip Windows cursors with image height <256 and keep Lotus with low opcode 0001-0083h
  1358. >7 ubyte 0
  1359. # skip Windows cursors with image width 256 and keep Lotus with positive opcode
  1360. >>6 ubyte >0 Lotus
  1361. # !:mime application/x-123
  1362. !:mime application/vnd.lotus-1-2-3
  1363. !:apple ????L123
  1364. # revision number (0404h = 123 1A, 0405h = Lotus Symphony , 0406h = 123 2.x wk1 , 8006h = fmt , ...)
  1365. # undocumented; (version 5.26) labeled the configurations as "Lotus 1-2-3"
  1366. >>>4 uleshort 0x0007 1-2-3 CoNFiguration, version 2.x (PGRAPH.CNF)
  1367. !:ext cnf
  1368. >>>4 uleshort 0x0C05 1-2-3 CoNFiguration, version 2.4J
  1369. !:ext cnf
  1370. >>>4 uleshort 0x0801 1-2-3 CoNFiguration, version 1-2.1
  1371. !:ext cnf
  1372. >>>4 uleshort 0x0802 Symphony CoNFiguration
  1373. !:ext cnf
  1374. >>>4 uleshort 0x0804 1-2-3 CoNFiguration, version 2.2
  1375. !:ext cnf
  1376. >>>4 uleshort 0x080A 1-2-3 CoNFiguration, version 2.3-2.4
  1377. !:ext cnf
  1378. >>>4 uleshort 0x1402 1-2-3 CoNFiguration, version 3.x
  1379. !:ext cnf
  1380. >>>4 uleshort 0x1450 1-2-3 CoNFiguration, version 4.x
  1381. !:ext cnf
  1382. # (version 5.26) labeled the entry as "Lotus 123"
  1383. # TrID labeles the entry as "Lotus 123 Worksheet (generic)"
  1384. >>>4 uleshort 0x0404 1-2-3 WorKSheet, version 1
  1385. # extension "wks" also for Microsoft Works document
  1386. !:ext wks
  1387. # (version 5.26) labeled the entry as "Lotus 123"
  1388. # TrID labeles the entry as "Lotus 123 Worksheet (generic)"
  1389. >>>4 uleshort 0x0405 Symphony WoRksheet, version 1.0
  1390. !:ext wrk/wr1
  1391. # (version 5.26) labeled the entry as "Lotus 1-2-3 wk1 document data"
  1392. # TrID labeles the entry as "Lotus 123 Worksheet (V2)"
  1393. >>>4 uleshort 0x0406 1-2-3/Symphony worksheet, version 2
  1394. # Symphony (.wr1)
  1395. !:ext wk1/wr1
  1396. # no example for this japan version
  1397. >>>4 uleshort 0x0600 1-2-3 WorKsheet, version 1.xJ
  1398. !:ext wj1
  1399. # no example or documentation for wk2
  1400. #>>>4 uleshort 0x???? 1-2-3 WorKsheet, version 2
  1401. #!:ext wk2
  1402. # undocumented japan version
  1403. >>>4 uleshort 0x0602 1-2-3 worksheet, version 2.4J
  1404. !:ext wj3
  1405. # (version 5.26) labeled the entry as "Lotus 1-2-3 fmt document data"
  1406. >>>4 uleshort 0x8006 1-2-3 ForMaTting data, version 2.x
  1407. # japan version 2.4J (fj3)
  1408. !:ext fmt/fj3
  1409. # no example for this version
  1410. >>>4 uleshort 0x8007 1-2-3 FoRMatting data, version 2.0
  1411. !:ext frm
  1412. # (version 5.26) labeled the entry as "Lotus 1-2-3"
  1413. >>>4 default x unknown worksheet or configuration
  1414. !:ext cnf
  1415. >>>>4 uleshort x \b, revision %#x
  1416. # 2nd record for most worksheets describes cells range
  1417. >>>6 use lotus-cells
  1418. # 3rd record for most japan worksheets describes cells range
  1419. >>>(8.s+10) use lotus-cells
  1420. # check and then display Lotus worksheet cells range
  1421. 0 name lotus-cells
  1422. # look for type (RANGE=0006h) + length (0008h) at record begin
  1423. >0 ubelong 0x06000800 \b, cell range
  1424. # cell range (start column, row, end column, row) start values normally 0,0~A1 cell
  1425. >>4 ulong !0
  1426. >>>4 uleshort x \b%d,
  1427. >>>6 uleshort x \b%d-
  1428. # end of cell range
  1429. >>8 uleshort x \b%d,
  1430. >>10 uleshort x \b%d
  1431. # EndOfLotus123
  1432. 0 string/b WordPro\0 Lotus WordPro
  1433. !:mime application/vnd.lotus-wordpro
  1434. 0 string/b WordPro\r\373 Lotus WordPro
  1435. !:mime application/vnd.lotus-wordpro
  1436. # Summary: Script used by InstallScield to uninstall applications
  1437. # Extension: .isu
  1438. # Submitted by: unknown
  1439. # Modified by (1): Abel Cheung <abelcheung@gmail.com> (replace useless entry)
  1440. 0 string \x71\xa8\x00\x00\x01\x02
  1441. >12 string Stirling\ Technologies, InstallShield Uninstall Script
  1442. # Winamp .avs
  1443. #0 string Nullsoft\ AVS\ Preset\ \060\056\061\032 A plug in for Winamp ms-windows Freeware media player
  1444. 0 string/b Nullsoft\ AVS\ Preset\ Winamp plug in
  1445. # Windows Metafile .WMF
  1446. 0 string/b \327\315\306\232 Windows metafile
  1447. !:mime image/wmf
  1448. !:ext wmf
  1449. 0 string/b \002\000\011\000 Windows metafile
  1450. !:mime image/wmf
  1451. !:ext wmf
  1452. 0 string/b \001\000\011\000 Windows metafile
  1453. !:mime image/wmf
  1454. !:ext wmf
  1455. #tz3 files whatever that is (MS Works files)
  1456. 0 string/b \003\001\001\004\070\001\000\000 tz3 ms-works file
  1457. 0 string/b \003\002\001\004\070\001\000\000 tz3 ms-works file
  1458. 0 string/b \003\003\001\004\070\001\000\000 tz3 ms-works file
  1459. # PGP sig files .sig
  1460. #0 string \211\000\077\003\005\000\063\237\127 065 to \027\266\151\064\005\045\101\233\021\002 PGP sig
  1461. 0 string \211\000\077\003\005\000\063\237\127\065\027\266\151\064\005\045\101\233\021\002 PGP sig
  1462. 0 string \211\000\077\003\005\000\063\237\127\066\027\266\151\064\005\045\101\233\021\002 PGP sig
  1463. 0 string \211\000\077\003\005\000\063\237\127\067\027\266\151\064\005\045\101\233\021\002 PGP sig
  1464. 0 string \211\000\077\003\005\000\063\237\127\070\027\266\151\064\005\045\101\233\021\002 PGP sig
  1465. 0 string \211\000\077\003\005\000\063\237\127\071\027\266\151\064\005\045\101\233\021\002 PGP sig
  1466. 0 string \211\000\225\003\005\000\062\122\207\304\100\345\042 PGP sig
  1467. # windows zips files .dmf
  1468. 0 string/b MDIF\032\000\010\000\000\000\372\046\100\175\001\000\001\036\001\000 MS Windows special zipped file
  1469. # Windows icons
  1470. # Update: Joerg Jenderek
  1471. # URL: https://en.wikipedia.org/wiki/CUR_(file_format)
  1472. # Note: similar to Windows CURsor. container for BMP (only DIB part) or PNG
  1473. 0 belong 0x00000100
  1474. >9 byte 0
  1475. >>0 byte x
  1476. >>0 use cur-ico-dir
  1477. >9 ubyte 0xff
  1478. >>0 byte x
  1479. >>0 use cur-ico-dir
  1480. # displays number of icons and information for icon or cursor
  1481. 0 name cur-ico-dir
  1482. # skip some Lotus 1-2-3 worksheets, CYCLE.PIC and keep Windows cursors with
  1483. # 1st data offset = dir header size + n * dir entry size = 6 + n * 10h = ?6h
  1484. >18 ulelong &0x00000006
  1485. # skip remaining worksheets, because valid only for DIB image (40) or PNG image (\x89PNG)
  1486. >>(18.l) ulelong x MS Windows
  1487. >>>0 ubelong 0x00000100 icon resource
  1488. # https://www.iana.org/assignments/media-types/image/vnd.microsoft.icon
  1489. !:mime image/vnd.microsoft.icon
  1490. #!:mime image/x-icon
  1491. !:ext ico
  1492. >>>>4 uleshort x - %d icon
  1493. # plural s
  1494. >>>>4 uleshort >1 \bs
  1495. # 1st icon
  1496. >>>>0x06 use ico-entry
  1497. # 2nd icon
  1498. >>>>4 uleshort >1
  1499. >>>>>0x16 use ico-entry
  1500. >>>0 ubelong 0x00000200 cursor resource
  1501. #!:mime image/x-cur
  1502. !:mime image/x-win-bitmap
  1503. !:ext cur
  1504. >>>>4 uleshort x - %d icon
  1505. >>>>4 uleshort >1 \bs
  1506. # 1st cursor
  1507. >>>>0x06 use cur-entry
  1508. #>>>>0x16 use cur-entry
  1509. # display information of one cursor entry
  1510. 0 name cur-entry
  1511. >0 use cur-ico-entry
  1512. >4 uleshort x \b, hotspot @%dx
  1513. >6 uleshort x \b%d
  1514. # display information of one icon entry
  1515. 0 name ico-entry
  1516. >0 use cur-ico-entry
  1517. # normally 0 1 but also found 14
  1518. >4 uleshort >1 \b, %d planes
  1519. # normally 0 1 but also found some 3, 4, some 6, 8, 24, many 32, two 256
  1520. >6 uleshort >1 \b, %d bits/pixel
  1521. # display shared information of cursor or icon entry
  1522. 0 name cur-ico-entry
  1523. >0 byte =0 \b, 256x
  1524. >0 byte !0 \b, %dx
  1525. >1 byte =0 \b256
  1526. >1 byte !0 \b%d
  1527. # number of colors in palette
  1528. >2 ubyte !0 \b, %d colors
  1529. # reserved 0 FFh
  1530. #>3 ubyte x \b, reserved %x
  1531. #>8 ulelong x \b, image size %d
  1532. # offset of PNG or DIB image
  1533. #>12 ulelong x \b, offset %#x
  1534. # PNG header (\x89PNG)
  1535. >(12.l) ubelong =0x89504e47
  1536. # 1 space char after "with" to get phrase "with PNG image" by magic in ./images
  1537. >>&-4 indirect x \b with
  1538. # DIB image
  1539. >(12.l) ubelong !0x89504e47
  1540. #>>&-4 use dib-image
  1541. # Windows non-animated cursors
  1542. # Update: Joerg Jenderek
  1543. # URL: https://en.wikipedia.org/wiki/CUR_(file_format)
  1544. # Note: similar to Windows ICOn. container for BMP ( only DIB part)
  1545. # GRR: line below is too general as it catches also Lotus 1-2-3 files
  1546. 0 belong 0x00000200
  1547. >9 byte 0
  1548. >>0 use cur-ico-dir
  1549. >9 ubyte 0xff
  1550. >>0 use cur-ico-dir
  1551. # .chr files
  1552. 0 string/b PK\010\010BGI Borland font
  1553. >4 string >\0 %s
  1554. # then there is a copyright notice
  1555. # .bgi files
  1556. 0 string/b pk\010\010BGI Borland device
  1557. >4 string >\0 %s
  1558. # then there is a copyright notice
  1559. # Windows Recycle Bin record file (named INFO2)
  1560. # By Abel Cheung (abelcheung AT gmail dot com)
  1561. # Version 4 always has 280 bytes (0x118) per record, version 5 has 800 bytes
  1562. # Since Vista uses another structure, INFO2 structure probably won't change
  1563. # anymore. Detailed analysis in:
  1564. # http://www.cybersecurityinstitute.biz/downloads/INFO2.pdf
  1565. 0 lelong 0x00000004
  1566. >12 lelong 0x00000118 Windows Recycle Bin INFO2 file (Win98 or below)
  1567. 0 lelong 0x00000005
  1568. >12 lelong 0x00000320 Windows Recycle Bin INFO2 file (Win2k - WinXP)
  1569. # From Doug Lee via a FreeBSD pr
  1570. 9 string GERBILDOC First Choice document
  1571. 9 string GERBILDB First Choice database
  1572. 9 string GERBILCLIP First Choice database
  1573. 0 string GERBIL First Choice device file
  1574. 9 string RABBITGRAPH RabbitGraph file
  1575. 0 string DCU1 Borland Delphi .DCU file
  1576. 0 string =!<spell> MKS Spell hash list (old format)
  1577. 0 string =!<spell2> MKS Spell hash list
  1578. # Too simple - MPi
  1579. #0 string AH Halo(TM) bitmapped font file
  1580. 0 lelong 0x08086b70 TurboC BGI file
  1581. 0 lelong 0x08084b50 TurboC Font file
  1582. # Debian#712046: The magic below identifies "Delphi compiled form data".
  1583. # An additional source of information is available at:
  1584. # http://www.woodmann.com/fravia/dafix_t1.htm
  1585. 0 string TPF0
  1586. >4 pstring >\0 Delphi compiled form '%s'
  1587. # tests for DBase files moved, updated and merged to database
  1588. 0 string PMCC Windows 3.x .GRP file
  1589. 1 string RDC-meg MegaDots
  1590. >8 byte >0x2F version %c
  1591. >9 byte >0x2F \b.%c file
  1592. 0 lelong 0x4C
  1593. >4 lelong 0x00021401 Windows shortcut file
  1594. # .PIF files added by Joerg Jenderek from https://smsoft.ru/en/pifdoc.htm
  1595. # only for windows versions equal or greater 3.0
  1596. 0x171 string MICROSOFT\ PIFEX\0 Windows Program Information File
  1597. !:mime application/x-dosexec
  1598. !:ext pif
  1599. #>2 string >\0 \b, Title:%.30s
  1600. >0x24 string >\0 \b for %.63s
  1601. >0x65 string >\0 \b, directory=%.64s
  1602. >0xA5 string >\0 \b, parameters=%.64s
  1603. #>0x181 leshort x \b, offset %x
  1604. #>0x183 leshort x \b, offsetdata %x
  1605. #>0x185 leshort x \b, section length %x
  1606. >0x187 search/0xB55 WINDOWS\ VMM\ 4.0\0
  1607. >>&0x5e ubyte >0
  1608. >>>&-1 string <PIFMGR.DLL \b, icon=%s
  1609. #>>>&-1 string PIFMGR.DLL \b, icon=%s
  1610. >>>&-1 string >PIFMGR.DLL \b, icon=%s
  1611. >>&0xF0 ubyte >0
  1612. >>>&-1 string <Terminal \b, font=%.32s
  1613. #>>>&-1 string =Terminal \b, font=%.32s
  1614. >>>&-1 string >Terminal \b, font=%.32s
  1615. >>&0x110 ubyte >0
  1616. >>>&-1 string <Lucida\ Console \b, TrueTypeFont=%.32s
  1617. #>>>&-1 string =Lucida\ Console \b, TrueTypeFont=%.32s
  1618. >>>&-1 string >Lucida\ Console \b, TrueTypeFont=%.32s
  1619. #>0x187 search/0xB55 WINDOWS\ 286\ 3.0\0 \b, Windows 3.X standard mode-style
  1620. #>0x187 search/0xB55 WINDOWS\ 386\ 3.0\0 \b, Windows 3.X enhanced mode-style
  1621. >0x187 search/0xB55 WINDOWS\ NT\ \ 3.1\0 \b, Windows NT-style
  1622. #>0x187 search/0xB55 WINDOWS\ NT\ \ 4.0\0 \b, Windows NT-style
  1623. >0x187 search/0xB55 CONFIG\ \ SYS\ 4.0\0 \b +CONFIG.SYS
  1624. #>>&06 string x \b:%s
  1625. >0x187 search/0xB55 AUTOEXECBAT\ 4.0\0 \b +AUTOEXEC.BAT
  1626. #>>&06 string x \b:%s
  1627. # DOS EPS Binary File Header
  1628. # From: Ed Sznyter <ews@Black.Market.NET>
  1629. 0 belong 0xC5D0D3C6 DOS EPS Binary File
  1630. !:mime image/x-eps
  1631. >4 long >0 Postscript starts at byte %d
  1632. >>8 long >0 length %d
  1633. >>>12 long >0 Metafile starts at byte %d
  1634. >>>>16 long >0 length %d
  1635. >>>20 long >0 TIFF starts at byte %d
  1636. >>>>24 long >0 length %d
  1637. # Norton Guide (.NG , .HLP) files added by Joerg Jenderek from source NG2HTML.C
  1638. # of http://www.davep.org/norton-guides/ng2h-105.tgz
  1639. # https://en.wikipedia.org/wiki/Norton_Guides
  1640. 0 string NG\0\001
  1641. # only value 0x100 found at offset 2
  1642. >2 ulelong 0x00000100 Norton Guide
  1643. !:mime application/x-norton-guide
  1644. # often like NORTON.NG but some times like NC.HLP
  1645. !:ext ng/hlp
  1646. # Title[40]
  1647. >>8 string >\0 "%-.40s"
  1648. #>>6 uleshort x \b, MenuCount=%u
  1649. # szCredits[5][66]
  1650. >>48 string >\0 \b, %-.66s
  1651. >>114 string >\0 %-.66s
  1652. # URL: https://en.wikipedia.org/wiki/Norton_Commander
  1653. # Reference: http://mark0.net/download/triddefs_xml.7z/defs/m/msg-nc-eng.trid.xml
  1654. # From: Joerg Jenderek
  1655. # Note: Message file is used by executable with same main name.
  1656. # Only tested with version 5.50 (english) and 2.01 (Windows)
  1657. 0 string Abort
  1658. # \0 or i
  1659. #>5 ubyte x %x
  1660. # skip ASCII Abort text by looking for error message like in NCVIEW.MSG
  1661. >6 search/7089 Non-DOS\ disk Norton Commander module message
  1662. !:mime application/x-norton-msg
  1663. !:ext msg
  1664. # URL: http://www.antonis.de/dos/dos-tuts/mpdostip/html/nwdostip.htm
  1665. # Reference: https://mark0.net/download/triddefs_xml.7z/defs/m/msg-netware-dos.trid.xml
  1666. # From: Joerg Jenderek
  1667. 0 string DOS\ Client\ Message\ File: Novell DOS client message
  1668. #!:mime application/octet-stream
  1669. #!:mime application/x-novell-msg
  1670. !:ext msg
  1671. # look for second letter instead space character
  1672. >26 ubyte >0x20
  1673. # digit 1 or often main or program name like: IPXODI.COM TASKID pnwtrap DOSRqstr
  1674. >>25 ubyte !0x20 %c
  1675. >>>26 ubyte !0x20 \b%c
  1676. >>>>27 ubyte !0x20 \b%c
  1677. >>>>>28 ubyte !0x20 \b%c
  1678. >>>>>>29 ubyte !0x20 \b%c
  1679. >>>>>>>30 ubyte !0x20 \b%c
  1680. >>>>>>>>31 ubyte !0x20 \b%c
  1681. >>>>>>>>>32 ubyte !0x20 \b%c
  1682. >>>>>>>>>>33 ubyte !0x20 \b%c
  1683. >>>>>>>>>>>34 ubyte !0x20 \b%c
  1684. >>>>>>>>>>>>35 ubyte !0x20 \b%c
  1685. >>>>>>>>>>>>>36 ubyte !0x20 \b%c
  1686. # followed by string like: 0 v.10 V1.20
  1687. #
  1688. # followed by ,\040Tran
  1689. >28 search/14 ,\040Tran
  1690. # probably translated version string like: 0 v1.00
  1691. >>&0 string x \b, tran version %s
  1692. # followed by Ctrl-J Ctrl-Z
  1693. >>>&0 ubyte !0xa \b, terminated by %#2.2x
  1694. >>>>&0 ubyte x \b%2.2x
  1695. # Ctrl-Z
  1696. >0x65 ubyte !0x1A \b, at 0x65 %#x
  1697. # one
  1698. >0x66 ubyte !0x01 \b, at 0x66 %#x
  1699. # URL: https://en.wikipedia.org/wiki/NetWare
  1700. # Reference: http://mark0.net/download/triddefs_xml.7z/defs/d/dat-novell-msg.trid.xml
  1701. # ftp://ftp.iitb.ac.in/LDP/en/NLM-HOWTO/NLM-HOWTO-single.html
  1702. # From: Joerg Jenderek
  1703. 0 string Novell\ Message\ Librarian\ Data\ File Novell message librarian data
  1704. #>35 string Version\ 1.00
  1705. #>49 string COPYRIGHT\ (c)\ 1985\ by\ Novell,\ Inc.
  1706. #>83 string \ \ All\ Rights\ Reserved
  1707. #!:mime application/octet-stream
  1708. #!:mime application/x-novell-msg
  1709. !:ext msg
  1710. #!:ext msg/dat
  1711. # 4DOS help (.HLP) files added by Joerg Jenderek from source TPHELP.PAS
  1712. # of https://www.4dos.info/
  1713. # pointer,HelpID[8]=4DHnnnmm
  1714. 0 ulelong 0x48443408 4DOS help file
  1715. >4 string x \b, version %-4.4s
  1716. # old binary Microsoft (.HLP) files added by Joerg Jenderek from http://file-extension.net/seeker/file_extension_hlp
  1717. 0 ulequad 0x3a000000024e4c MS Advisor help file
  1718. # HtmlHelp files (.chm)
  1719. 0 string/b ITSF\003\000\000\000\x60\000\000\000 MS Windows HtmlHelp Data
  1720. !:mime application/vnd.ms-htmlhelp
  1721. !:ext chm
  1722. # GFA-BASIC (Wolfram Kleff)
  1723. 2 string/b GFA-BASIC3 GFA-BASIC 3 data
  1724. #------------------------------------------------------------------------------
  1725. # From Stuart Caie <kyzer@4u.net> (developer of cabextract)
  1726. # Update: Joerg Jenderek
  1727. # URL: https://en.wikipedia.org/wiki/Cabinet_(file_format)
  1728. # Reference: https://msdn.microsoft.com/en-us/library/bb267310.aspx
  1729. # Note: verified by `7z l *.cab`
  1730. # Microsoft Cabinet files
  1731. 0 string/b MSCF\0\0\0\0 Microsoft Cabinet archive data
  1732. #
  1733. # https://support.microsoft.com/en-us/help/973559/frequently-asked-questions-about-the-microsoft-support-diagnostic-tool
  1734. # CAB with *.{diagcfg,diagpkg} is used by Microsoft Support Diagnostic Tool MSDT.EXE
  1735. # because some archive does not have *.diag* as 1st or 2nd archive member like
  1736. # O15CTRRemove.diagcab or AzureStorageAnalyticsLogs_global.DiagCab
  1737. # brute looking after header for filenames with diagcfg or diagpkg extension in CFFILE section
  1738. >0x2c search/980/c .diag \b, Diagnostic
  1739. !:mime application/vnd.ms-cab-compressed
  1740. !:ext diagcab
  1741. # http://fileformats.archiveteam.org/wiki/PUZ
  1742. # Microsoft Publisher version about 2003 has a "Pack and Go" feature that
  1743. # bundles a Publisher document *PNG.pub with all links into a CAB
  1744. >0x2c search/300/c png.pub\0 \b, Publisher Packed and Go
  1745. !:mime application/vnd.ms-cab-compressed
  1746. !:ext puz
  1747. # ppz variant with Microsoft PowerPoint Viewer ppview32.exe to play PowerPoint presentation
  1748. >0x2c search/17/c ppview32.exe\0 \b, PowerPoint Viewer Packed and Go
  1749. !:mime application/vnd.ms-powerpoint
  1750. #!:mime application/mspowerpoint
  1751. !:ext ppz
  1752. # URL: https://en.wikipedia.org/wiki/Windows_Desktop_Gadgets
  1753. # Reference: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/sidebar/
  1754. # http://win10gadgets.com/download/273/ All_CPU_Meter1.zip/All_CPU_Meter_V4.7.3.gadget
  1755. >0x2c search/968/c gadget.xml \b, Windows Desktop Gadget
  1756. #!:mime application/vnd.ms-cab-compressed
  1757. # http://extension.nirsoft.net/gadget
  1758. !:mime application/x-windows-gadget
  1759. !:ext gadget
  1760. # http://www.incredimail.com/
  1761. # IncrediMail CAB contains an initialisation file "content.ini" like in im2.ims
  1762. >0x2c search/3369/c content.ini\0 \b, IncrediMail
  1763. !:mime application/x-incredimail
  1764. # member Flavor.htm implies IncrediMail ecard like in tell_a_friend.imf
  1765. >>0x2c search/83/c Flavor.htm\0 ecard
  1766. !:ext imf
  1767. # member Macromedia Flash data *.swf implies IncrediMail skin like in im2.ims
  1768. >>0x2c search/211/c .swf\0 skin
  1769. !:ext ims
  1770. # member anim.im3 implies IncrediMail animation like in letter_fold.ima
  1771. >>0x2c search/92/c anim.im3\0 animation
  1772. !:ext ima
  1773. # other IncrediMail cab archive
  1774. >>0x2c default x
  1775. >>>0x2c search/116/c thumb ecard, image, notifier or skin
  1776. !:ext imf/imi/imn/ims
  1777. # http://file-extension.net/seeker/file_extension_ime
  1778. >>>0x2c default x emoticons or sound
  1779. !:ext ime/imw
  1780. # no Diagnostic, Packed and Go, Windows Desktop Gadget, IncrediMail
  1781. >0x2c default x
  1782. # look for 1st member name
  1783. >>(16.l+16) ubyte x
  1784. # From: Joerg Jenderek
  1785. # URL: https://docs.microsoft.com/en-us/windows-hardware/drivers/install/building-device-metadata-packages
  1786. # Reference: http://mark0.net/download/triddefs_xml.7z/defs/d/devicemetadata-ms.trid.xml
  1787. >>>&-1 string PackageInfo.xml \b, Device Metadata Package
  1788. !:mime application/vnd.ms-cab-compressed
  1789. !:ext devicemetadata-ms
  1790. # https://en.wikipedia.org/wiki/SNP_file_format
  1791. >>>&-1 string/c _accrpt_.snp \b, Access report snapshot
  1792. !:mime application/msaccess
  1793. !:ext snp
  1794. # https://en.wikipedia.org/wiki/Microsoft_InfoPath
  1795. >>>&-1 string manifest.xsf \b, InfoPath Form Template
  1796. !:mime application/vnd.ms-cab-compressed
  1797. #!:mime application/vnd.ms-infopath
  1798. !:ext xsn
  1799. # https://www.cabextract.org.uk/wince_cab_format/
  1800. # extension of DOS 8+3 name with ".000" of 1st archive member name implies Windows CE installer
  1801. >>>&7 string =.000 \b, WinCE install
  1802. !:mime application/vnd.ms-cab-compressed
  1803. !:ext cab
  1804. # https://support.microsoft.com/kb/934307/en-US
  1805. # All inspected MSU contain a file with name WSUSSCAN.cab
  1806. # that is called "Windows Update meta data" by Microsoft
  1807. >>>&-1 string/c wsusscan.cab \b, Microsoft Standalone Update
  1808. !:mime application/vnd.ms-cab-compressed
  1809. !:ext msu
  1810. >>>&-1 default x
  1811. # look at point character of 1st archive member name for file name extension
  1812. # GRR: search range is maybe too large and match point else where like in EN600x64.cab!
  1813. >>>>&-1 search/255 .
  1814. # http://www.pptfaq.com/FAQ00164_What_is_a_PPZ_file-.htm
  1815. # PPZ were created using Pack & Go feature of PowerPoint versions 97 - 2002
  1816. # packs optional files, a PowerPoint presentation *.ppt with optional PLAYLIST.LST to CAB
  1817. >>>>>&0 string/c ppt\0
  1818. >>>>>>28 uleshort >1 \b, PowerPoint Packed and Go
  1819. !:mime application/vnd.ms-powerpoint
  1820. #!:mime application/mspowerpoint
  1821. !:ext ppz
  1822. # or POWERPNT.PPT packed as POWERPNT.PP_ found on Windows 2000,XP setup CD in directory i386
  1823. >>>>>>28 uleshort =1 \b, one packed PowerPoint
  1824. !:mime application/vnd.ms-cab-compressed
  1825. !:ext pp_
  1826. # https://msdn.microsoft.com/en-us/library/windows/desktop/bb773190(v=vs.85).aspx
  1827. # first member *.theme implies Windows 7 Theme Pack like in CommunityShowcaseAqua3.themepack
  1828. # or Windows 8 Desktop Theme Pack like in PanoramicGlaciers.deskthemepack
  1829. >>>>>&0 string/c theme \b, Windows
  1830. !:mime application/x-windows-themepack
  1831. # https://www.drewkeller.com/content/using-theme-both-windows-7-and-windows-8
  1832. # 1st member Panoramic.theme or Panoramas.theme implies Windows 8-10 Theme Pack
  1833. # with MTSM=RJSPBS in [MasterThemeSelector] inside *.theme
  1834. >>>>>>(16.l+16) string =Panoram 8
  1835. !:ext deskthemepack
  1836. >>>>>>(16.l+16) string !Panoram 7 or 8
  1837. !:ext themepack/deskthemepack
  1838. >>>>>>(16.l+16) ubyte x Theme Pack
  1839. # URL: https://en.wikipedia.org/wiki/Microsoft_OneNote#File_format
  1840. # http://fileformats.archiveteam.org/wiki/OneNote
  1841. # Reference: https://mark0.net/download/triddefs_xml.7z/defs/o/onepkg.trid.xml
  1842. # 1st member name like: "Class Notes.one" "test-onenote.one" "Open Notebook.onetoc2" "Editor Öffnen.onetoc2"
  1843. >>>>>&0 string/c one \b, OneNote Package
  1844. !:mime application/msonenote
  1845. !:ext onepkg
  1846. >>>>>&0 default x
  1847. # look for null terminator of 1st member name
  1848. >>>>>>&0 search/255 \0
  1849. # 2nd member name WSUSSCAN.cab like in Microsoft-Windows-MediaFeaturePack-OOB-Package.msu
  1850. >>>>>>>&16 string/c wsusscan.cab \b, Microsoft Standalone Update
  1851. !:mime application/vnd.ms-cab-compressed
  1852. !:ext msu
  1853. >>>>>>>&16 default x
  1854. # archive with more then one file need some output in version 5.32 to avoid error message like
  1855. # Magdir/msdos, 1138: Warning: Current entry does not yet have a description for adding a MIME type
  1856. # Magdir/msdos, 1139: Warning: Current entry does not yet have a description for adding a EXTENSION type
  1857. # file: could not find any valid magic files!
  1858. >>>>>>>>28 uleshort >1 \b, many
  1859. !:mime application/vnd.ms-cab-compressed
  1860. !:ext cab
  1861. # remaining archives with just one file
  1862. >>>>>>>>28 uleshort =1
  1863. # neither extra bytes nor cab chain implies Windows 2000,XP setup files in directory i386
  1864. >>>>>>>>>30 uleshort =0x0000 \b, Windows 2000/XP setup
  1865. # cut of last char of source extension and add underscore to generate extension
  1866. # TERMCAP._ ... FXSCOUNT.H_ ... L3CODECA.AC_ ... NPDRMV2.ZI_
  1867. !:mime application/vnd.ms-cab-compressed
  1868. !:ext _/?_/??_
  1869. # archive need some output like "single" in version 5.32 to avoid error messages
  1870. >>>>>>>>>30 uleshort !0x0000 \b, single
  1871. !:mime application/vnd.ms-cab-compressed
  1872. !:ext cab
  1873. # first archive name without point character
  1874. >>>>&-1 default x
  1875. >>>>>28 uleshort =1 \b, single
  1876. !:mime application/vnd.ms-cab-compressed
  1877. # on XP_CD\I386\ like: NETWORKS._ PROTOCOL._ QUOTES._ SERVICES._
  1878. !:ext _
  1879. >>>>>28 uleshort >1 \b, many
  1880. !:mime application/vnd.ms-cab-compressed
  1881. # like: HP Envy 6000 printer driver packages Full_x86.cab Full_x64.cab
  1882. !:ext cab
  1883. # TODO: additional extensions like
  1884. # .xtp InfoPath Template Part
  1885. # .lvf Logitech Video Effects Face Accessory
  1886. >8 ulelong x \b, %u bytes
  1887. >28 uleshort 1 \b, 1 file
  1888. >28 uleshort >1 \b, %u files
  1889. # Reserved fields, set to zero
  1890. #>4 belong !0 \b, reserved1 %x
  1891. #>12 belong !0 \b, reserved2 %x
  1892. # offset of the first CFFILE entry coffFiles: minimal 2Ch
  1893. >16 ulelong x \b, at %#x
  1894. >(16.l) use cab-file
  1895. # at least also 2nd member
  1896. >28 uleshort >1
  1897. >>(16.l+16) ubyte x
  1898. >>>&0 search/255 \0
  1899. # second member info
  1900. >>>>&0 use cab-file
  1901. #>20 belong !0 \b, reserved %x
  1902. # Cabinet file format version. Currently, versionMajor = 1 and versionMinor = 3
  1903. >24 ubeshort !0x0301 \b version %#x
  1904. # number of CFFOLDER entries
  1905. >26 uleshort >1 \b, %u cffolders
  1906. # cabinet file option indicators 1~PREVIOUS, 2~NEXT, 4~reserved fields
  1907. # only found for flags 0 1 2 3 4 not 7
  1908. >30 uleshort >0 \b, flags %#x
  1909. # Cabinet files have a 16-bit cabinet setID field that is designed for application use.
  1910. # default is zero, however, the -i option of cabarc can be used to set this field
  1911. >32 uleshort >0 \b, ID %u
  1912. # iCabinet is number of this cabinet file in a set, where 0 for the first cabinet
  1913. #>34 uleshort x \b, iCabinet %u
  1914. # add one for display because humans start numbering by 1 and also fit to name of disk szDisk*
  1915. >34 uleshort+1 x \b, number %u
  1916. >30 uleshort &0x0004 \b, extra bytes
  1917. # cbCFHeader optional size of per-cabinet reserved area 14h 1800h
  1918. >>36 uleshort >0 %u in head
  1919. # cbCFFolder is optional size of per-folder reserved area
  1920. >>38 ubyte >0 %u in folder
  1921. # cbCFData is optional size of per-datablock reserved area
  1922. >>39 ubyte >0 %u in data block
  1923. # optional per-cabinet reserved area abReserve[cbCFHeader]
  1924. >>36 uleshort >0
  1925. # 1st CFFOLDER after reserved area in header
  1926. >>>(36.s+40) use cab-folder
  1927. # no reserved area in header
  1928. >30 uleshort ^0x0004
  1929. # no previous and next cab archive
  1930. >>30 uleshort =0x0000
  1931. >>>36 use cab-folder
  1932. # only previous cab archive
  1933. >>30 uleshort =0x0001 \b, previous
  1934. >>>36 use cab-anchor
  1935. # only next cab archive
  1936. >>30 uleshort =0x0002 \b, next
  1937. >>>36 use cab-anchor
  1938. # previous+next cab archive
  1939. # can not use sub routine cab-anchor to display previous and next cabinet together
  1940. #>>>36 use cab-anchor
  1941. #>>>>&0 use cab-anchor
  1942. >>30 uleshort =0x0003 \b, previous
  1943. >>>36 string x %s
  1944. # optional name of previous disk szDisk*
  1945. >>>>&1 string x disk %s
  1946. >>>>>&1 string x \b, next %s
  1947. # optional name of previous disk szDisk*
  1948. >>>>>>&1 string x disk %s
  1949. >>>>>>>&1 use cab-folder
  1950. # display filename and disk name of previous or next cabinet
  1951. 0 name cab-anchor
  1952. # optional name of previous/next cabinet file szCabinet*[255]
  1953. >&0 string x %s
  1954. # optional name of previous/next disk szDisk*[255]
  1955. >>&1 string x disk %s
  1956. # display folder structure CFFOLDER information like compression of cabinet
  1957. 0 name cab-folder
  1958. # offset of the CFDATA block in this folder
  1959. #>0 ulelong x \b, coffCabStart %#x
  1960. # number of CFDATA blocks in folder
  1961. >4 uleshort x \b, %u datablock
  1962. # plural s
  1963. >4 uleshort >1 \bs
  1964. # compression typeCompress: 0~None 1~MSZIP 0x1503~LZX:21 0x1003~LZX:16 0x0f03~LZX:15
  1965. >6 uleshort x \b, %#x compression
  1966. # optional per-folder reserved area
  1967. #>8 ubequad x \b, abReserve %#llx
  1968. # display member structure CFFILE information like member name of cabinet
  1969. 0 name cab-file
  1970. # cbFile is uncompressed size of file in bytes
  1971. #>0 ulelong x \b, cbFile %u
  1972. # uoffFolderStart is uncompressed offset of file in folder
  1973. #>4 ulelong >0 \b, uoffFolderStart %#x
  1974. # iFolder is index into the CFFOLDER area. 0 indicates first folder in cabinet
  1975. # define ifoldCONTINUED_FROM_PREV (0xFFFD)
  1976. # define ifoldCONTINUED_TO_NEXT (0xFFFE)
  1977. # define ifoldCONTINUED_PREV_AND_NEXT (0xFFFF)
  1978. >8 uleshort >0 \b, iFolder %#x
  1979. # date stamp for file
  1980. >10 lemsdosdate x last modified %s
  1981. # time stamp for file
  1982. >12 lemsdostime x %s
  1983. # attribs is attribute flags for file
  1984. # define _A_RDONLY (0x01) file is read-only
  1985. # define _A_HIDDEN (0x02) file is hidden
  1986. # define _A_SYSTEM (0x04) file is a system file
  1987. # define _A_ARCH (0x20) file modified since last backup
  1988. # example http://sebastien.kirche.free.fr/pebuilder_plugins/depends.cab
  1989. # define _A_EXEC (0x40) run after extraction
  1990. # define _A_NAME_IS_UTF (0x80) szName[] contains UTF
  1991. # define UNKNOWN (0x0100) undocumented or accident
  1992. #>14 uleshort x \b, attribs %#x
  1993. >14 uleshort >0 +
  1994. >>14 uleshort &0x0001 \bR
  1995. >>14 uleshort &0x0002 \bH
  1996. >>14 uleshort &0x0004 \bS
  1997. >>14 uleshort &0x0020 \bA
  1998. >>14 uleshort &0x0040 \bX
  1999. >>14 uleshort &0x0080 \bUtf
  2000. # unknown 0x0100 flag found on one XP_CD:\I386\DRIVER.CAB
  2001. >>14 uleshort &0x0100 \b?
  2002. # szName is name of archive member
  2003. >16 string x "%s"
  2004. # next archive member name if more files
  2005. #>>&17 string >\0 \b, NEXT NAME %-.50s
  2006. # InstallShield Cabinet files
  2007. 0 string/b ISc( InstallShield Cabinet archive data
  2008. >5 byte&0xf0 =0x60 version 6,
  2009. >5 byte&0xf0 !0x60 version 4/5,
  2010. >(12.l+40) lelong x %u files
  2011. # Windows CE package files
  2012. 0 string/b MSCE\0\0\0\0 Microsoft WinCE install header
  2013. >20 lelong 0 \b, architecture-independent
  2014. >20 lelong 103 \b, Hitachi SH3
  2015. >20 lelong 104 \b, Hitachi SH4
  2016. >20 lelong 0xA11 \b, StrongARM
  2017. >20 lelong 4000 \b, MIPS R4000
  2018. >20 lelong 10003 \b, Hitachi SH3
  2019. >20 lelong 10004 \b, Hitachi SH3E
  2020. >20 lelong 10005 \b, Hitachi SH4
  2021. >20 lelong 70001 \b, ARM 7TDMI
  2022. >52 leshort 1 \b, 1 file
  2023. >52 leshort >1 \b, %u files
  2024. >56 leshort 1 \b, 1 registry entry
  2025. >56 leshort >1 \b, %u registry entries
  2026. # Windows Enhanced Metafile (EMF)
  2027. # See msdn.microsoft.com/archive/en-us/dnargdi/html/msdn_enhmeta.asp
  2028. # for further information.
  2029. 0 ulelong 1
  2030. >40 string \ EMF Windows Enhanced Metafile (EMF) image data
  2031. >>44 ulelong x version %#x
  2032. 0 string/b \224\246\056 Microsoft Word Document
  2033. !:mime application/msword
  2034. # From: "Nelson A. de Oliveira" <naoliv@gmail.com>
  2035. # Magic type for Dell's BIOS .hdr files
  2036. # Dell's .hdr
  2037. 0 string/b $RBU
  2038. >23 string Dell %s system BIOS
  2039. >5 byte 2
  2040. >>48 byte x version %d.
  2041. >>49 byte x \b%d.
  2042. >>50 byte x \b%d
  2043. >5 byte <2
  2044. >>48 string x version %.3s
  2045. # Type: Microsoft Document Imaging Format (.mdi)
  2046. # URL: https://en.wikipedia.org/wiki/Microsoft_Document_Imaging_Format
  2047. # From: Daniele Sempione <scrows@oziosi.org>
  2048. # Too weak (EP)
  2049. #0 short 0x5045 Microsoft Document Imaging Format
  2050. # MS eBook format (.lit)
  2051. 0 string/b ITOLITLS Microsoft Reader eBook Data
  2052. >8 lelong x \b, version %u
  2053. !:mime application/x-ms-reader
  2054. # Windows CE Binary Image Data Format
  2055. # From: Dr. Jesus <j@hug.gs>
  2056. 0 string/b B000FF\n Windows Embedded CE binary image
  2057. # The second byte of these signatures is a file version; I don't know what,
  2058. # if anything, produced files with version numbers 0-2.
  2059. # From: John Elliott <johne@seasip.demon.co.uk>
  2060. 0 string \xfc\x03\x00 Mallard BASIC program data (v1.11)
  2061. 0 string \xfc\x04\x00 Mallard BASIC program data (v1.29+)
  2062. 0 string \xfc\x03\x01 Mallard BASIC protected program data (v1.11)
  2063. 0 string \xfc\x04\x01 Mallard BASIC protected program data (v1.29+)
  2064. 0 string MIOPEN Mallard BASIC Jetsam data
  2065. 0 string Jetsam0 Mallard BASIC Jetsam index data
  2066. # DOS backup 2.0 to 3.2
  2067. # URL: http://fileformats.archiveteam.org/wiki/BACKUP_(MS-DOS)
  2068. # Reference: http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/dos/restore/brtecdoc.htm
  2069. # backupid.@@@
  2070. # plausibility check for date
  2071. 0x3 ushort >1979
  2072. >0x5 ubyte-1 <31
  2073. >>0x6 ubyte-1 <12
  2074. # actually 121 nul bytes
  2075. >>>0x7 string \0\0\0\0\0\0\0\0
  2076. >>>>0x1 ubyte x DOS 2.0 backup id file, sequence %d
  2077. #!:mime application/octet-stream
  2078. !:ext @@@
  2079. >>>>0x0 ubyte 0xff \b, last disk
  2080. # backed up file
  2081. # skip some AppleWorks word like Tomahawk.Awp, WIN98SE-DE.vhd
  2082. # by looking for trailing nul of maximal file name string
  2083. 0x52 ubyte 0
  2084. # test for flag byte: FFh~complete file, 00h~split file
  2085. # FFh -127 = -1 -127 = -128
  2086. # 00h -127 = 0 -127 = -127
  2087. >0 byte-127 <-126
  2088. # plausibility check for file name length
  2089. >>0x53 ubyte-1 <78
  2090. # looking for terminating nul of file name string
  2091. >>>(0x53.b+4) ubyte 0
  2092. # looking if last char of string is valid DOS file name
  2093. >>>>(0x53.b+3) ubyte >0x1F
  2094. # actually 44 nul bytes
  2095. # but sometimes garbage according to Ralf Quint. So can not be used as test
  2096. #>0x54 string \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
  2097. # first char of full file name is DOS (5Ch) or UNIX (2Fh) path separator
  2098. # only DOS variant found. UNIX variant according to V32SLASH.TXT in archive PD0315.EXE
  2099. >>>>>5 ubyte&0x8C 0x0C
  2100. # ./msdos (version 5.30) labeled the entry as
  2101. # "DOS 2.0 backed up file %s, split file, sequence %d" or
  2102. # "DOS 2.0 backed up file %s, complete file"
  2103. >>>>>>0 ubyte x DOS 2.0-3.2 backed up
  2104. #>>>>>>0 ubyte 0xff complete
  2105. >>>>>>0 ubyte 0
  2106. >>>>>>>1 uleshort x sequence %d of
  2107. # full file name with path but without drive letter and colon stored from 0x05 til 0x52
  2108. >>>>>>0x5 string x file %s
  2109. #!:mime application/octet-stream
  2110. # backup name is original filename
  2111. #!:ext doc/exe/rar/zip
  2112. #!:ext *
  2113. # magic/Magdir/msdos, 1169: Warning: EXTENSION type ` *' has bad char '*'
  2114. # file: line 1169: Bad magic entry ' *'
  2115. # after header original file content
  2116. >>>>>>128 indirect x \b;
  2117. # DOS backup 3.3 to 5.x
  2118. # CONTROL.nnn files
  2119. 0 string \x8bBACKUP\x20
  2120. # actually 128 nul bytes
  2121. >0xa string \0\0\0\0\0\0\0\0
  2122. >>0x9 ubyte x DOS 3.3 backup control file, sequence %d
  2123. >>0x8a ubyte 0xff \b, last disk
  2124. # NB: The BACKUP.nnn files consist of the files backed up,
  2125. # concatenated.
  2126. # From: Joerg Jenderek
  2127. # URL: http://fileformats.archiveteam.org/wiki/MS-DOS_date/time
  2128. # Reference: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-dosdatetimetofiletime
  2129. # Note: DOS date+time format is different from formats such as Unix epoch
  2130. # bit encoded; uses year values relative to 1980 and 2 second precision
  2131. 0 name dos-date
  2132. # HHHHHMMMMMMSSSSS bit encoded Hour (0-23) Minute (0-59) SecondPart (*2)
  2133. #>0 uleshort x RAW TIME [%#4.4x]
  2134. # hour part
  2135. #>0 uleshort/2048 x hour [%u]
  2136. # YYYYYMMMMDDDDD bit encoded YearPart (+1980) Month (1-12) Day (1-31)
  2137. #>2 uleshort x RAW DATE [%#4.4x]
  2138. # day part
  2139. >2 uleshort&0x001F x %u
  2140. #>2 uleshort/16 x MONTH PART [%#x]
  2141. # GRR: not working
  2142. #>2 uleshort/16 &0x000F MONTH [%u]
  2143. #>2 uleshort&0x01E0 x MONTH PART [%#4.4x]
  2144. >2 uleshort&0x01E0 =0x0020 jan
  2145. >2 uleshort&0x01E0 =0x0040 feb
  2146. >2 uleshort&0x01E0 =0x0060 mar
  2147. >2 uleshort&0x01E0 =0x0080 apr
  2148. >2 uleshort&0x01E0 =0x00A0 may
  2149. >2 uleshort&0x01E0 =0x00C0 jun
  2150. >2 uleshort&0x01E0 =0x00E0 jul
  2151. >2 uleshort&0x01E0 =0x0100 aug
  2152. >2 uleshort&0x01E0 =0x0120 sep
  2153. >2 uleshort&0x01E0 =0x0140 oct
  2154. >2 uleshort&0x01E0 =0x0160 nov
  2155. >2 uleshort&0x01E0 =0x0180 dec
  2156. # year part
  2157. >2 uleshort/512 x 1980+%u
  2158. #