Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colcode
jadx
提交
25b2c8fe
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,发现更多精彩内容 >>
提交
25b2c8fe
编写于
7月 23, 2013
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: store line info, add fields and methods to api, refactoring
上级
36da79fe
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
315 addition
and
61 deletion
+315
-61
jadx-core/src/main/java/jadx/api/Decompiler.java
jadx-core/src/main/java/jadx/api/Decompiler.java
+2
-2
jadx-core/src/main/java/jadx/api/JavaClass.java
jadx-core/src/main/java/jadx/api/JavaClass.java
+67
-1
jadx-core/src/main/java/jadx/api/JavaField.java
jadx-core/src/main/java/jadx/api/JavaField.java
+25
-0
jadx-core/src/main/java/jadx/api/JavaMethod.java
jadx-core/src/main/java/jadx/api/JavaMethod.java
+31
-0
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
+10
-7
jadx-core/src/main/java/jadx/core/codegen/CodeGen.java
jadx-core/src/main/java/jadx/core/codegen/CodeGen.java
+1
-7
jadx-core/src/main/java/jadx/core/codegen/CodeWriter.java
jadx-core/src/main/java/jadx/core/codegen/CodeWriter.java
+63
-14
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+7
-4
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
+2
-1
jadx-core/src/main/java/jadx/core/codegen/RegionGen.java
jadx-core/src/main/java/jadx/core/codegen/RegionGen.java
+5
-5
jadx-core/src/main/java/jadx/core/dex/attributes/LineAttrNode.java
.../src/main/java/jadx/core/dex/attributes/LineAttrNode.java
+24
-0
jadx-core/src/main/java/jadx/core/dex/info/AccessInfo.java
jadx-core/src/main/java/jadx/core/dex/info/AccessInfo.java
+4
-0
jadx-core/src/main/java/jadx/core/dex/info/FieldInfo.java
jadx-core/src/main/java/jadx/core/dex/info/FieldInfo.java
+20
-0
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
+2
-2
jadx-core/src/main/java/jadx/core/dex/nodes/FieldNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/FieldNode.java
+15
-2
jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java
+2
-2
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
+28
-6
jadx-core/src/main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java
...main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java
+6
-7
jadx-core/src/main/java/jadx/core/dex/visitors/DotGraphVisitor.java
...src/main/java/jadx/core/dex/visitors/DotGraphVisitor.java
+1
-1
未找到文件。
jadx-core/src/main/java/jadx/api/Decompiler.java
浏览文件 @
25b2c8fe
...
...
@@ -65,7 +65,7 @@ public final class Decompiler {
for
(
ClassNode
classNode
:
root
.
getClasses
())
{
classes
.
add
(
new
JavaClass
(
this
,
classNode
));
}
return
classes
;
return
Collections
.
unmodifiableList
(
classes
)
;
}
public
List
<
JavaPackage
>
getPackages
()
{
...
...
@@ -85,7 +85,7 @@ public final class Decompiler {
packages
.
add
(
new
JavaPackage
(
entry
.
getKey
(),
entry
.
getValue
()));
}
Collections
.
sort
(
packages
);
return
packages
;
return
Collections
.
unmodifiableList
(
packages
)
;
}
public
void
saveAll
()
throws
InterruptedException
{
...
...
jadx-core/src/main/java/jadx/api/JavaClass.java
浏览文件 @
25b2c8fe
package
jadx.api
;
import
jadx.core.codegen.CodeWriter
;
import
jadx.core.dex.attributes.AttributeFlag
;
import
jadx.core.dex.info.AccessInfo
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.FieldNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
public
final
class
JavaClass
{
private
final
Decompiler
decompiler
;
private
final
ClassNode
cls
;
private
final
List
<
JavaClass
>
innerClasses
;
private
final
List
<
JavaField
>
fields
;
private
final
List
<
JavaMethod
>
methods
;
JavaClass
(
Decompiler
decompiler
,
ClassNode
classNode
)
{
this
.
decompiler
=
decompiler
;
this
.
cls
=
classNode
;
int
inClsCount
=
cls
.
getInnerClasses
().
size
();
if
(
inClsCount
==
0
)
{
this
.
innerClasses
=
Collections
.
emptyList
();
}
else
{
List
<
JavaClass
>
list
=
new
ArrayList
<
JavaClass
>(
inClsCount
);
for
(
ClassNode
inner
:
cls
.
getInnerClasses
())
{
list
.
add
(
new
JavaClass
(
decompiler
,
inner
));
}
this
.
innerClasses
=
Collections
.
unmodifiableList
(
list
);
}
int
fieldsCount
=
cls
.
getFields
().
size
();
if
(
fieldsCount
==
0
)
{
this
.
fields
=
Collections
.
emptyList
();
}
else
{
List
<
JavaField
>
flds
=
new
ArrayList
<
JavaField
>(
fieldsCount
);
for
(
FieldNode
f
:
cls
.
getFields
())
{
flds
.
add
(
new
JavaField
(
f
));
}
this
.
fields
=
Collections
.
unmodifiableList
(
flds
);
}
int
methodsCount
=
cls
.
getMethods
().
size
();
if
(
methodsCount
==
0
)
{
this
.
methods
=
Collections
.
emptyList
();
}
else
{
List
<
JavaMethod
>
mths
=
new
ArrayList
<
JavaMethod
>(
methodsCount
);
for
(
MethodNode
m
:
cls
.
getMethods
())
{
if
(!
m
.
getAttributes
().
contains
(
AttributeFlag
.
DONT_GENERATE
))
{
mths
.
add
(
new
JavaMethod
(
m
));
}
}
this
.
methods
=
Collections
.
unmodifiableList
(
mths
);
}
}
public
String
getCode
()
{
CodeWriter
code
=
cls
.
getCode
();
if
(
code
==
null
)
{
if
(
code
==
null
)
{
decompiler
.
processClass
(
cls
);
code
=
cls
.
getCode
();
}
...
...
@@ -34,8 +80,28 @@ public final class JavaClass {
return
cls
.
getPackage
();
}
public
AccessInfo
getAccessInfo
()
{
return
cls
.
getAccessFlags
();
}
public
List
<
JavaClass
>
getInnerClasses
()
{
return
innerClasses
;
}
public
List
<
JavaField
>
getFields
()
{
return
fields
;
}
public
List
<
JavaMethod
>
getMethods
()
{
return
methods
;
}
@Override
public
String
toString
()
{
return
getFullName
();
}
public
int
getDecompiledLine
()
{
return
cls
.
getDecompiledLine
();
}
}
jadx-core/src/main/java/jadx/api/JavaField.java
0 → 100644
浏览文件 @
25b2c8fe
package
jadx.api
;
import
jadx.core.dex.info.AccessInfo
;
import
jadx.core.dex.nodes.FieldNode
;
public
class
JavaField
{
private
final
FieldNode
field
;
public
JavaField
(
FieldNode
f
)
{
this
.
field
=
f
;
}
public
String
getName
()
{
return
field
.
getName
();
}
public
AccessInfo
getAccessFlags
()
{
return
field
.
getAccessFlags
();
}
public
int
getDecompiledLine
()
{
return
field
.
getDecompiledLine
();
}
}
jadx-core/src/main/java/jadx/api/JavaMethod.java
0 → 100644
浏览文件 @
25b2c8fe
package
jadx.api
;
import
jadx.core.dex.info.AccessInfo
;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.nodes.MethodNode
;
public
class
JavaMethod
{
private
final
MethodNode
mth
;
public
JavaMethod
(
MethodNode
m
)
{
this
.
mth
=
m
;
}
public
String
getName
()
{
MethodInfo
mi
=
mth
.
getMethodInfo
();
if
(
mi
.
isConstructor
())
{
return
mth
.
getParentClass
().
getShortName
();
}
else
if
(
mi
.
isClassInit
())
{
return
"static"
;
}
return
mi
.
getName
();
}
public
AccessInfo
getAccessFlags
()
{
return
mth
.
getAccessFlags
();
}
public
int
getDecompiledLine
()
{
return
mth
.
getDecompiledLine
();
}
}
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
浏览文件 @
25b2c8fe
...
...
@@ -59,7 +59,7 @@ public class ClassGen {
if
(!
""
.
equals
(
cls
.
getPackage
()))
{
clsCode
.
add
(
"package "
).
add
(
cls
.
getPackage
()).
add
(
';'
);
clsCode
.
endl
();
clsCode
.
newLine
();
}
if
(
imports
.
size
()
!=
0
)
{
...
...
@@ -71,7 +71,7 @@ public class ClassGen {
for
(
String
imp
:
sortImports
)
{
clsCode
.
startLine
(
"import "
).
add
(
imp
).
add
(
';'
);
}
clsCode
.
endl
();
clsCode
.
newLine
();
sortImports
.
clear
();
imports
.
clear
();
...
...
@@ -90,7 +90,7 @@ public class ClassGen {
makeClassDeclaration
(
code
);
makeClassBody
(
code
);
code
.
endl
();
code
.
newLine
();
}
public
void
makeClassDeclaration
(
CodeWriter
clsCode
)
{
...
...
@@ -139,6 +139,8 @@ public class ClassGen {
if
(!
cls
.
getInterfaces
().
isEmpty
())
clsCode
.
add
(
' '
);
}
clsCode
.
attachAnnotation
(
cls
);
}
public
boolean
makeGenericMap
(
CodeWriter
code
,
Map
<
ArgType
,
List
<
ArgType
>>
gmap
)
{
...
...
@@ -178,13 +180,13 @@ public class ClassGen {
CodeWriter
fieldsCode
=
makeFields
(
clsCode
,
cls
,
cls
.
getFields
());
clsCode
.
add
(
fieldsCode
);
if
(
fieldsCode
.
notEmpty
()
&&
mthsCode
.
notEmpty
())
clsCode
.
endl
();
clsCode
.
newLine
();
// insert inner classes code
if
(
cls
.
getInnerClasses
().
size
()
!=
0
)
{
clsCode
.
add
(
makeInnerClasses
(
cls
,
clsCode
.
getIndent
()));
if
(
mthsCode
.
notEmpty
())
clsCode
.
endl
();
clsCode
.
newLine
();
}
clsCode
.
add
(
mthsCode
);
clsCode
.
startLine
(
'}'
);
...
...
@@ -239,7 +241,7 @@ public class ClassGen {
}
if
(
it
.
hasNext
())
code
.
endl
();
code
.
newLine
();
}
return
code
;
}
...
...
@@ -278,7 +280,7 @@ public class ClassGen {
code
.
startLine
();
code
.
add
(
';'
);
code
.
endl
();
code
.
newLine
();
}
for
(
FieldNode
f
:
fields
)
{
...
...
@@ -297,6 +299,7 @@ public class ClassGen {
}
}
code
.
add
(
';'
);
code
.
attachAnnotation
(
f
);
}
return
code
;
}
...
...
jadx-core/src/main/java/jadx/core/codegen/CodeGen.java
浏览文件 @
25b2c8fe
...
...
@@ -21,14 +21,8 @@ public class CodeGen extends AbstractVisitor {
public
boolean
visit
(
ClassNode
cls
)
throws
CodegenException
{
ClassGen
clsGen
=
new
ClassGen
(
cls
,
null
,
isFallbackMode
());
CodeWriter
clsCode
=
clsGen
.
makeClass
();
clsCode
.
finish
();
cls
.
setCode
(
clsCode
);
// String fileName = cls.getClassInfo().getFullPath() + ".java";
// if (isFallbackMode())
// fileName += ".jadx";
// clsCode.save(dir, fileName);
return
false
;
}
...
...
jadx-core/src/main/java/jadx/core/codegen/CodeWriter.java
浏览文件 @
25b2c8fe
package
jadx.core.codegen
;
import
jadx.core.dex.attributes.LineAttrNode
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
java.io.File
;
import
java.io.PrintWriter
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -19,6 +23,9 @@ public class CodeWriter {
private
String
indentStr
;
private
int
indent
;
private
int
line
=
1
;
private
Map
<
Object
,
Integer
>
annotations
=
Collections
.
emptyMap
();
public
CodeWriter
()
{
this
.
indent
=
0
;
this
.
indentStr
=
""
;
...
...
@@ -29,32 +36,32 @@ public class CodeWriter {
updateIndent
();
}
public
CodeWriter
startLine
(
String
str
)
{
buf
.
append
(
NL
);
public
CodeWriter
startLine
()
{
addLine
(
);
buf
.
append
(
indentStr
);
buf
.
append
(
str
);
return
this
;
}
public
CodeWriter
startLine
(
char
c
)
{
buf
.
append
(
NL
);
addLine
(
);
buf
.
append
(
indentStr
);
buf
.
append
(
c
);
return
this
;
}
public
CodeWriter
startLine
(
int
ind
,
String
str
)
{
buf
.
append
(
NL
);
public
CodeWriter
startLine
(
String
str
)
{
addLine
(
);
buf
.
append
(
indentStr
);
for
(
int
i
=
0
;
i
<
ind
;
i
++)
buf
.
append
(
INDENT
);
buf
.
append
(
str
);
return
this
;
}
public
CodeWriter
startLine
()
{
buf
.
append
(
NL
);
public
CodeWriter
startLine
(
int
ind
,
String
str
)
{
addLine
(
);
buf
.
append
(
indentStr
);
for
(
int
i
=
0
;
i
<
ind
;
i
++)
buf
.
append
(
INDENT
);
buf
.
append
(
str
);
return
this
;
}
...
...
@@ -68,17 +75,47 @@ public class CodeWriter {
return
this
;
}
public
CodeWriter
add
(
CodeWriter
mthsCode
)
{
buf
.
append
(
mthsCode
.
toString
());
public
CodeWriter
add
(
CodeWriter
code
)
{
line
--;
for
(
Map
.
Entry
<
Object
,
Integer
>
entry
:
code
.
annotations
.
entrySet
())
{
attachAnnotation
(
entry
.
getKey
(),
line
+
entry
.
getValue
());
}
line
+=
code
.
line
;
buf
.
append
(
code
.
toString
());
return
this
;
}
public
CodeWriter
endl
()
{
public
CodeWriter
newLine
()
{
addLine
();
return
this
;
}
private
void
addLine
()
{
buf
.
append
(
NL
);
line
++;
}
public
int
getLine
()
{
return
line
;
}
public
Object
attachAnnotation
(
Object
obj
)
{
return
attachAnnotation
(
obj
,
line
);
}
public
Object
attachAnnotation
(
Object
obj
,
int
line
)
{
if
(
annotations
.
isEmpty
())
{
annotations
=
new
HashMap
<
Object
,
Integer
>();
}
return
annotations
.
put
(
obj
,
line
);
}
public
CodeWriter
indent
()
{
buf
.
append
(
indentStr
);
return
this
;
}
private
static
final
String
[]
INDENT_CACHE
=
new
String
[]
{
private
static
final
String
[]
INDENT_CACHE
=
new
String
[]{
""
,
INDENT
,
INDENT
+
INDENT
,
...
...
@@ -126,6 +163,18 @@ public class CodeWriter {
updateIndent
();
}
public
void
finish
()
{
buf
.
trimToSize
();
for
(
Map
.
Entry
<
Object
,
Integer
>
entry
:
annotations
.
entrySet
())
{
Object
v
=
entry
.
getKey
();
if
(
v
instanceof
LineAttrNode
)
{
LineAttrNode
l
=
(
LineAttrNode
)
v
;
l
.
setDecompiledLine
(
entry
.
getValue
());
}
}
annotations
.
clear
();
}
private
static
String
removeFirstEmptyLine
(
String
str
)
{
if
(
str
.
startsWith
(
NL
))
{
return
str
.
substring
(
NL
.
length
());
...
...
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
浏览文件 @
25b2c8fe
...
...
@@ -152,13 +152,16 @@ public class InsnGen {
}
else
{
CodeWriter
body
=
new
CodeWriter
(
code
.
getIndent
());
makeInsnBody
(
body
,
insn
,
state
);
if
(
state
.
contains
(
InsnGenState
.
SKIP
))
if
(
state
.
contains
(
InsnGenState
.
SKIP
))
{
return
false
;
}
code
.
startLine
();
if
(
insn
.
getSourceLine
()
!=
0
)
{
code
.
attachAnnotation
(
insn
.
getSourceLine
());
}
if
(
insn
.
getResult
()
!=
null
&&
!
state
.
contains
(
InsnGenState
.
NO_RESULT
))
code
.
startLine
(
assignVar
(
insn
)).
add
(
" = "
);
else
code
.
startLine
();
code
.
add
(
assignVar
(
insn
)).
add
(
" = "
);
code
.
add
(
body
);
...
...
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
浏览文件 @
25b2c8fe
...
...
@@ -108,6 +108,7 @@ public class MethodGen {
annotationGen
.
addThrows
(
mth
,
code
);
}
code
.
attachAnnotation
(
mth
);
}
public
CodeWriter
makeArguments
(
List
<
RegisterArg
>
args
)
{
...
...
@@ -225,7 +226,7 @@ public class MethodGen {
code
.
startLine
(
"// jadx: method processing error"
);
Throwable
cause
=
err
.
getCause
();
if
(
cause
!=
null
)
{
code
.
endl
();
code
.
newLine
();
code
.
add
(
"/*"
);
code
.
startLine
(
"Error: "
).
add
(
Utils
.
getStackTrace
(
cause
));
code
.
add
(
"*/"
);
...
...
jadx-core/src/main/java/jadx/core/codegen/RegionGen.java
浏览文件 @
25b2c8fe
...
...
@@ -165,14 +165,14 @@ public class RegionGen extends InsnGen {
case
AND:
case
OR:
String
mode
=
condition
.
getMode
()
==
IfCondition
.
MODE
.
AND
?
" && "
:
" || "
;
CodeWriter
cw
=
new
CodeWrit
er
();
StringBuilder
sb
=
new
StringBuild
er
();
for
(
IfCondition
arg
:
condition
.
getArgs
())
{
if
(
cw
.
notEmpty
()
)
{
cw
.
ad
d
(
mode
);
if
(
sb
.
length
()
!=
0
)
{
sb
.
appen
d
(
mode
);
}
cw
.
add
(
'('
).
add
(
makeCondition
(
arg
)).
ad
d
(
')'
);
sb
.
append
(
'('
).
append
(
makeCondition
(
arg
)).
appen
d
(
')'
);
}
return
cw
.
toString
();
return
sb
.
toString
();
default
:
return
"??"
+
condition
.
toString
();
}
...
...
jadx-core/src/main/java/jadx/core/dex/attributes/LineAttrNode.java
0 → 100644
浏览文件 @
25b2c8fe
package
jadx.core.dex.attributes
;
public
abstract
class
LineAttrNode
extends
AttrNode
{
private
int
sourceLine
;
private
int
decompiledLine
;
public
int
getSourceLine
()
{
return
sourceLine
;
}
public
void
setSourceLine
(
int
sourceLine
)
{
this
.
sourceLine
=
sourceLine
;
}
public
int
getDecompiledLine
()
{
return
decompiledLine
;
}
public
void
setDecompiledLine
(
int
decompiledLine
)
{
this
.
decompiledLine
=
decompiledLine
;
}
}
jadx-core/src/main/java/jadx/core/dex/info/AccessInfo.java
浏览文件 @
25b2c8fe
...
...
@@ -97,6 +97,10 @@ public class AccessInfo {
return
accFlags
;
}
public
AFType
getType
()
{
return
type
;
}
public
String
makeString
()
{
StringBuilder
code
=
new
StringBuilder
();
if
(
isPublic
())
...
...
jadx-core/src/main/java/jadx/core/dex/info/FieldInfo.java
浏览文件 @
25b2c8fe
...
...
@@ -39,6 +39,26 @@ public class FieldInfo {
return
declClass
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
FieldInfo
fieldInfo
=
(
FieldInfo
)
o
;
if
(!
name
.
equals
(
fieldInfo
.
name
))
return
false
;
if
(!
type
.
equals
(
fieldInfo
.
type
))
return
false
;
if
(!
declClass
.
equals
(
fieldInfo
.
declClass
))
return
false
;
return
true
;
}
@Override
public
int
hashCode
()
{
int
result
=
name
.
hashCode
();
result
=
31
*
result
+
type
.
hashCode
();
result
=
31
*
result
+
declClass
.
hashCode
();
return
result
;
}
@Override
public
String
toString
()
{
return
declClass
+
"."
+
name
+
" "
+
type
;
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
浏览文件 @
25b2c8fe
...
...
@@ -2,8 +2,8 @@ package jadx.core.dex.nodes;
import
jadx.core.Consts
;
import
jadx.core.codegen.CodeWriter
;
import
jadx.core.dex.attributes.AttrNode
;
import
jadx.core.dex.attributes.AttributeType
;
import
jadx.core.dex.attributes.LineAttrNode
;
import
jadx.core.dex.attributes.SourceFileAttr
;
import
jadx.core.dex.attributes.annotations.Annotation
;
import
jadx.core.dex.info.AccessInfo
;
...
...
@@ -32,7 +32,7 @@ import com.android.dx.io.ClassData.Field;
import
com.android.dx.io.ClassData.Method
;
import
com.android.dx.io.ClassDef
;
public
class
ClassNode
extends
AttrNode
implements
ILoadable
{
public
class
ClassNode
extends
Line
AttrNode
implements
ILoadable
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ClassNode
.
class
);
private
final
DexNode
dex
;
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/FieldNode.java
浏览文件 @
25b2c8fe
package
jadx.core.dex.nodes
;
import
jadx.core.dex.attributes.AttrNode
;
import
jadx.core.dex.attributes.
Line
AttrNode
;
import
jadx.core.dex.info.AccessInfo
;
import
jadx.core.dex.info.AccessInfo.AFType
;
import
jadx.core.dex.info.FieldInfo
;
...
...
@@ -8,7 +8,7 @@ import jadx.core.dex.instructions.args.ArgType;
import
com.android.dx.io.ClassData.Field
;
public
class
FieldNode
extends
AttrNode
{
public
class
FieldNode
extends
Line
AttrNode
{
private
final
FieldInfo
fieldInfo
;
private
final
AccessInfo
accFlags
;
...
...
@@ -41,6 +41,19 @@ public class FieldNode extends AttrNode {
this
.
type
=
type
;
}
@Override
public
int
hashCode
()
{
return
fieldInfo
.
hashCode
();
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
return
true
;
if
(
obj
==
null
||
getClass
()
!=
obj
.
getClass
())
return
false
;
FieldNode
other
=
(
FieldNode
)
obj
;
return
fieldInfo
.
equals
(
other
.
fieldInfo
);
}
@Override
public
String
toString
()
{
return
fieldInfo
.
getDeclClass
()
+
"."
+
fieldInfo
.
getName
()
+
" "
+
type
;
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java
浏览文件 @
25b2c8fe
package
jadx.core.dex.nodes
;
import
jadx.core.dex.attributes.AttrNode
;
import
jadx.core.dex.attributes.
Line
AttrNode
;
import
jadx.core.dex.instructions.InsnType
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.InsnArg
;
...
...
@@ -15,7 +15,7 @@ import java.util.List;
import
com.android.dx.io.instructions.DecodedInstruction
;
public
class
InsnNode
extends
AttrNode
{
public
class
InsnNode
extends
Line
AttrNode
{
protected
final
InsnType
insnType
;
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
浏览文件 @
25b2c8fe
package
jadx.core.dex.nodes
;
import
jadx.core.Consts
;
import
jadx.core.dex.attributes.AttrNode
;
import
jadx.core.dex.attributes.AttributeFlag
;
import
jadx.core.dex.attributes.JumpAttribute
;
import
jadx.core.dex.attributes.LineAttrNode
;
import
jadx.core.dex.attributes.LoopAttr
;
import
jadx.core.dex.attributes.annotations.Annotation
;
import
jadx.core.dex.info.AccessInfo
;
...
...
@@ -40,7 +40,7 @@ import com.android.dx.io.Code;
import
com.android.dx.io.Code.CatchHandler
;
import
com.android.dx.io.Code.Try
;
public
class
MethodNode
extends
AttrNode
implements
ILoadable
{
public
class
MethodNode
extends
Line
AttrNode
implements
ILoadable
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MethodNode
.
class
);
private
final
MethodInfo
mthInfo
;
...
...
@@ -101,8 +101,17 @@ public class MethodNode extends AttrNode implements ILoadable {
initTryCatches
(
mthCode
,
insnByOffset
);
initJumps
(
insnByOffset
);
if
(
mthCode
.
getDebugInfoOffset
()
>
0
)
{
(
new
DebugInfoParser
(
this
,
mthCode
.
getDebugInfoOffset
(),
insnByOffset
)).
process
();
int
debugInfoOffset
=
mthCode
.
getDebugInfoOffset
();
if
(
debugInfoOffset
>
0
)
{
DebugInfoParser
debugInfoParser
=
new
DebugInfoParser
(
this
,
debugInfoOffset
,
insnByOffset
);
debugInfoParser
.
process
();
if
(
instructions
.
size
()
!=
0
)
{
int
line
=
instructions
.
get
(
0
).
getSourceLine
();
if
(
line
!=
0
)
{
this
.
setSourceLine
(
line
-
1
);
}
}
}
}
catch
(
Exception
e
)
{
throw
new
DecodeException
(
this
,
"Load method exception"
,
e
);
...
...
@@ -414,7 +423,7 @@ public class MethodNode extends AttrNode implements ILoadable {
}
public
void
registerLoop
(
LoopAttr
loop
)
{
if
(
loops
.
isEmpty
())
{
if
(
loops
.
isEmpty
())
{
loops
=
new
ArrayList
<
LoopAttr
>(
5
);
}
loops
.
add
(
loop
);
...
...
@@ -422,7 +431,7 @@ public class MethodNode extends AttrNode implements ILoadable {
public
LoopAttr
getLoopForBlock
(
BlockNode
block
)
{
for
(
LoopAttr
loop
:
loops
)
{
if
(
loop
.
getLoopBlocks
().
contains
(
block
))
if
(
loop
.
getLoopBlocks
().
contains
(
block
))
return
loop
;
}
return
null
;
...
...
@@ -477,6 +486,19 @@ public class MethodNode extends AttrNode implements ILoadable {
return
mthInfo
;
}
@Override
public
int
hashCode
()
{
return
mthInfo
.
hashCode
();
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
return
true
;
if
(
obj
==
null
||
getClass
()
!=
obj
.
getClass
())
return
false
;
MethodNode
other
=
(
MethodNode
)
obj
;
return
mthInfo
.
equals
(
other
.
mthInfo
);
}
@Override
public
String
toString
()
{
return
retType
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java
浏览文件 @
25b2c8fe
...
...
@@ -49,9 +49,8 @@ public class DebugInfoParser {
public
void
process
()
throws
DecodeException
{
int
addr
=
0
;
int
line
;
int
line
=
section
.
readUleb128
()
;
line
=
section
.
readUleb128
();
int
param_size
=
section
.
readUleb128
();
// exclude 'this'
List
<
RegisterArg
>
mthArgs
=
mth
.
getArguments
(
false
);
assert
param_size
==
mthArgs
.
size
();
...
...
@@ -70,14 +69,14 @@ public class DebugInfoParser {
activeRegisters
[
rn
]
=
arg
;
}
addrChange
(-
1
,
1
);
// process '0' instruction
addrChange
(-
1
,
1
,
line
);
// process '0' instruction
int
c
=
section
.
readByte
()
&
0xFF
;
while
(
c
!=
DBG_END_SEQUENCE
)
{
switch
(
c
)
{
case
DBG_ADVANCE_PC:
{
int
addrInc
=
section
.
readUleb128
();
addr
=
addrChange
(
addr
,
addrInc
);
addr
=
addrChange
(
addr
,
addrInc
,
line
);
break
;
}
case
DBG_ADVANCE_LINE:
{
...
...
@@ -141,14 +140,13 @@ public class DebugInfoParser {
int
adjusted_opcode
=
c
-
DBG_FIRST_SPECIAL
;
line
+=
DBG_LINE_BASE
+
(
adjusted_opcode
%
DBG_LINE_RANGE
);
int
addrInc
=
(
adjusted_opcode
/
DBG_LINE_RANGE
);
addr
=
addrChange
(
addr
,
addrInc
);
addr
=
addrChange
(
addr
,
addrInc
,
line
);
}
else
{
throw
new
DecodeException
(
"Unknown debug insn code: "
+
c
);
}
break
;
}
}
c
=
section
.
readByte
()
&
0xFF
;
}
...
...
@@ -160,13 +158,14 @@ public class DebugInfoParser {
}
}
private
int
addrChange
(
int
addr
,
int
addrInc
)
{
private
int
addrChange
(
int
addr
,
int
addrInc
,
int
line
)
{
int
newAddr
=
addr
+
addrInc
;
for
(
int
i
=
addr
+
1
;
i
<=
newAddr
;
i
++)
{
InsnNode
insn
=
insnByOffset
[
i
];
if
(
insn
==
null
)
continue
;
insn
.
setSourceLine
(
line
);
for
(
InsnArg
arg
:
insn
.
getArguments
())
if
(
arg
.
isRegister
())
{
activeRegisters
[
arg
.
getRegNum
()]
=
arg
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/DotGraphVisitor.java
浏览文件 @
25b2c8fe
...
...
@@ -168,7 +168,7 @@ public class DotGraphVisitor extends AbstractVisitor {
}
else
{
CodeWriter
code
=
new
CodeWriter
(
0
);
MethodGen
.
makeFallbackInsns
(
code
,
mth
,
block
.
getInstructions
(),
false
);
String
str
=
escape
(
code
.
endl
().
toString
());
String
str
=
escape
(
code
.
newLine
().
toString
());
if
(
str
.
startsWith
(
NL
))
str
=
str
.
substring
(
NL
.
length
());
return
str
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录