mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-07-01 20:40:27 +03:00
Fix address conversion in BlockDisassembler to properly handle RVA addresses and ensure entry blocks are correctly identified
This commit is contained in:
@ -1,13 +1,41 @@
|
||||
namespace X86Disassembler.Analysers;
|
||||
namespace X86Disassembler.Analysers;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a disassembled function with its control flow graph
|
||||
/// </summary>
|
||||
public class AsmFunction
|
||||
{
|
||||
/// <summary>
|
||||
/// The starting address of the function
|
||||
/// </summary>
|
||||
public ulong Address { get; set; }
|
||||
|
||||
public List<InstructionBlock> Blocks { get; set; }
|
||||
/// <summary>
|
||||
/// The list of basic blocks that make up the function
|
||||
/// </summary>
|
||||
public List<InstructionBlock> Blocks { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// The entry block of the function
|
||||
/// </summary>
|
||||
public InstructionBlock? EntryBlock => Blocks.FirstOrDefault(b => b.Address == Address);
|
||||
|
||||
/// <summary>
|
||||
/// The exit blocks of the function (blocks that end with a return instruction)
|
||||
/// </summary>
|
||||
public List<InstructionBlock> ExitBlocks => Blocks.Where(b =>
|
||||
b.Instructions.Count > 0 &&
|
||||
b.Instructions[^1].Type.IsRet()).ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation of the function, including its address and blocks
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Function at {Address:X8}\n{string.Join("\n", Blocks.Select(x => $"\t{x}"))}";
|
||||
return $"Function at 0x{Address:X8}\n" +
|
||||
$"Entry Block: 0x{EntryBlock?.Address.ToString("X8") ?? "None"}\n" +
|
||||
$"Exit Blocks: {(ExitBlocks.Count > 0 ? string.Join(", ", ExitBlocks.Select(b => $"0x{b.Address:X8}")) : "None")}\n" +
|
||||
$"Total Blocks: {Blocks.Count}\n" +
|
||||
$"{string.Join("\n", Blocks.Select(x => $"\t{x}"))}";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user