frida-java-bridge 6.3.3 → 6.3.4

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 +20 -13
  2. package/package.json +1 -1
package/lib/android.js CHANGED
@@ -618,6 +618,7 @@ function _getArtRuntimeSpec (api) {
618
618
 
619
619
  const apiLevel = getAndroidApiLevel();
620
620
  const codename = getAndroidCodename();
621
+ const isApiLevel34OrApexEquivalent = Module.findExportByName('libart.so', '_ZN3art7AppInfo29GetPrimaryApkReferenceProfileEv') !== null;
621
622
 
622
623
  let spec = null;
623
624
 
@@ -645,7 +646,7 @@ function _getArtRuntimeSpec (api) {
645
646
  const threadListOffset = internTableOffset - pointerSize;
646
647
 
647
648
  let heapOffset;
648
- if (apiLevel >= 34) {
649
+ if (isApiLevel34OrApexEquivalent) {
649
650
  heapOffset = threadListOffset - (9 * pointerSize);
650
651
  } else if (apiLevel >= 24) {
651
652
  heapOffset = threadListOffset - (8 * pointerSize);
@@ -1807,6 +1808,9 @@ on_leave_gc_concurrent_copying_copying_phase (GumInvocationContext * ic)
1807
1808
  Gc: {
1808
1809
  copyingPhase: {
1809
1810
  onLeave: cm.on_leave_gc_concurrent_copying_copying_phase
1811
+ },
1812
+ runFlip: {
1813
+ onEnter: cm.on_leave_gc_concurrent_copying_copying_phase
1810
1814
  }
1811
1815
  }
1812
1816
  }
@@ -1884,19 +1888,22 @@ function ensureArtKnowsHowToHandleReplacementMethods (vm) {
1884
1888
 
1885
1889
  const apiLevel = getAndroidApiLevel();
1886
1890
 
1887
- let exportName = null;
1888
- if (apiLevel > 28) {
1889
- exportName = '_ZN3art2gc9collector17ConcurrentCopying12CopyingPhaseEv';
1890
- } else if (apiLevel > 22) {
1891
- exportName = '_ZN3art2gc9collector17ConcurrentCopying12MarkingPhaseEv';
1892
- }
1893
-
1894
- if (exportName !== null) {
1895
- Interceptor.attach(Module.getExportByName('libart.so', exportName), artController.hooks.Gc.copyingPhase);
1891
+ const mayUseCollector = (apiLevel > 28)
1892
+ ? new NativeFunction(Module.getExportByName('libart.so', '_ZNK3art2gc4Heap15MayUseCollectorENS0_13CollectorTypeE'), 'bool', ['pointer', 'int'])
1893
+ : () => false;
1894
+ const kCollectorTypeCMC = 3;
1896
1895
 
1897
- const collectorCMC = Module.findExportByName('libart.so', '_ZN3art2gc9collector11MarkCompact15CompactionPhaseEv');
1898
- if (collectorCMC !== null) {
1899
- Interceptor.attach(collectorCMC, artController.hooks.Gc.copyingPhase);
1896
+ if (mayUseCollector(getApi().artHeap, kCollectorTypeCMC)) {
1897
+ Interceptor.attach(Module.getExportByName('libart.so', '_ZN3art6Thread15RunFlipFunctionEPS0_b'), artController.hooks.Gc.runFlip);
1898
+ } else {
1899
+ let exportName = null;
1900
+ if (apiLevel > 28) {
1901
+ exportName = '_ZN3art2gc9collector17ConcurrentCopying12CopyingPhaseEv';
1902
+ } else if (apiLevel > 22) {
1903
+ exportName = '_ZN3art2gc9collector17ConcurrentCopying12MarkingPhaseEv';
1904
+ }
1905
+ if (exportName !== null) {
1906
+ Interceptor.attach(Module.getExportByName('libart.so', exportName), artController.hooks.Gc.copyingPhase);
1900
1907
  }
1901
1908
  }
1902
1909
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frida-java-bridge",
3
- "version": "6.3.3",
3
+ "version": "6.3.4",
4
4
  "description": "Java runtime interop from Frida",
5
5
  "main": "index.js",
6
6
  "files": [