frida-java-bridge 5.2.2 → 5.3.0
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/index.js +5 -0
- package/lib/android.js +89 -2
- package/lib/jvm.js +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@ const {
|
|
|
5
5
|
withRunnableArtThread,
|
|
6
6
|
makeArtClassVisitor,
|
|
7
7
|
makeArtClassLoaderVisitor,
|
|
8
|
+
backtrace,
|
|
8
9
|
deoptimizeEverything,
|
|
9
10
|
deoptimizeBootImage,
|
|
10
11
|
deoptimizeMethod
|
|
@@ -478,6 +479,10 @@ class Runtime {
|
|
|
478
479
|
return this.classFactory.array(type, elements);
|
|
479
480
|
}
|
|
480
481
|
|
|
482
|
+
backtrace (options) {
|
|
483
|
+
return backtrace(this.vm, options);
|
|
484
|
+
}
|
|
485
|
+
|
|
481
486
|
// Reference: http://stackoverflow.com/questions/2848575/how-to-detect-ui-thread-on-android
|
|
482
487
|
isMainThread () {
|
|
483
488
|
const Looper = this.classFactory.use('android.os.Looper');
|
package/lib/android.js
CHANGED
|
@@ -285,7 +285,9 @@ function _getApi () {
|
|
|
285
285
|
|
|
286
286
|
// Android >= 11
|
|
287
287
|
_ZN3art3jni12JniIdManager14DecodeMethodIdEP10_jmethodID: ['art::jni::JniIdManager::DecodeMethodId', 'pointer', ['pointer', 'pointer']],
|
|
288
|
-
_ZN3art11interpreter18GetNterpEntryPointEv: ['art::interpreter::GetNterpEntryPoint', 'pointer', []]
|
|
288
|
+
_ZN3art11interpreter18GetNterpEntryPointEv: ['art::interpreter::GetNterpEntryPoint', 'pointer', []],
|
|
289
|
+
|
|
290
|
+
_ZN3art7Monitor17TranslateLocationEPNS_9ArtMethodEjPPKcPi: ['art::Monitor::TranslateLocation', 'void', ['pointer', 'uint32', 'pointer', 'pointer']]
|
|
289
291
|
},
|
|
290
292
|
variables: {
|
|
291
293
|
_ZN3art3Dbg9gRegistryE: function (address) {
|
|
@@ -337,7 +339,8 @@ function _getApi () {
|
|
|
337
339
|
'_ZN3art3Dbg20ManageDeoptimizationEv',
|
|
338
340
|
'_ZN3art3Dbg9gRegistryE',
|
|
339
341
|
'_ZN3art3jni12JniIdManager14DecodeMethodIdEP10_jmethodID',
|
|
340
|
-
'_ZN3art11interpreter18GetNterpEntryPointEv'
|
|
342
|
+
'_ZN3art11interpreter18GetNterpEntryPointEv',
|
|
343
|
+
'_ZN3art7Monitor17TranslateLocationEPNS_9ArtMethodEjPPKcPi'
|
|
341
344
|
]
|
|
342
345
|
}]
|
|
343
346
|
: [{
|
|
@@ -1812,6 +1815,89 @@ function translateMethod (methodId) {
|
|
|
1812
1815
|
return artController.replacedMethods.translate(methodId);
|
|
1813
1816
|
}
|
|
1814
1817
|
|
|
1818
|
+
class BacktraceVisitor extends ArtStackVisitor {
|
|
1819
|
+
constructor (thread, limit) {
|
|
1820
|
+
const api = getApi();
|
|
1821
|
+
|
|
1822
|
+
super(thread, api['art::Thread::GetLongJumpContext'](thread), 'include-inlined-frames');
|
|
1823
|
+
|
|
1824
|
+
this.frames = [];
|
|
1825
|
+
this.limit = limit;
|
|
1826
|
+
|
|
1827
|
+
this._translateLocation = api['art::Monitor::TranslateLocation'];
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
visitFrame () {
|
|
1831
|
+
this._collectFrame(this.describeLocation());
|
|
1832
|
+
|
|
1833
|
+
return this.frames.length < this.limit;
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
_collectFrame (location) {
|
|
1837
|
+
if (location === 'upcall') {
|
|
1838
|
+
return;
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
const tokens = location.split(/['"]/, 3);
|
|
1842
|
+
const rawMethodSignature = tokens[1];
|
|
1843
|
+
if (rawMethodSignature.startsWith('<')) {
|
|
1844
|
+
return;
|
|
1845
|
+
}
|
|
1846
|
+
const details = tokens[2];
|
|
1847
|
+
|
|
1848
|
+
const separatorIndex = rawMethodSignature.indexOf(' ');
|
|
1849
|
+
const returnType = rawMethodSignature.substring(0, separatorIndex);
|
|
1850
|
+
const rest = rawMethodSignature.substring(separatorIndex + 1);
|
|
1851
|
+
const argsStartIndex = rest.indexOf('(');
|
|
1852
|
+
const argsEndIndex = rest.indexOf(')', argsStartIndex + 1);
|
|
1853
|
+
const rawArgumentTypes = rest.substring(argsStartIndex + 1, argsEndIndex);
|
|
1854
|
+
const argumentTypes = (rawArgumentTypes !== '') ? rawArgumentTypes.split(', ') : [];
|
|
1855
|
+
|
|
1856
|
+
const classAndMethodName = rest.substring(0, argsStartIndex);
|
|
1857
|
+
const methodNameStartIndex = classAndMethodName.lastIndexOf('.');
|
|
1858
|
+
const className = classAndMethodName.substring(0, methodNameStartIndex);
|
|
1859
|
+
const methodName = classAndMethodName.substring(methodNameStartIndex + 1);
|
|
1860
|
+
let dexPc = parseInt(details.substring(13), 16);
|
|
1861
|
+
|
|
1862
|
+
const actualMethod = this.getMethod();
|
|
1863
|
+
const translatedMethod = translateMethod(actualMethod);
|
|
1864
|
+
if (!translatedMethod.equals(actualMethod)) {
|
|
1865
|
+
dexPc = 0;
|
|
1866
|
+
}
|
|
1867
|
+
const fileNamePtr = Memory.alloc(16);
|
|
1868
|
+
const lineNumberPtr = fileNamePtr.add(8);
|
|
1869
|
+
this._translateLocation(translatedMethod, dexPc, fileNamePtr, lineNumberPtr);
|
|
1870
|
+
const fileName = fileNamePtr.readPointer().readUtf8String();
|
|
1871
|
+
const lineNumber = lineNumberPtr.readS32();
|
|
1872
|
+
|
|
1873
|
+
this.frames.push({
|
|
1874
|
+
method: {
|
|
1875
|
+
handle: translatedMethod,
|
|
1876
|
+
name: methodName,
|
|
1877
|
+
returnType,
|
|
1878
|
+
argumentTypes
|
|
1879
|
+
},
|
|
1880
|
+
className,
|
|
1881
|
+
fileName,
|
|
1882
|
+
lineNumber
|
|
1883
|
+
});
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
function backtrace (vm, options = {}) {
|
|
1888
|
+
const { limit = 16 } = options;
|
|
1889
|
+
|
|
1890
|
+
let frames = null;
|
|
1891
|
+
|
|
1892
|
+
withRunnableArtThread(vm, vm.getEnv(), thread => {
|
|
1893
|
+
const visitor = new BacktraceVisitor(thread, limit);
|
|
1894
|
+
visitor.walkStack(true);
|
|
1895
|
+
frames = visitor.frames;
|
|
1896
|
+
});
|
|
1897
|
+
|
|
1898
|
+
return frames;
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1815
1901
|
function revertGlobalPatches () {
|
|
1816
1902
|
patchedClasses.forEach(entry => {
|
|
1817
1903
|
entry.vtablePtr.writePointer(entry.vtable);
|
|
@@ -4065,6 +4151,7 @@ module.exports = {
|
|
|
4065
4151
|
ArtMethod,
|
|
4066
4152
|
makeMethodMangler,
|
|
4067
4153
|
translateMethod,
|
|
4154
|
+
backtrace,
|
|
4068
4155
|
revertGlobalPatches,
|
|
4069
4156
|
deoptimizeEverything,
|
|
4070
4157
|
deoptimizeBootImage,
|
package/lib/jvm.js
CHANGED
|
@@ -811,8 +811,8 @@ function _getJvmMethodSpec () {
|
|
|
811
811
|
|
|
812
812
|
const getAdapterPointer = adapterInConstMethod
|
|
813
813
|
? function (method, constMethod) {
|
|
814
|
-
|
|
815
|
-
|
|
814
|
+
return constMethod.add(constantPoolOffset + 2 * pointerSize);
|
|
815
|
+
}
|
|
816
816
|
: function (method, constMethod) {
|
|
817
817
|
return method.add(i2iEntryOffset + pointerSize);
|
|
818
818
|
};
|