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
f56ea529
Commit
f56ea529
authored
Oct 05, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add public Zygisk API
Still WIP
parent
cb4361b7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
322 additions
and
46 deletions
+322
-46
api.hpp
native/jni/zygisk/api.hpp
+255
-23
entry.cpp
native/jni/zygisk/entry.cpp
+1
-1
gen_jni_hooks.py
native/jni/zygisk/gen_jni_hooks.py
+2
-2
hook.cpp
native/jni/zygisk/hook.cpp
+47
-3
jni_hooks.hpp
native/jni/zygisk/jni_hooks.hpp
+15
-15
ptrace.cpp
native/jni/zygisk/ptrace.cpp
+1
-1
utils.cpp
native/jni/zygisk/utils.cpp
+1
-1
zygisk.hpp
native/jni/zygisk/zygisk.hpp
+0
-0
No files found.
native/jni/zygisk/api.hpp
View file @
f56ea529
This diff is collapsed.
Click to expand it.
native/jni/zygisk/entry.cpp
View file @
f56ea529
...
...
@@ -10,7 +10,7 @@
#include <magisk.hpp>
#include <db.hpp>
#include "
inject
.hpp"
#include "
zygisk
.hpp"
#include "deny/deny.hpp"
using
namespace
std
;
...
...
native/jni/zygisk/gen_jni_hooks.py
View file @
f56ea529
...
...
@@ -87,7 +87,7 @@ class ForkAndSpec(JNIHook):
return
'nativeForkAndSpecialize'
def
init_args
(
self
):
return
'
SpecializeAppProcessArgs
args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);'
return
'
AppSpecializeArgsImpl
args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);'
def
body
(
self
):
decl
=
''
...
...
@@ -118,7 +118,7 @@ class ForkServer(ForkAndSpec):
return
'nativeForkSystemServer'
def
init_args
(
self
):
return
'
ForkSystemServerArgs
args(uid, gid, gids, runtime_flags, permitted_capabilities, effective_capabilities);'
return
'
ServerSpecializeArgsImpl
args(uid, gid, gids, runtime_flags, permitted_capabilities, effective_capabilities);'
# Common args
uid
=
Argument
(
'uid'
,
jint
)
...
...
native/jni/zygisk/hook.cpp
View file @
f56ea529
...
...
@@ -6,7 +6,7 @@
#include <flags.h>
#include <daemon.hpp>
#include "
inject
.hpp"
#include "
zygisk
.hpp"
#include "memory.hpp"
#include "api.hpp"
...
...
@@ -29,6 +29,50 @@ enum {
FLAG_MAX
};
struct
AppSpecializeArgsImpl
{
jint
&
uid
;
jint
&
gid
;
jintArray
&
gids
;
jint
&
runtime_flags
;
jint
&
mount_external
;
jstring
&
se_info
;
jstring
&
nice_name
;
jstring
&
instruction_set
;
jstring
&
app_data_dir
;
/* Optional */
jboolean
*
is_child_zygote
=
nullptr
;
jboolean
*
is_top_app
=
nullptr
;
jobjectArray
*
pkg_data_info_list
=
nullptr
;
jobjectArray
*
whitelisted_data_info_list
=
nullptr
;
jboolean
*
mount_data_dirs
=
nullptr
;
jboolean
*
mount_storage_dirs
=
nullptr
;
AppSpecializeArgsImpl
(
jint
&
uid
,
jint
&
gid
,
jintArray
&
gids
,
jint
&
runtime_flags
,
jint
&
mount_external
,
jstring
&
se_info
,
jstring
&
nice_name
,
jstring
&
instruction_set
,
jstring
&
app_data_dir
)
:
uid
(
uid
),
gid
(
gid
),
gids
(
gids
),
runtime_flags
(
runtime_flags
),
mount_external
(
mount_external
),
se_info
(
se_info
),
nice_name
(
nice_name
),
instruction_set
(
instruction_set
),
app_data_dir
(
app_data_dir
)
{}
};
struct
ServerSpecializeArgsImpl
{
jint
&
uid
;
jint
&
gid
;
jintArray
&
gids
;
jint
&
runtime_flags
;
jlong
&
permitted_capabilities
;
jlong
&
effective_capabilities
;
ServerSpecializeArgsImpl
(
jint
&
uid
,
jint
&
gid
,
jintArray
&
gids
,
jint
&
runtime_flags
,
jlong
&
permitted_capabilities
,
jlong
&
effective_capabilities
)
:
uid
(
uid
),
gid
(
gid
),
gids
(
gids
),
runtime_flags
(
runtime_flags
),
permitted_capabilities
(
permitted_capabilities
),
effective_capabilities
(
effective_capabilities
)
{}
};
#define DCL_PRE_POST(name) \
void name##_pre(); \
void name##_post();
...
...
@@ -36,8 +80,8 @@ void name##_post();
struct
HookContext
{
JNIEnv
*
env
;
union
{
SpecializeAppProcessArgs
*
args
;
ForkSystemServerArgs
*
server_args
;
AppSpecializeArgsImpl
*
args
;
ServerSpecializeArgsImpl
*
server_args
;
void
*
raw_args
;
};
const
char
*
process
;
...
...
native/jni/zygisk/jni_hooks.hpp
View file @
f56ea529
This diff is collapsed.
Click to expand it.
native/jni/zygisk/ptrace.cpp
View file @
f56ea529
...
...
@@ -24,7 +24,7 @@
#include <utils.hpp>
#include "
inject
.hpp"
#include "
zygisk
.hpp"
#include "ptrace.hpp"
using
namespace
std
;
...
...
native/jni/zygisk/utils.cpp
View file @
f56ea529
#include <cinttypes>
#include <utils.hpp>
#include "
inject
.hpp"
#include "
zygisk
.hpp"
using
namespace
std
;
...
...
native/jni/zygisk/
inject
.hpp
→
native/jni/zygisk/
zygisk
.hpp
View file @
f56ea529
File moved
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