Skip to content
This repository was archived by the owner on Jun 11, 2026. It is now read-only.
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

* Preserve trampoline argument registers in code-coverage builds.
* Preserve object-hook super trampolines in optimized Release builds, fixing https://github.com/steipete/InterposeKit/issues/29. Thanks to [@Thomvis](https://github.com/Thomvis).
* Preserve floating-point arguments when object hooks invoke original methods on arm64. Thanks to [@ishutinvv](https://github.com/ishutinvv).

## 0.01

Expand Down
6 changes: 3 additions & 3 deletions Sources/SuperBuilder/src/ITKSuperBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ asm volatile (

#if PROTECT_FLOATING_POINT_REGISTERS
// pop {q0-q7}
"ldp q6, q7, [sp], #32\n"
"ldp q4, q5, [sp], #32\n"
"ldp q2, q3, [sp], #32\n"
"ldp q0, q1, [sp], #32\n"
"ldp q2, q3, [sp], #32\n"
"ldp q4, q5, [sp], #32\n"
"ldp q6, q7, [sp], #32\n"
#endif

// get new return (adr of the objc_super class)
Expand Down
20 changes: 20 additions & 0 deletions Tests/InterposeKitTests/ObjectInterposeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,26 @@ final class ObjectInterposeTests: InterposeKitTestCase {
try hook.revert()
}

#if arch(arm64)
func test8FloatingPointParameters() throws {
let testObj = TestClass()
let expected = 87_654_321.0
XCTAssertEqual(testObj.combine(1, 2, 3, 4, 5, 6, 7, 8), expected)

let hook = try testObj.hook(#selector(TestClass.combine)) { (store: TypedHook
<@convention(c) (AnyObject, Selector, Double, Double, Double, Double,
Double, Double, Double, Double) -> Double,
@convention(block) (AnyObject, Double, Double, Double, Double,
Double, Double, Double, Double) -> Double>) in {
store.original($0, store.selector, $1, $2, $3, $4, $5, $6, $7, $8)
}
}

XCTAssertEqual(testObj.combine(1, 2, 3, 4, 5, 6, 7, 8), expected)
try hook.revert()
}
#endif

func testObjectCallReturn() throws {
let testObj = TestClass()
let str = "foo"
Expand Down
9 changes: 9 additions & 0 deletions Tests/InterposeKitTests/TestClass.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ class TestClass: NSObject {
var1 + var2 + var3 + var4 + var5 + var6
}

#if arch(arm64)
// swiftlint:disable:next function_parameter_count
@objc dynamic func combine(_ value0: Double, _ value1: Double, _ value2: Double, _ value3: Double,
_ value4: Double, _ value5: Double, _ value6: Double, _ value7: Double) -> Double {
value0 + (value1 * 10) + (value2 * 100) + (value3 * 1_000)
+ (value4 * 10_000) + (value5 * 100_000) + (value6 * 1_000_000) + (value7 * 10_000_000)
}
#endif

// This requires _objc_msgSendSuper_stret on x64, returns a large struct
@objc dynamic func invert3DTransform(_ input: CATransform3D) -> CATransform3D {
input.inverted
Expand Down
Loading