frida-java-bridge 6.3.2 → 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 +25 -10
  2. package/package.json +1 -1
package/lib/android.js CHANGED
@@ -591,8 +591,9 @@ function _getArtRuntimeSpec (api) {
591
591
  * gc::Heap* heap_; <-- we need to find this
592
592
  * std::unique_ptr<ArenaPool> jit_arena_pool_; <----- API level >= 24
593
593
  * std::unique_ptr<ArenaPool> arena_pool_; __
594
- * std::unique_ptr<ArenaPool> low_4gb_arena_pool_; <--|__ API level >= 23
594
+ * std::unique_ptr<ArenaPool> low_4gb_arena_pool_/linear_alloc_arena_pool_; <--|__ API level >= 23
595
595
  * std::unique_ptr<LinearAlloc> linear_alloc_; \_
596
+ * std::atomic<LinearAlloc*> startup_linear_alloc_;<----- API level >= 34
596
597
  * size_t max_spins_before_thin_lock_inflation_;
597
598
  * MonitorList* monitor_list_;
598
599
  * MonitorPool* monitor_pool_;
@@ -617,6 +618,7 @@ function _getArtRuntimeSpec (api) {
617
618
 
618
619
  const apiLevel = getAndroidApiLevel();
619
620
  const codename = getAndroidCodename();
621
+ const isApiLevel34OrApexEquivalent = Module.findExportByName('libart.so', '_ZN3art7AppInfo29GetPrimaryApkReferenceProfileEv') !== null;
620
622
 
621
623
  let spec = null;
622
624
 
@@ -644,7 +646,9 @@ function _getArtRuntimeSpec (api) {
644
646
  const threadListOffset = internTableOffset - pointerSize;
645
647
 
646
648
  let heapOffset;
647
- if (apiLevel >= 24) {
649
+ if (isApiLevel34OrApexEquivalent) {
650
+ heapOffset = threadListOffset - (9 * pointerSize);
651
+ } else if (apiLevel >= 24) {
648
652
  heapOffset = threadListOffset - (8 * pointerSize);
649
653
  } else if (apiLevel >= 23) {
650
654
  heapOffset = threadListOffset - (7 * pointerSize);
@@ -1804,6 +1808,9 @@ on_leave_gc_concurrent_copying_copying_phase (GumInvocationContext * ic)
1804
1808
  Gc: {
1805
1809
  copyingPhase: {
1806
1810
  onLeave: cm.on_leave_gc_concurrent_copying_copying_phase
1811
+ },
1812
+ runFlip: {
1813
+ onEnter: cm.on_leave_gc_concurrent_copying_copying_phase
1807
1814
  }
1808
1815
  }
1809
1816
  }
@@ -1881,15 +1888,23 @@ function ensureArtKnowsHowToHandleReplacementMethods (vm) {
1881
1888
 
1882
1889
  const apiLevel = getAndroidApiLevel();
1883
1890
 
1884
- let exportName = null;
1885
- if (apiLevel > 28) {
1886
- exportName = '_ZN3art2gc9collector17ConcurrentCopying12CopyingPhaseEv';
1887
- } else if (apiLevel > 22) {
1888
- exportName = '_ZN3art2gc9collector17ConcurrentCopying12MarkingPhaseEv';
1889
- }
1891
+ const mayUseCollector = (apiLevel > 28)
1892
+ ? new NativeFunction(Module.getExportByName('libart.so', '_ZNK3art2gc4Heap15MayUseCollectorENS0_13CollectorTypeE'), 'bool', ['pointer', 'int'])
1893
+ : () => false;
1894
+ const kCollectorTypeCMC = 3;
1890
1895
 
1891
- if (exportName !== null) {
1892
- Interceptor.attach(Module.getExportByName('libart.so', exportName), 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);
1907
+ }
1893
1908
  }
1894
1909
  }
1895
1910
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frida-java-bridge",
3
- "version": "6.3.2",
3
+ "version": "6.3.4",
4
4
  "description": "Java runtime interop from Frida",
5
5
  "main": "index.js",
6
6
  "files": [