Skip to content

Hook individual objects #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 78 commits into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
f4287f3
add sample for segfault
steipete Jun 6, 2020
807a047
push changes for abort trap 6
steipete Jun 6, 2020
e8a63b8
Cursed first version
steipete Jun 6, 2020
333ba4c
cleanup
steipete Jun 6, 2020
4f85b46
Remove object retain to allow integer returns
steipete Jun 7, 2020
839a2e5
Add integer test case
steipete Jun 7, 2020
a053337
Remove zombies
steipete Jun 7, 2020
7d349a8
Add combined test
steipete Jun 7, 2020
463dc81
Add swiftlint rule
steipete Jun 7, 2020
1fb6c6c
Illegal Instruction 4
steipete Jun 7, 2020
faa3e53
Work around compiler crash
steipete Jun 7, 2020
55cc408
add object task
steipete Jun 7, 2020
d822fc0
Try to make watchOS compile
steipete Jun 7, 2020
e42f2ff
Large class refactor, rename task to hook
steipete Jun 7, 2020
5f0fe6f
remove swiftlint rule for Foundation
steipete Jun 7, 2020
e05016b
swiftlint
steipete Jun 7, 2020
c5cb344
Move types into method call
steipete Jun 7, 2020
eadb073
Add ITKAddSuperMethod and new generics
steipete Jun 8, 2020
0c5624c
Add more tests
steipete Jun 8, 2020
40e8f66
x64 works!
steipete Jun 8, 2020
c9fc2df
Add additional tests
steipete Jun 8, 2020
7888297
Fix memory leak
steipete Jun 8, 2020
17475fd
cleanup
steipete Jun 8, 2020
1357b8d
write arm64
steipete Jun 9, 2020
7a562e8
Use thread local storage
steipete Jun 9, 2020
5c6b75d
cleanup
steipete Jun 9, 2020
9993a61
add links to assembly
steipete Jun 9, 2020
9f345e3
Add test and stret handling
steipete Jun 9, 2020
10c4aa4
Document!
steipete Jun 9, 2020
ef4431f
Remove assembly based object hook
steipete Jun 9, 2020
db7b24d
add link to article
steipete Jun 10, 2020
5619117
header cleanup
steipete Jun 11, 2020
84a1923
Add floating point register protection
steipete Jun 11, 2020
aa86ace
tweak assembly
steipete Jun 11, 2020
430ea37
Prepare new test
steipete Jun 13, 2020
c0779aa
Add tests, remove KVO support
steipete Jun 14, 2020
d014741
lipstick
steipete Jun 14, 2020
53c9371
remove test host for CI
steipete Jun 14, 2020
3c7e36f
really remove test host
steipete Jun 14, 2020
5faede9
use error log
steipete Jun 14, 2020
1695fc7
Disable code signing
steipete Jun 14, 2020
9c9d0d0
todo
steipete Jun 14, 2020
ef94e2f
Warn instead of error for unknown architectures
steipete Jun 14, 2020
ab78db4
Touched by Xcode 11.6
steipete Jun 14, 2020
cd828b5
Addd ILP32 link
steipete Jun 14, 2020
0d20b61
disable code signing
steipete Jun 14, 2020
f960072
Support removal of multiple hooks
steipete Jun 14, 2020
df9ce33
fix jazzy
steipete Jun 14, 2020
562885f
Move error to own file
steipete Jun 14, 2020
505578f
Return self on apply
steipete Jun 14, 2020
524bf93
Support shorter syntax as NSObject category
steipete Jun 14, 2020
e3a954d
Use shorter syntax
steipete Jun 14, 2020
26721b6
Update readme
steipete Jun 14, 2020
304f8ad
Fix Linux
steipete Jun 14, 2020
33f0777
move file to source
steipete Jun 15, 2020
8e024eb
Remove interpose NSObject helper, add class-based version
steipete Jun 15, 2020
54f8686
refer to @_dynamicReplacement
steipete Jun 15, 2020
6f2f13f
Merge branch 'master' into peter/objecthooks
steipete Jun 15, 2020
a66718a
add improvement idea
steipete Jun 15, 2020
66b2224
use shorter hook syntax
steipete Jun 15, 2020
600c58b
Don't swiftlint analyze tests
steipete Jun 15, 2020
471adce
Move SuperBuilder to SwiftPM folder structure
steipete Jun 15, 2020
c73f3c8
Update swiftlint_analyze.yml
steipete Jun 15, 2020
ff9644c
Improve Linux Support
steipete Jun 15, 2020
9207555
Linux Support
steipete Jun 15, 2020
cb3e6b3
Swiftlint
steipete Jun 15, 2020
e55364a
remove unused decl rule
steipete Jun 15, 2020
dcb01ab
add object example
steipete Jun 15, 2020
748a544
Linux
steipete Jun 15, 2020
e994a63
Linux
steipete Jun 15, 2020
122d4df
Linux
steipete Jun 15, 2020
363429b
Linux
steipete Jun 15, 2020
b040f7f
equatable
steipete Jun 15, 2020
9965a84
add objc to error
steipete Jun 15, 2020
a953f70
Linux support
steipete Jun 15, 2020
e042d8f
linux
steipete Jun 15, 2020
a202a0f
linux
steipete Jun 15, 2020
b90bdcd
add docs
steipete Jun 15, 2020
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: 2 additions & 2 deletions .github/workflows/swiftlint_analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ on:
- 'InterposeKit.xcodeproj/**'
- 'Sources/**/*.[ch]'
- 'Sources/**/*.swift'
- 'Tests/**/*.swift'
- '!Tests/**/*.swift'
- '!Tests/LinuxMain.swift'
pull_request:
paths:
- '.github/workflows/swiftlint_analyze.yml'
- 'InterposeKit.xcodeproj/**'
- 'Sources/**/*.[ch]'
- 'Sources/**/*.swift'
- 'Tests/**/*.swift'
- '!Tests/**/*.swift'
- '!Tests/LinuxMain.swift'

