Skip to content

Commit

Permalink
android: Actually fix the kAccCompileDontBother constant
Browse files Browse the repository at this point in the history
Turns out its value changed in Android 8.1. Also, the constant didn't
exist before 7.0.
  • Loading branch information
oleavr committed Jun 20, 2022
1 parent 632ca77 commit cdc3d36
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const kAccSkipAccessChecks = 0x00080000;
const kAccSingleImplementation = 0x08000000;
const kAccNterpEntryPointFastPathFlag = 0x00100000;
const kAccNterpInvokeFastPathFlag = 0x00200000;
const kAccCompileDontBother = 0x02000000;
const kAccPublicApi = 0x10000000;
const kAccXposedHookedMethod = 0x10000000;

Expand Down Expand Up @@ -435,6 +434,18 @@ function _getApi () {
temporaryApi.vm = vms.readPointer();

if (isArt) {
const apiLevel = getAndroidApiLevel();

let kAccCompileDontBother;
if (apiLevel >= 27) {
kAccCompileDontBother = 0x02000000;
} else if (apiLevel >= 24) {
kAccCompileDontBother = 0x01000000;
} else {
kAccCompileDontBother = 0;
}
temporaryApi.kAccCompileDontBother = kAccCompileDontBother;

const artRuntime = temporaryApi.vm.add(pointerSize).readPointer();
temporaryApi.artRuntime = artRuntime;
const runtimeOffset = getArtRuntimeSpec(temporaryApi).offset;
Expand Down Expand Up @@ -3314,6 +3325,8 @@ class ArtMethodMangler {
}

replace (impl, isInstanceMethod, argTypes, vm, api) {
const { kAccCompileDontBother, artNterpEntryPoint } = api;

this.originalMethod = fetchArtMethod(this.methodId, vm);

const originalFlags = this.originalMethod.accessFlags;
Expand Down Expand Up @@ -3351,8 +3364,6 @@ class ArtMethodMangler {

// Replace Nterp quick entrypoints with art_quick_to_interpreter_bridge to force stepping out
// of ART's next-generation interpreter and use the quick stub instead.
const { artNterpEntryPoint } = api;

if (artNterpEntryPoint !== undefined && quickCode.equals(artNterpEntryPoint)) {
patchArtMethod(hookedMethodId, {
quickCode: api.artQuickToInterpreterBridge
Expand Down

0 comments on commit cdc3d36

Please sign in to comment.