react-native 0.60.1 → 0.60.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/Components/TextInput/TextInput.js +7 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/WebSocket/RCTReconnectingWebSocket.m +0 -82
- package/Libraries/WebSocket/RCTWebSocket.xcodeproj/project.pbxproj +0 -165
- package/Libraries/WebSocket/React-RCTWebSocket.podspec +1 -3
- package/React/Base/RCTVersion.m +1 -1
- package/React/Modules/RCTRedBox.m +1 -1
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/hermes/unicode/AndroidUnicodeUtils.java +6 -0
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +9 -6
- package/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +3 -1
- package/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +6 -0
- package/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java +24 -24
- package/android/com/facebook/react/react-native/0.60.5/react-native-0.60.5-javadoc.jar +0 -0
- package/android/com/facebook/react/react-native/0.60.5/react-native-0.60.5-javadoc.jar.md5 +1 -0
- package/android/com/facebook/react/react-native/0.60.5/react-native-0.60.5-javadoc.jar.sha1 +1 -0
- package/android/com/facebook/react/react-native/{0.60.1/react-native-0.60.1-sources.jar → 0.60.5/react-native-0.60.5-sources.jar} +0 -0
- package/android/com/facebook/react/react-native/0.60.5/react-native-0.60.5-sources.jar.md5 +1 -0
- package/android/com/facebook/react/react-native/0.60.5/react-native-0.60.5-sources.jar.sha1 +1 -0
- package/android/com/facebook/react/react-native/{0.60.1/react-native-0.60.1.aar → 0.60.5/react-native-0.60.5.aar} +0 -0
- package/android/com/facebook/react/react-native/0.60.5/react-native-0.60.5.aar.md5 +1 -0
- package/android/com/facebook/react/react-native/0.60.5/react-native-0.60.5.aar.sha1 +1 -0
- package/android/com/facebook/react/react-native/{0.60.1/react-native-0.60.1.pom → 0.60.5/react-native-0.60.5.pom} +1 -1
- package/android/com/facebook/react/react-native/0.60.5/react-native-0.60.5.pom.md5 +1 -0
- package/android/com/facebook/react/react-native/0.60.5/react-native-0.60.5.pom.sha1 +1 -0
- package/android/com/facebook/react/react-native/maven-metadata.xml +3 -3
- package/android/com/facebook/react/react-native/maven-metadata.xml.md5 +1 -1
- package/android/com/facebook/react/react-native/maven-metadata.xml.sha1 +1 -1
- package/package.json +4 -4
- package/react.gradle +10 -14
- package/scripts/launchPackager.bat +2 -1
- package/template/_prettierrc.js +6 -0
- package/template/android/app/build.gradle +1 -1
- package/template/ios/Podfile +0 -1
- package/template/package.json +2 -2
- package/Libraries/fishhook/LICENSE +0 -22
- package/Libraries/fishhook/README.md +0 -75
- package/Libraries/fishhook/React-fishhook.podspec +0 -31
- package/Libraries/fishhook/fishhook.c +0 -210
- package/Libraries/fishhook/fishhook.h +0 -76
- package/android/com/facebook/react/react-native/0.60.1/react-native-0.60.1-javadoc.jar +0 -0
- package/android/com/facebook/react/react-native/0.60.1/react-native-0.60.1-javadoc.jar.md5 +0 -1
- package/android/com/facebook/react/react-native/0.60.1/react-native-0.60.1-javadoc.jar.sha1 +0 -1
- package/android/com/facebook/react/react-native/0.60.1/react-native-0.60.1-sources.jar.md5 +0 -1
- package/android/com/facebook/react/react-native/0.60.1/react-native-0.60.1-sources.jar.sha1 +0 -1
- package/android/com/facebook/react/react-native/0.60.1/react-native-0.60.1.aar.md5 +0 -1
- package/android/com/facebook/react/react-native/0.60.1/react-native-0.60.1.aar.sha1 +0 -1
- package/android/com/facebook/react/react-native/0.60.1/react-native-0.60.1.pom.md5 +0 -1
- package/android/com/facebook/react/react-native/0.60.1/react-native-0.60.1.pom.sha1 +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.5",
|
|
4
4
|
"bin": "./cli.js",
|
|
5
5
|
"description": "A framework for building native apps using React",
|
|
6
6
|
"license": "MIT",
|
|
@@ -81,9 +81,9 @@
|
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@babel/runtime": "^7.0.0",
|
|
84
|
-
"@react-native-community/cli": "^2.0
|
|
85
|
-
"@react-native-community/cli-platform-android": "^2.0
|
|
86
|
-
"@react-native-community/cli-platform-ios": "^2.
|
|
84
|
+
"@react-native-community/cli": "^2.6.0",
|
|
85
|
+
"@react-native-community/cli-platform-android": "^2.6.0",
|
|
86
|
+
"@react-native-community/cli-platform-ios": "^2.4.1",
|
|
87
87
|
"abort-controller": "^3.0.0",
|
|
88
88
|
"art": "^0.10.0",
|
|
89
89
|
"base64-js": "^1.1.2",
|
package/react.gradle
CHANGED
|
@@ -16,7 +16,7 @@ def reactRoot = file(config.root ?: "../../")
|
|
|
16
16
|
def inputExcludes = config.inputExcludes ?: ["android/**", "ios/**"]
|
|
17
17
|
def bundleConfig = config.bundleConfig ? "${reactRoot}/${config.bundleConfig}" : null ;
|
|
18
18
|
def enableVmCleanup = config.enableVmCleanup == null ? true : config.enableVmCleanup
|
|
19
|
-
def hermesCommand = config.hermesCommand ?: "../../node_modules/
|
|
19
|
+
def hermesCommand = config.hermesCommand ?: "../../node_modules/hermesvm/%OS-BIN%/hermes"
|
|
20
20
|
|
|
21
21
|
def reactNativeDevServerPort() {
|
|
22
22
|
def value = project.getProperties().get("reactNativeDevServerPort")
|
|
@@ -76,10 +76,11 @@ afterEvaluate {
|
|
|
76
76
|
def resourcesDir = file("$buildDir/generated/res/react/${targetPath}")
|
|
77
77
|
|
|
78
78
|
def jsBundleFile = file("$jsBundleDir/$bundleAssetName")
|
|
79
|
-
def jsSourceMapsDir = file("$buildDir/
|
|
80
|
-
def
|
|
81
|
-
def
|
|
82
|
-
def
|
|
79
|
+
def jsSourceMapsDir = file("$buildDir/generated/sourcemaps/react/${targetPath}")
|
|
80
|
+
def jsIntermediateSourceMapsDir = file("$buildDir/intermediates/sourcemaps/react/${targetPath}")
|
|
81
|
+
def jsPackagerSourceMapFile = file("$jsIntermediateSourceMapsDir/${bundleAssetName}.packager.map")
|
|
82
|
+
def jsCompilerSourceMapFile = file("$jsIntermediateSourceMapsDir/${bundleAssetName}.compiler.map")
|
|
83
|
+
def jsOutputSourceMapFile = file("$jsSourceMapsDir/${bundleAssetName}.map")
|
|
83
84
|
|
|
84
85
|
// Additional node and packager commandline arguments
|
|
85
86
|
def nodeExecutableAndArgs = config.nodeExecutableAndArgs ?: ["node"]
|
|
@@ -99,6 +100,8 @@ afterEvaluate {
|
|
|
99
100
|
jsBundleDir.mkdirs()
|
|
100
101
|
resourcesDir.deleteDir()
|
|
101
102
|
resourcesDir.mkdirs()
|
|
103
|
+
jsIntermediateSourceMapsDir.deleteDir()
|
|
104
|
+
jsIntermediateSourceMapsDir.mkdirs()
|
|
102
105
|
jsSourceMapsDir.deleteDir()
|
|
103
106
|
jsSourceMapsDir.mkdirs()
|
|
104
107
|
}
|
|
@@ -126,11 +129,11 @@ afterEvaluate {
|
|
|
126
129
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|
127
130
|
commandLine("cmd", "/c", *nodeExecutableAndArgs, cliPath, bundleCommand, "--platform", "android", "--dev", "${devEnabled}",
|
|
128
131
|
"--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir,
|
|
129
|
-
"--sourcemap-output", jsPackagerSourceMapFile, *extraArgs)
|
|
132
|
+
"--sourcemap-output", enableHermes ? jsPackagerSourceMapFile : jsOutputSourceMapFile, *extraArgs)
|
|
130
133
|
} else {
|
|
131
134
|
commandLine(*nodeExecutableAndArgs, cliPath, bundleCommand, "--platform", "android", "--dev", "${devEnabled}",
|
|
132
135
|
"--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir,
|
|
133
|
-
"--sourcemap-output", jsPackagerSourceMapFile, *extraArgs)
|
|
136
|
+
"--sourcemap-output", enableHermes ? jsPackagerSourceMapFile : jsOutputSourceMapFile, *extraArgs)
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
if (enableHermes) {
|
|
@@ -167,13 +170,6 @@ afterEvaluate {
|
|
|
167
170
|
}
|
|
168
171
|
}
|
|
169
172
|
}
|
|
170
|
-
} else {
|
|
171
|
-
doLast {
|
|
172
|
-
ant.move(
|
|
173
|
-
file: jsPackagerSourceMapFile,
|
|
174
|
-
tofile: jsOutputSourceMapFile
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
173
|
}
|
|
178
174
|
|
|
179
175
|
enabled config."bundleIn${targetName}" != null
|
|
@@ -192,7 +192,7 @@ dependencies {
|
|
|
192
192
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
193
193
|
|
|
194
194
|
if (enableHermes) {
|
|
195
|
-
def hermesPath = "../../node_modules/
|
|
195
|
+
def hermesPath = "../../node_modules/hermesvm/android/";
|
|
196
196
|
debugImplementation files(hermesPath + "hermes-debug.aar")
|
|
197
197
|
releaseImplementation files(hermesPath + "hermes-release.aar")
|
|
198
198
|
} else {
|
package/template/ios/Podfile
CHANGED
|
@@ -6,7 +6,6 @@ target 'HelloWorld' do
|
|
|
6
6
|
pod 'React', :path => '../node_modules/react-native/'
|
|
7
7
|
pod 'React-Core', :path => '../node_modules/react-native/React'
|
|
8
8
|
pod 'React-DevSupport', :path => '../node_modules/react-native/React'
|
|
9
|
-
pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
|
|
10
9
|
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
|
|
11
10
|
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
|
|
12
11
|
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
|
package/template/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"react": "16.8.6",
|
|
11
|
-
"react-native": "0.60.
|
|
11
|
+
"react-native": "0.60.5"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@babel/core": "^7.5.0",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@react-native-community/eslint-config": "^0.0.3",
|
|
17
17
|
"babel-jest": "^24.1.0",
|
|
18
18
|
"jest": "^24.1.0",
|
|
19
|
-
"metro-react-native-babel-preset": "
|
|
19
|
+
"metro-react-native-babel-preset": "0.54.1",
|
|
20
20
|
"react-test-renderer": "16.8.6"
|
|
21
21
|
},
|
|
22
22
|
"jest": {
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2013, Facebook, Inc.
|
|
2
|
-
// All rights reserved.
|
|
3
|
-
// Redistribution and use in source and binary forms, with or without
|
|
4
|
-
// modification, are permitted provided that the following conditions are met:
|
|
5
|
-
// * Redistributions of source code must retain the above copyright notice,
|
|
6
|
-
// this list of conditions and the following disclaimer.
|
|
7
|
-
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
8
|
-
// this list of conditions and the following disclaimer in the documentation
|
|
9
|
-
// and/or other materials provided with the distribution.
|
|
10
|
-
// * Neither the name Facebook nor the names of its contributors may be used to
|
|
11
|
-
// endorse or promote products derived from this software without specific
|
|
12
|
-
// prior written permission.
|
|
13
|
-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
14
|
-
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
15
|
-
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
16
|
-
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
17
|
-
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
18
|
-
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
19
|
-
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
20
|
-
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
21
|
-
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22
|
-
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
# fishhook
|
|
2
|
-
|
|
3
|
-
__fishhook__ is a very simple library that enables dynamically rebinding symbols in Mach-O binaries running on iOS in the simulator and on device. This provides functionality that is similar to using [`DYLD_INTERPOSE`][interpose] on OS X. At Facebook, we've found it useful as a way to hook calls in libSystem for debugging/tracing purposes (for example, auditing for double-close issues with file descriptors).
|
|
4
|
-
|
|
5
|
-
[interpose]: http://opensource.apple.com/source/dyld/dyld-210.2.3/include/mach-o/dyld-interposing.h "<mach-o/dyld-interposing.h>"
|
|
6
|
-
|
|
7
|
-
## Usage
|
|
8
|
-
|
|
9
|
-
Once you add `fishhook.h`/`fishhook.c` to your project, you can rebind symbols as follows:
|
|
10
|
-
```Objective-C
|
|
11
|
-
#import <dlfcn.h>
|
|
12
|
-
|
|
13
|
-
#import <UIKit/UIKit.h>
|
|
14
|
-
|
|
15
|
-
#import "AppDelegate.h"
|
|
16
|
-
#import "fishhook.h"
|
|
17
|
-
|
|
18
|
-
static int (*orig_close)(int);
|
|
19
|
-
static int (*orig_open)(const char *, int, ...);
|
|
20
|
-
|
|
21
|
-
int my_close(int fd) {
|
|
22
|
-
printf("Calling real close(%d)\n", fd);
|
|
23
|
-
return orig_close(fd);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
int my_open(const char *path, int oflag, ...) {
|
|
27
|
-
va_list ap = {0};
|
|
28
|
-
mode_t mode = 0;
|
|
29
|
-
|
|
30
|
-
if ((oflag & O_CREAT) != 0) {
|
|
31
|
-
// mode only applies to O_CREAT
|
|
32
|
-
va_start(ap, oflag);
|
|
33
|
-
mode = va_arg(ap, int);
|
|
34
|
-
va_end(ap);
|
|
35
|
-
printf("Calling real open('%s', %d, %d)\n", path, oflag, mode);
|
|
36
|
-
return orig_open(path, oflag, mode);
|
|
37
|
-
} else {
|
|
38
|
-
printf("Calling real open('%s', %d)\n", path, oflag);
|
|
39
|
-
return orig_open(path, oflag, mode);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
int main(int argc, char * argv[])
|
|
44
|
-
{
|
|
45
|
-
@autoreleasepool {
|
|
46
|
-
rebind_symbols((struct rebinding[2]){{"close", my_close, (void *)&orig_close}, {"open", my_open, (void *)&orig_open}}, 2);
|
|
47
|
-
|
|
48
|
-
// Open our own binary and print out first 4 bytes (which is the same
|
|
49
|
-
// for all Mach-O binaries on a given architecture)
|
|
50
|
-
int fd = open(argv[0], O_RDONLY);
|
|
51
|
-
uint32_t magic_number = 0;
|
|
52
|
-
read(fd, &magic_number, 4);
|
|
53
|
-
printf("Mach-O Magic Number: %x \n", magic_number);
|
|
54
|
-
close(fd);
|
|
55
|
-
|
|
56
|
-
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
### Sample output
|
|
61
|
-
```
|
|
62
|
-
Calling real open('/var/mobile/Applications/161DA598-5B83-41F5-8A44-675491AF6A2C/Test.app/Test', 0)
|
|
63
|
-
Mach-O Magic Number: feedface
|
|
64
|
-
Calling real close(3)
|
|
65
|
-
...
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## How it works
|
|
69
|
-
|
|
70
|
-
`dyld` binds lazy and non-lazy symbols by updating pointers in particular sections of the `__DATA` segment of a Mach-O binary. __fishhook__ re-binds these symbols by determining the locations to update for each of the symbol names passed to `rebind_symbols` and then writing out the corresponding replacements.
|
|
71
|
-
|
|
72
|
-
For a given image, the `__DATA` segment may contain two sections that are relevant for dynamic symbol bindings: `__nl_symbol_ptr` and `__la_symbol_ptr`. `__nl_symbol_ptr` is an array of pointers to non-lazily bound data (these are bound at the time a library is loaded) and `__la_symbol_ptr` is an array of pointers to imported functions that is generally filled by a routine called `dyld_stub_binder` during the first call to that symbol (it's also possible to tell `dyld` to bind these at launch). In order to find the name of the symbol that corresponds to a particular location in one of these sections, we have to jump through several layers of indirection. For the two relevant sections, the section headers (`struct section`s from `<mach-o/loader.h>`) provide an offset (in the `reserved1` field) into what is known as the indirect symbol table. The indirect symbol table, which is located in the `__LINKEDIT` segment of the binary, is just an array of indexes into the symbol table (also in `__LINKEDIT`) whose order is identical to that of the pointers in the non-lazy and lazy symbol sections. So, given `struct section nl_symbol_ptr`, the corresponding index in the symbol table of the first address in that section is `indirect_symbol_table[nl_symbol_ptr->reserved1]`. The symbol table itself is an array of `struct nlist`s (see `<mach-o/nlist.h>`), and each `nlist` contains an index into the string table in `__LINKEDIT` which where the actual symbol names are stored. So, for each pointer `__nl_symbol_ptr` and `__la_symbol_ptr`, we are able to find the corresponding symbol and then the corresponding string to compare against the requested symbol names, and if there is a match, we replace the pointer in the section with the replacement.
|
|
73
|
-
|
|
74
|
-
The process of looking up the name of a given entry in the lazy or non-lazy pointer tables looks like this:
|
|
75
|
-

|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
#
|
|
4
|
-
# This source code is licensed under the MIT license found in the
|
|
5
|
-
# LICENSE file in the root directory of this source tree.
|
|
6
|
-
|
|
7
|
-
require "json"
|
|
8
|
-
|
|
9
|
-
package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json")))
|
|
10
|
-
version = package['version']
|
|
11
|
-
|
|
12
|
-
source = { :git => 'https://github.com/facebook/react-native.git' }
|
|
13
|
-
if version == '1000.0.0'
|
|
14
|
-
# This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
|
|
15
|
-
source[:commit] = `git rev-parse HEAD`.strip
|
|
16
|
-
else
|
|
17
|
-
source[:tag] = "v#{version}"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
Pod::Spec.new do |s|
|
|
21
|
-
s.name = "React-fishhook"
|
|
22
|
-
s.version = version
|
|
23
|
-
s.summary = "A very simple library that enables dynamically rebinding symbols in Mach-O binaries running on iOS in the simulator and on device."
|
|
24
|
-
s.homepage = "http://facebook.github.io/react-native/"
|
|
25
|
-
s.license = package["license"]
|
|
26
|
-
s.author = "Facebook, Inc. and its affiliates"
|
|
27
|
-
s.platforms = { :ios => "9.0", :tvos => "9.2" }
|
|
28
|
-
s.source = source
|
|
29
|
-
s.source_files = "*.{c,h}"
|
|
30
|
-
s.header_dir = "fishhook"
|
|
31
|
-
end
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2013, Facebook, Inc.
|
|
2
|
-
// All rights reserved.
|
|
3
|
-
// Redistribution and use in source and binary forms, with or without
|
|
4
|
-
// modification, are permitted provided that the following conditions are met:
|
|
5
|
-
// * Redistributions of source code must retain the above copyright notice,
|
|
6
|
-
// this list of conditions and the following disclaimer.
|
|
7
|
-
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
8
|
-
// this list of conditions and the following disclaimer in the documentation
|
|
9
|
-
// and/or other materials provided with the distribution.
|
|
10
|
-
// * Neither the name Facebook nor the names of its contributors may be used to
|
|
11
|
-
// endorse or promote products derived from this software without specific
|
|
12
|
-
// prior written permission.
|
|
13
|
-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
14
|
-
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
15
|
-
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
16
|
-
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
17
|
-
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
18
|
-
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
19
|
-
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
20
|
-
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
21
|
-
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22
|
-
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
23
|
-
|
|
24
|
-
#import "fishhook.h"
|
|
25
|
-
|
|
26
|
-
#import <dlfcn.h>
|
|
27
|
-
#import <stdlib.h>
|
|
28
|
-
#import <string.h>
|
|
29
|
-
#import <sys/types.h>
|
|
30
|
-
#import <mach-o/dyld.h>
|
|
31
|
-
#import <mach-o/loader.h>
|
|
32
|
-
#import <mach-o/nlist.h>
|
|
33
|
-
|
|
34
|
-
#ifdef __LP64__
|
|
35
|
-
typedef struct mach_header_64 mach_header_t;
|
|
36
|
-
typedef struct segment_command_64 segment_command_t;
|
|
37
|
-
typedef struct section_64 section_t;
|
|
38
|
-
typedef struct nlist_64 nlist_t;
|
|
39
|
-
#define LC_SEGMENT_ARCH_DEPENDENT LC_SEGMENT_64
|
|
40
|
-
#else
|
|
41
|
-
typedef struct mach_header mach_header_t;
|
|
42
|
-
typedef struct segment_command segment_command_t;
|
|
43
|
-
typedef struct section section_t;
|
|
44
|
-
typedef struct nlist nlist_t;
|
|
45
|
-
#define LC_SEGMENT_ARCH_DEPENDENT LC_SEGMENT
|
|
46
|
-
#endif
|
|
47
|
-
|
|
48
|
-
#ifndef SEG_DATA_CONST
|
|
49
|
-
#define SEG_DATA_CONST "__DATA_CONST"
|
|
50
|
-
#endif
|
|
51
|
-
|
|
52
|
-
struct rebindings_entry {
|
|
53
|
-
struct rebinding *rebindings;
|
|
54
|
-
size_t rebindings_nel;
|
|
55
|
-
struct rebindings_entry *next;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
static struct rebindings_entry *_rebindings_head;
|
|
59
|
-
|
|
60
|
-
static int prepend_rebindings(struct rebindings_entry **rebindings_head,
|
|
61
|
-
struct rebinding rebindings[],
|
|
62
|
-
size_t nel) {
|
|
63
|
-
struct rebindings_entry *new_entry = (struct rebindings_entry *) malloc(sizeof(struct rebindings_entry));
|
|
64
|
-
if (!new_entry) {
|
|
65
|
-
return -1;
|
|
66
|
-
}
|
|
67
|
-
new_entry->rebindings = (struct rebinding *) malloc(sizeof(struct rebinding) * nel);
|
|
68
|
-
if (!new_entry->rebindings) {
|
|
69
|
-
free(new_entry);
|
|
70
|
-
return -1;
|
|
71
|
-
}
|
|
72
|
-
memcpy(new_entry->rebindings, rebindings, sizeof(struct rebinding) * nel);
|
|
73
|
-
new_entry->rebindings_nel = nel;
|
|
74
|
-
new_entry->next = *rebindings_head;
|
|
75
|
-
*rebindings_head = new_entry;
|
|
76
|
-
return 0;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
static void perform_rebinding_with_section(struct rebindings_entry *rebindings,
|
|
80
|
-
section_t *section,
|
|
81
|
-
intptr_t slide,
|
|
82
|
-
nlist_t *symtab,
|
|
83
|
-
char *strtab,
|
|
84
|
-
uint32_t *indirect_symtab) {
|
|
85
|
-
uint32_t *indirect_symbol_indices = indirect_symtab + section->reserved1;
|
|
86
|
-
void **indirect_symbol_bindings = (void **)((uintptr_t)slide + section->addr);
|
|
87
|
-
for (uint i = 0; i < section->size / sizeof(void *); i++) {
|
|
88
|
-
uint32_t symtab_index = indirect_symbol_indices[i];
|
|
89
|
-
if (symtab_index == INDIRECT_SYMBOL_ABS || symtab_index == INDIRECT_SYMBOL_LOCAL ||
|
|
90
|
-
symtab_index == (INDIRECT_SYMBOL_LOCAL | INDIRECT_SYMBOL_ABS)) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
uint32_t strtab_offset = symtab[symtab_index].n_un.n_strx;
|
|
94
|
-
char *symbol_name = strtab + strtab_offset;
|
|
95
|
-
if (strnlen(symbol_name, 2) < 2) {
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
struct rebindings_entry *cur = rebindings;
|
|
99
|
-
while (cur) {
|
|
100
|
-
for (uint j = 0; j < cur->rebindings_nel; j++) {
|
|
101
|
-
if (strcmp(&symbol_name[1], cur->rebindings[j].name) == 0) {
|
|
102
|
-
if (cur->rebindings[j].replaced != NULL &&
|
|
103
|
-
indirect_symbol_bindings[i] != cur->rebindings[j].replacement) {
|
|
104
|
-
*(cur->rebindings[j].replaced) = indirect_symbol_bindings[i];
|
|
105
|
-
}
|
|
106
|
-
indirect_symbol_bindings[i] = cur->rebindings[j].replacement;
|
|
107
|
-
goto symbol_loop;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
cur = cur->next;
|
|
111
|
-
}
|
|
112
|
-
symbol_loop:;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
static void rebind_symbols_for_image(struct rebindings_entry *rebindings,
|
|
117
|
-
const struct mach_header *header,
|
|
118
|
-
intptr_t slide) {
|
|
119
|
-
Dl_info info;
|
|
120
|
-
if (dladdr(header, &info) == 0) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
segment_command_t *cur_seg_cmd;
|
|
125
|
-
segment_command_t *linkedit_segment = NULL;
|
|
126
|
-
struct symtab_command* symtab_cmd = NULL;
|
|
127
|
-
struct dysymtab_command* dysymtab_cmd = NULL;
|
|
128
|
-
|
|
129
|
-
uintptr_t cur = (uintptr_t)header + sizeof(mach_header_t);
|
|
130
|
-
for (uint i = 0; i < header->ncmds; i++, cur += cur_seg_cmd->cmdsize) {
|
|
131
|
-
cur_seg_cmd = (segment_command_t *)cur;
|
|
132
|
-
if (cur_seg_cmd->cmd == LC_SEGMENT_ARCH_DEPENDENT) {
|
|
133
|
-
if (strcmp(cur_seg_cmd->segname, SEG_LINKEDIT) == 0) {
|
|
134
|
-
linkedit_segment = cur_seg_cmd;
|
|
135
|
-
}
|
|
136
|
-
} else if (cur_seg_cmd->cmd == LC_SYMTAB) {
|
|
137
|
-
symtab_cmd = (struct symtab_command*)cur_seg_cmd;
|
|
138
|
-
} else if (cur_seg_cmd->cmd == LC_DYSYMTAB) {
|
|
139
|
-
dysymtab_cmd = (struct dysymtab_command*)cur_seg_cmd;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (!symtab_cmd || !dysymtab_cmd || !linkedit_segment ||
|
|
144
|
-
!dysymtab_cmd->nindirectsyms) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Find base symbol/string table addresses
|
|
149
|
-
uintptr_t linkedit_base = (uintptr_t)slide + linkedit_segment->vmaddr - linkedit_segment->fileoff;
|
|
150
|
-
nlist_t *symtab = (nlist_t *)(linkedit_base + symtab_cmd->symoff);
|
|
151
|
-
char *strtab = (char *)(linkedit_base + symtab_cmd->stroff);
|
|
152
|
-
|
|
153
|
-
// Get indirect symbol table (array of uint32_t indices into symbol table)
|
|
154
|
-
uint32_t *indirect_symtab = (uint32_t *)(linkedit_base + dysymtab_cmd->indirectsymoff);
|
|
155
|
-
|
|
156
|
-
cur = (uintptr_t)header + sizeof(mach_header_t);
|
|
157
|
-
for (uint i = 0; i < header->ncmds; i++, cur += cur_seg_cmd->cmdsize) {
|
|
158
|
-
cur_seg_cmd = (segment_command_t *)cur;
|
|
159
|
-
if (cur_seg_cmd->cmd == LC_SEGMENT_ARCH_DEPENDENT) {
|
|
160
|
-
if (strcmp(cur_seg_cmd->segname, SEG_DATA) != 0 &&
|
|
161
|
-
strcmp(cur_seg_cmd->segname, SEG_DATA_CONST) != 0) {
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
for (uint j = 0; j < cur_seg_cmd->nsects; j++) {
|
|
165
|
-
section_t *sect =
|
|
166
|
-
(section_t *)(cur + sizeof(segment_command_t)) + j;
|
|
167
|
-
if ((sect->flags & SECTION_TYPE) == S_LAZY_SYMBOL_POINTERS) {
|
|
168
|
-
perform_rebinding_with_section(rebindings, sect, slide, symtab, strtab, indirect_symtab);
|
|
169
|
-
}
|
|
170
|
-
if ((sect->flags & SECTION_TYPE) == S_NON_LAZY_SYMBOL_POINTERS) {
|
|
171
|
-
perform_rebinding_with_section(rebindings, sect, slide, symtab, strtab, indirect_symtab);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
static void _rebind_symbols_for_image(const struct mach_header *header,
|
|
179
|
-
intptr_t slide) {
|
|
180
|
-
rebind_symbols_for_image(_rebindings_head, header, slide);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
int rebind_symbols_image(void *header,
|
|
184
|
-
intptr_t slide,
|
|
185
|
-
struct rebinding rebindings[],
|
|
186
|
-
size_t rebindings_nel) {
|
|
187
|
-
struct rebindings_entry *rebindings_head = NULL;
|
|
188
|
-
int retval = prepend_rebindings(&rebindings_head, rebindings, rebindings_nel);
|
|
189
|
-
rebind_symbols_for_image(rebindings_head, (const struct mach_header *) header, slide);
|
|
190
|
-
free(rebindings_head);
|
|
191
|
-
return retval;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
int rebind_symbols(struct rebinding rebindings[], size_t rebindings_nel) {
|
|
195
|
-
int retval = prepend_rebindings(&_rebindings_head, rebindings, rebindings_nel);
|
|
196
|
-
if (retval < 0) {
|
|
197
|
-
return retval;
|
|
198
|
-
}
|
|
199
|
-
// If this was the first call, register callback for image additions (which is also invoked for
|
|
200
|
-
// existing images, otherwise, just run on existing images
|
|
201
|
-
if (!_rebindings_head->next) {
|
|
202
|
-
_dyld_register_func_for_add_image(_rebind_symbols_for_image);
|
|
203
|
-
} else {
|
|
204
|
-
uint32_t c = _dyld_image_count();
|
|
205
|
-
for (uint32_t i = 0; i < c; i++) {
|
|
206
|
-
_rebind_symbols_for_image(_dyld_get_image_header(i), _dyld_get_image_vmaddr_slide(i));
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return retval;
|
|
210
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2013, Facebook, Inc.
|
|
2
|
-
// All rights reserved.
|
|
3
|
-
// Redistribution and use in source and binary forms, with or without
|
|
4
|
-
// modification, are permitted provided that the following conditions are met:
|
|
5
|
-
// * Redistributions of source code must retain the above copyright notice,
|
|
6
|
-
// this list of conditions and the following disclaimer.
|
|
7
|
-
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
8
|
-
// this list of conditions and the following disclaimer in the documentation
|
|
9
|
-
// and/or other materials provided with the distribution.
|
|
10
|
-
// * Neither the name Facebook nor the names of its contributors may be used to
|
|
11
|
-
// endorse or promote products derived from this software without specific
|
|
12
|
-
// prior written permission.
|
|
13
|
-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
14
|
-
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
15
|
-
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
16
|
-
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
17
|
-
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
18
|
-
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
19
|
-
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
20
|
-
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
21
|
-
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22
|
-
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
23
|
-
|
|
24
|
-
#ifndef fishhook_h
|
|
25
|
-
#define fishhook_h
|
|
26
|
-
|
|
27
|
-
#include <stddef.h>
|
|
28
|
-
#include <stdint.h>
|
|
29
|
-
|
|
30
|
-
#if !defined(FISHHOOK_EXPORT)
|
|
31
|
-
#define FISHHOOK_VISIBILITY __attribute__((visibility("hidden")))
|
|
32
|
-
#else
|
|
33
|
-
#define FISHHOOK_VISIBILITY __attribute__((visibility("default")))
|
|
34
|
-
#endif
|
|
35
|
-
|
|
36
|
-
#ifdef __cplusplus
|
|
37
|
-
extern "C" {
|
|
38
|
-
#endif //__cplusplus
|
|
39
|
-
|
|
40
|
-
/*
|
|
41
|
-
* A structure representing a particular intended rebinding from a symbol
|
|
42
|
-
* name to its replacement
|
|
43
|
-
*/
|
|
44
|
-
struct rebinding {
|
|
45
|
-
const char *name;
|
|
46
|
-
void *replacement;
|
|
47
|
-
void **replaced;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/*
|
|
51
|
-
* For each rebinding in rebindings, rebinds references to external, indirect
|
|
52
|
-
* symbols with the specified name to instead point at replacement for each
|
|
53
|
-
* image in the calling process as well as for all future images that are loaded
|
|
54
|
-
* by the process. If rebind_functions is called more than once, the symbols to
|
|
55
|
-
* rebind are added to the existing list of rebindings, and if a given symbol
|
|
56
|
-
* is rebound more than once, the later rebinding will take precedence.
|
|
57
|
-
*/
|
|
58
|
-
FISHHOOK_VISIBILITY
|
|
59
|
-
int rebind_symbols(struct rebinding rebindings[], size_t rebindings_nel);
|
|
60
|
-
|
|
61
|
-
/*
|
|
62
|
-
* Rebinds as above, but only in the specified image. The header should point
|
|
63
|
-
* to the mach-o header, the slide should be the slide offset. Others as above.
|
|
64
|
-
*/
|
|
65
|
-
FISHHOOK_VISIBILITY
|
|
66
|
-
int rebind_symbols_image(void *header,
|
|
67
|
-
intptr_t slide,
|
|
68
|
-
struct rebinding rebindings[],
|
|
69
|
-
size_t rebindings_nel);
|
|
70
|
-
|
|
71
|
-
#ifdef __cplusplus
|
|
72
|
-
}
|
|
73
|
-
#endif //__cplusplus
|
|
74
|
-
|
|
75
|
-
#endif //fishhook_h
|
|
76
|
-
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
8816e0b758d4eae39ec93dba5ee63498
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
f519d60075e3c46191f5a90bd2ee26faea423596
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
9ba4e9658f47b2bd48d3b4cad73b2eb6
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
16d7d2f7045a97c85c32e70a5094665b0bf7da4c
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
822fc3535340c75626a13a93e4bf5c99
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
b0763bf58a80fc9b8ea972c408272dc98507ee9b
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
af705ed9c87a6cbfb7439ec47ba03061
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
352836e8376ef3d0310b5db4a5bcb68da0e1f798
|