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
9 changes: 7 additions & 2 deletions HighLevelIL/HLILDerefField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ public long Offset
}
}

public ulong MemoryIndex
/// <summary>
/// The named-member index, or null when there is no named member. Mirrors Python
/// <c>_get_member_index</c> (renamed from <c>MemoryIndex</c> for parity with
/// <see cref="HLILStructField.MemberIndex"/> and <see cref="HLILDerefFieldSSA"/>).
/// </summary>
public long? MemberIndex
{
get
{
return this.RawOperands[2];
return HighLevelILInstruction.MemberIndexFromRawOperand(this.RawOperands[2]);
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions HighLevelIL/HLILDerefFieldSSA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ public long Offset
}
}

public ulong MemoryIndex
/// <summary>
/// The named-member index, or null when there is no named member. Mirrors Python
/// <c>_get_member_index</c> (renamed from <c>MemoryIndex</c> for parity with
/// <see cref="HLILStructField.MemberIndex"/> and <see cref="HLILDerefField"/>).
/// </summary>
public long? MemberIndex
{
get
{
return this.RawOperands[3];
return HighLevelILInstruction.MemberIndexFromRawOperand(this.RawOperands[3]);
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions HighLevelIL/HLILStructField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ public long Offset
}
}

public ulong MemberIndex
/// <summary>
/// The named-member index, or null when there is no named member. Mirrors Python
/// <c>_get_member_index</c>: the sentinel (1&lt;&lt;63) means no named member.
/// </summary>
public long? MemberIndex
{
get
{
return this.RawOperands[2];
return HighLevelILInstruction.MemberIndexFromRawOperand(this.RawOperands[2]);
}
}
}
Expand Down
19 changes: 16 additions & 3 deletions Struct/BNHighLevelILInstruction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ public abstract class HighLevelILInstruction :
{ HighLevelILOperation.HLIL_ASSERT, 1 }, // cond

{ HighLevelILOperation.HLIL_VAR, 1 }, // var
{ HighLevelILOperation.HLIL_STRUCT_FIELD, 2 }, // base, fieldOffset/index
{ HighLevelILOperation.HLIL_STRUCT_FIELD, 3 }, // base, fieldOffset, memberIndex
{ HighLevelILOperation.HLIL_ARRAY_INDEX, 2 }, // base, index
{ HighLevelILOperation.HLIL_SPLIT, 2 }, // hi, lo
{ HighLevelILOperation.HLIL_DEREF, 1 }, // addr
{ HighLevelILOperation.HLIL_DEREF_FIELD, 2 }, // addr, fieldOffset/index
{ HighLevelILOperation.HLIL_DEREF_FIELD, 3 }, // addr, fieldOffset, memberIndex
{ HighLevelILOperation.HLIL_ADDRESS_OF, 1 }, // var/expr

{ HighLevelILOperation.HLIL_CONST, 1 }, // value
Expand Down Expand Up @@ -201,7 +201,7 @@ public abstract class HighLevelILInstruction :
{ HighLevelILOperation.HLIL_VAR_SSA, 2 }, // var, version
{ HighLevelILOperation.HLIL_ARRAY_INDEX_SSA, 3 }, // base, index, srcMem
{ HighLevelILOperation.HLIL_DEREF_SSA, 2 }, // addr, srcMem
{ HighLevelILOperation.HLIL_DEREF_FIELD_SSA, 3 }, // addr, field, srcMem
{ HighLevelILOperation.HLIL_DEREF_FIELD_SSA, 4 }, // addr, srcMem, fieldOffset, memberIndex

{ HighLevelILOperation.HLIL_CALL_SSA, 4 }, // dest, params(list), outputs(list), srcMem
{ HighLevelILOperation.HLIL_SYSCALL_SSA, 3 }, // params(list), outputs(list), srcMem
Expand Down Expand Up @@ -986,6 +986,19 @@ public double GetOperandAsDouble(OperandIndex operand)
{
return BitConverter.UInt64BitsToDouble(this.RawOperands[(ulong)operand]);
}

// member_index mask: mirrors Python HighLevelILInstruction._get_member_index. The sentinel
// (1<<63) means "no named member" and is returned as null; otherwise the (non-negative)
// named-member index. Callers pass the already-extracted raw operand value.
internal static long? MemberIndexFromRawOperand(ulong rawOperand)
{
if (0UL != (rawOperand & (1UL << 63)))
{
return null;
}

return (long)rawOperand;
}

public RegisterValue GetOperandAsConstantData(
OperandIndex operand1 ,
Expand Down
Loading