Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
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
Magisk
Commits
2b17c771
Commit
2b17c771
authored
Aug 18, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Zygisk 1st class citizen
parent
c252a50f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
12 additions
and
108 deletions
+12
-108
Android.mk
native/jni/Android.mk
+4
-14
applets.cpp
native/jni/core/applets.cpp
+0
-3
daemon.hpp
native/jni/include/daemon.hpp
+0
-6
hide_utils.cpp
native/jni/magiskhide/hide_utils.cpp
+0
-31
magiskhide.cpp
native/jni/magiskhide/magiskhide.cpp
+2
-42
magiskhide.hpp
native/jni/magiskhide/magiskhide.hpp
+0
-12
hook.cpp
native/jni/zygisk/hook.cpp
+6
-0
No files found.
native/jni/Android.mk
View file @
2b17c771
...
@@ -11,7 +11,7 @@ ifdef B_MAGISK
...
@@ -11,7 +11,7 @@ ifdef B_MAGISK
include $(CLEAR_VARS)
include $(CLEAR_VARS)
LOCAL_MODULE := magisk
LOCAL_MODULE := magisk
LOCAL_STATIC_LIBRARIES := libnanopb libsystemproperties libutils libphmap
LOCAL_STATIC_LIBRARIES := libnanopb libsystemproperties libutils libphmap
libxhook
LOCAL_C_INCLUDES := jni/include
LOCAL_C_INCLUDES := jni/include
LOCAL_SRC_FILES := \
LOCAL_SRC_FILES := \
...
@@ -33,23 +33,13 @@ LOCAL_SRC_FILES := \
...
@@ -33,23 +33,13 @@ LOCAL_SRC_FILES := \
su/su.cpp \
su/su.cpp \
su/connect.cpp \
su/connect.cpp \
su/pts.cpp \
su/pts.cpp \
su/su_daemon.cpp
su/su_daemon.cpp \
LOCAL_LDLIBS := -llog
LOCAL_CPPFLAGS := -DENABLE_INJECT=$(ENABLE_INJECT)
ifeq ($(DISABLE_ZYGISK),1)
LOCAL_SRC_FILES += magiskhide/proc_monitor.cpp
LOCAL_CPPFLAGS := -DENABLE_INJECT=0
else
LOCAL_STATIC_LIBRARIES += libxhook
LOCAL_SRC_FILES += \
zygisk/entry.cpp \
zygisk/entry.cpp \
zygisk/utils.cpp \
zygisk/utils.cpp \
zygisk/hook.cpp \
zygisk/hook.cpp \
zygisk/memory.cpp
zygisk/memory.cpp
LOCAL_CPPFLAGS := -DENABLE_INJECT=1
endif
LOCAL_LDLIBS := -llog
include $(BUILD_EXECUTABLE)
include $(BUILD_EXECUTABLE)
...
...
native/jni/core/applets.cpp
View file @
2b17c771
...
@@ -20,11 +20,9 @@ static int call_applet(int argc, char *argv[]) {
...
@@ -20,11 +20,9 @@ static int call_applet(int argc, char *argv[]) {
return
(
*
applet_main
[
i
])(
argc
,
argv
);
return
(
*
applet_main
[
i
])(
argc
,
argv
);
}
}
}
}
#if ENABLE_INJECT
if
(
str_starts
(
base
,
"app_process"
))
{
if
(
str_starts
(
base
,
"app_process"
))
{
return
app_process_main
(
argc
,
argv
);
return
app_process_main
(
argc
,
argv
);
}
}
#endif
fprintf
(
stderr
,
"%s: applet not found
\n
"
,
base
.
data
());
fprintf
(
stderr
,
"%s: applet not found
\n
"
,
base
.
data
());
return
1
;
return
1
;
}
}
...
@@ -48,4 +46,3 @@ int main(int argc, char *argv[]) {
...
@@ -48,4 +46,3 @@ int main(int argc, char *argv[]) {
return
call_applet
(
argc
,
argv
);
return
call_applet
(
argc
,
argv
);
}
}
native/jni/include/daemon.hpp
View file @
2b17c771
...
@@ -57,9 +57,3 @@ void su_daemon_handler(int client, ucred *credential);
...
@@ -57,9 +57,3 @@ void su_daemon_handler(int client, ucred *credential);
// MagiskHide
// MagiskHide
void
auto_start_magiskhide
(
bool
late_props
);
void
auto_start_magiskhide
(
bool
late_props
);
int
stop_magiskhide
();
int
stop_magiskhide
();
#if ENABLE_INJECT
// For injected process to access daemon
int
remote_check_hide
(
int
uid
,
const
char
*
process
);
void
remote_request_hide
();
#endif
native/jni/magiskhide/hide_utils.cpp
View file @
2b17c771
...
@@ -299,12 +299,6 @@ int launch_magiskhide(bool late_props) {
...
@@ -299,12 +299,6 @@ int launch_magiskhide(bool late_props) {
if
(
late_props
)
if
(
late_props
)
hide_late_sensitive_props
();
hide_late_sensitive_props
();
#if !ENABLE_INJECT
// Start monitoring
if
(
new_daemon_thread
(
&
proc_monitor
))
return
DAEMON_ERROR
;
#endif
hide_state
=
true
;
hide_state
=
true
;
update_hide_config
();
update_hide_config
();
...
@@ -322,9 +316,6 @@ int stop_magiskhide() {
...
@@ -322,9 +316,6 @@ int stop_magiskhide() {
LOGI
(
"* Disable MagiskHide
\n
"
);
LOGI
(
"* Disable MagiskHide
\n
"
);
uid_proc_map
.
clear
();
uid_proc_map
.
clear
();
hide_set
.
clear
();
hide_set
.
clear
();
#if !ENABLE_INJECT
pthread_kill
(
monitor_thread
,
SIGTERMTHRD
);
#endif
}
}
hide_state
=
false
;
hide_state
=
false
;
...
@@ -334,9 +325,6 @@ int stop_magiskhide() {
...
@@ -334,9 +325,6 @@ int stop_magiskhide() {
void
auto_start_magiskhide
(
bool
late_props
)
{
void
auto_start_magiskhide
(
bool
late_props
)
{
if
(
hide_enabled
())
{
if
(
hide_enabled
())
{
#if !ENABLE_INJECT
pthread_kill
(
monitor_thread
,
SIGALRM
);
#endif
hide_late_sensitive_props
();
hide_late_sensitive_props
();
}
else
{
}
else
{
db_settings
dbs
;
db_settings
dbs
;
...
@@ -375,22 +363,3 @@ bool is_hide_target(int uid, string_view process, int max_len) {
...
@@ -375,22 +363,3 @@ bool is_hide_target(int uid, string_view process, int max_len) {
}
}
return
false
;
return
false
;
}
}
#if !ENABLE_INJECT
void
test_proc_monitor
()
{
if
(
procfp
==
nullptr
&&
(
procfp
=
opendir
(
"/proc"
))
==
nullptr
)
exit
(
1
);
proc_monitor
();
}
#endif
#if ENABLE_INJECT
int
check_uid_map
(
int
client
)
{
if
(
!
hide_enabled
())
return
0
;
int
uid
=
read_int
(
client
);
string
process
=
read_string
(
client
);
return
is_hide_target
(
uid
,
process
)
?
1
:
0
;
}
#endif
native/jni/magiskhide/magiskhide.cpp
View file @
2b17c771
...
@@ -62,17 +62,6 @@ void magiskhide_handler(int client, ucred *cred) {
...
@@ -62,17 +62,6 @@ void magiskhide_handler(int client, ucred *cred) {
case
HIDE_STATUS
:
case
HIDE_STATUS
:
res
=
hide_enabled
()
?
HIDE_IS_ENABLED
:
HIDE_NOT_ENABLED
;
res
=
hide_enabled
()
?
HIDE_IS_ENABLED
:
HIDE_NOT_ENABLED
;
break
;
break
;
#if ENABLE_INJECT
case
REMOTE_CHECK_HIDE
:
res
=
check_uid_map
(
client
);
break
;
case
REMOTE_DO_HIDE
:
kill
(
cred
->
pid
,
SIGSTOP
);
write_int
(
client
,
0
);
hide_daemon
(
cred
->
pid
);
close
(
client
);
return
;
#endif
}
}
write_int
(
client
,
res
);
write_int
(
client
,
res
);
...
@@ -107,13 +96,9 @@ int magiskhide_main(int argc, char *argv[]) {
...
@@ -107,13 +96,9 @@ int magiskhide_main(int argc, char *argv[]) {
hide_unmount
();
hide_unmount
();
execvp
(
argv
[
2
],
argv
+
2
);
execvp
(
argv
[
2
],
argv
+
2
);
exit
(
1
);
exit
(
1
);
}
}
else
{
#if 0 && !ENABLE_INJECT
else if (opt == "test"sv)
test_proc_monitor();
#endif
else
usage
(
argv
[
0
]);
usage
(
argv
[
0
]);
}
// Send request
// Send request
int
fd
=
connect_daemon
();
int
fd
=
connect_daemon
();
...
@@ -169,28 +154,3 @@ int magiskhide_main(int argc, char *argv[]) {
...
@@ -169,28 +154,3 @@ int magiskhide_main(int argc, char *argv[]) {
return_code
:
return_code
:
return
req
==
HIDE_STATUS
?
(
code
==
HIDE_IS_ENABLED
?
0
:
1
)
:
code
!=
DAEMON_SUCCESS
;
return
req
==
HIDE_STATUS
?
(
code
==
HIDE_IS_ENABLED
?
0
:
1
)
:
code
!=
DAEMON_SUCCESS
;
}
}
#if ENABLE_INJECT
int
remote_check_hide
(
int
uid
,
const
char
*
process
)
{
int
fd
=
connect_daemon
();
write_int
(
fd
,
MAGISKHIDE
);
write_int
(
fd
,
REMOTE_CHECK_HIDE
);
write_int
(
fd
,
uid
);
write_string
(
fd
,
process
);
int
res
=
read_int
(
fd
);
close
(
fd
);
return
res
;
}
void
remote_request_hide
()
{
int
fd
=
connect_daemon
();
write_int
(
fd
,
MAGISKHIDE
);
write_int
(
fd
,
REMOTE_DO_HIDE
);
// Should receive SIGSTOP before reading anything
// During process stop, magiskd will cleanup our mount ns
read_int
(
fd
);
close
(
fd
);
}
#endif
native/jni/magiskhide/magiskhide.hpp
View file @
2b17c771
...
@@ -21,16 +21,6 @@ int add_list(int client);
...
@@ -21,16 +21,6 @@ int add_list(int client);
int
rm_list
(
int
client
);
int
rm_list
(
int
client
);
void
ls_list
(
int
client
);
void
ls_list
(
int
client
);
#if !ENABLE_INJECT
// Process monitoring
extern
pthread_t
monitor_thread
;
[[
noreturn
]]
void
proc_monitor
();
[[
noreturn
]]
void
test_proc_monitor
();
#else
// Response whether target process should be hidden
int
check_uid_map
(
int
client
);
#endif
// Utility functions
// Utility functions
void
crawl_procfs
(
const
std
::
function
<
bool
(
int
)
>
&
fn
);
void
crawl_procfs
(
const
std
::
function
<
bool
(
int
)
>
&
fn
);
void
crawl_procfs
(
DIR
*
dir
,
const
std
::
function
<
bool
(
int
)
>
&
fn
);
void
crawl_procfs
(
DIR
*
dir
,
const
std
::
function
<
bool
(
int
)
>
&
fn
);
...
@@ -54,8 +44,6 @@ enum {
...
@@ -54,8 +44,6 @@ enum {
RM_HIDELIST
,
RM_HIDELIST
,
LS_HIDELIST
,
LS_HIDELIST
,
HIDE_STATUS
,
HIDE_STATUS
,
REMOTE_CHECK_HIDE
,
REMOTE_DO_HIDE
};
};
enum
{
enum
{
...
...
native/jni/zygisk/hook.cpp
View file @
2b17c771
...
@@ -114,6 +114,12 @@ string get_class_name(JNIEnv *env, jclass clazz) {
...
@@ -114,6 +114,12 @@ string get_class_name(JNIEnv *env, jclass clazz) {
// -----------------------------------------------------------------
// -----------------------------------------------------------------
// TODOs
int
remote_check_hide
(
int
uid
,
const
char
*
process
)
{
return
0
;
}
void
remote_request_hide
()
{}
// -----------------------------------------------------------------
#define DCL_HOOK_FUNC(ret, func, ...) \
#define DCL_HOOK_FUNC(ret, func, ...) \
ret (*old_##func)(__VA_ARGS__); \
ret (*old_##func)(__VA_ARGS__); \
ret new_##func(__VA_ARGS__)
ret new_##func(__VA_ARGS__)
...
...
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