Skip to content

StringExtractor

Namespace: Dotsider.Core.Analysis

Assembly: Dotsider.Core.dll

Extracts strings from .NET assemblies across three sources: the #US heap (user string literals), the #Strings heap (metadata identifiers), and raw printable character sequences from the binary.

public sealed class StringExtractor

ObjectStringExtractor

Extracts strings from .NET assemblies across three sources: the #US heap (user string literals), the #Strings heap (metadata identifiers), and raw printable character sequences from the binary.

Parameters:

public StringExtractor(AssemblyAnalyzer analyzer)

Number of malformed entries skipped during the last ExtractMetadataStrings call.

Returns: Int32

public int SkippedMetadataStringCount { get; }

Number of malformed entries skipped during the last ExtractUserStrings call.

Returns: Int32

public int SkippedUserStringCount { get; }

Extracts all identifier strings from the #Strings metadata heap. These are type names, method names, namespace names, and other metadata identifiers.

Returns: IReadOnlyList<StringEntry>

A list of string entries from the metadata strings heap.

public IReadOnlyList<StringEntry> ExtractMetadataStrings()

Extracts raw printable character sequences from the binary file. Scans for consecutive ASCII printable characters (0x20-0x7E) of at least minLength bytes.

Parameters:

  • minLength (Int32): The minimum number of consecutive printable characters to consider a string.

Returns: IReadOnlyList<StringEntry>

A list of string entries extracted from the raw binary.

public IReadOnlyList<StringEntry> ExtractRawStrings(int minLength = 4)

Extracts printable UTF-16LE character sequences from the binary file. Scans for runs of little-endian code units in the printable ASCII range (0x20–0x7E stored as two bytes), which is how managed string literals freeze in Native AOT images. The file is scanned once per byte parity, so runs at odd offsets are found too. Accepting the full BMP instead would drown the results in noise — most random 16-bit values decode to a printable character.

Parameters:

  • minLength (Int32): The minimum number of consecutive printable characters to consider a string.

Returns: IReadOnlyList<StringEntry>

A list of string entries extracted from the raw binary.

public IReadOnlyList<StringEntry> ExtractRawUtf16Strings(int minLength = 4)

Extracts all user string literals from the #US metadata heap. These are the string constants used in IL code via ldstr.

Returns: IReadOnlyList<StringEntry>

A list of string entries from the user strings heap.

public IReadOnlyList<StringEntry> ExtractUserStrings()