frida-java-bridge 6.2.2 → 6.2.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.
package/index.js CHANGED
@@ -440,9 +440,13 @@ class Runtime {
440
440
  handleBindApplication.apply(this, arguments);
441
441
  };
442
442
 
443
- const getPackageInfoNoCheck = ActivityThread.getPackageInfoNoCheck;
444
- getPackageInfoNoCheck.implementation = function (appInfo) {
445
- const apk = getPackageInfoNoCheck.apply(this, arguments);
443
+ const getPackageInfoCandidates = ActivityThread.getPackageInfo.overloads
444
+ .map(m => [m.argumentTypes.length, m])
445
+ .sort(([arityA,], [arityB,]) => arityB - arityA)
446
+ .map(([_, method]) => method);
447
+ const getPackageInfo = getPackageInfoCandidates[0];
448
+ getPackageInfo.implementation = function (...args) {
449
+ const apk = getPackageInfo.call(this, ...args);
446
450
 
447
451
  if (!initialized && hookpoint === 'early') {
448
452
  initialized = true;
package/lib/android.js CHANGED
@@ -81,7 +81,6 @@ const SOCK_STREAM = 1;
81
81
 
82
82
  const getArtRuntimeSpec = memoize(_getArtRuntimeSpec);
83
83
  const getArtInstrumentationSpec = memoize(_getArtInstrumentationSpec);
84
- const getArtClassLinkerSpec = memoize(_getArtClassLinkerSpec);
85
84
  const getArtMethodSpec = memoize(_getArtMethodSpec);
86
85
  const getArtThreadSpec = memoize(_getArtThreadSpec);
87
86
  const getArtManagedStackSpec = memoize(_getArtManagedStackSpec);
@@ -103,6 +102,7 @@ const nativeFunctionOptions = {
103
102
  const artThreadStateTransitions = {};
104
103
 
105
104
  let cachedApi = null;
105
+ let cachedArtClassLinkerSpec = null;
106
106
  let MethodMangler = null;
107
107
  let artController = null;
108
108
  const inlineHooks = [];
@@ -139,7 +139,7 @@ function _getApi () {
139
139
 
140
140
  const temporaryApi = {
141
141
  module: vmModule,
142
- flavor: flavor,
142
+ flavor,
143
143
  addLocalReference: null
144
144
  };
145
145
 
@@ -448,7 +448,8 @@ function _getApi () {
448
448
 
449
449
  const artRuntime = temporaryApi.vm.add(pointerSize).readPointer();
450
450
  temporaryApi.artRuntime = artRuntime;
451
- const runtimeOffset = getArtRuntimeSpec(temporaryApi).offset;
451
+ const runtimeSpec = getArtRuntimeSpec(temporaryApi);
452
+ const runtimeOffset = runtimeSpec.offset;
452
453
  const instrumentationOffset = runtimeOffset.instrumentation;
453
454
  temporaryApi.artInstrumentation = (instrumentationOffset !== null) ? artRuntime.add(instrumentationOffset) : null;
454
455
 
@@ -463,7 +464,7 @@ function _getApi () {
463
464
  */
464
465
  const classLinker = artRuntime.add(runtimeOffset.classLinker).readPointer();
465
466
 
466
- const classLinkerOffsets = getArtClassLinkerSpec(temporaryApi).offset;
467
+ const classLinkerOffsets = getArtClassLinkerSpec(artRuntime, runtimeSpec).offset;
467
468
  const quickResolutionTrampoline = classLinker.add(classLinkerOffsets.quickResolutionTrampoline).readPointer();
468
469
  const quickImtConflictTrampoline = classLinker.add(classLinkerOffsets.quickImtConflictTrampoline).readPointer();
469
470
  const quickGenericJniTrampoline = classLinker.add(classLinkerOffsets.quickGenericJniTrampoline).readPointer();
@@ -471,10 +472,10 @@ function _getApi () {
471
472
 
472
473
  temporaryApi.artClassLinker = {
473
474
  address: classLinker,
474
- quickResolutionTrampoline: quickResolutionTrampoline,
475
- quickImtConflictTrampoline: quickImtConflictTrampoline,
476
- quickGenericJniTrampoline: quickGenericJniTrampoline,
477
- quickToInterpreterBridgeTrampoline: quickToInterpreterBridgeTrampoline
475
+ quickResolutionTrampoline,
476
+ quickImtConflictTrampoline,
477
+ quickGenericJniTrampoline,
478
+ quickToInterpreterBridgeTrampoline
478
479
  };
479
480
 
480
481
  const vm = new VM(temporaryApi);
@@ -613,49 +614,57 @@ function _getArtRuntimeSpec (api) {
613
614
  const endOffset = startOffset + (100 * pointerSize);
614
615
 
615
616
  const apiLevel = getAndroidApiLevel();
617
+ const codename = getAndroidCodename();
616
618
 
617
619
  let spec = null;
618
620
 
619
621
  for (let offset = startOffset; offset !== endOffset; offset += pointerSize) {
620
622
  const value = runtime.add(offset).readPointer();
621
623
  if (value.equals(vm)) {
622
- let classLinkerOffset = null;
624
+ let classLinkerOffsets;
623
625
  let jniIdManagerOffset = null;
624
- if (apiLevel >= 33 || getAndroidCodename() === 'Tiramisu') {
625
- classLinkerOffset = offset - (4 * pointerSize);
626
+ if (apiLevel >= 33 || codename === 'Tiramisu') {
627
+ classLinkerOffsets = [offset - (4 * pointerSize)];
626
628
  jniIdManagerOffset = offset - pointerSize;
627
- } else if (apiLevel >= 30 || getAndroidCodename() === 'R') {
628
- classLinkerOffset = offset - (3 * pointerSize);
629
+ } else if (apiLevel >= 30 || codename === 'R') {
630
+ classLinkerOffsets = [offset - (3 * pointerSize), offset - (4 * pointerSize)];
629
631
  jniIdManagerOffset = offset - pointerSize;
630
632
  } else if (apiLevel >= 29) {
631
- classLinkerOffset = offset - (2 * pointerSize);
633
+ classLinkerOffsets = [offset - (2 * pointerSize)];
632
634
  } else if (apiLevel >= 27) {
633
- classLinkerOffset = offset - STD_STRING_SIZE - (3 * pointerSize);
635
+ classLinkerOffsets = [offset - STD_STRING_SIZE - (3 * pointerSize)];
634
636
  } else {
635
- classLinkerOffset = offset - STD_STRING_SIZE - (2 * pointerSize);
637
+ classLinkerOffsets = [offset - STD_STRING_SIZE - (2 * pointerSize)];
636
638
  }
637
639
 
638
- const internTableOffset = classLinkerOffset - pointerSize;
639
- const threadListOffset = internTableOffset - pointerSize;
640
+ for (const classLinkerOffset of classLinkerOffsets) {
641
+ const internTableOffset = classLinkerOffset - pointerSize;
642
+ const threadListOffset = internTableOffset - pointerSize;
640
643
 
641
- let heapOffset;
642
- if (apiLevel >= 24) {
643
- heapOffset = threadListOffset - (8 * pointerSize);
644
- } else if (apiLevel >= 23) {
645
- heapOffset = threadListOffset - (7 * pointerSize);
646
- } else {
647
- heapOffset = threadListOffset - (4 * pointerSize);
648
- }
644
+ let heapOffset;
645
+ if (apiLevel >= 24) {
646
+ heapOffset = threadListOffset - (8 * pointerSize);
647
+ } else if (apiLevel >= 23) {
648
+ heapOffset = threadListOffset - (7 * pointerSize);
649
+ } else {
650
+ heapOffset = threadListOffset - (4 * pointerSize);
651
+ }
649
652
 
650
- spec = {
651
- offset: {
652
- heap: heapOffset,
653
- threadList: threadListOffset,
654
- internTable: internTableOffset,
655
- classLinker: classLinkerOffset,
656
- jniIdManager: jniIdManagerOffset
653
+ const candidate = {
654
+ offset: {
655
+ heap: heapOffset,
656
+ threadList: threadListOffset,
657
+ internTable: internTableOffset,
658
+ classLinker: classLinkerOffset,
659
+ jniIdManager: jniIdManagerOffset
660
+ }
661
+ };
662
+ if (tryGetArtClassLinkerSpec(runtime, candidate) !== null) {
663
+ spec = candidate;
664
+ break;
657
665
  }
658
- };
666
+ }
667
+
659
668
  break;
660
669
  }
661
670
  }
@@ -833,7 +842,19 @@ function _getArtInstrumentationSpec () {
833
842
  };
834
843
  }
835
844
 
836
- function _getArtClassLinkerSpec (api) {
845
+ function getArtClassLinkerSpec (runtime, runtimeSpec) {
846
+ const spec = tryGetArtClassLinkerSpec(runtime, runtimeSpec);
847
+ if (spec === null) {
848
+ throw new Error('Unable to determine ClassLinker field offsets');
849
+ }
850
+ return spec;
851
+ }
852
+
853
+ function tryGetArtClassLinkerSpec (runtime, runtimeSpec) {
854
+ if (cachedArtClassLinkerSpec !== null) {
855
+ return cachedArtClassLinkerSpec;
856
+ }
857
+
837
858
  /*
838
859
  * On Android 5.x:
839
860
  *
@@ -862,11 +883,9 @@ function _getArtClassLinkerSpec (api) {
862
883
  * }
863
884
  */
864
885
 
865
- const runtime = api.artRuntime;
866
- const runtimeSpec = getArtRuntimeSpec(api);
867
-
868
- const classLinker = runtime.add(runtimeSpec.offset.classLinker).readPointer();
869
- const internTable = runtime.add(runtimeSpec.offset.internTable).readPointer();
886
+ const { classLinker: classLinkerOffset, internTable: internTableOffset } = runtimeSpec.offset;
887
+ const classLinker = runtime.add(classLinkerOffset).readPointer();
888
+ const internTable = runtime.add(internTableOffset).readPointer();
870
889
 
871
890
  const startOffset = (pointerSize === 4) ? 100 : 200;
872
891
  const endOffset = startOffset + (100 * pointerSize);
@@ -911,8 +930,8 @@ function _getArtClassLinkerSpec (api) {
911
930
  }
912
931
  }
913
932
 
914
- if (spec === null) {
915
- throw new Error('Unable to determine ClassLinker field offsets');
933
+ if (spec !== null) {
934
+ cachedArtClassLinkerSpec = spec;
916
935
  }
917
936
 
918
937
  return spec;
@@ -1001,7 +1020,7 @@ function _getArtMethodSpec (vm) {
1001
1020
  const size = (apiLevel <= 21) ? (quickCodeOffset + 32) : (quickCodeOffset + pointerSize);
1002
1021
 
1003
1022
  spec = {
1004
- size: size,
1023
+ size,
1005
1024
  offset: {
1006
1025
  jniCode: jniCodeOffset,
1007
1026
  quickCode: quickCodeOffset,
@@ -3506,12 +3525,12 @@ class DalvikMethodMangler {
3506
3525
  vtablePtr.writePointer(shadowVtable);
3507
3526
 
3508
3527
  entry = {
3509
- classObject: classObject,
3510
- vtablePtr: vtablePtr,
3511
- vtableCountPtr: vtableCountPtr,
3512
- vtable: vtable,
3513
- vtableCount: vtableCount,
3514
- shadowVtable: shadowVtable,
3528
+ classObject,
3529
+ vtablePtr,
3530
+ vtableCountPtr,
3531
+ vtable,
3532
+ vtableCount,
3533
+ shadowVtable,
3515
3534
  shadowVtableCount: vtableCount,
3516
3535
  targetMethods: new Map()
3517
3536
  };
@@ -186,39 +186,94 @@ class ClassFactory {
186
186
  _make (name, getClassHandle, env) {
187
187
  const C = makeClassWrapperConstructor();
188
188
  const proto = Object.create(Wrapper.prototype, {
189
- $n: {
189
+ [Symbol.for('n')]: {
190
190
  value: name
191
191
  },
192
- $C: {
192
+ $n: {
193
+ get () {
194
+ return this[Symbol.for('n')];
195
+ }
196
+ },
197
+ [Symbol.for('C')]: {
193
198
  value: C
194
199
  },
195
- $w: {
200
+ $C: {
201
+ get () {
202
+ return this[Symbol.for('C')];
203
+ }
204
+ },
205
+ [Symbol.for('w')]: {
196
206
  value: null,
197
207
  writable: true
198
208
  },
199
- $_s: {
209
+ $w: {
210
+ get () {
211
+ return this[Symbol.for('w')];
212
+ },
213
+ set (val) {
214
+ this[Symbol.for('w')] = val;
215
+ }
216
+ },
217
+ [Symbol.for('_s')]: {
200
218
  writable: true
201
219
  },
202
- $c: {
220
+ $_s: {
221
+ get () {
222
+ return this[Symbol.for('_s')];
223
+ },
224
+ set (val) {
225
+ this[Symbol.for('_s')] = val;
226
+ }
227
+ },
228
+ [Symbol.for('c')]: {
203
229
  value: [null]
204
230
  },
205
- $m: {
231
+ $c: {
232
+ get () {
233
+ return this[Symbol.for('c')];
234
+ }
235
+ },
236
+ [Symbol.for('m')]: {
206
237
  value: new Map()
207
238
  },
208
- $l: {
239
+ $m: {
240
+ get () {
241
+ return this[Symbol.for('m')];
242
+ }
243
+ },
244
+ [Symbol.for('l')]: {
209
245
  value: null,
210
246
  writable: true
211
247
  },
212
- $gch: {
248
+ $l: {
249
+ get () {
250
+ return this[Symbol.for('l')];
251
+ },
252
+ set (val) {
253
+ this[Symbol.for('l')] = val;
254
+ }
255
+ },
256
+ [Symbol.for('gch')]: {
213
257
  value: getClassHandle
214
258
  },
215
- $f: {
259
+ $gch: {
260
+ get () {
261
+ return this[Symbol.for('gch')];
262
+ }
263
+ },
264
+ [Symbol.for('f')]: {
216
265
  value: this
266
+ },
267
+ $f: {
268
+ get () {
269
+ return this[Symbol.for('f')];
270
+ }
217
271
  }
218
272
  });
219
273
  C.prototype = proto;
220
274
 
221
275
  const classWrapper = new C(null);
276
+ proto[Symbol.for('w')] = classWrapper;
222
277
  proto.$w = classWrapper;
223
278
 
224
279
  const h = classWrapper.$borrowClassHandle(env);
@@ -809,14 +864,20 @@ wrapperHandler = {
809
864
  };
810
865
 
811
866
  Object.defineProperties(Wrapper.prototype, {
812
- $new: {
813
- enumerable: true,
867
+ [Symbol.for('new')]: {
868
+ enumerable: false,
814
869
  get () {
815
870
  return this.$getCtor('allocAndInit');
816
871
  }
817
872
  },
818
- $alloc: {
873
+ $new: {
819
874
  enumerable: true,
875
+ get () {
876
+ return this[Symbol.for('new')];
877
+ }
878
+ },
879
+ [Symbol.for('alloc')]: {
880
+ enumerable: false,
820
881
  value () {
821
882
  const env = vm.getEnv();
822
883
  const h = this.$borrowClassHandle(env);
@@ -829,14 +890,26 @@ Object.defineProperties(Wrapper.prototype, {
829
890
  }
830
891
  }
831
892
  },
832
- $init: {
893
+ $alloc: {
833
894
  enumerable: true,
895
+ get () {
896
+ return this[Symbol.for('$alloc')];
897
+ }
898
+ },
899
+ [Symbol.for('init')]: {
900
+ enumerable: false,
834
901
  get () {
835
902
  return this.$getCtor('initOnly');
836
903
  }
837
904
  },
838
- $dispose: {
905
+ $init: {
839
906
  enumerable: true,
907
+ get () {
908
+ return this[Symbol.for('init')];
909
+ }
910
+ },
911
+ [Symbol.for('dispose')]: {
912
+ enumerable: false,
840
913
  value () {
841
914
  const ref = this.$r;
842
915
  if (ref !== null) {
@@ -849,14 +922,26 @@ Object.defineProperties(Wrapper.prototype, {
849
922
  }
850
923
  }
851
924
  },
852
- $clone: {
925
+ $dispose: {
926
+ enumerable: true,
927
+ get () {
928
+ return this[Symbol.for('dispose')];
929
+ }
930
+ },
931
+ [Symbol.for('clone')]: {
932
+ enumerable: false,
853
933
  value (env) {
854
934
  const C = this.$C;
855
935
  return new C(this.$h, this.$t, env);
856
936
  }
857
937
  },
858
- class: {
859
- enumerable: true,
938
+ $clone: {
939
+ value (env) {
940
+ return this[Symbol.for('clone')](env);
941
+ }
942
+ },
943
+ [Symbol.for('class')]: {
944
+ enumerable: false,
860
945
  get () {
861
946
  const env = vm.getEnv();
862
947
  const h = this.$borrowClassHandle(env);
@@ -868,8 +953,14 @@ Object.defineProperties(Wrapper.prototype, {
868
953
  }
869
954
  }
870
955
  },
871
- $className: {
956
+ class: {
872
957
  enumerable: true,
958
+ get () {
959
+ return this[Symbol.for('class')];
960
+ }
961
+ },
962
+ [Symbol.for('className')]: {
963
+ enumerable: false,
873
964
  get () {
874
965
  const handle = this.$h;
875
966
  if (handle === null) {
@@ -879,22 +970,41 @@ Object.defineProperties(Wrapper.prototype, {
879
970
  return vm.getEnv().getObjectClassName(handle);
880
971
  }
881
972
  },
882
- $ownMembers: {
973
+ $className: {
883
974
  enumerable: true,
975
+ get () {
976
+ return this[Symbol.for('className')];
977
+ }
978
+ },
979
+ [Symbol.for('ownMembers')]: {
980
+ enumerable: false,
884
981
  get () {
885
982
  const model = this.$l;
886
983
  return model.list();
887
984
  }
888
985
  },
889
- $super: {
986
+ $ownMembers: {
890
987
  enumerable: true,
988
+ get () {
989
+ return this[Symbol.for('ownMembers')];
990
+ }
991
+ },
992
+ [Symbol.for('super')]: {
993
+ enumerable: false,
891
994
  get () {
892
995
  const env = vm.getEnv();
893
996
  const C = this.$s.$C;
894
997
  return new C(this.$h, STRATEGY_DIRECT, env);
895
998
  }
896
999
  },
897
- $s: {
1000
+ $super: {
1001
+ enumerable: true,
1002
+ get () {
1003
+ return this[Symbol.for('super')];
1004
+ }
1005
+ },
1006
+ [Symbol.for('s')]: {
1007
+ enumerable: false,
898
1008
  get () {
899
1009
  const proto = Object.getPrototypeOf(this);
900
1010
 
@@ -934,13 +1044,25 @@ Object.defineProperties(Wrapper.prototype, {
934
1044
  return superWrapper;
935
1045
  }
936
1046
  },
937
- $isSameObject: {
1047
+ $s: {
1048
+ get () {
1049
+ return this[Symbol.for('s')];
1050
+ }
1051
+ },
1052
+ [Symbol.for('isSameObject')]: {
1053
+ enumerable: false,
938
1054
  value (obj) {
939
1055
  const env = vm.getEnv();
940
1056
  return env.isSameObject(obj.$h, this.$h);
941
1057
  }
942
1058
  },
943
- $getCtor: {
1059
+ $isSameObject: {
1060
+ value (obj) {
1061
+ return this[Symbol.for('isSameObject')](obj);
1062
+ }
1063
+ },
1064
+ [Symbol.for('getCtor')]: {
1065
+ enumerable: false,
944
1066
  value (type) {
945
1067
  const slot = this.$c;
946
1068
 
@@ -959,7 +1081,13 @@ Object.defineProperties(Wrapper.prototype, {
959
1081
  return ctor[type];
960
1082
  }
961
1083
  },
962
- $borrowClassHandle: {
1084
+ $getCtor: {
1085
+ value (type) {
1086
+ return this[Symbol.for('getCtor')](type);
1087
+ }
1088
+ },
1089
+ [Symbol.for('borrowClassHandle')]: {
1090
+ enumerable: false,
963
1091
  value (env) {
964
1092
  const className = this.$n;
965
1093
  const classHandles = this.$f._classHandles;
@@ -973,7 +1101,13 @@ Object.defineProperties(Wrapper.prototype, {
973
1101
  return handle.ref();
974
1102
  }
975
1103
  },
976
- $copyClassHandle: {
1104
+ $borrowClassHandle: {
1105
+ value (env) {
1106
+ return this[Symbol.for('borrowClassHandle')](env);
1107
+ }
1108
+ },
1109
+ [Symbol.for('copyClassHandle')]: {
1110
+ enumerable: false,
977
1111
  value (env) {
978
1112
  const h = this.$borrowClassHandle(env);
979
1113
  try {
@@ -983,7 +1117,13 @@ Object.defineProperties(Wrapper.prototype, {
983
1117
  }
984
1118
  }
985
1119
  },
986
- $getHandle: {
1120
+ $copyClassHandle: {
1121
+ value (env) {
1122
+ return this[Symbol.for('copyClassHandle')](env);
1123
+ }
1124
+ },
1125
+ [Symbol.for('getHandle')]: {
1126
+ enumerable: false,
987
1127
  value (env) {
988
1128
  const handle = this.$h;
989
1129
 
@@ -996,7 +1136,13 @@ Object.defineProperties(Wrapper.prototype, {
996
1136
  return handle;
997
1137
  }
998
1138
  },
999
- $list: {
1139
+ $getHandle: {
1140
+ value (env) {
1141
+ return this[Symbol.for('getHandle')](env);
1142
+ }
1143
+ },
1144
+ [Symbol.for('list')]: {
1145
+ enumerable: false,
1000
1146
  value () {
1001
1147
  const superWrapper = this.$s;
1002
1148
  const superMembers = (superWrapper !== null) ? superWrapper.$list() : [];
@@ -1005,7 +1151,13 @@ Object.defineProperties(Wrapper.prototype, {
1005
1151
  return Array.from(new Set(superMembers.concat(model.list())));
1006
1152
  }
1007
1153
  },
1008
- $has: {
1154
+ $list: {
1155
+ get () {
1156
+ return this[Symbol.for('list')];
1157
+ }
1158
+ },
1159
+ [Symbol.for('has')]: {
1160
+ enumerable: false,
1009
1161
  value (member) {
1010
1162
  const members = this.$m;
1011
1163
  if (members.has(member)) {
@@ -1025,7 +1177,13 @@ Object.defineProperties(Wrapper.prototype, {
1025
1177
  return false;
1026
1178
  }
1027
1179
  },
1028
- $find: {
1180
+ $has: {
1181
+ value (member) {
1182
+ return this[Symbol.for('has')](member);
1183
+ }
1184
+ },
1185
+ [Symbol.for('find')]: {
1186
+ enumerable: false,
1029
1187
  value (member) {
1030
1188
  const members = this.$m;
1031
1189
 
@@ -1056,7 +1214,13 @@ Object.defineProperties(Wrapper.prototype, {
1056
1214
  return null;
1057
1215
  }
1058
1216
  },
1059
- toJSON: {
1217
+ $find: {
1218
+ value (member) {
1219
+ return this[Symbol.for('find')](member);
1220
+ }
1221
+ },
1222
+ [Symbol.for('toJSON')]: {
1223
+ enumerable: false,
1060
1224
  value () {
1061
1225
  const wrapperName = this.$n;
1062
1226
 
@@ -1072,6 +1236,11 @@ Object.defineProperties(Wrapper.prototype, {
1072
1236
 
1073
1237
  return `<instance: ${wrapperName}, $className: ${actualName}>`;
1074
1238
  }
1239
+ },
1240
+ toJSON: {
1241
+ get () {
1242
+ return this[Symbol.for('toJSON')];
1243
+ }
1075
1244
  }
1076
1245
  });
1077
1246
 
@@ -1409,6 +1578,10 @@ dispatcherPrototype = Object.create(Function.prototype, {
1409
1578
  return method.apply(receiver, args);
1410
1579
  }
1411
1580
 
1581
+ if (this.methodName === 'toString') {
1582
+ return `<class: ${receiver.$n}>`;
1583
+ }
1584
+
1412
1585
  throwOverloadError(this.methodName, this.overloads, 'argument types do not match any of:');
1413
1586
  }
1414
1587
  }
@@ -1647,6 +1820,12 @@ methodPrototype = Object.create(Function.prototype, {
1647
1820
  env.popLocalFrame(NULL);
1648
1821
  }
1649
1822
  }
1823
+ },
1824
+ toString: {
1825
+ enumerable: true,
1826
+ value () {
1827
+ return `function ${this.methodName}(${this.argumentTypes.map(t => t.className).join(', ')}): ${this.returnType.className}`;
1828
+ }
1650
1829
  }
1651
1830
  });
1652
1831
 
@@ -1972,6 +2151,22 @@ Object.defineProperties(Field.prototype, {
1972
2151
  get () {
1973
2152
  return this._p[2];
1974
2153
  }
2154
+ },
2155
+ toString: {
2156
+ enumerable: true,
2157
+ value () {
2158
+ const inlineString = `Java.Field{holder: ${this.holder}, fieldType: ${this.fieldType}, fieldReturnType: ${this.fieldReturnType}, value: ${this.value}}`;
2159
+ if (inlineString.length < 200) {
2160
+ return inlineString;
2161
+ }
2162
+ const multilineString = `Java.Field{
2163
+ \tholder: ${this.holder},
2164
+ \tfieldType: ${this.fieldType},
2165
+ \tfieldReturnType: ${this.fieldReturnType},
2166
+ \tvalue: ${this.value},
2167
+ }`;
2168
+ return multilineString.split('\n').map(l => l.length > 200 ? l.slice(0, l.indexOf(' ') + 1) + '...,' : l).join('\n');
2169
+ },
1975
2170
  }
1976
2171
  });
1977
2172
 
@@ -390,7 +390,10 @@ model_add_method (Model * self,
390
390
  gchar * key, type;
391
391
  const gchar * value;
392
392
 
393
- key = g_strdup (name);
393
+ if (name[0] == '$')
394
+ key = g_strdup_printf ("_%s", name);
395
+ else
396
+ key = g_strdup (name);
394
397
 
395
398
  type = (modifiers & kAccStatic) != 0 ? 's' : 'i';
396
399
 
@@ -410,7 +413,10 @@ model_add_field (Model * self,
410
413
  GHashTable * members = self->members;
411
414
  gchar * key, type;
412
415
 
413
- key = g_strdup (name);
416
+ if (name[0] == '$')
417
+ key = g_strdup_printf ("_%s", name);
418
+ else
419
+ key = g_strdup (name);
414
420
  while (g_hash_table_contains (members, key))
415
421
  {
416
422
  gchar * new_key = g_strdup_printf ("_%s", key);
package/lib/jvm.js CHANGED
@@ -765,7 +765,7 @@ function readJvmMethod (method, constMethod, constMethodSize) {
765
765
  : NULL;
766
766
 
767
767
  return {
768
- method: method,
768
+ method,
769
769
  methodSize: spec.method.size,
770
770
  const: constMethod,
771
771
  constSize: constMethodSize,
@@ -844,7 +844,7 @@ function _getJvmMethodSpec () {
844
844
  };
845
845
 
846
846
  return {
847
- getAdapterPointer: getAdapterPointer,
847
+ getAdapterPointer,
848
848
  method: {
849
849
  size: methodSize,
850
850
  constMethodOffset,
package/lib/mkdex.js CHANGED
@@ -800,7 +800,7 @@ function computeModel (classes) {
800
800
  methods: methodItems,
801
801
  protos: protoItems,
802
802
  parameters: parameterItems,
803
- annotationDirectories: annotationDirectories,
803
+ annotationDirectories,
804
804
  annotationSets: annotationSetItems,
805
805
  throwsAnnotations: throwsAnnotationItems,
806
806
  types: typeItems,
package/lib/result.js CHANGED
@@ -7,6 +7,6 @@ function checkJniResult (name, result) {
7
7
  }
8
8
 
9
9
  module.exports = {
10
- checkJniResult: checkJniResult,
10
+ checkJniResult,
11
11
  JNI_OK: 0
12
12
  };
package/lib/types.js CHANGED
@@ -51,6 +51,9 @@ const primitiveTypes = {
51
51
  },
52
52
  write (address, value) {
53
53
  address.writeU8(value);
54
+ },
55
+ toString () {
56
+ return this.name;
54
57
  }
55
58
  },
56
59
  byte: {
@@ -69,6 +72,9 @@ const primitiveTypes = {
69
72
  },
70
73
  write (address, value) {
71
74
  address.writeS8(value);
75
+ },
76
+ toString () {
77
+ return this.name;
72
78
  }
73
79
  },
74
80
  char: {
@@ -96,6 +102,9 @@ const primitiveTypes = {
96
102
  },
97
103
  write (address, value) {
98
104
  address.writeU16(value);
105
+ },
106
+ toString () {
107
+ return this.name;
99
108
  }
100
109
  },
101
110
  short: {
@@ -114,6 +123,9 @@ const primitiveTypes = {
114
123
  },
115
124
  write (address, value) {
116
125
  address.writeS16(value);
126
+ },
127
+ toString () {
128
+ return this.name;
117
129
  }
118
130
  },
119
131
  int: {
@@ -132,6 +144,9 @@ const primitiveTypes = {
132
144
  },
133
145
  write (address, value) {
134
146
  address.writeS32(value);
147
+ },
148
+ toString () {
149
+ return this.name;
135
150
  }
136
151
  },
137
152
  long: {
@@ -150,6 +165,9 @@ const primitiveTypes = {
150
165
  },
151
166
  write (address, value) {
152
167
  address.writeS64(value);
168
+ },
169
+ toString () {
170
+ return this.name;
153
171
  }
154
172
  },
155
173
  float: {
@@ -168,6 +186,9 @@ const primitiveTypes = {
168
186
  },
169
187
  write (address, value) {
170
188
  address.writeFloat(value);
189
+ },
190
+ toString () {
191
+ return this.name;
171
192
  }
172
193
  },
173
194
  double: {
@@ -186,6 +207,9 @@ const primitiveTypes = {
186
207
  },
187
208
  write (address, value) {
188
209
  address.writeDouble(value);
210
+ },
211
+ toString () {
212
+ return this.name;
189
213
  }
190
214
  },
191
215
  void: {
@@ -202,6 +226,9 @@ const primitiveTypes = {
202
226
  },
203
227
  toJni () {
204
228
  return NULL;
229
+ },
230
+ toString () {
231
+ return this.name;
205
232
  }
206
233
  }
207
234
  };
@@ -345,6 +372,9 @@ function getAnyObjectType (typeName, unbox, factory) {
345
372
  }
346
373
 
347
374
  return o.$h;
375
+ },
376
+ toString () {
377
+ return this.name;
348
378
  }
349
379
  };
350
380
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frida-java-bridge",
3
- "version": "6.2.2",
3
+ "version": "6.2.4",
4
4
  "description": "Java runtime interop from Frida",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -18,42 +18,18 @@
18
18
  },
19
19
  "homepage": "https://github.com/frida/frida-java-bridge#readme",
20
20
  "scripts": {
21
- "lint": "semistandard"
21
+ "lint": "eslint lib",
22
+ "fix": "eslint --fix lib"
22
23
  },
23
24
  "dependencies": {
24
25
  "jssha": "^3.1.2"
25
26
  },
26
27
  "devDependencies": {
27
- "semistandard": "^16.0.0"
28
- },
29
- "semistandard": {
30
- "globals": [
31
- "Arm64Relocator",
32
- "Arm64Writer",
33
- "CModule",
34
- "DebugSymbol",
35
- "File",
36
- "Instruction",
37
- "Int64",
38
- "Interceptor",
39
- "MatchPattern",
40
- "Memory",
41
- "Module",
42
- "NULL",
43
- "NativeCallback",
44
- "NativeFunction",
45
- "NativePointer",
46
- "Process",
47
- "Script",
48
- "Thread",
49
- "ThumbRelocator",
50
- "ThumbWriter",
51
- "UnixInputStream",
52
- "UnixOutputStream",
53
- "X86Relocator",
54
- "X86Writer",
55
- "ptr",
56
- "uint64"
57
- ]
28
+ "eslint": "^8.33.0",
29
+ "eslint-config-semistandard": "^17.0.0",
30
+ "eslint-config-standard": "^17.0.0",
31
+ "eslint-plugin-import": "^2.27.5",
32
+ "eslint-plugin-n": "^15.6.1",
33
+ "eslint-plugin-promise": "^6.1.1"
58
34
  }
59
35
  }