Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Handle/BNBasicBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,9 @@ ref length
break;
}

yield return new InstructionTextLine(tokens);
// Carry the instruction's start address on the line, mirroring Python's
// Function.instructions / BinaryView.instructions which yield (tokens, addr).
yield return new InstructionTextLine(tokens, address);
address += length;
}

Expand Down
16 changes: 13 additions & 3 deletions NavigationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,7 @@ private static void VerifyDerivedStringLayout()
return null;
}

// Match the requested platform (or the view default) first, then fall back to the
// first candidate, exactly as Python does.
// Match the requested platform (or the view default) first.
Platform? resolved = platform;
if (null == resolved)
{
Expand All @@ -545,7 +544,18 @@ private static void VerifyDerivedStringLayout()
}
}

return candidates[0];
// Implicit-platform lookups fall back to the first candidate, exactly as Python does
// when plat is None (get_function_at falls back to funcs[0]). An explicit platform
// with no match returns null: Python's plat-is-not-None branch is a strict
// BNGetAnalysisFunction(view, plat, addr) lookup that returns None when no function on
// that platform sits at the address -- it must NOT silently return a different
// platform's function.
if (null == platform)
{
return candidates[0];
}

return null;
}

/// <summary>
Expand Down
28 changes: 20 additions & 8 deletions Struct/BNInstructionTextLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,30 @@ internal unsafe struct BNInstructionTextLine
public ulong count;
}

public sealed class InstructionTextLine
public sealed class InstructionTextLine
{
public InstructionTextToken[] Tokens { get; } = Array.Empty<InstructionTextToken>();

public InstructionTextLine()

// The virtual address of the first byte of the instruction this line disassembles. Python's
// Function.instructions / BinaryView.instructions generators yield (tokens, addr) per
// instruction; this field carries that address so consumers do not lose it. It is 0 when the
// line was not produced by an address-walking generator (e.g. synthesized token lists).
public ulong Address { get; } = 0;

public InstructionTextLine()
{

}
public InstructionTextLine(InstructionTextToken[] tokens)

public InstructionTextLine(InstructionTextToken[] tokens)
{
this.Tokens = tokens;
this.Tokens = tokens;
}

public InstructionTextLine(InstructionTextToken[] tokens, ulong address)
{
this.Tokens = tokens;
this.Address = address;
}

public override string ToString()
Expand All @@ -42,7 +54,7 @@ public override string ToString()
{
builder.Append(token.Text);
}

return builder.ToString();
}
}
Expand Down
Loading