Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colcode
jadx
提交
8da0ba82
J
jadx
项目概览
colcode
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
8da0ba82
编写于
6月 16, 2013
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Save source file name, move constant strings
上级
35ee0a25
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
84 addition
and
26 deletion
+84
-26
src/main/java/jadx/Consts.java
src/main/java/jadx/Consts.java
+6
-0
src/main/java/jadx/codegen/AnnotationGen.java
src/main/java/jadx/codegen/AnnotationGen.java
+3
-3
src/main/java/jadx/codegen/ClassGen.java
src/main/java/jadx/codegen/ClassGen.java
+14
-0
src/main/java/jadx/codegen/CodeWriter.java
src/main/java/jadx/codegen/CodeWriter.java
+6
-5
src/main/java/jadx/dex/attributes/AttributeType.java
src/main/java/jadx/dex/attributes/AttributeType.java
+6
-7
src/main/java/jadx/dex/attributes/AttributesList.java
src/main/java/jadx/dex/attributes/AttributesList.java
+1
-1
src/main/java/jadx/dex/attributes/BlockRegState.java
src/main/java/jadx/dex/attributes/BlockRegState.java
+1
-1
src/main/java/jadx/dex/attributes/SourceFileAttr.java
src/main/java/jadx/dex/attributes/SourceFileAttr.java
+24
-0
src/main/java/jadx/dex/info/ClassInfo.java
src/main/java/jadx/dex/info/ClassInfo.java
+3
-3
src/main/java/jadx/dex/nodes/ClassNode.java
src/main/java/jadx/dex/nodes/ClassNode.java
+11
-1
src/main/java/jadx/dex/nodes/parser/DebugInfoParser.java
src/main/java/jadx/dex/nodes/parser/DebugInfoParser.java
+9
-5
未找到文件。
src/main/java/jadx/Consts.java
浏览文件 @
8da0ba82
...
...
@@ -15,5 +15,11 @@ public class Consts {
public
static
final
String
CLASS_STRING_BUILDER
=
"java.lang.StringBuilder"
;
public
static
final
String
DALVIK_ANNOTATION_PKG
=
"dalvik.annotation."
;
public
static
final
String
DALVIK_SIGNATURE
=
"dalvik.annotation.Signature"
;
public
static
final
String
DALVIK_INNER_CLASS
=
"dalvik.annotation.InnerClass"
;
public
static
final
String
DALVIK_THROWS
=
"dalvik.annotation.Throws"
;
public
static
final
String
DALVIK_ANNOTATION_DEFAULT
=
"dalvik.annotation.AnnotationDefault"
;
public
static
final
String
DEFAULT_PACKAGE_NAME
=
"defpackage"
;
}
src/main/java/jadx/codegen/AnnotationGen.java
浏览文件 @
8da0ba82
...
...
@@ -59,7 +59,7 @@ public class AnnotationGen {
for
(
Annotation
a
:
aList
.
getAll
())
{
String
aCls
=
a
.
getAnnotationClass
();
if
(
aCls
.
startsWith
(
"dalvik.annotation."
))
{
if
(
aCls
.
startsWith
(
Consts
.
DALVIK_ANNOTATION_PKG
))
{
// skip
if
(
Consts
.
DEBUG
)
{
code
.
startLine
(
"// "
+
a
);
...
...
@@ -97,7 +97,7 @@ public class AnnotationGen {
@SuppressWarnings
(
"unchecked"
)
public
void
addThrows
(
MethodNode
mth
,
CodeWriter
code
)
{
Annotation
an
=
mth
.
getAttributes
().
getAnnotation
(
"dalvik.annotation.Throws"
);
Annotation
an
=
mth
.
getAttributes
().
getAnnotation
(
Consts
.
DALVIK_THROWS
);
if
(
an
!=
null
)
{
Object
exs
=
an
.
getDefaultValue
();
code
.
add
(
" throws "
);
...
...
@@ -111,7 +111,7 @@ public class AnnotationGen {
}
public
Object
getAnnotationDefaultValue
(
String
name
)
{
Annotation
an
=
cls
.
getAttributes
().
getAnnotation
(
"dalvik.annotation.AnnotationDefault"
);
Annotation
an
=
cls
.
getAttributes
().
getAnnotation
(
Consts
.
DALVIK_ANNOTATION_DEFAULT
);
if
(
an
!=
null
)
{
Annotation
defAnnotation
=
(
Annotation
)
an
.
getDefaultValue
();
return
defAnnotation
.
getValues
().
get
(
name
);
...
...
src/main/java/jadx/codegen/ClassGen.java
浏览文件 @
8da0ba82
package
jadx.codegen
;
import
jadx.Consts
;
import
jadx.dex.attributes.AttrNode
;
import
jadx.dex.attributes.AttributeFlag
;
import
jadx.dex.attributes.AttributeType
;
import
jadx.dex.attributes.EnumClassAttr
;
import
jadx.dex.attributes.EnumClassAttr.EnumField
;
import
jadx.dex.attributes.IAttribute
;
import
jadx.dex.attributes.SourceFileAttr
;
import
jadx.dex.info.AccessInfo
;
import
jadx.dex.info.ClassInfo
;
import
jadx.dex.instructions.args.ArgType
;
...
...
@@ -169,6 +172,8 @@ public class ClassGen {
public
void
makeClassBody
(
CodeWriter
clsCode
)
throws
CodegenException
{
clsCode
.
add
(
'{'
);
insertSourceFileInfo
(
clsCode
,
cls
);
CodeWriter
mthsCode
=
makeMethods
(
clsCode
,
cls
.
getMethods
());
CodeWriter
fieldsCode
=
makeFields
(
clsCode
,
cls
,
cls
.
getFields
());
clsCode
.
add
(
fieldsCode
);
...
...
@@ -224,6 +229,7 @@ public class ClassGen {
MethodGen
mthGen
=
new
MethodGen
(
this
,
mth
);
mthGen
.
addDefinition
(
code
);
code
.
add
(
" {"
);
insertSourceFileInfo
(
code
,
mth
);
code
.
add
(
mthGen
.
makeInstructions
(
code
.
getIndent
()));
code
.
startLine
(
'}'
);
}
...
...
@@ -363,6 +369,14 @@ public class ClassGen {
return
false
;
}
private
void
insertSourceFileInfo
(
CodeWriter
code
,
AttrNode
node
)
{
IAttribute
sourceFileAttr
=
node
.
getAttributes
().
get
(
AttributeType
.
SOURCE_FILE
);
if
(
sourceFileAttr
!=
null
)
{
code
.
startLine
(
1
,
"// compiled from: "
);
code
.
add
(((
SourceFileAttr
)
sourceFileAttr
).
getFileName
());
}
}
public
Set
<
ClassInfo
>
getImports
()
{
return
imports
;
}
...
...
src/main/java/jadx/codegen/CodeWriter.java
浏览文件 @
8da0ba82
...
...
@@ -78,7 +78,7 @@ public class CodeWriter {
return
this
;
}
private
static
final
String
[]
indentCache
=
new
String
[]
{
private
static
final
String
[]
INDENT_CACHE
=
new
String
[]
{
""
,
INDENT
,
INDENT
+
INDENT
,
...
...
@@ -88,11 +88,12 @@ public class CodeWriter {
};
private
void
updateIndent
()
{
if
(
indent
<
6
)
{
this
.
indentStr
=
indentCache
[
indent
];
int
curIndent
=
indent
;
if
(
curIndent
<
6
)
{
this
.
indentStr
=
INDENT_CACHE
[
curIndent
];
}
else
{
StringBuilder
s
=
new
StringBuilder
(
i
ndent
*
INDENT
.
length
());
for
(
int
i
=
0
;
i
<
i
ndent
;
i
++)
{
StringBuilder
s
=
new
StringBuilder
(
curI
ndent
*
INDENT
.
length
());
for
(
int
i
=
0
;
i
<
curI
ndent
;
i
++)
{
s
.
append
(
INDENT
);
}
this
.
indentStr
=
s
.
toString
();
...
...
src/main/java/jadx/dex/attributes/AttributeType.java
浏览文件 @
8da0ba82
package
jadx.dex.attributes
;
public
enum
AttributeType
{
// TODO? add attribute target (insn, block, method, field, class)
// instructions
/* Multi attributes */
JUMP
(
false
),
// blocks
LOOP
(
false
),
CATCH_BLOCK
(
false
),
/* Uniq attributes */
EXC_HANDLER
(
true
),
SPLITTER_BLOCK
(
true
),
FORCE_RETURN
(
true
),
// fields
FIELD_VALUE
(
true
),
// methods
JADX_ERROR
(
true
),
METHOD_INLINE
(
true
),
// classes
ENUM_CLASS
(
true
),
// any
ANNOTATION_LIST
(
true
),
ANNOTATION_MTH_PARAMETERS
(
true
),
SOURCE_FILE
(
true
),
DECLARE_VARIABLE
(
true
);
private
static
final
int
notUniqCount
;
...
...
src/main/java/jadx/dex/attributes/AttributesList.java
浏览文件 @
8da0ba82
...
...
@@ -20,7 +20,7 @@ import java.util.Set;
* 2. attribute - class instance associated for attribute type,
* only one attached to node for unique attributes, multiple for others
*/
public
class
AttributesList
{
public
final
class
AttributesList
{
private
final
Set
<
AttributeFlag
>
flags
;
private
final
Map
<
AttributeType
,
IAttribute
>
uniqAttr
;
...
...
src/main/java/jadx/dex/attributes/BlockRegState.java
浏览文件 @
8da0ba82
...
...
@@ -4,7 +4,7 @@ import jadx.dex.instructions.args.RegisterArg;
import
jadx.dex.instructions.args.TypedVar
;
import
jadx.dex.nodes.MethodNode
;
public
class
BlockRegState
{
public
final
class
BlockRegState
{
private
final
RegisterArg
[]
regs
;
...
...
src/main/java/jadx/dex/attributes/SourceFileAttr.java
0 → 100644
浏览文件 @
8da0ba82
package
jadx.dex.attributes
;
public
class
SourceFileAttr
implements
IAttribute
{
private
final
String
fileName
;
public
SourceFileAttr
(
String
fileName
)
{
this
.
fileName
=
fileName
;
}
public
String
getFileName
()
{
return
fileName
;
}
@Override
public
AttributeType
getType
()
{
return
AttributeType
.
SOURCE_FILE
;
}
@Override
public
String
toString
()
{
return
"SOURCE:"
+
fileName
;
}
}
src/main/java/jadx/dex/info/ClassInfo.java
浏览文件 @
8da0ba82
package
jadx.dex.info
;
import
jadx.Consts
;
import
jadx.deobf.NameMapper
;
import
jadx.dex.instructions.args.ArgType
;
import
jadx.dex.nodes.DexNode
;
...
...
@@ -11,7 +12,6 @@ import java.util.WeakHashMap;
public
final
class
ClassInfo
{
private
static
final
Map
<
ArgType
,
ClassInfo
>
CLASSINFO_CACHE
=
new
WeakHashMap
<
ArgType
,
ClassInfo
>();
private
static
final
String
DEFAULT_PACKAGE_NAME
=
"defpackage"
;
public
static
ClassInfo
fromDex
(
DexNode
dex
,
int
clsIndex
)
{
if
(
clsIndex
==
DexNode
.
NO_INDEX
)
...
...
@@ -62,7 +62,7 @@ public final class ClassInfo {
int
dot
=
fullObjectName
.
lastIndexOf
(
'.'
);
if
(
dot
==
-
1
)
{
// rename default package if it used from class with package (often for obfuscated apps),
pkg
=
DEFAULT_PACKAGE_NAME
;
pkg
=
Consts
.
DEFAULT_PACKAGE_NAME
;
name
=
fullObjectName
;
}
else
{
pkg
=
fullObjectName
.
substring
(
0
,
dot
);
...
...
@@ -110,7 +110,7 @@ public final class ClassInfo {
}
public
boolean
isPackageDefault
()
{
return
pkg
.
isEmpty
()
||
pkg
.
equals
(
DEFAULT_PACKAGE_NAME
);
return
pkg
.
isEmpty
()
||
pkg
.
equals
(
Consts
.
DEFAULT_PACKAGE_NAME
);
}
public
String
getNameWithoutPackage
()
{
...
...
src/main/java/jadx/dex/nodes/ClassNode.java
浏览文件 @
8da0ba82
...
...
@@ -3,6 +3,7 @@ package jadx.dex.nodes;
import
jadx.Consts
;
import
jadx.dex.attributes.AttrNode
;
import
jadx.dex.attributes.AttributeType
;
import
jadx.dex.attributes.SourceFileAttr
;
import
jadx.dex.attributes.annotations.Annotation
;
import
jadx.dex.info.AccessInfo
;
import
jadx.dex.info.AccessInfo.AFType
;
...
...
@@ -85,8 +86,17 @@ public class ClassNode extends AttrNode implements ILoadable {
parseClassSignature
();
setFieldsTypesFromSignature
();
int
sfIdx
=
cls
.
getSourceFileIndex
();
if
(
sfIdx
!=
DexNode
.
NO_INDEX
)
{
String
fileName
=
dex
.
getString
(
sfIdx
);
if
(!
this
.
getFullName
().
contains
(
fileName
.
replace
(
".java"
,
""
)))
{
this
.
getAttributes
().
add
(
new
SourceFileAttr
(
fileName
));
LOG
.
info
(
"TODO: move class {} to {} file"
,
this
,
fileName
);
}
}
int
accFlagsValue
;
Annotation
a
=
getAttributes
().
getAnnotation
(
"dalvik.annotation.InnerClass"
);
Annotation
a
=
getAttributes
().
getAnnotation
(
Consts
.
DALVIK_INNER_CLASS
);
if
(
a
!=
null
)
accFlagsValue
=
(
Integer
)
a
.
getValues
().
get
(
"accessFlags"
);
else
...
...
src/main/java/jadx/dex/nodes/parser/DebugInfoParser.java
浏览文件 @
8da0ba82
package
jadx.dex.nodes.parser
;
import
jadx.dex.attributes.SourceFileAttr
;
import
jadx.dex.info.LocalVarInfo
;
import
jadx.dex.instructions.args.InsnArg
;
import
jadx.dex.instructions.args.RegisterArg
;
...
...
@@ -50,7 +51,6 @@ public class DebugInfoParser {
public
void
process
()
throws
DecodeException
{
int
addr
=
0
;
int
line
;
// String source_file;
line
=
section
.
readUleb128
();
int
param_size
=
section
.
readUleb128
();
// exclude 'this'
...
...
@@ -124,14 +124,18 @@ public class DebugInfoParser {
}
case
DBG_SET_PROLOGUE_END:
break
;
case
DBG_SET_EPILOGUE_BEGIN:
// do nothing
break
;
case
DBG_SET_FILE:
section
.
readUleb128
();
// source_file = dex.getString(idx);
case
DBG_SET_FILE:
{
int
idx
=
section
.
readUleb128
()
-
1
;
if
(
idx
!=
DexNode
.
NO_INDEX
)
{
String
sourceFile
=
dex
.
getString
(
idx
);
mth
.
getAttributes
().
add
(
new
SourceFileAttr
(
sourceFile
));
}
break
;
}
default
:
{
if
(
c
>=
DBG_FIRST_SPECIAL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录