Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:VHD (Virtual Hard Disk)

From ReverseEngineering.wiki
Format
On this wiki Facts · Code · Notes · Topics

Microsoft Virtual PC / Hyper-V VHD: a 512-byte big-endian footer starting "conectix" (also copied at the start of dynamic images) with disk type 2 fixed, 3 dynamic or 4 differencing; dynamic and differencing disks add a 1024-byte "cxsparse" header and a block allocation table.

Identification

A fixed VHD is the raw disk followed by a 512-byte footer at the end of the file. A dynamic or differencing VHD has a copy of the footer at offset 0 as well, so "conectix" at offset 0 means dynamic/differencing, and the authoritative footer is in the last 512 bytes. QEMU's probe (vpc_probe) checks only for "conectix" at the buffer start; its open code also locates the footer at the end for fixed images.

Footer (512 bytes, big endian; qemu block/vpc.c vhd_footer)

cookie "conectix" (8); features (4); version (4, 0x00010000 as written by QEMU); data_offset (8; offset of the next header, 0xFFFFFFFFFFFFFFFF for fixed); timestamp (4; seconds since 2000-01-01 00:00 UTC, base 946684800 in Unix time); creator_app (4, e.g. "vpc "); creator version major/minor (2+2); creator_os (4, e.g. "Wi2k"); original size (8); current size (8); disk geometry cylinders (2), heads (1), sectors per track (1); disk type (4); checksum (4); unique id (16); saved state (1); reserved (427).

Disk type (enum vhd_type): 2 fixed, 3 dynamic, 4 differencing. Checksum = one's complement of the byte sum of the footer with the checksum field excluded (vpc_checksum).

Size: QEMU uses the geometry (C x H x S x 512) unless current_size is preferred; maximum VHD_MAX_SECTORS 0xff000000 sectors (2040 GiB). Some tools write geometry that disagrees with current_size, so prefer current_size when they differ (Unverified as general rule; QEMU has a force_size_calc option because of this).

Dynamic disk header (1024 bytes at data_offset, "cxsparse")

cookie "cxsparse" (8); data_offset (8, unused 0xFF..); table_offset (8, offset of BAT); header version (4, 0x00010000); max_table_entries (4); block_size (4, power of two, 2 MiB default); checksum (4); parent unique id (16); parent timestamp (4); reserved (4); parent name UTF-16 (512); 8 parent locator entries (24 bytes each: platform code, data space, data length, reserved, data offset); reserved (256).

Unverified: the BAT holds one 32-bit big-endian sector number per block (0xFFFFFFFF = not allocated), and each allocated block starts with a sector bitmap (one bit per 512-byte sector, padded to a sector multiple) followed by the data.

Code & repositories

  • qemu block/vpc.c (GPL-2.0). libyal libvhdi documents the same format (LGPL-3).
  • https://github.com/qemu/qemu @ a19f59a72d96056d9a8f48cf6c77f5787491e414 · license: GPL-2.0-only (declared by the contributor; GitHub's detector did not recognize COPYING)
    block/qcow2.h, vpc.c, vhdx.h/.c, vmdk.c, vdi.c: on-disk structures of the virtual disk formats (COPYING is GPL-2.0; individual files carry GPL/MIT headers)
    Tested on: source read, not run: source read only · checked 2026-10-19; last activity 2026-10-17