HyperDbg/hyperdbg/include/SDK/headers
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
..
Assertions.h change SDK folders to lowercase 2024-07-28 20:42:48 +09:00
BasicTypes.h New platform functions added for hyperhv compilation 2026-08-23 13:04:20 +02:00
Connection.h header files 2026-08-06 21:11:59 +03:30
Constants.h change help messages of uin and uout commands 2026-09-15 13:59:46 +02:00
DataTypes.h Swepped hyperhv project for platform functions and swapped them 2026-08-17 15:24:25 +02:00
ErrorCodes.h moving pool mananger from hyperhv to hyperkd 2026-06-04 00:06:41 +02:00
Events.h refactor IOCTL codes 2026-05-17 17:07:59 +02:00
HardwareDebugger.h fix: correct typos and one copy-paste error in comments and messages 2026-04-23 12:38:48 +00:00
Ioctls.h header files 2026-08-06 21:11:59 +03:30
LbrDefinitions.h perform adjustments for call_stack filter option of LBR 2026-05-17 04:27:56 +02:00
Pcie.h Size the PCI CAM config space buffer at its real 256 bytes 2026-10-04 21:46:13 +02:00
PtDefinitions.h add user mode PT parameter parser 2026-06-30 20:30:25 +02:00
RequestStructures.h Add dps command 2026-08-29 03:25:53 -07:00
ScriptEngineCommonDefinitions.h update function parameter to the script engine 2026-08-14 21:40:42 +08:00
Symbols.h refactor IOCTL codes 2026-05-17 17:07:59 +02:00