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
8eef4a90
Commit
8eef4a90
authored
Oct 24, 2018
by
sergey-wowwow
Committed by
skylot
Oct 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: saves all resources (#375)
parent
87f50ab5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
20 deletions
+44
-20
ResourceType.java
jadx-core/src/main/java/jadx/api/ResourceType.java
+0
-17
ResourcesLoader.java
jadx-core/src/main/java/jadx/api/ResourcesLoader.java
+6
-0
ResContainer.java
jadx-core/src/main/java/jadx/core/xmlgen/ResContainer.java
+20
-0
ResourcesSaver.java
jadx-core/src/main/java/jadx/core/xmlgen/ResourcesSaver.java
+18
-3
No files found.
jadx-core/src/main/java/jadx/api/ResourceType.java
View file @
8eef4a90
...
@@ -30,21 +30,4 @@ public enum ResourceType {
...
@@ -30,21 +30,4 @@ public enum ResourceType {
}
}
return
UNKNOWN
;
return
UNKNOWN
;
}
}
public
static
boolean
isSupportedForUnpack
(
ResourceType
type
)
{
switch
(
type
)
{
case
CODE:
case
LIB:
case
FONT:
case
UNKNOWN:
return
false
;
case
MANIFEST:
case
XML:
case
ARSC:
case
IMG:
return
true
;
}
return
false
;
}
}
}
jadx-core/src/main/java/jadx/api/ResourcesLoader.java
View file @
8eef4a90
...
@@ -105,6 +105,12 @@ public final class ResourcesLoader {
...
@@ -105,6 +105,12 @@ public final class ResourcesLoader {
case
IMG:
case
IMG:
return
ResContainer
.
singleImageFile
(
rf
.
getName
(),
inputStream
);
return
ResContainer
.
singleImageFile
(
rf
.
getName
(),
inputStream
);
case
CODE:
case
LIB:
case
FONT:
case
UNKNOWN:
return
ResContainer
.
singleBinaryFile
(
rf
.
getName
(),
inputStream
);
default
:
default
:
if
(
size
>
LOAD_SIZE_LIMIT
)
{
if
(
size
>
LOAD_SIZE_LIMIT
)
{
return
ResContainer
.
singleFile
(
rf
.
getName
(),
return
ResContainer
.
singleFile
(
rf
.
getName
(),
...
...
jadx-core/src/main/java/jadx/core/xmlgen/ResContainer.java
View file @
8eef4a90
...
@@ -5,11 +5,13 @@ import java.awt.image.BufferedImage;
...
@@ -5,11 +5,13 @@ import java.awt.image.BufferedImage;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
org.apache.commons.io.IOUtils
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.annotations.Nullable
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -30,6 +32,8 @@ public class ResContainer implements Comparable<ResContainer> {
...
@@ -30,6 +32,8 @@ public class ResContainer implements Comparable<ResContainer> {
private
CodeWriter
content
;
private
CodeWriter
content
;
@Nullable
@Nullable
private
BufferedImage
image
;
private
BufferedImage
image
;
@Nullable
private
InputStream
binary
;
private
ResContainer
(
String
name
,
List
<
ResContainer
>
subFiles
)
{
private
ResContainer
(
String
name
,
List
<
ResContainer
>
subFiles
)
{
this
.
name
=
name
;
this
.
name
=
name
;
...
@@ -63,6 +67,17 @@ public class ResContainer implements Comparable<ResContainer> {
...
@@ -63,6 +67,17 @@ public class ResContainer implements Comparable<ResContainer> {
return
resContainer
;
return
resContainer
;
}
}
public
static
ResContainer
singleBinaryFile
(
String
name
,
InputStream
content
)
{
ResContainer
resContainer
=
new
ResContainer
(
name
,
Collections
.
emptyList
());
try
{
resContainer
.
binary
=
new
ByteArrayInputStream
(
IOUtils
.
toByteArray
(
content
));
}
catch
(
IOException
e
)
{
LOG
.
warn
(
"Contents of the binary resource '{}' not saved, got exception {}"
,
name
,
e
);
}
return
resContainer
;
}
public
static
ResContainer
multiFile
(
String
name
)
{
public
static
ResContainer
multiFile
(
String
name
)
{
return
new
ResContainer
(
name
,
new
ArrayList
<>());
return
new
ResContainer
(
name
,
new
ArrayList
<>());
}
}
...
@@ -80,6 +95,11 @@ public class ResContainer implements Comparable<ResContainer> {
...
@@ -80,6 +95,11 @@ public class ResContainer implements Comparable<ResContainer> {
return
content
;
return
content
;
}
}
@Nullable
public
InputStream
getBinary
()
{
return
binary
;
}
public
void
setContent
(
@Nullable
CodeWriter
content
)
{
public
void
setContent
(
@Nullable
CodeWriter
content
)
{
this
.
content
=
content
;
this
.
content
=
content
;
}
}
...
...
jadx-core/src/main/java/jadx/core/xmlgen/ResourcesSaver.java
View file @
8eef4a90
...
@@ -3,10 +3,14 @@ package jadx.core.xmlgen;
...
@@ -3,10 +3,14 @@ package jadx.core.xmlgen;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.List
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.mockito.internal.util.io.IOUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -30,9 +34,6 @@ public class ResourcesSaver implements Runnable {
...
@@ -30,9 +34,6 @@ public class ResourcesSaver implements Runnable {
@Override
@Override
public
void
run
()
{
public
void
run
()
{
if
(!
ResourceType
.
isSupportedForUnpack
(
resourceFile
.
getType
()))
{
return
;
}
ResContainer
rc
=
resourceFile
.
loadContent
();
ResContainer
rc
=
resourceFile
.
loadContent
();
if
(
rc
!=
null
)
{
if
(
rc
!=
null
)
{
saveResources
(
rc
);
saveResources
(
rc
);
...
@@ -89,6 +90,20 @@ public class ResourcesSaver implements Runnable {
...
@@ -89,6 +90,20 @@ public class ResourcesSaver implements Runnable {
cw
.
save
(
outFile
);
cw
.
save
(
outFile
);
return
;
return
;
}
}
InputStream
binary
=
rc
.
getBinary
();
if
(
binary
!=
null
)
{
try
{
outFile
.
getParentFile
().
mkdirs
();
FileOutputStream
binaryFileStream
=
new
FileOutputStream
(
outFile
);
IOUtils
.
copy
(
binary
,
binaryFileStream
);
binaryFileStream
.
close
();
binary
.
close
();
}
catch
(
IOException
e
)
{
LOG
.
warn
(
"Resource '{}' not saved, got exception {}"
,
rc
.
getName
(),
e
);
}
return
;
}
LOG
.
warn
(
"Resource '{}' not saved, unknown type"
,
rc
.
getName
());
LOG
.
warn
(
"Resource '{}' not saved, unknown type"
,
rc
.
getName
());
}
}
}
}
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