Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_39073359
jadx
提交
86a4ed7f
J
jadx
项目概览
qq_39073359
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
86a4ed7f
编写于
5月 10, 2019
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: store all temp files in one temp dir, use NIO api instead commons-io
上级
19c57258
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
55 addition
and
45 deletion
+55
-45
jadx-core/build.gradle
jadx-core/build.gradle
+3
-7
jadx-core/src/main/java/jadx/core/clsp/ClsSet.java
jadx-core/src/main/java/jadx/core/clsp/ClsSet.java
+1
-1
jadx-core/src/main/java/jadx/core/utils/android/Res9patchStreamDecoder.java
.../java/jadx/core/utils/android/Res9patchStreamDecoder.java
+2
-2
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
+31
-3
jadx-core/src/main/java/jadx/core/utils/files/InputFile.java
jadx-core/src/main/java/jadx/core/utils/files/InputFile.java
+1
-5
jadx-core/src/main/java/jadx/core/utils/files/JavaToDex.java
jadx-core/src/main/java/jadx/core/utils/files/JavaToDex.java
+1
-1
jadx-core/src/main/java/jadx/core/xmlgen/ResourcesSaver.java
jadx-core/src/main/java/jadx/core/xmlgen/ResourcesSaver.java
+3
-4
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
+13
-22
未找到文件。
jadx-core/build.gradle
浏览文件 @
86a4ed7f
...
...
@@ -4,20 +4,16 @@ dependencies {
runtime
files
(
jadxClasspath
)
compile
files
(
'lib/dx-1.16.jar'
)
compile
'commons-io:commons-io:2.6'
compile
'org.ow2.asm:asm:7.1'
compile
'org.jetbrains:annotations:17.0.0'
compile
'uk.com.robust-it:cloning:1.9.12'
compile
'org.smali:baksmali:2.2.7'
compile
(
'org.smali:smali:2.2.7'
)
{
exclude
group:
'com.google.guava'
}
compile
'com.google.guava:guava:27.1-jre'
compile
'org.smali:baksmali:2.2.7'
testCompile
'org.apache.commons:commons-lang3:3.8.1'
// update dependency in smali
testCompile
'com.google.guava:guava:27.1-jre'
testCompile
'com.beust:jcommander:1.74'
}
jadx-core/src/main/java/jadx/core/clsp/ClsSet.java
浏览文件 @
86a4ed7f
...
...
@@ -160,7 +160,7 @@ public class ClsSet {
}
void
save
(
Path
path
)
throws
IOException
{
File
s
.
createDirectories
(
path
.
getParent
()
);
File
Utils
.
makeDirsForFile
(
path
);
String
outputName
=
path
.
getFileName
().
toString
();
if
(
outputName
.
endsWith
(
CLST_EXTENSION
))
{
try
(
BufferedOutputStream
outputStream
=
new
BufferedOutputStream
(
Files
.
newOutputStream
(
path
)))
{
...
...
jadx-core/src/main/java/jadx/core/utils/android/Res9patchStreamDecoder.java
浏览文件 @
86a4ed7f
...
...
@@ -25,7 +25,7 @@ import java.io.OutputStream;
import
javax.imageio.ImageIO
;
import
org.apache.commons.io.IOUtil
s
;
import
com.google.common.io.ByteStream
s
;
import
jadx.core.utils.exceptions.JadxException
;
...
...
@@ -36,7 +36,7 @@ public class Res9patchStreamDecoder {
public
void
decode
(
InputStream
in
,
OutputStream
out
)
throws
JadxException
{
try
{
byte
[]
data
=
IOUtil
s
.
toByteArray
(
in
);
byte
[]
data
=
ByteStream
s
.
toByteArray
(
in
);
BufferedImage
im
=
ImageIO
.
read
(
new
ByteArrayInputStream
(
data
));
int
w
=
im
.
getWidth
();
...
...
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
浏览文件 @
86a4ed7f
...
...
@@ -45,6 +45,12 @@ public class FileUtils {
}
}
public
static
void
makeDirsForFile
(
Path
path
)
{
if
(
path
!=
null
)
{
makeDirs
(
path
.
getParent
().
toFile
());
}
}
public
static
void
makeDirsForFile
(
File
file
)
{
if
(
file
!=
null
)
{
makeDirs
(
file
.
getParentFile
());
...
...
@@ -63,13 +69,35 @@ public class FileUtils {
}
}
private
static
final
Path
TEMP_ROOT_DIR
=
createTempRootDir
();
private
static
Path
createTempRootDir
()
{
try
{
Path
dir
=
Files
.
createTempDirectory
(
"jadx-instance-"
);
dir
.
toFile
().
deleteOnExit
();
return
dir
;
}
catch
(
Exception
e
)
{
throw
new
JadxRuntimeException
(
"Failed to create temp root directory"
,
e
);
}
}
public
static
Path
createTempDir
(
String
prefix
)
{
try
{
Path
dir
=
Files
.
createTempDirectory
(
TEMP_ROOT_DIR
,
prefix
);
dir
.
toFile
().
deleteOnExit
();
return
dir
;
}
catch
(
Exception
e
)
{
throw
new
JadxRuntimeException
(
"Failed to create temp directory with suffix: "
+
prefix
,
e
);
}
}
public
static
Path
createTempFile
(
String
suffix
)
{
try
{
Path
path
=
Files
.
createTempFile
(
"jadx-tmp-"
,
suffix
);
Path
path
=
Files
.
createTempFile
(
TEMP_ROOT_DIR
,
"jadx-tmp-"
,
suffix
);
path
.
toFile
().
deleteOnExit
();
return
path
;
}
catch
(
IO
Exception
e
)
{
throw
new
JadxRuntimeException
(
"Failed to create temp file with suffix: "
+
suffix
);
}
catch
(
Exception
e
)
{
throw
new
JadxRuntimeException
(
"Failed to create temp file with suffix: "
+
suffix
,
e
);
}
}
...
...
jadx-core/src/main/java/jadx/core/utils/files/InputFile.java
浏览文件 @
86a4ed7f
...
...
@@ -3,7 +3,6 @@ package jadx.core.utils.files;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.StandardCopyOption
;
...
...
@@ -14,7 +13,6 @@ import java.util.jar.JarOutputStream;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipFile
;
import
org.apache.commons.io.IOUtils
;
import
org.jetbrains.annotations.Nullable
;
import
org.jf.smali.Smali
;
import
org.jf.smali.SmaliOptions
;
...
...
@@ -150,9 +148,7 @@ public class InputFile {
}
}
else
if
(
entryName
.
equals
(
"instant-run.zip"
)
&&
ext
.
equals
(
".dex"
))
{
Path
jarFile
=
FileUtils
.
createTempFile
(
"instant-run.zip"
);
try
(
OutputStream
fos
=
Files
.
newOutputStream
(
jarFile
))
{
IOUtils
.
copy
(
inputStream
,
fos
);
}
Files
.
copy
(
inputStream
,
jarFile
,
StandardCopyOption
.
REPLACE_EXISTING
);
InputFile
tempFile
=
new
InputFile
(
jarFile
.
toFile
());
tempFile
.
loadFromZip
(
ext
);
List
<
DexFile
>
dexFiles
=
tempFile
.
getDexFiles
();
...
...
jadx-core/src/main/java/jadx/core/utils/files/JavaToDex.java
浏览文件 @
86a4ed7f
...
...
@@ -41,7 +41,7 @@ public class JavaToDex {
try
(
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
errOut
=
new
ByteArrayOutputStream
())
{
DxContext
context
=
new
DxContext
(
out
,
errOut
);
Path
dir
=
File
s
.
createTempDirectory
(
"jadx"
);
Path
dir
=
File
Utils
.
createTempDir
(
jar
.
getFileName
().
toString
()
);
DxArgs
args
=
new
DxArgs
(
context
,
dir
.
toAbsolutePath
().
toString
(),
...
...
jadx-core/src/main/java/jadx/core/xmlgen/ResourcesSaver.java
浏览文件 @
86a4ed7f
package
jadx.core.xmlgen
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.nio.file.Files
;
import
java.nio.file.StandardCopyOption
;
import
org.apache.commons.io.IOUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -91,8 +90,8 @@ public class ResourcesSaver implements Runnable {
private
void
saveResourceFile
(
ResourceFile
resFile
,
File
outFile
)
throws
JadxException
{
ResourcesLoader
.
decodeStream
(
resFile
,
(
size
,
is
)
->
{
try
(
FileOutputStream
fileStream
=
new
FileOutputStream
(
outFile
))
{
IOUtils
.
copy
(
is
,
fileStream
);
try
{
Files
.
copy
(
is
,
outFile
.
toPath
(),
StandardCopyOption
.
REPLACE_EXISTING
);
}
catch
(
Exception
e
)
{
throw
new
JadxRuntimeException
(
"Resource file save error"
,
e
);
}
...
...
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
浏览文件 @
86a4ed7f
...
...
@@ -6,6 +6,8 @@ import java.io.IOException;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Modifier
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -34,6 +36,7 @@ import jadx.core.dex.nodes.MethodNode;
import
jadx.core.dex.nodes.RootNode
;
import
jadx.core.dex.visitors.DepthTraversal
;
import
jadx.core.dex.visitors.IDexTreeVisitor
;
import
jadx.core.utils.files.FileUtils
;
import
jadx.core.xmlgen.ResourceStorage
;
import
jadx.core.xmlgen.entry.ResourceEntry
;
import
jadx.tests.api.compiler.DynamicCompiler
;
...
...
@@ -361,30 +364,19 @@ public abstract class IntegrationTest extends TestUtils {
}
protected
File
createTempFile
(
String
suffix
)
{
File
temp
=
null
;
try
{
temp
=
File
.
createTempFile
(
"jadx-tmp-"
,
System
.
nanoTime
()
+
suffix
)
;
Path
temp
;
if
(
deleteTmpFiles
)
{
temp
.
deleteOnExit
(
);
temp
=
FileUtils
.
createTempFile
(
suffix
);
}
else
{
System
.
out
.
println
(
"Temporary file path: "
+
temp
.
getAbsolutePath
());
}
}
catch
(
IOException
e
)
{
fail
(
e
.
getMessage
());
}
return
temp
;
}
private
static
File
createTempDir
(
String
prefix
)
throws
IOException
{
File
baseDir
=
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
));
String
baseName
=
prefix
+
'-'
+
System
.
nanoTime
();
for
(
int
counter
=
1
;
counter
<
1000
;
counter
++)
{
File
tempDir
=
new
File
(
baseDir
,
baseName
+
counter
);
if
(
tempDir
.
mkdir
())
{
return
tempDir
;
// don't delete on exit
temp
=
Files
.
createTempFile
(
"jadx"
,
suffix
);
System
.
out
.
println
(
"Temporary file saved: "
+
temp
.
toAbsolutePath
());
}
return
temp
.
toFile
();
}
catch
(
Exception
e
)
{
throw
new
AssertionError
(
e
.
getMessage
());
}
throw
new
IOException
(
"Failed to create temp directory"
);
}
private
List
<
File
>
compileClass
(
Class
<?>
cls
)
throws
IOException
{
...
...
@@ -404,9 +396,8 @@ public abstract class IntegrationTest extends TestUtils {
assertThat
(
"Test source file not found: "
+
javaFileName
,
file
.
exists
(),
is
(
true
));
List
<
File
>
compileFileList
=
Collections
.
singletonList
(
file
);
File
outTmp
=
createTempDir
(
"jadx-tmp-classes"
);
outTmp
.
deleteOnExit
();
List
<
File
>
files
=
StaticCompiler
.
compile
(
compileFileList
,
outTmp
,
withDebugInfo
,
useEclipseCompiler
);
Path
outTmp
=
FileUtils
.
createTempDir
(
"jadx-tmp-classes"
);
List
<
File
>
files
=
StaticCompiler
.
compile
(
compileFileList
,
outTmp
.
toFile
(),
withDebugInfo
,
useEclipseCompiler
);
files
.
forEach
(
File:
:
deleteOnExit
);
// remove classes which are parents for test class
String
clsName
=
clsFullName
.
substring
(
clsFullName
.
lastIndexOf
(
'.'
)
+
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录