mar-v-in/ArtHook

How hook execSQL method?

wyhuan opened this issue · 3 comments

how hook "android.database.sqlite.SQLiteDatabase->execSQL"?

I try fail

    File folder = this.getFilesDir();
    File f = new File(folder.getAbsolutePath() + "/test");
    SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(f, null);
    String sql = ".......";
    db.execSQL(sql);

@Hook("android.database.sqlite.SQLiteDatabase->execSQL")
public void SQLiteDatabase_execSQL(String sql) throws SQLException {
    Log.e(TAG, "SQLiteDatabase_execSQL: " + sql);
    OriginalMethod.by("SQLiteDatabase_execSQL").invoke(sql);
}

What is not working? Be more precise!

You invoke the original method by identifier, but don't declare the identifier via @BackupIdentifier("SQLiteDatabase_execSQL")

I tried your way, but without success

@Hook("android.database.sqlite.SQLiteDatabase->execSQL")
@BackupIdentifier("SQLiteDatabase_execSQL")
public void SQLiteDatabase_execSQL(String sql) throws SQLException {
    Log.e("neil", "SQLiteDatabase_execSQL: " + sql);
    OriginalMethod.by("SQLiteDatabase_execSQL").invoke(sql);
}

Can you hook to this method?
android.database.sqlite.SQLiteDatabase->execSQL

You can try

File folder = this.getFilesDir();
File f = new File(folder.getAbsolutePath() + "/test");
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(f, null);
String sql = ".......";
db.execSQL(sql);

I have solved the problem is to find the original function of the problem。3Q