Skip to content

Commit 9e83ea1

Browse files
committed
Ensure that auto call type adjustments don't overwrite user call type adjustments of the same confidence
A call type adjustment set via `SetAutoCallTypeAdjustment` will only take effect if any existing call type adjustment, automatic or user-defined, is of a lower confidence level. This ensures that user call type adjustments with full confidence will not be overridden by a workflow. Similar changes have been made to `SetAutoCallStackAdjustment`, `SetAutoInlinedDuringAnalysis` and the overload of `SetAutoCallRegisterStackAdjustment` that adjusts a single register stack.
1 parent cf2285c commit 9e83ea1

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

binaryninjaapi.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12435,12 +12435,53 @@ namespace BinaryNinja {
1243512435
std::vector<ArchAndAddr> GetUnresolvedIndirectBranches();
1243612436
bool HasUnresolvedIndirectBranches();
1243712437

12438+
/*! \brief Apply an automatic type adjustment to the call at `addr` in `arch`.
12439+
12440+
The adjustment will take effect if the new confidence level is higher than the confidence
12441+
level of any existing adjustment at the given address, whether automatic or user-defined.
12442+
12443+
\param arch Architecture for the call instruction
12444+
\param addr Address of the call instruction
12445+
\param adjust Type adjustment to apply
12446+
*/
1243812447
void SetAutoCallTypeAdjustment(Architecture* arch, uint64_t addr, const Confidence<Ref<Type>>& adjust);
12448+
12449+
/*! \brief Apply an automatic stack adjustment to the call at `addr` in `arch`.
12450+
12451+
The adjustment will take effect if the new confidence level is higher than the confidence
12452+
level of any existing adjustment at the given address, whether automatic or user-defined.
12453+
12454+
\param arch Architecture for the call instruction
12455+
\param addr Address of the call instruction
12456+
\param adjust Stack adjustment to apply
12457+
*/
1243912458
void SetAutoCallStackAdjustment(Architecture* arch, uint64_t addr, const Confidence<int64_t>& adjust);
12459+
12460+
/*! \brief Apply automatic register stack adjustments to the call at `addr` in `arch`.
12461+
12462+
\note This overwrites any existing register stack adjustments at the given address,
12463+
irrespective of their confidence level.
12464+
12465+
\param arch Architecture for the call instruction
12466+
\param addr Address of the call instruction
12467+
\param adjust Map of register stack adjustments to apply
12468+
*/
1244012469
void SetAutoCallRegisterStackAdjustment(
1244112470
Architecture* arch, uint64_t addr, const std::map<uint32_t, Confidence<int32_t>>& adjust);
12471+
12472+
/*! \brief Apply an automatic register stack adjustment for a specific register stack to the call at `addr` in `arch`.
12473+
12474+
The adjustment will take effect if the new confidence level is higher than the confidence
12475+
level of any existing adjustment at the given address, whether automatic or user-defined.
12476+
12477+
\param arch Architecture for the call instruction
12478+
\param addr Address of the call instruction
12479+
\param regStack Register stack identifier
12480+
\param adjust Register stack adjustment to apply
12481+
*/
1244212482
void SetAutoCallRegisterStackAdjustment(
1244312483
Architecture* arch, uint64_t addr, uint32_t regStack, const Confidence<int32_t>& adjust);
12484+
1244412485
void SetUserCallTypeAdjustment(Architecture* arch, uint64_t addr, const Confidence<Ref<Type>>& adjust);
1244512486
void SetUserCallStackAdjustment(Architecture* arch, uint64_t addr, const Confidence<int64_t>& adjust);
1244612487
void SetUserCallRegisterStackAdjustment(
@@ -12641,6 +12682,15 @@ namespace BinaryNinja {
1264112682
bool GetInstructionContainingAddress(Architecture* arch, uint64_t addr, uint64_t* start);
1264212683

1264312684
Confidence<bool> IsInlinedDuringAnalysis();
12685+
/*! Set whether the function should be inlined during analysis.
12686+
12687+
This will take effect if the new confidence level is higher than the confidence
12688+
level of the existing value of `IsInlinedDuringAnalysis`, whether automatic or
12689+
user-defined.
12690+
12691+
\param inlined Whether the function should be inlined.
12692+
12693+
*/
1264412694
void SetAutoInlinedDuringAnalysis(Confidence<bool> inlined);
1264512695
void SetUserInlinedDuringAnalysis(Confidence<bool> inlined);
1264612696

0 commit comments

Comments
 (0)