Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/test/.project
/test/build/
/test/node_modules/
/out/
3 changes: 3 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

npx frida-compile index.js -o out/frida-java-bridge.js -c -S -B esm -T none
9 changes: 8 additions & 1 deletion lib/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,10 @@ function _getApi () {
function tryGetEnvJvmti (vm, runtime) {
let env = null;

if (globalThis.FRIDA_JAVA_BRIDGE_DISABLE_JVMTI === true) {
return env;
}

vm.perform(() => {
const ensurePluginLoadedAddr = getApi().find('_ZN3art7Runtime18EnsurePluginLoadedEPKcPNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE');
if (ensurePluginLoadedAddr === null) {
Expand Down Expand Up @@ -1149,7 +1153,10 @@ export function getArtClassSpec (vm) {
}
}
if (offsetCopiedMethods === -1) {
throw new Error('Unable to find copied methods in java/lang/Thread; please file a bug');
// Layout changed (seen on Android 16): there is no u16 matching the methods array length.
// 0 is an impossible offset (it's the klass_ header), so it is used as a sentinel telling
// the native side to iterate over the whole methods array instead of only the declared ones.
offsetCopiedMethods = 0;
}

spec = {
Expand Down
10 changes: 6 additions & 4 deletions lib/class-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ model_new (jclass class_handle,
guint field_array_cursor;
gboolean merged_fields = art_api.class_offset_sfields == 0;

elements = read_art_array (class_object, art_api.class_offset_methods, sizeof (gsize), NULL);
n = *(guint16 *) (class_object + art_api.class_offset_copied_methods_offset);
elements = read_art_array (class_object, art_api.class_offset_methods, sizeof (gsize), &n);
if (art_api.class_offset_copied_methods_offset != 0)
n = *(guint16 *) (class_object + art_api.class_offset_copied_methods_offset);
for (i = 0; i != n; i++)
{
jmethodID id;
Expand Down Expand Up @@ -613,8 +614,9 @@ collect_matching_class_methods (ArtClassVisitor * self,
class_name_length = strlen (class_name);
seen_method_names = ctx->include_signature ? NULL : g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);

elements = read_art_array (klass, art_api.class_offset_methods, sizeof (gsize), NULL);
n = *(guint16 *) ((gpointer) klass + art_api.class_offset_copied_methods_offset);
elements = read_art_array (klass, art_api.class_offset_methods, sizeof (gsize), &n);
if (art_api.class_offset_copied_methods_offset != 0)
n = *(guint16 *) ((gpointer) klass + art_api.class_offset_copied_methods_offset);
for (i = 0; i != n; i++)
{
ArtMethod * method;
Expand Down
Loading