60 lines
1.3 KiB
C#
60 lines
1.3 KiB
C#
// Copyright (c) StellaOps. All rights reserved.
|
|
// Licensed under BUSL-1.1. See LICENSE in the project root.
|
|
|
|
namespace StellaOps.Scanner.ChangeTrace.ByteDiff;
|
|
|
|
/// <summary>
|
|
/// Analyzes binary format sections (ELF, PE, Mach-O).
|
|
/// </summary>
|
|
public interface ISectionAnalyzer
|
|
{
|
|
/// <summary>
|
|
/// Extract section information from binary.
|
|
/// </summary>
|
|
Task<IReadOnlyList<SectionInfo>> AnalyzeAsync(byte[] binary, CancellationToken ct = default);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Information about a binary section.
|
|
/// </summary>
|
|
/// <param name="Name">Section name (e.g., ".text", ".data").</param>
|
|
/// <param name="Offset">Offset in bytes from start of file.</param>
|
|
/// <param name="Size">Size in bytes.</param>
|
|
/// <param name="Type">Type of section.</param>
|
|
public sealed record SectionInfo(
|
|
string Name,
|
|
long Offset,
|
|
long Size,
|
|
SectionType Type);
|
|
|
|
/// <summary>
|
|
/// Type of binary section.
|
|
/// </summary>
|
|
public enum SectionType
|
|
{
|
|
/// <summary>
|
|
/// Code section (.text).
|
|
/// </summary>
|
|
Code,
|
|
|
|
/// <summary>
|
|
/// Data section (.data, .rodata).
|
|
/// </summary>
|
|
Data,
|
|
|
|
/// <summary>
|
|
/// Uninitialized data section (.bss).
|
|
/// </summary>
|
|
Bss,
|
|
|
|
/// <summary>
|
|
/// Debug information (.debug_*).
|
|
/// </summary>
|
|
Debug,
|
|
|
|
/// <summary>
|
|
/// Other section type.
|
|
/// </summary>
|
|
Other
|
|
}
|