Fix build and code structure improvements. New but essential UI functionality. CI improvements. Documentation improvements. AI module improvements.
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
using System.Buffers.Binary;
|
||||
using System.Text;
|
||||
using StellaOps.Scanner.CallGraph.Binary;
|
||||
using StellaOps.Scanner.CallGraph.Binary.Disassembly;
|
||||
using StellaOps.Scanner.CallGraph.Binary.Analysis;
|
||||
using StellaOps.Scanner.CallGraph.Binary.Disassembly;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
|
||||
// Avoid ambiguity by using fully qualified names where needed
|
||||
using DisassemblyTextSection = StellaOps.Scanner.CallGraph.Binary.Disassembly.BinaryTextSection;
|
||||
using DisassemblyArchitecture = StellaOps.Scanner.CallGraph.Binary.Disassembly.BinaryArchitecture;
|
||||
using DisassemblyTextSectionReader = StellaOps.Scanner.CallGraph.Binary.Disassembly.BinaryTextSectionReader;
|
||||
|
||||
namespace StellaOps.Scanner.CallGraph.Tests;
|
||||
|
||||
public class BinaryTextSectionReaderTests
|
||||
@@ -21,10 +27,10 @@ public class BinaryTextSectionReaderTests
|
||||
var path = WriteTempFile(data);
|
||||
try
|
||||
{
|
||||
var section = await BinaryTextSectionReader.TryReadAsync(path, BinaryFormat.Elf, CancellationToken.None);
|
||||
var section = await DisassemblyTextSectionReader.TryReadAsync(path, BinaryFormat.Elf, CancellationToken.None);
|
||||
Assert.NotNull(section);
|
||||
Assert.Equal(".text", section!.SectionName);
|
||||
Assert.Equal(BinaryArchitecture.X64, section.Architecture);
|
||||
Assert.Equal(DisassemblyArchitecture.X64, section.Architecture);
|
||||
Assert.Equal(0x1000UL, section.VirtualAddress);
|
||||
Assert.Equal(textBytes, section.Bytes);
|
||||
}
|
||||
@@ -44,10 +50,10 @@ public class BinaryTextSectionReaderTests
|
||||
var path = WriteTempFile(data);
|
||||
try
|
||||
{
|
||||
var section = await BinaryTextSectionReader.TryReadAsync(path, BinaryFormat.Pe, CancellationToken.None);
|
||||
var section = await DisassemblyTextSectionReader.TryReadAsync(path, BinaryFormat.Pe, CancellationToken.None);
|
||||
Assert.NotNull(section);
|
||||
Assert.Equal(".text", section!.SectionName);
|
||||
Assert.Equal(BinaryArchitecture.X64, section.Architecture);
|
||||
Assert.Equal(DisassemblyArchitecture.X64, section.Architecture);
|
||||
Assert.Equal(0x1000UL, section.VirtualAddress);
|
||||
Assert.Equal(textBytes, section.Bytes);
|
||||
}
|
||||
@@ -67,10 +73,10 @@ public class BinaryTextSectionReaderTests
|
||||
var path = WriteTempFile(data);
|
||||
try
|
||||
{
|
||||
var section = await BinaryTextSectionReader.TryReadAsync(path, BinaryFormat.MachO, CancellationToken.None);
|
||||
var section = await DisassemblyTextSectionReader.TryReadAsync(path, BinaryFormat.MachO, CancellationToken.None);
|
||||
Assert.NotNull(section);
|
||||
Assert.Equal("__text", section!.SectionName);
|
||||
Assert.Equal(BinaryArchitecture.Arm64, section.Architecture);
|
||||
Assert.Equal(DisassemblyArchitecture.Arm64, section.Architecture);
|
||||
Assert.Equal(0x1000UL, section.VirtualAddress);
|
||||
Assert.Equal(textBytes, section.Bytes);
|
||||
}
|
||||
@@ -196,7 +202,7 @@ public class BinaryTextSectionReaderTests
|
||||
WriteUInt32(data, sectionHeaderStart + 8, (uint)textBytes.Length);
|
||||
WriteUInt32(data, sectionHeaderStart + 12, 0x1000);
|
||||
WriteUInt32(data, sectionHeaderStart + 16, (uint)textBytes.Length);
|
||||
WriteUInt32(data, sectionHeaderStart + 20, textOffset);
|
||||
WriteUInt32(data, sectionHeaderStart + 20, (uint)textOffset);
|
||||
|
||||
Array.Copy(textBytes, 0, data, textOffset, textBytes.Length);
|
||||
return data;
|
||||
@@ -222,17 +228,17 @@ public class BinaryTextSectionReaderTests
|
||||
WriteInt32(data, 8, 0);
|
||||
WriteUInt32(data, 12, 2); // filetype
|
||||
WriteUInt32(data, 16, 1); // ncmds
|
||||
WriteUInt32(data, 20, cmdSize);
|
||||
WriteUInt32(data, 20, (uint)cmdSize);
|
||||
WriteUInt32(data, 24, 0); // flags
|
||||
WriteUInt32(data, 28, 0); // reserved
|
||||
|
||||
WriteUInt32(data, commandStart + 0, 0x19); // LC_SEGMENT_64
|
||||
WriteUInt32(data, commandStart + 4, cmdSize);
|
||||
WriteUInt32(data, commandStart + 4, (uint)cmdSize);
|
||||
WriteAscii(data, commandStart + 8, "__TEXT", 16);
|
||||
WriteUInt64(data, commandStart + 24, 0x1000);
|
||||
WriteUInt64(data, commandStart + 32, 0x1000);
|
||||
WriteUInt64(data, commandStart + 40, textOffset);
|
||||
WriteUInt64(data, commandStart + 48, textBytes.Length);
|
||||
WriteUInt64(data, commandStart + 40, (ulong)textOffset);
|
||||
WriteUInt64(data, commandStart + 48, (ulong)textBytes.Length);
|
||||
WriteInt32(data, commandStart + 56, 7);
|
||||
WriteInt32(data, commandStart + 60, 5);
|
||||
WriteUInt32(data, commandStart + 64, 1); // nsects
|
||||
@@ -242,8 +248,8 @@ public class BinaryTextSectionReaderTests
|
||||
WriteAscii(data, sectionStart + 0, "__text", 16);
|
||||
WriteAscii(data, sectionStart + 16, "__TEXT", 16);
|
||||
WriteUInt64(data, sectionStart + 32, 0x1000);
|
||||
WriteUInt64(data, sectionStart + 40, textBytes.Length);
|
||||
WriteUInt32(data, sectionStart + 48, textOffset);
|
||||
WriteUInt64(data, sectionStart + 40, (ulong)textBytes.Length);
|
||||
WriteUInt32(data, sectionStart + 48, (uint)textOffset);
|
||||
|
||||
Array.Copy(textBytes, 0, data, textOffset, textBytes.Length);
|
||||
return data;
|
||||
|
||||
Reference in New Issue
Block a user