jobs:
Expand Down
2 changes: 0 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ included:
- Sources
- Tests
analyzer_rules:
- unused_import
- unused_declaration
line_length: 120
identifier_name:
excluded:
Expand Down
28 changes: 19 additions & 9 deletions Example/InterposeExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@
objects = {

/* Begin PBXBuildFile section */
781095BF248D8AD7008A943C /* InterposeExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 781095BD248D8AD7008A943C /* InterposeExampleTests.swift */; };
7880B124248280B300AD2251 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7880B123248280B300AD2251 /* AppDelegate.swift */; };
7880B126248280B300AD2251 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7880B125248280B300AD2251 /* SceneDelegate.swift */; };
7880B128248280B300AD2251 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7880B127248280B300AD2251 /* ViewController.swift */; };
7880B12B248280B300AD2251 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7880B129248280B300AD2251 /* Main.storyboard */; };
7880B12D248280B500AD2251 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7880B12C248280B500AD2251 /* Assets.xcassets */; };
7880B130248280B500AD2251 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7880B12E248280B500AD2251 /* LaunchScreen.storyboard */; };
78C39DDC2483363300B46395 /* InterposeKit in Frameworks */ = {isa = PBXBuildFile; productRef = 78C39DDB2483363300B46395 /* InterposeKit */; };
78C39DE22483366B00B46395 /* Defaults-Release.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 78C39DDE2483366B00B46395 /* Defaults-Release.xcconfig */; };
78C39DE32483366B00B46395 /* Defaults-Testing.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 78C39DDF2483366B00B46395 /* Defaults-Testing.xcconfig */; };
78C39DE42483366B00B46395 /* Defaults.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 78C39DE02483366B00B46395 /* Defaults.xcconfig */; };
78C39DE52483366B00B46395 /* Defaults-Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 78C39DE12483366B00B46395 /* Defaults-Debug.xcconfig */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -31,6 +28,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
781095BD248D8AD7008A943C /* InterposeExampleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InterposeExampleTests.swift; sourceTree = "<group>"; };
781095BE248D8AD7008A943C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7880B120248280B300AD2251 /* InterposeExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = InterposeExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
7880B123248280B300AD2251 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7880B125248280B300AD2251 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -67,11 +66,21 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
781095BC248D8AD7008A943C /* InterposeExampleTests */ = {
isa = PBXGroup;
children = (
781095BD248D8AD7008A943C /* InterposeExampleTests.swift */,
781095BE248D8AD7008A943C /* Info.plist */,
);
path = InterposeExampleTests;
sourceTree = "<group>";
};
7880B117248280B300AD2251 = {
isa = PBXGroup;
children = (
78C39DD8248335B100B46395 /* Interpose */,
7880B122248280B300AD2251 /* InterposeExample */,
781095BC248D8AD7008A943C /* InterposeExampleTests */,
7880B121248280B300AD2251 /* Products */,
7880B14E248281D000AD2251 /* Frameworks */,
);
Expand Down Expand Up @@ -170,7 +179,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1150;
LastUpgradeCheck = 1150;
LastUpgradeCheck = 1160;
ORGANIZATIONNAME = "PSPDFKit GmbH";
TargetAttributes = {
7880B11F248280B300AD2251 = {
Expand Down Expand Up @@ -210,10 +219,6 @@
files = (
7880B130248280B500AD2251 /* LaunchScreen.storyboard in Resources */,
7880B12D248280B500AD2251 /* Assets.xcassets in Resources */,
78C39DE22483366B00B46395 /* Defaults-Release.xcconfig in Resources */,
78C39DE52483366B00B46395 /* Defaults-Debug.xcconfig in Resources */,
78C39DE32483366B00B46395 /* Defaults-Testing.xcconfig in Resources */,
78C39DE42483366B00B46395 /* Defaults.xcconfig in Resources */,
7880B12B248280B300AD2251 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -242,6 +247,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
781095BF248D8AD7008A943C /* InterposeExampleTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -404,6 +410,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = InterposeExample/InterposeExample.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = Y5PE65HELJ;
INFOPLIST_FILE = InterposeExample/Info.plist;
Expand All @@ -423,6 +430,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = InterposeExample/InterposeExample.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = Y5PE65HELJ;
INFOPLIST_FILE = InterposeExample/Info.plist;
Expand All @@ -442,6 +450,7 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = Y5PE65HELJ;
INFOPLIST_FILE = InterposeExampleTests/Info.plist;
Expand All @@ -464,6 +473,7 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = Y5PE65HELJ;
INFOPLIST_FILE = InterposeExampleTests/Info.plist;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1150"
LastUpgradeVersion = "1160"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -39,6 +39,16 @@
ReferencedContainer = "container:..">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7880B135248280B500AD2251"
BuildableName = "InterposeExampleTests.xctest"
BlueprintName = "InterposeExampleTests"
ReferencedContainer = "container:InterposeExample.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
20 changes: 11 additions & 9 deletions Example/InterposeExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
private func fixMacCatalystInputSystemSessionRace() {
do {
try Interpose.whenAvailable(["RTIInput", "SystemSession"]) {

let lock = DispatchQueue(label: "com.steipete.document-state-hack")
try $0.hook("documentState", { store in { `self` in
lock.sync {
store((@convention(c) (AnyObject, Selector) -> AnyObject).self)(`self`, store.selector)
}} as @convention(block) (AnyObject) -> AnyObject})

try $0.hook("setDocumentState:", { store in { `self`, newValue in
lock.sync {
store((@convention(c) (AnyObject, Selector, AnyObject) -> Void).self)(`self`, store.selector, newValue)
}} as @convention(block) (AnyObject, AnyObject) -> Void})

try $0.hook("documentState") { (store: TypedHook<@convention(c) (AnyObject, Selector) -> AnyObject, @convention(block) (AnyObject) -> AnyObject>) in { `self` in
lock.sync { store.original(`self`, store.selector) }
}
}

try $0.hook("setDocumentState:") { (store: TypedHook<@convention(c) (AnyObject, Selector, AnyObject) -> Void, @convention(block) (AnyObject, AnyObject) -> Void>) in { `self`, newValue in
lock.sync { store.original(`self`, store.selector, newValue) }
}
}
}
} catch {
print("Failed to fix input system: \(error).")
Expand Down
22 changes: 22 additions & 0 deletions Example/InterposeExampleTests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
33 changes: 33 additions & 0 deletions Example/InterposeExampleTests/InterposeExampleTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// InterposeExampleTests.swift
// InterposeExampleTests
//
// Created by Peter Steinberger on 30.05.20.
//

import XCTest
@testable import InterposeExample

class InterposeExampleTests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}

func testPerformanceExample() throws {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}

}
Loading