Files
rea/docs/guides/data/evtx-archives.md
morluto 44fbcfc787 feat(evtx)!: page event records with offset and report page facts (#15636)
* feat(evtx): page event records with offset and report page facts

inspect_evtx_archive stopped walking at max_records, so records past the first 20,000 (the newest events of a default-size Application log) could not be listed. The walk now covers every record. max_records stays a 20,000-record page bound, which limits retained Evidence. A new zero-based offset selects the first record listed. The result reports page { offset, limit, returned, total, next_offset }, and the record-limit-reached diagnostic names offset=next_offset. Coverage now describes parse loss only, so a page that leaves records out by selection is no longer partial, and chunk ending facts and endpoint checks cover records past the page.

Fixes #15612

* feat(evtx)!: qualify the file-tail offset for small and wrapped logs

The suggested tail offset is now the larger of 0 and page.total minus max_records, so a log smaller than one page gets a valid offset. File order is oldest first only in a log that has not wrapped; the guide and descriptions now say how chunks[] locates the newest records in a wrapped log.

BREAKING CHANGE: inspect_evtx_archive results now require page. Evidence saved before this change has no page, and inspect_analysis_view refuses to summarise it. Re-run inspect_evtx_archive on the log to produce current Evidence.
2026-12-01 17:15:02 -05:00

6.0 KiB

Offline Windows event log inventory

inspect_evtx_archive / rea inspect-evtx-archive reads one local Windows Event Log (.evtx) file and lists its records. It never contacts a live Event Log service, boots the source system, or executes event-provided content.

rea inspect-artifact ./capture.data recognizes the complete ElfFile signature and recommends inspect_evtx_archive, regardless of the filename. Recognition names the format; the dedicated reader reports malformed or incomplete structure.

What this version reads

Records are reported in file order. For each record the inventory keeps the chunk it was found in, its byte offset inside that 64 KiB chunk, the EventRecordID its header states as a lossless decimal string, the SystemTime with all seven fractional digits, and the byte extent the record declares. Each chunk reports its position in the file as chunk_number, the event numbers and timestamps of its first and last record, and whether its header checksum matched. When a damaged record ends the walk inside a chunk, the records after that point were never examined, so the chunk's last_event_record_id and last_timestamp_ms are null rather than the last record that was listed.

The channel, provider, event ID, level, EventData values and user identifiers live inside the embedded event XML, which this version does not decode: they are absent rather than inferred from the record number. Typed payload values, event templates, substitution arrays and per-record checksums are likewise not resolved.

Page through the records

Every record in the file is walked and counted, but one call lists at most max_records of them (default and maximum 20,000), starting at the zero-based file-order ordinal offset (default 0). The ceiling bounds the retained Evidence, which grows by roughly 240 bytes of JSON per listed record. Chunk facts and diagnostics always cover the whole file.

page reports offset, limit (the effective max_records), returned, total records in the file and next_offset (null when no records remain). When records remain, a record-limit-reached diagnostic names the offset= value for the next call. The file tail starts at the larger of 0 and page.total minus max_records. For a 33,227-record log:

rea inspect-evtx-archive ./Application.evtx --offset 13227 --max-records 20000 --json

File order is oldest first only in a log that has not wrapped. A wrapped log reuses its oldest chunks, so newer records can sit in earlier slots. In that case, use the record identifiers in chunks[] to find the newest chunk; the ordinal of its first record is the sum of events over the chunks before it.

Each page is separate Evidence, because offset and max_records are part of the request.

Sources and coverage

source_coverage states what the inventory examined. event_xml and typed_payload_values are always not-decoded; templates is always not-resolved. record_checksums is always not-verified and network is always not-contacted. status describes parse loss, not the selected page: it is complete-within-scope only when every chunk was read without a structural diagnostic. A diagnostic limit, a truncated record, an undecodable chunk or a chunk whose first record identifier disagrees with the identifier in that record makes it partial, and each cause appears in diagnostics. Records left out by offset or max_records were examined and do not make it partial.

A chunk is numbered by its physical position in the file, never by a value stored in the chunk. The first event record number at 0x08 and the first record identifier at 0x18 are distinct fields. A disagreement between the identifier and the first record's own identifier is reported as first-record-id-mismatch.

The declared file chunk count and the physical chunk-slot count are reported separately. Logs exported with wevtutil epl keep zero-filled slots after the declared chunks; those slots are unused space and do not affect coverage. Any other disagreement, including a nonzero slot after the declared chunks, is partial coverage; readable chunks are still inventoried. Both endpoint identifiers are checked after a complete chunk walk, and each record must carry a matching trailing size. Child identifiers include the source digest, so identical paths or positions do not conflate different logs.

A wrapped log leaves stale bytes after its last record. Those bytes are not reported as a truncation, and they do not discard the events the chunk did contain.

The chunk's last-record offset bounds the last record's start, and the free-space offset bounds its end. Bytes after the last record are not inventoried. Invalid or inconsistent offsets leave the live region unknown and make coverage partial. An incomplete final chunk is also reported and skipped.

Structure and bounds

The file must start with the ElfFile signature and the 128-byte block header must be at least as large as itself; anything else is reported as not-an-evtx-file or invalid-header rather than being scanned as records. A chunk that does not start with ElfChnk is skipped with invalid-chunk, and its neighbours are still read.

max_file_bytes (64 MiB) bounds the read. A file over that limit is refused with a resource error before parsing starts, so it yields no inventory at all. max_records (20000) bounds the records listed per call; see Page through the records. Diagnostic growth is bounded separately, because one malformed chunk can contain many bad records.

Retain the complete inventory with a summary

Use --detail summary --evidence_output /absolute/new-evidence.bundle.json for counts, the record page, artifact identity and source coverage in the reply. The bundle retains the complete parent Evidence, including the inventoried records and diagnostics. The summary names that parent and its digest. Complete summary projection does not imply complete source coverage; format limits, omissions and unsupported content remain explicit in source_coverage.