Numbers

December 12, 2025 ยท View on GitHub

Type records and symbol records may contain instances of the Number type. In the PDB documentation, these are called "numeric leaves".

Example: The S_CONSTANT record contains a Number field which is the value of the constant.

Number contains a numeric value of a given value and type. The type of the number is represented in its encoding, so there is no need for an external specification of the type of the number.

Number is a variable-length data type. Its size can be determined from its encoded form.

The representation of Number always requires at least two bytes. These first two bytes either specify the literal value of the number (with an implied type), or they specify the type and size of the Number. The first two bytes are encoded as a little-endian uint16_t value, and we refer to this uint16_t value as the leaf.

If leaf is less than 0x8000, then the type is implicitly LF_USHORT (an unsigned 16-bit value), the value is simply the leaf value itself, and there are no additional bytes after the first two bytes. This is the simplest case and is very common.

If leaf is greater or equal to 0x8000, then the leaf specifies the type and size of the Number:

LeafLeaf TypeSize
(bytes)
Description
0x8000LF_CHAR1signed 8-bit integer
0x8001LF_SHORT2signed 16-bit integer
0x8002LF_USHORT2unsigned 16-bit integer
0x8003LF_LONG4signed 32-bit integer
0x8004LF_ULONG4unsigned 32-bit integer
0x8005LF_REAL32432-bit floating-point
0x8006LF_REAL64864-bit floating-point
0x8007LF_REAL801080-bit floating-point
0x8008LF_REAL12816128-bit floating-point
0x8009LF_QUADWORD8signed 64-bit integer
0x800aLF_UQUADWORD8unsigned 64-bit integer
0x800bLF_REAL48648-bit floating-point
0x800cLF_COMPLEX32832-bit floating-point complex (real, imaginary)
0x800dLF_COMPLEX641664-bit floating-point complex (real, imaginary)
0x800eLF_COMPLEX802080-bit floating-point complex (real, imaginary)
0x800fLF_COMPLEX12832128-bit floating-point complex (real, imaginary)
0x8010LF_VARSTRING*Variable-length string; see below
0x8017LF_OCTWORD16signed 128-bit integer
0x8018LF_UOCTWORD16unsigned 128-bit integer
0x8019LF_DECIMAL16OLE variant decimal value
0x801aLF_DATE8OLE variant date value
0x801bLF_UTF8STRING*UTF-8 NUL-terminated string

In this table, the "Size (Bytes)" column specifies the number of bytes that follow the leaf value; the size does not count the number of bytes in the leaf value itself. For example, the total size of an LF_ULONG number is 6 bytes, not 4 bytes.

There is no leaf value for an unsigned 8-bit value because all unsigned 8-bit values can be stored directly in leaf.

LF_VARSTRING (0x8010)

For LF_VARSTRING, the leaf value is followed by a uint16_t value that specifies the length in bytes of the string data, followed by the length data. There is no alignment padding after the string data.

Examples

Encoded bytesLeaf TypeValue
00 00LF_USHORT0
0a 01LF_USHORT266 (0x010a)
00 80 41LF_CHAR'A'
01 80 fe ffLF_SHORT-2
02 80 fe ffLF_USHORT0xfffe
03 80 11 22 00 00LF_LONG0x2211
04 80 fe ff ff ffLF_LONG-2
04 80 fe ff ff ffLF_ULONG0xfffffffe
1b 80 41 42 43 00LF_UTF8STRING"ABC"
10 80 04 00 44 45 46LF_VARSTRING"DEF"