Workflow Tools Control Yard

Home / Windows

File type from its first bytes

A file's name can say .pdf while its bytes are a program. Pick a file, and the page reads its first bytes on your computer and names the type they start with; for a Windows program it reads the PE header: EXE or DLL, 32 or 64-bit, the CPU and whether it is .NET. Nothing of the file leaves the browser.

The page reads the first 64 KB. The same first bytes at the command line: Format-Hex -Path .\file.bin -Count 64 in PowerShell 6.2 and later; Windows PowerShell 5.1 has no -Count.

The signatures

The first row whose bytes match names the file. A ZIP file is looked into for word/, xl/, ppt/ and visio/ in its first file names, which mark Office files. An OLE2 compound file is the container of .doc, .xls, .ppt, .msi, .msg and other files, told apart by what is inside it, which the page does not read.

TypeBytesUsual names
MS-DOS or Windows program (MZ)4D 5A.exe, .dll, .sys, .ocx, .cpl, .scr, .efi, .drv, .com
Linux or Unix program or library (ELF)7F 45 4C 46-
PDF document25 50 44 46 2D.pdf
ZIP archive50 4B 03 04.zip, .docx, .xlsx, .pptx, .jar, .apk
7-Zip archive37 7A BC AF 27 1C.7z
RAR archive, version 552 61 72 21 1A 07 01 00.rar
RAR archive52 61 72 21 1A 07 00.rar
gzip compressed data1F 8B.gz, .tgz
bzip2 compressed data42 5A 68.bz2
XZ compressed dataFD 37 7A 58 5A 00.xz
Microsoft Cabinet archive4D 53 43 46 00 00 00 00.cab
OLE2 compound fileD0 CF 11 E0 A1 B1 1A E1.doc, .xls, .ppt, .msi, .msp, .msg, .pub, .vsd
Rich Text Format document7B 5C 72 74 66.rtf, .doc
PNG image89 50 4E 47 0D 0A 1A 0A.png
JPEG imageFF D8 FF.jpg, .jpeg, .jpe, .jfif
GIF image47 49 46 38.gif
TIFF image, little-endian49 49 2A 00.tif, .tiff
TIFF image, big-endian4D 4D 00 2A.tif, .tiff
Windows bitmap (BMP)42 4D.bmp
Windows icon00 00 01 00.ico
WebP image52 49 46 46 + at 8: 57 45 42 50.webp
WAVE audio52 49 46 46 + at 8: 57 41 56 45.wav
AVI video52 49 46 46 + at 8: 41 56 49 20.avi
Windows shortcut4C 00 00 00 01 14 02 00 00 00 00 00 C0 00 00 00 00 00 00 46.lnk
Windows registry hive72 65 67 66-
Windows event log45 6C 66 46 69 6C 65 00.evtx
.reg file, Unicode (Version 5.00)FF FE + at 2: 57 00 69 00 6E 00 64 00 6F 00 77 00 73 00 20 00 52 00 65 00 67 00 69 00 73 00 74 00 72 00 79 00 20 00 45 00 64 00 69 00 74 00 6F 00 72 00 20 00.reg
.reg file, ANSI (Version 5.00)57 69 6E 64 6F 77 73 20 52 65 67 69 73 74 72 79 20 45 64 69 74 6F 72 20.reg
.reg file (REGEDIT4)52 45 47 45 44 49 54.reg
Windows imaging file (WIM)4D 53 57 49 4D 00 00 00.wim
Virtual hard disk (VHD)63 6F 6E 65 63 74 69 78.vhd
Virtual hard disk (VHDX)76 68 64 78 66 69 6C 65.vhdx
ISO 9660 disc imageat 32769: 43 44 30 30 31.iso

Windows programs: the PE header

A Windows program or DLL starts with MZ, the MS-DOS stub. At offset 0x3c the stub holds the offset of the PE signature, PE and two null bytes; the COFF header after it gives the machine and the flags (0x2000 marks a DLL), and the optional header after that says PE32 (0x10b) or PE32+ (0x20b, a 64-bit address space), the subsystem, and the data directories: a certificate table means the file carries a certificate, such as an Authenticode signature, and a CLR runtime header means managed code: a .NET assembly. The page does not check the certificate.

Machine types

