HyperDbg/hyperdbg/hyperhv
enzo-berry 5c95fed361 Size the PCI CAM config space buffer at its real 256 bytes
PCI CAM configuration space is 256 bytes, offsets 0x00 to 0xff, but
CAM_CONFIG_SPACE_LENGTH is defined as 255, next to BUS_MAX_NUM and
DEV_MAX_NUM which legitimately are 255.

The buffer that holds a captured config space is sized from that constant:

    BYTE ConfigSpaceAdditional[CAM_CONFIG_SPACE_LENGTH - sizeof(PORTABLE_PCI_CONFIG_SPACE_HEADER)];

giving 64 + 191 = 255 contiguous bytes. Every loop over it, however, is
written in terms of the real 256-byte size and steps in units that overshoot
the constant. ExtensionCommandPcidevinfo() fills the buffer with

    for (UINT16 i = 0; i < CAM_CONFIG_SPACE_LENGTH; i += 4)

which runs i = 0, 4, ... 252 and writes a DWORD each time, so it writes 256
bytes into those 255 - one byte past the end of the config space, into the
first byte of MmioBarInfo[0].Is64Bit that follows it in PCI_DEV. The write
stays inside the enclosing struct, so this is a correctness bug rather than
memory corruption, but the last byte of config space is stored outside the
buffer that is meant to hold it. The two raw-dump loops (i += 16) likewise
cover 256 bytes and read the last one from beyond the buffer.

Define the constant as the length it is named for. The buffer becomes 64 +
192 = 256 bytes, the fill loop lands exactly on the end, and both dump loops
cover exactly 16 rows of 16 bytes. The existing

    static_assert(sizeof(DEBUGGEE_PCIDEVINFO_REQUEST_RESPONSE_PACKET) < PacketChunkSize)

still holds with the one byte the packet grows by.

PciReadCam()/PciWriteCam() compare a byte offset against the same constant,
so the bound is switched to >= to keep meaning a valid offset now that the
constant is a length rather than the highest offset. Both comparisons are
still statically false because Offset is a BYTE; this only stops the check
from being wrong if that parameter is ever widened.
2026-10-04 21:46:13 +02:00
..
code Size the PCI CAM config space buffer at its real 256 bytes 2026-10-04 21:46:13 +02:00
header Swepped hyperhv project for platform functions and swapped them 2026-08-17 15:24:25 +02:00
CMakeLists.txt change arch and file names 2026-02-13 12:12:44 +03:30
hyperhv.def build based on new libhyperdbg 2024-06-24 18:05:54 +09:00
hyperhv.vcxproj New fail came up, so new fix 2026-08-23 15:17:38 +02:00
hyperhv.vcxproj.filters New fail came up, so new fix 2026-08-23 15:17:38 +02:00
packages.config add WDK and SDK NuGet packages and Fix CI/CD 2026-06-21 03:02:49 +02:00
pch.c build based on new libhyperdbg 2024-06-24 18:05:54 +09:00
pch.h Added new platform API functions and changed them in the source code 2026-08-23 13:04:20 +02:00