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
8cb1f361
Commit
8cb1f361
authored
Jun 03, 2019
by
swift_gan
Committed by
swift_gan
Jun 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[XposedCompat]fix GetOatQuickMethodHeader error
parent
5818b078
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
2 deletions
+44
-2
sandhook_native.h
nativehook/src/main/cpp/sandhook_native.h
+1
-1
CMakeLists.txt
xposedcompat_new/CMakeLists.txt
+10
-0
art_jni_trampoline.cpp
xposedcompat_new/src/main/cpp/art_jni_trampoline.cpp
+26
-1
art_jni_trampoline.h
xposedcompat_new/src/main/cpp/art_jni_trampoline.h
+5
-0
XposedCompat.java
...ava/com/swift/sandhook/xposedcompat_new/XposedCompat.java
+2
-0
libsandhook-native.so
...mpat_new/src/main/jniLibs/arm64-v8a/libsandhook-native.so
+0
-0
libsandhook-native.so
...at_new/src/main/jniLibs/armeabi-v7a/libsandhook-native.so
+0
-0
No files found.
nativehook/src/main/cpp/sandhook_native.h
View file @
8cb1f361
...
...
@@ -5,7 +5,7 @@
#ifndef SANDHOOK_SANDHOOK_NATIVE_H
#define SANDHOOK_SANDHOOK_NATIVE_H
#include "hook.h"
typedef
size_t
REG
;
#define EXPORT __attribute__ ((visibility ("default")))
...
...
xposedcompat_new/CMakeLists.txt
View file @
8cb1f361
...
...
@@ -49,8 +49,17 @@ include_directories(
src/main/cpp
src/main/cpp/libffi
src/main/cpp/libffi/platform_include
../nativehook/src/main/cpp
)
add_library
(
sandhook-native
SHARED
IMPORTED
)
set_target_properties
(
sandhook-native
PROPERTIES IMPORTED_LOCATION
${
CMAKE_SOURCE_DIR
}
/src/main/jniLibs/
${
ANDROID_ABI
}
/libsandhook-native.so
)
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
...
...
@@ -71,6 +80,7 @@ find_library( # Sets the name of the path variable.
target_link_libraries
(
# Specifies the target library.
sandhook-xp
sandhook-native
# Links the target library to the log library
# included in the NDK.
${
log-lib
}
)
...
...
xposedcompat_new/src/main/cpp/art_jni_trampoline.cpp
View file @
8cb1f361
...
...
@@ -3,8 +3,20 @@
//
#include <cstring>
#include <utils/log.h>
#include "art_jni_trampoline.h"
#include "sandhook_native.h"
//bug fix hooks
void
*
NewGetOatQuickMethodHeader
(
void
*
artMethod
,
uintptr_t
pc
)
{
std
::
set
<
void
*>::
iterator
it
=
hookMethods
.
find
(
artMethod
);
if
(
it
!=
hookMethods
.
end
())
{
LOGE
(
"skip GetOatQuickMethodHeader"
);
return
nullptr
;
}
return
GetOatQuickMethodHeaderBackup
(
artMethod
,
pc
);
}
//bug fix hooks
#define EXPORT_LANG_ClASS(c) jclass Types::java_lang_##c; jmethodID Types::java_lang_##c##_init; jmethodID Types::java_value_##c;
...
...
@@ -274,6 +286,13 @@ Java_com_swift_sandhook_xposedcompat_1new_XposedCompat_init(JNIEnv *env, jclass
bridgeMethod
=
env
->
FromReflectedMethod
(
jbridgeMethod
);
env
->
GetJavaVM
(
&
javaVM
);
Types
::
Load
(
env
);
if
(
sizeof
(
size_t
)
==
8
)
{
GetOatQuickMethodHeaderBackup
=
reinterpret_cast
<
void
*
(
*
)(
void
*
,
uintptr_t
)
>
(
SandInlineHookSym
(
"/system/lib64/libart.so"
,
"_ZN3art9ArtMethod23GetOatQuickMethodHeaderEm"
,
(
void
*
)
NewGetOatQuickMethodHeader
));
}
else
{
GetOatQuickMethodHeaderBackup
=
reinterpret_cast
<
void
*
(
*
)(
void
*
,
uintptr_t
)
>
(
SandInlineHookSym
(
"/system/lib/libart.so"
,
"_ZN3art9ArtMethod23GetOatQuickMethodHeaderEj"
,
(
void
*
)
NewGetOatQuickMethodHeader
));
}
}
extern
"C"
...
...
@@ -299,3 +318,9 @@ Java_com_swift_sandhook_xposedcompat_1new_XposedCompat_getJNITrampoline(JNIEnv *
return
0
;
}
}
extern
"C"
JNIEXPORT
void
JNICALL
Java_com_swift_sandhook_xposedcompat_1new_XposedCompat_addHookMethod
(
JNIEnv
*
env
,
jclass
type
,
jobject
hookMethod
)
{
hookMethods
.
insert
(
env
->
FromReflectedMethod
(
hookMethod
));
}
xposedcompat_new/src/main/cpp/art_jni_trampoline.h
View file @
8cb1f361
...
...
@@ -8,6 +8,7 @@
#include <cstdint>
#include <jni.h>
#include <list>
#include <set>
#include "ffi_cxx.h"
jclass
java_lang_Object
;
...
...
@@ -16,6 +17,9 @@ jclass bridgeClass;
jmethodID
bridgeMethod
;
void
*
(
*
GetOatQuickMethodHeaderBackup
)(
void
*
,
uintptr_t
)
=
nullptr
;
struct
ArtHookParam
{
jint
slot
;
bool
is_static_
;
...
...
@@ -24,6 +28,7 @@ struct ArtHookParam {
};
std
::
list
<
ArtHookParam
*>
hookParams
=
std
::
list
<
ArtHookParam
*>
();
std
::
set
<
void
*>
hookMethods
=
std
::
set
<
void
*>
();
template
<
typename
U
,
typename
T
>
U
ForceCast
(
T
*
x
)
{
...
...
xposedcompat_new/src/main/java/com/swift/sandhook/xposedcompat_new/XposedCompat.java
View file @
8cb1f361
...
...
@@ -61,6 +61,7 @@ public class XposedCompat {
private
native
static
long
getJNITrampoline
(
int
slot
,
boolean
isStatic
,
char
retShorty
,
char
[]
paramsShorty
);
private
native
static
void
addHookMethod
(
Member
hookMethod
);
public
static
long
getJNITrampoline
(
Member
origin
,
int
slot
)
{
if
(
origin
instanceof
Constructor
)
{
...
...
@@ -98,6 +99,7 @@ public class XposedCompat {
hookInfos
[
slot
]
=
hookInfo
;
try
{
SandHook
.
hook
(
new
HookWrapper
.
HookEntity
(
origin
,
hook
,
backup
));
addHookMethod
(
hook
);
return
true
;
}
catch
(
HookErrorException
e
)
{
HookLog
.
e
(
"hook error!"
,
e
);
...
...
xposedcompat_new/src/main/jniLibs/arm64-v8a/libsandhook-native.so
0 → 100644
View file @
8cb1f361
File added
xposedcompat_new/src/main/jniLibs/armeabi-v7a/libsandhook-native.so
0 → 100644
View file @
8cb1f361
File added
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