diff --git a/Function/BNGetDerivedStringCodeReferences.cs b/Function/BNGetDerivedStringCodeReferences.cs
index efc0e50..4aec198 100644
--- a/Function/BNGetDerivedStringCodeReferences.cs
+++ b/Function/BNGetDerivedStringCodeReferences.cs
@@ -25,10 +25,10 @@ internal static extern IntPtr BNGetDerivedStringCodeReferences(
IntPtr str ,
// size_t* count
- IntPtr count ,
+ out UIntPtr count,
// bool limit
- bool limit ,
+ [MarshalAs(UnmanagedType.I1)] bool limit,
// size_t maxItems
UIntPtr maxItems
diff --git a/NavigationExtensions.cs b/NavigationExtensions.cs
index 727fb16..8875071 100644
--- a/NavigationExtensions.cs
+++ b/NavigationExtensions.cs
@@ -516,6 +516,55 @@ public static DerivedString[] GetDerivedStrings(this BinaryView view)
}
}
+ ///
+ /// Returns code references associated with an analyzed derived string.
+ ///
+ public static ReferenceSource[] GetDerivedStringCodeReferences(
+ this BinaryView view,
+ DerivedString derivedString,
+ ulong? maxItems = null
+ )
+ {
+ if (null == view)
+ {
+ throw new ArgumentNullException(nameof(view));
+ }
+
+ if (null == derivedString)
+ {
+ throw new ArgumentNullException(nameof(derivedString));
+ }
+
+ BNDerivedString native = derivedString.ToNativeEx();
+ try
+ {
+ using (ScopedAllocator allocator = new ScopedAllocator())
+ {
+ IntPtr references = NativeMethods.BNGetDerivedStringCodeReferences(
+ view.DangerousGetHandle(),
+ allocator.AllocStruct(native),
+ out UIntPtr countValue,
+ maxItems.HasValue,
+ new UIntPtr(maxItems.GetValueOrDefault())
+ );
+
+ return UnsafeUtils.TakeStructArrayEx(
+ references,
+ countValue.ToUInt64(),
+ ReferenceSource.FromNative,
+ NativeMethods.BNFreeCodeReferences
+ );
+ }
+ }
+ finally
+ {
+ if (IntPtr.Zero != native.value)
+ {
+ NativeMethods.BNFreeStringRef(native.value);
+ }
+ }
+ }
+
// Adapts BNFreeDerivedStringList (which takes a UIntPtr count) to the
// Action signature TakeStructArrayEx expects. Named method, not a
// lambda, per the project's C# style rules.