Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SandHook
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
SandHook
Commits
19478899
Commit
19478899
authored
Mar 14, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pre support Android Q
parent
a9597adf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
8 deletions
+49
-8
arch.h
hooklib/src/main/cpp/includes/arch.h
+2
-0
hide_api.h
hooklib/src/main/cpp/includes/hide_api.h
+2
-0
sandhook.cpp
hooklib/src/main/cpp/sandhook.cpp
+1
-0
hide_api.cpp
hooklib/src/main/cpp/utils/hide_api.cpp
+44
-8
No files found.
hooklib/src/main/cpp/includes/arch.h
View file @
19478899
...
...
@@ -42,5 +42,7 @@ static void clearCacheArm32(char* begin, char *end)
#define ANDROID_O 26
#define ANDROID_O2 27
#define ANDROID_P 28
//could not 29
#define ANDROID_Q 29
#endif //SANDHOOK_ARCH_H
\ No newline at end of file
hooklib/src/main/cpp/includes/hide_api.h
View file @
19478899
...
...
@@ -33,6 +33,8 @@ extern "C" {
void
*
getInterpreterBridge
(
bool
isNative
);
bool
replaceUpdateCompilerOptionsQ
();
}
#endif //SANDHOOK_HIDE_API_H
hooklib/src/main/cpp/sandhook.cpp
View file @
19478899
...
...
@@ -306,6 +306,7 @@ JNIEXPORT jboolean JNICALL
Java_com_swift_sandhook_SandHook_disableVMInline
(
JNIEnv
*
env
,
jclass
type
)
{
if
(
SDK_INT
<
ANDROID_N
)
return
JNI_FALSE
;
replaceUpdateCompilerOptionsQ
();
art
::
CompilerOptions
*
compilerOptions
=
getGlobalCompilerOptions
();
if
(
compilerOptions
==
nullptr
)
return
JNI_FALSE
;
...
...
hooklib/src/main/cpp/utils/hide_api.cpp
View file @
19478899
...
...
@@ -4,6 +4,7 @@
#include "../includes/hide_api.h"
#include "../includes/arch.h"
#include "../includes/elf_util.h"
#include "../includes/log.h"
extern
int
SDK_INT
;
...
...
@@ -13,6 +14,7 @@ extern "C" {
void
*
(
*
jitLoad
)(
bool
*
)
=
nullptr
;
void
*
jitCompilerHandle
=
nullptr
;
bool
(
*
jitCompileMethod
)(
void
*
,
void
*
,
void
*
,
bool
)
=
nullptr
;
bool
(
*
jitCompileMethodQ
)(
void
*
,
void
*
,
void
*
,
bool
,
bool
)
=
nullptr
;
void
(
*
innerSuspendVM
)()
=
nullptr
;
void
(
*
innerResumeVM
)()
=
nullptr
;
...
...
@@ -21,6 +23,9 @@ extern "C" {
art
::
jit
::
JitCompiler
**
globalJitCompileHandlerAddr
=
nullptr
;
//for Android Q
void
(
**
origin_jit_update_options
)(
void
*
)
=
nullptr
;
void
*
(
*
get
)(
bool
*
)
=
nullptr
;
const
char
*
art_lib_path
;
...
...
@@ -40,8 +45,14 @@ extern "C" {
//init compile
if
(
SDK_INT
>=
ANDROID_N
)
{
jitCompileMethod
=
reinterpret_cast
<
bool
(
*
)(
void
*
,
void
*
,
void
*
,
bool
)
>
(
getSymCompat
(
jit_lib_path
,
"jit_compile_method"
));
if
(
SDK_INT
>=
ANDROID_Q
)
{
jitCompileMethodQ
=
reinterpret_cast
<
bool
(
*
)(
void
*
,
void
*
,
void
*
,
bool
,
bool
)
>
(
getSymCompat
(
jit_lib_path
,
"jit_compile_method"
));
}
else
{
jitCompileMethod
=
reinterpret_cast
<
bool
(
*
)(
void
*
,
void
*
,
void
*
,
bool
)
>
(
getSymCompat
(
jit_lib_path
,
"jit_compile_method"
));
}
jitLoad
=
reinterpret_cast
<
void
*
(
*
)(
bool
*
)
>
(
getSymCompat
(
jit_lib_path
,
"jit_load"
));
bool
generate_debug_info
=
false
;
jitCompilerHandle
=
(
jitLoad
)(
&
generate_debug_info
);
...
...
@@ -79,19 +90,26 @@ extern "C" {
if
(
SDK_INT
>=
ANDROID_N
)
{
globalJitCompileHandlerAddr
=
reinterpret_cast
<
art
::
jit
::
JitCompiler
**>
(
getSymCompat
(
art_lib_path
,
"_ZN3art3jit3Jit20jit_compiler_handle_E"
));
SandHook
::
ElfImg
elfImg
(
art_lib_path
);
void
*
sym
=
reinterpret_cast
<
void
*>
(
elfImg
.
getSymbAddress
(
"art_quick_to_interpreter_bridge"
));
}
int
i
=
1
;
if
(
SDK_INT
>=
ANDROID_Q
)
{
origin_jit_update_options
=
reinterpret_cast
<
void
(
**
)(
void
*
)
>
(
getSymCompat
(
art_lib_path
,
"_ZN3art3jit3Jit20jit_update_options_E"
));
}
}
bool
compileMethod
(
void
*
artMethod
,
void
*
thread
)
{
if
(
jitCompileMethod
==
nullptr
)
{
return
false
;
if
(
SDK_INT
>=
ANDROID_Q
)
{
if
(
jitCompileMethodQ
==
nullptr
)
{
return
false
;
}
return
jitCompileMethodQ
(
jitCompilerHandle
,
artMethod
,
thread
,
false
,
false
);
}
else
{
if
(
jitCompileMethod
==
nullptr
)
{
return
false
;
}
return
jitCompileMethod
(
jitCompilerHandle
,
artMethod
,
thread
,
false
);
}
return
jitCompileMethod
(
jitCompilerHandle
,
artMethod
,
thread
,
false
);
}
void
suspendVM
()
{
...
...
@@ -169,5 +187,23 @@ extern "C" {
}
}
//to replace jit_update_option
void
fake_jit_update_options
(
void
*
handle
)
{
//do nothing
LOGW
(
"android q: art request update compiler options"
);
return
;
}
bool
replaceUpdateCompilerOptionsQ
()
{
if
(
SDK_INT
<
ANDROID_Q
)
return
false
;
if
(
origin_jit_update_options
==
nullptr
||
origin_jit_update_options
<=
0
||
*
origin_jit_update_options
==
nullptr
||
*
origin_jit_update_options
<=
0
)
return
false
;
*
origin_jit_update_options
=
fake_jit_update_options
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment