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
bade4f2c
Commit
bade4f2c
authored
Aug 21, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make xhook log as Magisk
parent
5754782a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
16 deletions
+19
-16
core.hpp
native/jni/core/core.hpp
+0
-1
logging.cpp
native/jni/core/logging.cpp
+14
-10
Android.mk
native/jni/external/Android.mk
+1
-1
daemon.hpp
native/jni/include/daemon.hpp
+1
-1
entry.cpp
native/jni/zygisk/entry.cpp
+3
-3
No files found.
native/jni/core/core.hpp
View file @
bade4f2c
...
@@ -8,7 +8,6 @@ extern int DAEMON_STATE;
...
@@ -8,7 +8,6 @@ extern int DAEMON_STATE;
void
unlock_blocks
();
void
unlock_blocks
();
void
reboot
();
void
reboot
();
void
magisk_logging
();
void
start_log_daemon
();
void
start_log_daemon
();
void
setup_logfile
(
bool
reset
);
void
setup_logfile
(
bool
reset
);
...
...
native/jni/core/logging.cpp
View file @
bade4f2c
...
@@ -149,6 +149,20 @@ static int magisk_log(int prio, const char *fmt, va_list ap) {
...
@@ -149,6 +149,20 @@ static int magisk_log(int prio, const char *fmt, va_list ap) {
return
len
;
return
len
;
}
}
// Used to override external C library logging
extern
"C"
int
magisk_log_print
(
int
prio
,
const
char
*
tag
,
const
char
*
fmt
,
...)
{
char
buf
[
4096
];
auto
len
=
strlcpy
(
buf
,
tag
,
sizeof
(
buf
));
// Prevent format specifications in the tag
std
::
replace
(
buf
,
buf
+
len
,
'%'
,
'_'
);
snprintf
(
buf
+
len
,
sizeof
(
buf
)
-
len
,
": %s"
,
fmt
);
va_list
argv
;
va_start
(
argv
,
fmt
);
int
ret
=
magisk_log
(
prio
,
buf
,
argv
);
va_end
(
argv
);
return
ret
;
}
#define mlog(prio) [](auto fmt, auto ap){ return magisk_log(ANDROID_LOG_##prio, fmt, ap); }
#define mlog(prio) [](auto fmt, auto ap){ return magisk_log(ANDROID_LOG_##prio, fmt, ap); }
void
magisk_logging
()
{
void
magisk_logging
()
{
log_cb
.
d
=
mlog
(
DEBUG
);
log_cb
.
d
=
mlog
(
DEBUG
);
...
@@ -158,16 +172,6 @@ void magisk_logging() {
...
@@ -158,16 +172,6 @@ void magisk_logging() {
log_cb
.
ex
=
nop_ex
;
log_cb
.
ex
=
nop_ex
;
}
}
#define alog(prio) [](auto fmt, auto ap){ \
return __android_log_vprint(ANDROID_LOG_##prio, "Magisk", fmt, ap); }
void
android_logging
()
{
log_cb
.
d
=
alog
(
DEBUG
);
log_cb
.
i
=
alog
(
INFO
);
log_cb
.
w
=
alog
(
WARN
);
log_cb
.
e
=
alog
(
ERROR
);
log_cb
.
ex
=
nop_ex
;
}
void
start_log_daemon
()
{
void
start_log_daemon
()
{
int
fds
[
2
];
int
fds
[
2
];
if
(
pipe2
(
fds
,
O_CLOEXEC
)
==
0
)
{
if
(
pipe2
(
fds
,
O_CLOEXEC
)
==
0
)
{
...
...
native/jni/external/Android.mk
View file @
bade4f2c
...
@@ -365,7 +365,7 @@ include $(CLEAR_VARS)
...
@@ -365,7 +365,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE:= libxhook
LOCAL_MODULE:= libxhook
LOCAL_C_INCLUDES := $(LOCAL_PATH)/xhook/libxhook/jni
LOCAL_C_INCLUDES := $(LOCAL_PATH)/xhook/libxhook/jni
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_CFLAGS := -Wall -Wextra -Werror -fvisibility=hidden
LOCAL_CFLAGS := -Wall -Wextra -Werror -fvisibility=hidden
-D__android_log_print=magisk_log_print
LOCAL_CONLYFLAGS := -std=c11
LOCAL_CONLYFLAGS := -std=c11
LOCAL_SRC_FILES := \
LOCAL_SRC_FILES := \
xhook/libxhook/jni/xh_log.c \
xhook/libxhook/jni/xh_log.c \
...
...
native/jni/include/daemon.hpp
View file @
bade4f2c
...
@@ -48,7 +48,7 @@ enum : int {
...
@@ -48,7 +48,7 @@ enum : int {
int
connect_daemon
(
bool
create
=
false
);
int
connect_daemon
(
bool
create
=
false
);
void
android
_logging
();
void
magisk
_logging
();
// Daemon handlers
// Daemon handlers
void
post_fs_data
(
int
client
);
void
post_fs_data
(
int
client
);
...
...
native/jni/zygisk/entry.cpp
View file @
bade4f2c
...
@@ -81,7 +81,7 @@ static void inject_cleanup_wait() {
...
@@ -81,7 +81,7 @@ static void inject_cleanup_wait() {
__attribute__
((
constructor
))
__attribute__
((
constructor
))
static
void
inject_init
()
{
static
void
inject_init
()
{
if
(
char
*
env
=
getenv
(
INJECT_ENV_2
))
{
if
(
char
*
env
=
getenv
(
INJECT_ENV_2
))
{
android
_logging
();
magisk
_logging
();
LOGD
(
"zygisk: inject 2nd stage
\n
"
);
LOGD
(
"zygisk: inject 2nd stage
\n
"
);
active_threads
=
1
;
active_threads
=
1
;
unsetenv
(
INJECT_ENV_2
);
unsetenv
(
INJECT_ENV_2
);
...
@@ -100,7 +100,7 @@ static void inject_init() {
...
@@ -100,7 +100,7 @@ static void inject_init() {
active_threads
++
;
active_threads
++
;
new_daemon_thread
(
&
unload_first_stage
,
env
);
new_daemon_thread
(
&
unload_first_stage
,
env
);
}
else
if
(
getenv
(
INJECT_ENV_1
))
{
}
else
if
(
getenv
(
INJECT_ENV_1
))
{
android
_logging
();
magisk
_logging
();
LOGD
(
"zygisk: inject 1st stage
\n
"
);
LOGD
(
"zygisk: inject 1st stage
\n
"
);
char
*
ld
=
getenv
(
"LD_PRELOAD"
);
char
*
ld
=
getenv
(
"LD_PRELOAD"
);
...
@@ -128,7 +128,7 @@ static void inject_init() {
...
@@ -128,7 +128,7 @@ static void inject_init() {
// Start code for magiskd IPC
// Start code for magiskd IPC
int
app_process_main
(
int
argc
,
char
*
argv
[])
{
int
app_process_main
(
int
argc
,
char
*
argv
[])
{
android
_logging
();
magisk
_logging
();
if
(
int
fd
=
connect_daemon
();
fd
>=
0
)
{
if
(
int
fd
=
connect_daemon
();
fd
>=
0
)
{
write_int
(
fd
,
ZYGISK_REQUEST
);
write_int
(
fd
,
ZYGISK_REQUEST
);
...
...
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