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
2d82ad93
Commit
2d82ad93
authored
Nov 30, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Macro -> template
parent
384c257a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
11 deletions
+19
-11
bootimg.cpp
native/jni/magiskboot/bootimg.cpp
+3
-3
bootimg.hpp
native/jni/magiskboot/bootimg.hpp
+1
-1
cpio.cpp
native/jni/magiskboot/cpio.cpp
+2
-2
dtb.cpp
native/jni/magiskboot/dtb.cpp
+2
-2
files.hpp
native/jni/utils/files.hpp
+10
-2
memory.cpp
native/jni/zygisk/memory.cpp
+1
-1
No files found.
native/jni/magiskboot/bootimg.cpp
View file @
2d82ad93
...
@@ -291,11 +291,11 @@ dyn_img_hdr *boot_img::create_hdr(uint8_t *addr, format_t type) {
...
@@ -291,11 +291,11 @@ dyn_img_hdr *boot_img::create_hdr(uint8_t *addr, format_t type) {
#define get_block(name) \
#define get_block(name) \
name = hdr_addr + off; \
name = hdr_addr + off; \
off += hdr->name##_size(); \
off += hdr->name##_size(); \
off =
do_align
(off, hdr->page_size());
off =
align_to
(off, hdr->page_size());
#define get_ignore(name) \
#define get_ignore(name) \
if (hdr->name##_size()) { \
if (hdr->name##_size()) { \
auto blk_sz =
do_align
(hdr->name##_size(), hdr->page_size()); \
auto blk_sz =
align_to
(hdr->name##_size(), hdr->page_size()); \
ignore_size += blk_sz; \
ignore_size += blk_sz; \
off += blk_sz; \
off += blk_sz; \
}
}
...
@@ -505,7 +505,7 @@ int unpack(const char *image, bool skip_decomp, bool hdr) {
...
@@ -505,7 +505,7 @@ int unpack(const char *image, bool skip_decomp, bool hdr) {
}
}
#define file_align_with(page_size) \
#define file_align_with(page_size) \
write_zero(fd, align_
off
(lseek(fd, 0, SEEK_CUR) - off.header, page_size))
write_zero(fd, align_
padding
(lseek(fd, 0, SEEK_CUR) - off.header, page_size))
#define file_align() file_align_with(boot.hdr->page_size())
#define file_align() file_align_with(boot.hdr->page_size())
...
...
native/jni/magiskboot/bootimg.hpp
View file @
2d82ad93
...
@@ -523,7 +523,7 @@ struct dyn_img_vnd_v3 : public dyn_img_hdr_vendor {
...
@@ -523,7 +523,7 @@ struct dyn_img_vnd_v3 : public dyn_img_hdr_vendor {
impl_val
(
header_size
)
impl_val
(
header_size
)
impl_val
(
dtb_size
)
impl_val
(
dtb_size
)
size_t
hdr_space
()
override
{
auto
sz
=
page_size
();
return
do_align
(
hdr_size
(),
sz
);
}
size_t
hdr_space
()
override
{
return
align_to
(
hdr_size
(),
page_size
()
);
}
// Make API compatible
// Make API compatible
char
*
extra_cmdline
()
override
{
return
&
v4_vnd
->
cmdline
[
BOOT_ARGS_SIZE
];
}
char
*
extra_cmdline
()
override
{
return
&
v4_vnd
->
cmdline
[
BOOT_ARGS_SIZE
];
}
...
...
native/jni/magiskboot/cpio.cpp
View file @
2d82ad93
...
@@ -111,7 +111,7 @@ bool cpio::exists(const char *name) {
...
@@ -111,7 +111,7 @@ bool cpio::exists(const char *name) {
}
}
#define do_out(buf, len) pos += fwrite(buf, 1, len, out);
#define do_out(buf, len) pos += fwrite(buf, 1, len, out);
#define out_align() do_out(zeros, align_
off
(pos, 4))
#define out_align() do_out(zeros, align_
padding
(pos, 4))
void
cpio
::
dump
(
FILE
*
out
)
{
void
cpio
::
dump
(
FILE
*
out
)
{
size_t
pos
=
0
;
size_t
pos
=
0
;
unsigned
inode
=
300000
;
unsigned
inode
=
300000
;
...
@@ -211,7 +211,7 @@ bool cpio::mv(const char *from, const char *to) {
...
@@ -211,7 +211,7 @@ bool cpio::mv(const char *from, const char *to) {
return
false
;
return
false
;
}
}
#define pos_align(p) p =
do_align
(p, 4)
#define pos_align(p) p =
align_to
(p, 4)
void
cpio
::
load_cpio
(
const
char
*
buf
,
size_t
sz
)
{
void
cpio
::
load_cpio
(
const
char
*
buf
,
size_t
sz
)
{
size_t
pos
=
0
;
size_t
pos
=
0
;
...
...
native/jni/magiskboot/dtb.cpp
View file @
2d82ad93
...
@@ -297,8 +297,8 @@ static bool dt_table_patch(const Header *hdr, const char *out) {
...
@@ -297,8 +297,8 @@ static bool dt_table_patch(const Header *hdr, const char *out) {
auto
size
=
fdt_totalsize
(
fdt
);
auto
size
=
fdt_totalsize
(
fdt
);
total_size
+=
xwrite
(
fd
,
fdt
,
size
);
total_size
+=
xwrite
(
fd
,
fdt
,
size
);
if
constexpr
(
!
is_aosp
)
{
if
constexpr
(
!
is_aosp
)
{
val
.
second
.
len
=
do_align
(
size
,
align
);
val
.
second
.
len
=
align_to
(
size
,
align
);
write_zero
(
fd
,
align_
off
(
lseek
(
fd
,
0
,
SEEK_CUR
),
align
));
write_zero
(
fd
,
align_
padding
(
lseek
(
fd
,
0
,
SEEK_CUR
),
align
));
}
}
free
(
fdt
);
free
(
fdt
);
}
}
...
...
native/jni/utils/files.hpp
View file @
2d82ad93
...
@@ -10,8 +10,16 @@
...
@@ -10,8 +10,16 @@
#include "xwrap.hpp"
#include "xwrap.hpp"
#define do_align(p, a) (((p) + (a) - 1) / (a) * (a))
template
<
typename
T
>
#define align_off(p, a) (do_align(p, a) - (p))
static
inline
T
align_to
(
T
v
,
int
a
)
{
static_assert
(
std
::
is_integral
<
T
>::
value
);
return
(
v
+
a
-
1
)
/
a
*
a
;
}
template
<
typename
T
>
static
inline
T
align_padding
(
T
v
,
int
a
)
{
return
align_to
(
v
,
a
)
-
v
;
}
struct
file_attr
{
struct
file_attr
{
struct
stat
st
;
struct
stat
st
;
...
...
native/jni/zygisk/memory.cpp
View file @
2d82ad93
...
@@ -20,7 +20,7 @@ void *memory_block::allocate(size_t sz) {
...
@@ -20,7 +20,7 @@ void *memory_block::allocate(size_t sz) {
nullptr
,
CAPACITY
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
|
MAP_ANONYMOUS
,
-
1
,
0
));
nullptr
,
CAPACITY
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
|
MAP_ANONYMOUS
,
-
1
,
0
));
_curr
=
_area
;
_curr
=
_area
;
}
}
return
_curr
.
fetch_add
(
do_align
(
sz
,
ALIGN
));
return
_curr
.
fetch_add
(
align_to
(
sz
,
ALIGN
));
}
}
void
memory_block
::
release
()
{
void
memory_block
::
release
()
{
...
...
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