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
c282a8f3
Commit
c282a8f3
authored
Jun 02, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Loop for every for logging
parent
b9eab395
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
77 deletions
+92
-77
log_monitor.c
jni/daemon/log_monitor.c
+18
-8
magisk.h
jni/magisk.h
+1
-0
hide_daemon.c
jni/magiskhide/hide_daemon.c
+1
-1
magiskhide.h
jni/magiskhide/magiskhide.h
+0
-3
proc_monitor.c
jni/magiskhide/proc_monitor.c
+66
-59
misc.c
jni/utils/misc.c
+6
-6
No files found.
jni/daemon/log_monitor.c
View file @
c282a8f3
...
...
@@ -9,6 +9,7 @@
#include <limits.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/wait.h>
#include "magisk.h"
#include "utils.h"
...
...
@@ -23,17 +24,26 @@ static void *logger_thread(void *args) {
FILE
*
logfile
=
xfdopen
(
xopen
(
LOGFILE
,
O_WRONLY
|
O_CREAT
|
O_CLOEXEC
|
O_TRUNC
,
0644
),
"w"
);
// Disable buffering
setbuf
(
logfile
,
NULL
);
int
fd
,
log_pid
;
while
(
1
)
{
// Start logcat
char
*
const
command
[]
=
{
"logcat"
,
"-s"
,
"Magisk"
,
"-v"
,
"time"
,
NULL
};
int
fd
;
run_command
(
&
fd
,
"/system/bin/logcat"
,
command
);
log_pid
=
run_command
(
&
fd
,
"/system/bin/logcat"
,
command
);
while
(
fdgets
(
buffer
,
PATH_MAX
,
fd
))
{
fprintf
(
logfile
,
"%s"
,
buffer
);
}
// Should never be here, but well...
free
(
buffer
);
// For some reason it went here, clear buffer and restart
close
(
fd
);
kill
(
log_pid
,
SIGTERM
);
waitpid
(
log_pid
,
NULL
,
0
);
system
(
"logcat -c"
);
}
// Should never be here, but well...
fclose
(
logfile
);
free
(
buffer
);
return
NULL
;
}
...
...
jni/magisk.h
View file @
c282a8f3
...
...
@@ -32,6 +32,7 @@
#define MOUNTPOINT "/magisk"
#define COREDIR MOUNTPOINT "/.core"
#define HOSTSFILE COREDIR "/hosts"
#define HIDELIST COREDIR "/hidelist"
#define MAINIMG "/data/magisk.img"
#define DATABIN "/data/magisk"
#define MANAGERAPK DATABIN "/magisk.apk"
...
...
jni/magiskhide/hide_daemon.c
View file @
c282a8f3
...
...
@@ -113,7 +113,7 @@ int hide_daemon() {
// Unmount loop mounts
vec_for_each_r
(
&
mount_list
,
line
)
{
if
(
strstr
(
line
,
"/dev/block/loop"
)
&&
!
strstr
(
line
,
DUMM
YPATH
))
{
if
(
strstr
(
line
,
"/dev/block/loop"
)
&&
!
strstr
(
line
,
DUMM
DIR
))
{
sscanf
(
line
,
"%*s %512s"
,
buffer
);
lazy_unmount
(
buffer
);
}
...
...
jni/magiskhide/magiskhide.h
View file @
c282a8f3
...
...
@@ -3,9 +3,6 @@
#include <pthread.h>
#define HIDELIST "/magisk/.core/magiskhide/hidelist"
#define DUMMYPATH "/dev/magisk/dummy"
// Kill process
void
kill_proc
(
int
pid
);
...
...
jni/magiskhide/proc_monitor.c
View file @
c282a8f3
...
...
@@ -101,8 +101,11 @@ void proc_monitor() {
break
;
}
// Monitor am_proc_start
while
(
1
)
{
// Clear previous buffer
system
(
"logcat -b events -c"
);
// Monitor am_proc_start
char
*
const
command
[]
=
{
"logcat"
,
"-b"
,
"events"
,
"-v"
,
"raw"
,
"-s"
,
"am_proc_start"
,
NULL
};
log_pid
=
run_command
(
&
log_fd
,
"/system/bin/logcat"
,
command
);
...
...
@@ -170,6 +173,10 @@ void proc_monitor() {
}
}
// Should never be here
quit_pthread
(
SIGUSR1
);
// For some reason it went here, restart logging
kill
(
log_pid
,
SIGTERM
);
waitpid
(
log_pid
,
NULL
,
0
);
close
(
log_fd
);
log_pid
=
0
;
}
}
jni/utils/misc.c
View file @
c282a8f3
...
...
@@ -67,7 +67,7 @@ int file_to_vector(const char* filename, struct vector *v) {
size_t
len
=
0
;
ssize_t
read
;
FILE
*
fp
=
x
fopen
(
filename
,
"r"
);
FILE
*
fp
=
fopen
(
filename
,
"r"
);
if
(
fp
==
NULL
)
return
1
;
...
...
@@ -105,16 +105,16 @@ int isNum(const char *s) {
/* Read a whole line from file descriptor */
ssize_t
fdgets
(
char
*
buf
,
const
size_t
size
,
int
fd
)
{
ssize_t
read
=
0
;
ssize_t
len
=
0
;
buf
[
0
]
=
'\0'
;
while
(
xread
(
fd
,
buf
+
read
,
1
)
&&
read
<
size
-
1
)
{
if
(
buf
[
read
]
==
'\0'
||
buf
[
read
++
]
==
'\n'
)
{
buf
[
read
]
=
'\0'
;
while
(
read
(
fd
,
buf
+
len
,
1
)
>=
0
&&
len
<
size
-
1
)
{
if
(
buf
[
len
]
==
'\0'
||
buf
[
len
++
]
==
'\n'
)
{
buf
[
len
]
=
'\0'
;
break
;
}
}
buf
[
size
-
1
]
=
'\0'
;
return
read
;
return
len
;
}
/* Call func for each process */
...
...
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