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
6f609f0d
Commit
6f609f0d
authored
Feb 24, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Several improvements
parent
ee2a3047
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
19 deletions
+18
-19
Android.mk
jni/bootimgtools/Android.mk
+1
-1
bootimg.h
jni/bootimgtools/bootimg.h
+1
-1
hexpatch.c
jni/bootimgtools/hexpatch.c
+3
-3
main.c
jni/bootimgtools/main.c
+7
-8
repack.c
jni/bootimgtools/repack.c
+3
-3
unpack.c
jni/bootimgtools/unpack.c
+3
-3
No files found.
jni/bootimgtools/Android.mk
View file @
6f609f0d
...
...
@@ -3,6 +3,6 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := bootimgtools
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := main.c
extract
.c repack.c hexpatch.c
LOCAL_SRC_FILES := main.c
unpack
.c repack.c hexpatch.c
LOCAL_CFLAGS += -std=gnu11
include $(BUILD_EXECUTABLE)
jni/bootimgtools/bootimg.h
View file @
6f609f0d
...
...
@@ -93,7 +93,7 @@ struct boot_img_hdr
** else: jump to kernel_addr
*/
int
extract
(
const
char
*
image
);
int
unpack
(
const
char
*
image
);
int
repack
(
const
char
*
image
);
int
hexpatch
(
char
*
image
,
char
*
from
,
char
*
to
);
...
...
jni/bootimgtools/hexpatch.c
View file @
6f609f0d
...
...
@@ -9,7 +9,7 @@
#include "bootimg.h"
int
hex2int
(
char
c
)
{
static
int
hex2int
(
char
c
)
{
int
first
=
c
/
16
-
3
;
int
second
=
c
%
16
;
int
result
=
first
*
10
+
second
;
...
...
@@ -17,13 +17,13 @@ int hex2int(char c) {
return
result
;
}
int
hex2ascii
(
char
c
,
char
d
)
{
static
int
hex2ascii
(
char
c
,
char
d
)
{
int
high
=
hex2int
(
c
)
*
16
;
int
low
=
hex2int
(
d
);
return
high
+
low
;
}
void
hexstr2str
(
char
*
hex
,
char
*
str
)
{
static
void
hexstr2str
(
char
*
hex
,
char
*
str
)
{
char
buf
=
0
;
for
(
int
i
=
0
,
length
=
strlen
(
hex
);
i
<
length
;
++
i
){
if
(
i
%
2
){
...
...
jni/bootimgtools/main.c
View file @
6f609f0d
...
...
@@ -7,22 +7,21 @@
Patch Boot Image
*********************/
int
usage
(
char
*
arg0
)
{
static
int
usage
(
char
*
arg0
)
{
fprintf
(
stderr
,
"Boot Image Unpack/Repack Tool
\n
"
);
fprintf
(
stderr
,
"%s --
extract
<bootimage>
\n
"
,
arg0
);
fprintf
(
stderr
,
"%s --
unpack
<bootimage>
\n
"
,
arg0
);
fprintf
(
stderr
,
" Unpack <bootimage> into current directory
\n\n
"
);
fprintf
(
stderr
,
"%s --repack <bootimage>
\n
"
,
arg0
);
fprintf
(
stderr
,
" Repack kernel, dt, ramdisk... from current directory to new-image.img
\n
<bootimage> is the image you've just unpacked
\n\n
"
);
fprintf
(
stderr
,
" Repack kernel, dt
b
, ramdisk... from current directory to new-image.img
\n
<bootimage> is the image you've just unpacked
\n\n
"
);
fprintf
(
stderr
,
"%s --hexpatch <bootimage> <hexpattern1> <hexpattern2>
\n
"
,
arg0
);
fprintf
(
stderr
,
" Search <hexpattern1> in <bootimage>, and replace with <hexpattern2>
\n\n
"
);
return
1
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
char
ch
;
struct
option
long_options
[]
=
{
{
"
extract"
,
required_argument
,
NULL
,
'e
'
},
{
"
unpack"
,
required_argument
,
NULL
,
'u
'
},
{
"repack"
,
required_argument
,
NULL
,
'r'
},
{
"hexpatch"
,
required_argument
,
NULL
,
'p'
},
{
NULL
,
0
,
NULL
,
0
}
...
...
@@ -30,7 +29,7 @@ int main(int argc, char *argv[])
while
((
ch
=
getopt_long
(
argc
,
argv
,
"e:r:p:"
,
long_options
,
NULL
))
!=
-
1
)
{
switch
(
ch
)
{
case
'e'
:
return
extract
(
optarg
);
return
unpack
(
optarg
);
case
'r'
:
return
repack
(
optarg
);
case
'p'
:
...
...
@@ -42,4 +41,4 @@ int main(int argc, char *argv[])
}
}
return
0
;
}
\ No newline at end of file
}
jni/bootimgtools/repack.c
View file @
6f609f0d
...
...
@@ -12,8 +12,8 @@
#include "bootimg.h"
// Global pointer of current positions
void
*
ibase
,
*
ipos
;
int
ofd
,
opos
;
static
void
*
ibase
,
*
ipos
;
static
int
ofd
,
opos
;
static
size_t
dump
(
const
char
*
filename
)
{
int
fd
=
open
(
filename
,
O_RDONLY
);
...
...
@@ -60,7 +60,7 @@ static int aosp() {
printf
(
"AOSP Boot Image Detected
\n
"
);
char
*
name
;
struct
boot_img_hdr
hdr
,
ihdr
;
boot_img_hdr
hdr
,
ihdr
;
// Read the original header
memcpy
(
&
ihdr
,
ibase
,
sizeof
(
ihdr
));
...
...
jni/bootimgtools/
extract
.c
→
jni/bootimgtools/
unpack
.c
View file @
6f609f0d
...
...
@@ -12,7 +12,7 @@
#include "bootimg.h"
// Global pointer of current positions
unsigned
char
*
base
,
*
pos
;
static
unsigned
char
*
base
,
*
pos
;
static
void
dump
(
size_t
size
,
const
char
*
filename
)
{
unlink
(
filename
);
...
...
@@ -37,7 +37,7 @@ static int aosp() {
char
name
[
PATH_MAX
],
*
ext
;
// Read the header
struct
boot_img_hdr
hdr
;
boot_img_hdr
hdr
;
memcpy
(
&
hdr
,
base
,
sizeof
(
hdr
));
pos
=
base
+
hdr
.
page_size
;
...
...
@@ -108,7 +108,7 @@ static int aosp() {
return
0
;
}
int
extract
(
const
char
*
image
)
{
int
unpack
(
const
char
*
image
)
{
int
fd
=
open
(
image
,
O_RDONLY
),
ret
=
0
;
size_t
size
=
lseek
(
fd
,
0
,
SEEK_END
);
lseek
(
fd
,
0
,
SEEK_SET
);
...
...
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