ValueConstantMachine
0x0IMAGE_FILE_MACHINE_UNKNOWNThe content of this field is assumed to be applicable to any machine type
0x184IMAGE_FILE_MACHINE_ALPHAAlpha AXP, 32-bit address space
0x284IMAGE_FILE_MACHINE_ALPHA64Alpha 64, 64-bit address space
0x1d3IMAGE_FILE_MACHINE_AM33Matsushita AM33
0x8664IMAGE_FILE_MACHINE_AMD64x64
0x1c0IMAGE_FILE_MACHINE_ARMARM little endian
0xaa64IMAGE_FILE_MACHINE_ARM64ARM64 little endian
0xA641IMAGE_FILE_MACHINE_ARM64ECABI that enables interoperability between native ARM64 and emulated x64 code.
0xA64EIMAGE_FILE_MACHINE_ARM64XBinary format that allows both native ARM64 and ARM64EC code to coexist in the same file.
0x1c4IMAGE_FILE_MACHINE_ARMNTARM Thumb-2 little endian
0x284IMAGE_FILE_MACHINE_AXP64AXP 64 (Same as Alpha 64)
0xebcIMAGE_FILE_MACHINE_EBCEFI byte code
0x14cIMAGE_FILE_MACHINE_I386Intel 386 or later processors and compatible processors
0x200IMAGE_FILE_MACHINE_IA64Intel Itanium processor family
0x6232IMAGE_FILE_MACHINE_LOONGARCH32LoongArch 32-bit processor family
0x6264IMAGE_FILE_MACHINE_LOONGARCH64LoongArch 64-bit processor family
0x9041IMAGE_FILE_MACHINE_M32RMitsubishi M32R little endian
0x266IMAGE_FILE_MACHINE_MIPS16MIPS16
0x366IMAGE_FILE_MACHINE_MIPSFPUMIPS with FPU
0x466IMAGE_FILE_MACHINE_MIPSFPU16MIPS16 with FPU
0x1f0IMAGE_FILE_MACHINE_POWERPCPower PC little endian
0x1f1IMAGE_FILE_MACHINE_POWERPCFPPower PC with floating point support
0x160IMAGE_FILE_MACHINE_R3000BEMIPS I compatible 32-bit big endian
0x162IMAGE_FILE_MACHINE_R3000MIPS I compatible 32-bit little endian
0x166IMAGE_FILE_MACHINE_R4000MIPS III compatible 64-bit little endian
0x168IMAGE_FILE_MACHINE_R10000MIPS IV compatible 64-bit little endian
0x5032IMAGE_FILE_MACHINE_RISCV32RISC-V 32-bit address space
0x5064IMAGE_FILE_MACHINE_RISCV64RISC-V 64-bit address space
0x5128IMAGE_FILE_MACHINE_RISCV128RISC-V 128-bit address space
0x1a2IMAGE_FILE_MACHINE_SH3Hitachi SH3
0x1a3IMAGE_FILE_MACHINE_SH3DSPHitachi SH3 DSP
0x1a6IMAGE_FILE_MACHINE_SH4Hitachi SH4
0x1a8IMAGE_FILE_MACHINE_SH5Hitachi SH5
0x1c2IMAGE_FILE_MACHINE_THUMBThumb
0x169IMAGE_FILE_MACHINE_WCEMIPSV2MIPS little-endian WCE v2

Subsystems

ValueConstantSubsystem
0IMAGE_SUBSYSTEM_UNKNOWNAn unknown subsystem
1IMAGE_SUBSYSTEM_NATIVEDevice drivers and native Windows processes
2IMAGE_SUBSYSTEM_WINDOWS_GUIThe Windows graphical user interface (GUI) subsystem
3IMAGE_SUBSYSTEM_WINDOWS_CUIThe Windows character subsystem
5IMAGE_SUBSYSTEM_OS2_CUIThe OS/2 character subsystem
7IMAGE_SUBSYSTEM_POSIX_CUIThe Posix character subsystem
8IMAGE_SUBSYSTEM_NATIVE_WINDOWSNative Win9x driver
9IMAGE_SUBSYSTEM_WINDOWS_CE_GUIWindows CE
10IMAGE_SUBSYSTEM_EFI_APPLICATIONAn Extensible Firmware Interface (EFI) application
11IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVERAn EFI driver with boot services
12IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVERAn EFI driver with run-time services
13IMAGE_SUBSYSTEM_EFI_ROMAn EFI ROM image
14IMAGE_SUBSYSTEM_XBOXXBOX
16IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATIONWindows boot application.

Sources

More Windows tools