Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
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
open-source
jadx
Commits
c9b781d5
Unverified
Commit
c9b781d5
authored
Jan 02, 2018
by
skylot
Committed by
GitHub
Jan 02, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #119 from ITMonkeys/master
support for Android InstantRun Apk
parents
0b49abf3
e53a72c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
17 deletions
+35
-17
InputFile.java
jadx-core/src/main/java/jadx/core/utils/files/InputFile.java
+35
-17
No files found.
jadx-core/src/main/java/jadx/core/utils/files/InputFile.java
View file @
c9b781d5
...
...
@@ -10,6 +10,7 @@ import java.io.FileOutputStream;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.jar.JarOutputStream
;
import
java.util.zip.ZipEntry
;
...
...
@@ -84,36 +85,53 @@ public class InputFile {
private
boolean
loadFromZip
(
String
ext
)
throws
IOException
,
DecodeException
{
ZipFile
zf
=
new
ZipFile
(
file
);
// Input file could be .apk or .zip files
// we should consider the input file could contain only one single dex, multi-dex, or instantRun support dex for Android .apk files
String
instantRunDexSuffix
=
"classes"
+
ext
;
int
index
=
0
;
while
(
true
)
{
String
entryName
=
"classes"
+
(
index
==
0
?
""
:
index
)
+
ext
;
ZipEntry
entry
=
zf
.
getEntry
(
entryName
);
if
(
entry
==
null
)
{
break
;
}
for
(
Enumeration
<?
extends
ZipEntry
>
e
=
zf
.
entries
();
e
.
hasMoreElements
();
)
{
ZipEntry
entry
=
e
.
nextElement
();
String
entryName
=
entry
.
getName
();
InputStream
inputStream
=
zf
.
getInputStream
(
entry
);
try
{
if
(
ext
.
equals
(
".dex"
))
{
addDexFile
(
entryName
,
new
Dex
(
inputStream
));
}
else
if
(
ext
.
equals
(
".jar"
))
{
File
jarFile
=
FileUtils
.
createTempFile
(
entryName
);
if
((
entryName
.
startsWith
(
"classes"
)
&&
entryName
.
endsWith
(
ext
))
||
entryName
.
endsWith
(
instantRunDexSuffix
))
{
if
(
ext
.
equals
(
".dex"
))
{
index
++;
addDexFile
(
entryName
,
new
Dex
(
inputStream
));
}
else
if
(
ext
.
equals
(
".jar"
))
{
index
++;
File
jarFile
=
FileUtils
.
createTempFile
(
entryName
);
FileOutputStream
fos
=
new
FileOutputStream
(
jarFile
);
try
{
IOUtils
.
copy
(
inputStream
,
fos
);
}
finally
{
close
(
fos
);
}
addDexFile
(
entryName
,
loadFromJar
(
jarFile
));
}
else
{
throw
new
JadxRuntimeException
(
"Unexpected extension in zip: "
+
ext
);
}
}
else
if
(
entryName
.
equals
(
"instant-run.zip"
)
&&
ext
.
equals
(
".dex"
))
{
File
jarFile
=
FileUtils
.
createTempFile
(
"instant-run.zip"
);
FileOutputStream
fos
=
new
FileOutputStream
(
jarFile
);
try
{
IOUtils
.
copy
(
inputStream
,
fos
);
}
finally
{
close
(
fos
);
}
addDexFile
(
entryName
,
loadFromJar
(
jarFile
));
}
else
{
throw
new
JadxRuntimeException
(
"Unexpected extension in zip: "
+
ext
);
InputFile
tempFile
=
new
InputFile
(
jarFile
);
tempFile
.
loadFromZip
(
ext
);
List
<
DexFile
>
dexFiles
=
tempFile
.
getDexFiles
();
if
(!
dexFiles
.
isEmpty
())
{
index
+=
dexFiles
.
size
();
this
.
dexFiles
.
addAll
(
dexFiles
);
}
}
}
finally
{
close
(
inputStream
);
}
index
++;
if
(
index
==
1
)
{
index
=
2
;
}
}
zf
.
close
();
return
index
>
0
;
...
...
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