Class MemoryScan
- Namespace
- CStructSharp.Memory
- Assembly
- CStructSharp.dll
Deterministic bounded scan transport over caller-supplied ranges, independent of candidate interpretation.
public static class MemoryScan
- Inheritance
-
MemoryScan
- Inherited Members
Methods
Run(IEnumerable<MemoryRegion>, MemoryScanVisitor, MemoryAccessContext, int, int, int, int, int)
Streams known windows, reusing context bytes and retaining later islands after unavailable reads.
public static MemoryScanResult Run(IEnumerable<MemoryRegion> ranges, MemoryScanVisitor visitor, MemoryAccessContext context, int windowBytes = 1048576, int overlapBytes = 0, int unavailableStride = 1, int maxWindows = 1000000, int maxRanges = 100000)
Parameters
rangesIEnumerable<MemoryRegion>Explicit finite logical ranges, with caller-owned sources.
visitorMemoryScanVisitorSynchronous borrowed-window callback. It must enforce candidate/hit/result limits.
contextMemoryAccessContextShared CPU, translation and transport budget; cancellation always propagates.
windowBytesintOwned candidate-start bytes per full window, between 1 and 64 MiB.
overlapBytesintContext on either side, at most windowBytes. Complete candidates must fit the chosen context bound.
unavailableStrideintExplicit unavailable-unit size in bytes, aligned to logical coordinates.
maxWindowsintMaximum callbacks, also bounding retained consumer work.
maxRangesintMaximum supplied ranges, before coalescing.
Returns
- MemoryScanResult
Coverage and explicit completion reason. Exhausted ranges can still contain unavailable coverage.
Remarks
Ranges are supplied in desired order. Adjacent ranges in the same source are continuous; overlapping or descending adjacent ranges in that source are rejected. Unknown intervals break continuity. A positive short read is retried. UnavailableStride explicitly permits skipping to the next aligned unit after a failed byte; use 1 for arbitrary byte-level holes or the source's known page granularity. Coverage counts that whole skipped unit as unavailable. Align candidates using window.Address, not buffer offset zero.
Exceptions
- ArgumentOutOfRangeException
Limits or scratch sizes are invalid.
- ArgumentException
Neighboring ranges in one source overlap or descend.
- MemoryAccessException
The shared budget is exhausted.
- OperationCanceledException
Cancellation was requested.