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.
| Type | Bytes | Usual 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 document | 25 50 44 46 2D | |
| ZIP archive | 50 4B 03 04 | .zip, .docx, .xlsx, .pptx, .jar, .apk |
| 7-Zip archive | 37 7A BC AF 27 1C | .7z |
| RAR archive, version 5 | 52 61 72 21 1A 07 01 00 | .rar |
| RAR archive | 52 61 72 21 1A 07 00 | .rar |
| gzip compressed data | 1F 8B | .gz, .tgz |
| bzip2 compressed data | 42 5A 68 | .bz2 |
| XZ compressed data | FD 37 7A 58 5A 00 | .xz |
| Microsoft Cabinet archive | 4D 53 43 46 00 00 00 00 | .cab |
| OLE2 compound file | D0 CF 11 E0 A1 B1 1A E1 | .doc, .xls, .ppt, .msi, .msp, .msg, .pub, .vsd |
| Rich Text Format document | 7B 5C 72 74 66 | .rtf, .doc |
| PNG image | 89 50 4E 47 0D 0A 1A 0A | .png |
| JPEG image | FF D8 FF | .jpg, .jpeg, .jpe, .jfif |
| GIF image | 47 49 46 38 | .gif |
| TIFF image, little-endian | 49 49 2A 00 | .tif, .tiff |
| TIFF image, big-endian | 4D 4D 00 2A | .tif, .tiff |
| Windows bitmap (BMP) | 42 4D | .bmp |
| Windows icon | 00 00 01 00 | .ico |
| WebP image | 52 49 46 46 + at 8: 57 45 42 50 | .webp |
| WAVE audio | 52 49 46 46 + at 8: 57 41 56 45 | .wav |
| AVI video | 52 49 46 46 + at 8: 41 56 49 20 | .avi |
| Windows shortcut | 4C 00 00 00 01 14 02 00 00 00 00 00 C0 00 00 00 00 00 00 46 | .lnk |
| Windows registry hive | 72 65 67 66 | - |
| Windows event log | 45 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 image | at 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
| Value | Constant | Machine |
|---|---|---|
0x0 | IMAGE_FILE_MACHINE_UNKNOWN | The content of this field is assumed to be applicable to any machine type |
0x184 | IMAGE_FILE_MACHINE_ALPHA | Alpha AXP, 32-bit address space |
0x284 | IMAGE_FILE_MACHINE_ALPHA64 | Alpha 64, 64-bit address space |
0x1d3 | IMAGE_FILE_MACHINE_AM33 | Matsushita AM33 |
0x8664 | IMAGE_FILE_MACHINE_AMD64 | x64 |
0x1c0 | IMAGE_FILE_MACHINE_ARM | ARM little endian |
0xaa64 | IMAGE_FILE_MACHINE_ARM64 | ARM64 little endian |
0xA641 | IMAGE_FILE_MACHINE_ARM64EC | ABI that enables interoperability between native ARM64 and emulated x64 code. |
0xA64E | IMAGE_FILE_MACHINE_ARM64X | Binary format that allows both native ARM64 and ARM64EC code to coexist in the same file. |
0x1c4 | IMAGE_FILE_MACHINE_ARMNT | ARM Thumb-2 little endian |
0x284 | IMAGE_FILE_MACHINE_AXP64 | AXP 64 (Same as Alpha 64) |
0xebc | IMAGE_FILE_MACHINE_EBC | EFI byte code |
0x14c | IMAGE_FILE_MACHINE_I386 | Intel 386 or later processors and compatible processors |
0x200 | IMAGE_FILE_MACHINE_IA64 | Intel Itanium processor family |
0x6232 | IMAGE_FILE_MACHINE_LOONGARCH32 | LoongArch 32-bit processor family |
0x6264 | IMAGE_FILE_MACHINE_LOONGARCH64 | LoongArch 64-bit processor family |
0x9041 | IMAGE_FILE_MACHINE_M32R | Mitsubishi M32R little endian |
0x266 | IMAGE_FILE_MACHINE_MIPS16 | MIPS16 |
0x366 | IMAGE_FILE_MACHINE_MIPSFPU | MIPS with FPU |
0x466 | IMAGE_FILE_MACHINE_MIPSFPU16 | MIPS16 with FPU |
0x1f0 | IMAGE_FILE_MACHINE_POWERPC | Power PC little endian |
0x1f1 | IMAGE_FILE_MACHINE_POWERPCFP | Power PC with floating point support |
0x160 | IMAGE_FILE_MACHINE_R3000BE | MIPS I compatible 32-bit big endian |
0x162 | IMAGE_FILE_MACHINE_R3000 | MIPS I compatible 32-bit little endian |
0x166 | IMAGE_FILE_MACHINE_R4000 | MIPS III compatible 64-bit little endian |
0x168 | IMAGE_FILE_MACHINE_R10000 | MIPS IV compatible 64-bit little endian |
0x5032 | IMAGE_FILE_MACHINE_RISCV32 | RISC-V 32-bit address space |
0x5064 | IMAGE_FILE_MACHINE_RISCV64 | RISC-V 64-bit address space |
0x5128 | IMAGE_FILE_MACHINE_RISCV128 | RISC-V 128-bit address space |
0x1a2 | IMAGE_FILE_MACHINE_SH3 | Hitachi SH3 |
0x1a3 | IMAGE_FILE_MACHINE_SH3DSP | Hitachi SH3 DSP |
0x1a6 | IMAGE_FILE_MACHINE_SH4 | Hitachi SH4 |
0x1a8 | IMAGE_FILE_MACHINE_SH5 | Hitachi SH5 |
0x1c2 | IMAGE_FILE_MACHINE_THUMB | Thumb |
0x169 | IMAGE_FILE_MACHINE_WCEMIPSV2 | MIPS little-endian WCE v2 |
Subsystems
| Value | Constant | Subsystem |
|---|---|---|
| 0 | IMAGE_SUBSYSTEM_UNKNOWN | An unknown subsystem |
| 1 | IMAGE_SUBSYSTEM_NATIVE | Device drivers and native Windows processes |
| 2 | IMAGE_SUBSYSTEM_WINDOWS_GUI | The Windows graphical user interface (GUI) subsystem |
| 3 | IMAGE_SUBSYSTEM_WINDOWS_CUI | The Windows character subsystem |
| 5 | IMAGE_SUBSYSTEM_OS2_CUI | The OS/2 character subsystem |
| 7 | IMAGE_SUBSYSTEM_POSIX_CUI | The Posix character subsystem |
| 8 | IMAGE_SUBSYSTEM_NATIVE_WINDOWS | Native Win9x driver |
| 9 | IMAGE_SUBSYSTEM_WINDOWS_CE_GUI | Windows CE |
| 10 | IMAGE_SUBSYSTEM_EFI_APPLICATION | An Extensible Firmware Interface (EFI) application |
| 11 | IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER | An EFI driver with boot services |
| 12 | IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER | An EFI driver with run-time services |
| 13 | IMAGE_SUBSYSTEM_EFI_ROM | An EFI ROM image |
| 14 | IMAGE_SUBSYSTEM_XBOX | XBOX |
| 16 | IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION | Windows boot application. |
Sources
- The signatures: the magic files of file(1), the Unix file command (file at commit 4fd573d): Magdir/
msdos, archive, compress, pdf, ole2compounddocs, msooxml, rtf, images, jpeg, riff, windows, virtual, filesystems and elf. file is under its own BSD-style licence. - The PE header, machine types and subsystems: Microsoft's PE Format (win32 at commit bc82a65), used under the Creative Commons Attribution 4.0 International licence (creativecommons.org/
licenses/ by/ 4.0/). - Format-Hex: Microsoft's Format-Hex reference (PowerShell-Docs at commit aedd8ef, same licence).
More Windows tools
-
Windows error code lookup
Look up 0x80070005, 0xC000006D, 1603 or any other system error, HRESULT, NTSTATUS or bug check code.
-
Robocopy command builder
Build a robocopy command line, paste one to see what each switch does, and decode its exit codes.
-
Msiexec silent install builder
Build install, uninstall and repair commands and look up MSI exit codes.
-
PowerShell EncodedCommand decoder
Read the script inside an encoded PowerShell command, layer by layer, or encode one.
-
.reg file value decoder
hex(2), hex(7), hex(b) and dword values of a .reg file as text and numbers, and a value written as .reg lines.
-
Certificate decoder
Read a certificate, a chain or a request: names, dates, thumbprint, template and account SID.
-
Access mask decoder
Read an access mask such as 0x1200A9 or -1610612736 as file, registry or Active Directory rights.
-
icacls explainer and command builder
Read icacls output such as (OI)(CI)(RX) in plain words, or build commands to grant, deny and remove rights.
-
KMS client keys and slmgr commands
Get the KMS client setup key (GVLK) of a Windows or Windows Server edition and the slmgr commands to activate it.
-
File hash checker
Work out the SHA-256, SHA-1, SHA-512 or MD5 hash of a file in your browser and compare it with the publisher's.
-
Zone.Identifier reader
The Mark of the Web on a downloaded file: its zone and address, and the commands that show and remove it.
-
Windows and IANA time zone names
Eastern Standard Time to America/New_York or America/Toronto and back, with tzutil, PowerShell and timedatectl.