frida-java-bridge 6.3.7 → 6.3.9

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.
Files changed (2) hide show
  1. package/lib/android.js +32 -8
  2. package/package.json +1 -1
package/lib/android.js CHANGED
@@ -151,6 +151,11 @@ function _getApi () {
151
151
  addLocalReference: null
152
152
  };
153
153
 
154
+ temporaryApi.isApiLevel34OrApexEquivalent = isArt && (
155
+ temporaryApi.find('_ZN3art7AppInfo29GetPrimaryApkReferenceProfileEv') !== null ||
156
+ temporaryApi.find('_ZN3art6Thread15RunFlipFunctionEPS0_') !== null
157
+ );
158
+
154
159
  const pending = isArt
155
160
  ? {
156
161
  functions: {
@@ -623,8 +628,7 @@ function _getArtRuntimeSpec (api) {
623
628
 
624
629
  const apiLevel = getAndroidApiLevel();
625
630
  const codename = getAndroidCodename();
626
- const isApiLevel34OrApexEquivalent = api.find('_ZN3art7AppInfo29GetPrimaryApkReferenceProfileEv') !== null ||
627
- api.find('_ZN3art6Thread15RunFlipFunctionEPS0_') !== null;
631
+ const { isApiLevel34OrApexEquivalent } = api;
628
632
 
629
633
  let spec = null;
630
634
 
@@ -633,7 +637,7 @@ function _getArtRuntimeSpec (api) {
633
637
  if (value.equals(vm)) {
634
638
  let classLinkerOffsets;
635
639
  let jniIdManagerOffset = null;
636
- if (apiLevel >= 33 || codename === 'Tiramisu') {
640
+ if (apiLevel >= 33 || codename === 'Tiramisu' || isApiLevel34OrApexEquivalent) {
637
641
  classLinkerOffsets = [offset - (4 * pointerSize)];
638
642
  jniIdManagerOffset = offset - pointerSize;
639
643
  } else if (apiLevel >= 30 || codename === 'R') {
@@ -829,6 +833,7 @@ function _getArtInstrumentationSpec () {
829
833
  '4-28': 212,
830
834
  '4-29': 172,
831
835
  '4-30': 180,
836
+ '4-31': 180,
832
837
  '8-21': 224,
833
838
  '8-22': 224,
834
839
  '8-23': 296,
@@ -838,7 +843,8 @@ function _getArtInstrumentationSpec () {
838
843
  '8-27': 352,
839
844
  '8-28': 392,
840
845
  '8-29': 328,
841
- '8-30': 336
846
+ '8-30': 336,
847
+ '8-31': 336
842
848
  };
843
849
 
844
850
  const deoptEnabledOffset = deoptimizationEnabledOffsets[`${pointerSize}-${getAndroidApiLevel()}`];
@@ -944,6 +950,8 @@ function tryGetArtClassLinkerSpec (runtime, runtimeSpec) {
944
950
 
945
951
  if (spec !== null) {
946
952
  cachedArtClassLinkerSpec = spec;
953
+ } else {
954
+ throw new Error('Unable to determine ClassLinker field offsets');
947
955
  }
948
956
 
949
957
  return spec;
@@ -1853,19 +1861,30 @@ function instrumentArtQuickEntrypoints (vm) {
1853
1861
  }
1854
1862
 
1855
1863
  function instrumentArtMethodInvocationFromInterpreter () {
1864
+ const api = getApi();
1865
+
1856
1866
  const apiLevel = getAndroidApiLevel();
1867
+ const { isApiLevel34OrApexEquivalent } = api;
1857
1868
 
1858
1869
  let artInterpreterDoCallExportRegex;
1859
1870
  if (apiLevel <= 22) {
1860
1871
  artInterpreterDoCallExportRegex = /^_ZN3art11interpreter6DoCallILb[0-1]ELb[0-1]EEEbPNS_6mirror9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE$/;
1861
- } else if (apiLevel <= 33) {
1872
+ } else if (apiLevel <= 33 && !isApiLevel34OrApexEquivalent) {
1862
1873
  artInterpreterDoCallExportRegex = /^_ZN3art11interpreter6DoCallILb[0-1]ELb[0-1]EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE$/;
1863
- } else {
1874
+ } else if (isApiLevel34OrApexEquivalent) {
1864
1875
  artInterpreterDoCallExportRegex = /^_ZN3art11interpreter6DoCallILb[0-1]EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtbPNS_6JValueE$/;
1876
+ } else {
1877
+ throw new Error('Unable to find method invocation in ART; please file a bug');
1878
+ }
1879
+
1880
+ const art = api.module;
1881
+ const entries = [...art.enumerateExports(), ...art.enumerateSymbols()].filter(entry => artInterpreterDoCallExportRegex.test(entry.name));
1882
+
1883
+ if (entries.length === 0) {
1884
+ throw new Error('Unable to find method invocation in ART; please file a bug');
1865
1885
  }
1866
1886
 
1867
- const art = getApi().module;
1868
- for (const entry of [...art.enumerateExports(), ...art.enumerateSymbols()].filter(entry => artInterpreterDoCallExportRegex.test(entry.name))) {
1887
+ for (const entry of entries) {
1869
1888
  Interceptor.attach(entry.address, artController.hooks.Interpreter.doCall);
1870
1889
  }
1871
1890
  }
@@ -4237,6 +4256,7 @@ function recompileExceptionClearForArm (buffer, pc, exceptionClearImpl, nextFunc
4237
4256
  case 'beq.w':
4238
4257
  case 'beq':
4239
4258
  case 'bne':
4259
+ case 'bne.w':
4240
4260
  case 'bgt':
4241
4261
  branchTarget = ptr(insn.operands[0].value);
4242
4262
  break;
@@ -4332,6 +4352,10 @@ function recompileExceptionClearForArm (buffer, pc, exceptionClearImpl, nextFunc
4332
4352
  writer.putBCondLabelWide('eq', branchLabelFromOperand(insn.operands[0]));
4333
4353
  keep = false;
4334
4354
  break;
4355
+ case 'bne.w':
4356
+ writer.putBCondLabelWide('ne', branchLabelFromOperand(insn.operands[0]));
4357
+ keep = false;
4358
+ break;
4335
4359
  case 'beq':
4336
4360
  case 'bne':
4337
4361
  case 'bgt':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frida-java-bridge",
3
- "version": "6.3.7",
3
+ "version": "6.3.9",
4
4
  "description": "Java runtime interop from Frida",
5
5
  "main": "index.js",
6
6
  "files": [