Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
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
4e284c4c
Commit
4e284c4c
authored
May 02, 2013
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use chars instead strings, code refactoring
parent
c363bea5
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
70 additions
and
77 deletions
+70
-77
ClassGen.java
src/main/java/jadx/codegen/ClassGen.java
+11
-11
CodeWriter.java
src/main/java/jadx/codegen/CodeWriter.java
+1
-1
InsnGen.java
src/main/java/jadx/codegen/InsnGen.java
+13
-18
MethodGen.java
src/main/java/jadx/codegen/MethodGen.java
+2
-2
RegionGen.java
src/main/java/jadx/codegen/RegionGen.java
+1
-1
TypeGen.java
src/main/java/jadx/codegen/TypeGen.java
+1
-0
FieldInfo.java
src/main/java/jadx/dex/info/FieldInfo.java
+1
-1
IndexInsnNode.java
src/main/java/jadx/dex/instructions/IndexInsnNode.java
+1
-1
ArgType.java
src/main/java/jadx/dex/instructions/args/ArgType.java
+2
-5
InsnArg.java
src/main/java/jadx/dex/instructions/args/InsnArg.java
+4
-0
RegisterArg.java
src/main/java/jadx/dex/instructions/args/RegisterArg.java
+1
-0
TypedVar.java
src/main/java/jadx/dex/instructions/args/TypedVar.java
+5
-5
DexNode.java
src/main/java/jadx/dex/nodes/DexNode.java
+1
-1
InsnNode.java
src/main/java/jadx/dex/nodes/InsnNode.java
+1
-1
MethodNode.java
src/main/java/jadx/dex/nodes/MethodNode.java
+1
-2
BlockMakerVisitor.java
src/main/java/jadx/dex/visitors/BlockMakerVisitor.java
+12
-13
BlockProcessingHelper.java
src/main/java/jadx/dex/visitors/BlockProcessingHelper.java
+3
-2
ConstInlinerVisitor.java
src/main/java/jadx/dex/visitors/ConstInlinerVisitor.java
+1
-1
DotGraphVisitor.java
src/main/java/jadx/dex/visitors/DotGraphVisitor.java
+2
-2
MethodInlinerVisitor.java
src/main/java/jadx/dex/visitors/MethodInlinerVisitor.java
+1
-2
BlockUtils.java
src/main/java/jadx/utils/BlockUtils.java
+3
-6
StringUtils.java
src/main/java/jadx/utils/StringUtils.java
+1
-1
Utils.java
src/main/java/jadx/utils/Utils.java
+1
-1
No files found.
src/main/java/jadx/codegen/ClassGen.java
View file @
4e284c4c
...
@@ -55,7 +55,7 @@ public class ClassGen {
...
@@ -55,7 +55,7 @@ public class ClassGen {
CodeWriter
clsCode
=
new
CodeWriter
();
CodeWriter
clsCode
=
new
CodeWriter
();
if
(!
""
.
equals
(
cls
.
getPackage
()))
{
if
(!
""
.
equals
(
cls
.
getPackage
()))
{
clsCode
.
add
(
"package "
).
add
(
cls
.
getPackage
()).
add
(
";"
);
clsCode
.
add
(
"package "
).
add
(
cls
.
getPackage
()).
add
(
';'
);
clsCode
.
endl
();
clsCode
.
endl
();
}
}
...
@@ -66,7 +66,7 @@ public class ClassGen {
...
@@ -66,7 +66,7 @@ public class ClassGen {
Collections
.
sort
(
sortImports
);
Collections
.
sort
(
sortImports
);
for
(
String
imp
:
sortImports
)
{
for
(
String
imp
:
sortImports
)
{
clsCode
.
startLine
(
"import "
).
add
(
imp
).
add
(
";"
);
clsCode
.
startLine
(
"import "
).
add
(
imp
).
add
(
';'
);
}
}
clsCode
.
endl
();
clsCode
.
endl
();
...
@@ -165,7 +165,7 @@ public class ClassGen {
...
@@ -165,7 +165,7 @@ public class ClassGen {
}
}
public
void
makeClassBody
(
CodeWriter
clsCode
)
throws
CodegenException
{
public
void
makeClassBody
(
CodeWriter
clsCode
)
throws
CodegenException
{
clsCode
.
add
(
"{"
);
clsCode
.
add
(
'{'
);
CodeWriter
mthsCode
=
makeMethods
(
clsCode
,
cls
.
getMethods
());
CodeWriter
mthsCode
=
makeMethods
(
clsCode
,
cls
.
getMethods
());
clsCode
.
add
(
makeFields
(
clsCode
,
cls
,
cls
.
getFields
()));
clsCode
.
add
(
makeFields
(
clsCode
,
cls
,
cls
.
getFields
()));
...
@@ -174,7 +174,7 @@ public class ClassGen {
...
@@ -174,7 +174,7 @@ public class ClassGen {
clsCode
.
add
(
makeInnerClasses
(
cls
,
clsCode
.
getIndent
()));
clsCode
.
add
(
makeInnerClasses
(
cls
,
clsCode
.
getIndent
()));
}
}
clsCode
.
add
(
mthsCode
);
clsCode
.
add
(
mthsCode
);
clsCode
.
startLine
(
"}"
);
clsCode
.
startLine
(
'}'
);
}
}
private
CodeWriter
makeInnerClasses
(
ClassNode
cls2
,
int
indent
)
throws
CodegenException
{
private
CodeWriter
makeInnerClasses
(
ClassNode
cls2
,
int
indent
)
throws
CodegenException
{
...
@@ -190,7 +190,7 @@ public class ClassGen {
...
@@ -190,7 +190,7 @@ public class ClassGen {
return
innerClsCode
;
return
innerClsCode
;
}
}
private
CodeWriter
makeMethods
(
CodeWriter
clsCode
,
List
<
MethodNode
>
mthList
)
throws
CodegenException
{
private
CodeWriter
makeMethods
(
CodeWriter
clsCode
,
List
<
MethodNode
>
mthList
)
{
CodeWriter
code
=
new
CodeWriter
(
clsCode
.
getIndent
()
+
1
);
CodeWriter
code
=
new
CodeWriter
(
clsCode
.
getIndent
()
+
1
);
for
(
Iterator
<
MethodNode
>
it
=
mthList
.
iterator
();
it
.
hasNext
();)
{
for
(
Iterator
<
MethodNode
>
it
=
mthList
.
iterator
();
it
.
hasNext
();)
{
MethodNode
mth
=
it
.
next
();
MethodNode
mth
=
it
.
next
();
...
@@ -208,7 +208,7 @@ public class ClassGen {
...
@@ -208,7 +208,7 @@ public class ClassGen {
code
.
add
(
" default "
).
add
(
v
);
code
.
add
(
" default "
).
add
(
v
);
}
}
}
}
code
.
add
(
";"
);
code
.
add
(
';'
);
}
else
{
}
else
{
if
(
mth
.
isNoCode
())
if
(
mth
.
isNoCode
())
continue
;
continue
;
...
@@ -217,7 +217,7 @@ public class ClassGen {
...
@@ -217,7 +217,7 @@ public class ClassGen {
mthGen
.
addDefinition
(
code
);
mthGen
.
addDefinition
(
code
);
code
.
add
(
" {"
);
code
.
add
(
" {"
);
code
.
add
(
mthGen
.
makeInstructions
(
code
.
getIndent
()));
code
.
add
(
mthGen
.
makeInstructions
(
code
.
getIndent
()));
code
.
startLine
(
"}"
);
code
.
startLine
(
'}'
);
}
}
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
String
msg
=
ErrorsCounter
.
methodError
(
mth
,
"Method generation error"
,
e
);
String
msg
=
ErrorsCounter
.
methodError
(
mth
,
"Method generation error"
,
e
);
...
@@ -268,7 +268,7 @@ public class ClassGen {
...
@@ -268,7 +268,7 @@ public class ClassGen {
annotationGen
.
addForField
(
code
,
f
);
annotationGen
.
addForField
(
code
,
f
);
code
.
startLine
(
f
.
getAccessFlags
().
makeString
());
code
.
startLine
(
f
.
getAccessFlags
().
makeString
());
code
.
add
(
TypeGen
.
translate
(
this
,
f
.
getType
()));
code
.
add
(
TypeGen
.
translate
(
this
,
f
.
getType
()));
code
.
add
(
" "
);
code
.
add
(
' '
);
code
.
add
(
f
.
getName
());
code
.
add
(
f
.
getName
());
FieldValueAttr
fv
=
(
FieldValueAttr
)
f
.
getAttributes
().
get
(
AttributeType
.
FIELD_VALUE
);
FieldValueAttr
fv
=
(
FieldValueAttr
)
f
.
getAttributes
().
get
(
AttributeType
.
FIELD_VALUE
);
if
(
fv
!=
null
)
{
if
(
fv
!=
null
)
{
...
@@ -279,7 +279,7 @@ public class ClassGen {
...
@@ -279,7 +279,7 @@ public class ClassGen {
code
.
add
(
annotationGen
.
encValueToString
(
fv
.
getValue
()));
code
.
add
(
annotationGen
.
encValueToString
(
fv
.
getValue
()));
}
}
}
}
code
.
add
(
";"
);
code
.
add
(
';'
);
}
}
if
(
fields
.
size
()
!=
0
)
if
(
fields
.
size
()
!=
0
)
code
.
endl
();
code
.
endl
();
...
@@ -299,7 +299,7 @@ public class ClassGen {
...
@@ -299,7 +299,7 @@ public class ClassGen {
if
(
generics
!=
null
)
{
if
(
generics
!=
null
)
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
baseClass
);
sb
.
append
(
baseClass
);
sb
.
append
(
"<"
);
sb
.
append
(
'<'
);
int
len
=
generics
.
length
;
int
len
=
generics
.
length
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
if
(
i
!=
0
)
{
if
(
i
!=
0
)
{
...
@@ -311,7 +311,7 @@ public class ClassGen {
...
@@ -311,7 +311,7 @@ public class ClassGen {
else
else
sb
.
append
(
'?'
);
sb
.
append
(
'?'
);
}
}
sb
.
append
(
">"
);
sb
.
append
(
'>'
);
return
sb
.
toString
();
return
sb
.
toString
();
}
else
{
}
else
{
return
baseClass
;
return
baseClass
;
...
...
src/main/java/jadx/codegen/CodeWriter.java
View file @
4e284c4c
...
@@ -13,7 +13,7 @@ public class CodeWriter {
...
@@ -13,7 +13,7 @@ public class CodeWriter {
private
static
final
int
MAX_FILENAME_LENGTH
=
128
;
private
static
final
int
MAX_FILENAME_LENGTH
=
128
;
public
static
final
String
NL
=
System
.
getProperty
(
"line.separator"
);
public
static
final
String
NL
=
System
.
getProperty
(
"line.separator"
);
p
ublic
static
final
String
INDENT
=
"\t"
;
p
rivate
static
final
String
INDENT
=
"\t"
;
private
StringBuilder
buf
=
new
StringBuilder
();
private
StringBuilder
buf
=
new
StringBuilder
();
private
String
indentStr
;
private
String
indentStr
;
...
...
src/main/java/jadx/codegen/InsnGen.java
View file @
4e284c4c
...
@@ -84,20 +84,15 @@ public class InsnGen {
...
@@ -84,20 +84,15 @@ public class InsnGen {
}
}
public
String
assignVar
(
InsnNode
insn
)
{
public
String
assignVar
(
InsnNode
insn
)
{
try
{
RegisterArg
arg
=
insn
.
getResult
();
RegisterArg
arg
=
insn
.
getResult
();
if
(
insn
.
getAttributes
().
contains
(
AttributeType
.
DECLARE_VARIABLE
))
{
if
(
insn
.
getAttributes
().
contains
(
AttributeType
.
DECLARE_VARIABLE
))
{
return
declareVar
(
arg
);
return
declareVar
(
arg
);
}
else
{
}
else
{
return
mgen
.
makeArgName
(
arg
);
return
mgen
.
makeArgName
(
arg
);
}
}
catch
(
CodegenException
e
)
{
LOG
.
error
(
"Assign var codegen error"
,
e
);
return
"<error>"
;
}
}
}
}
public
String
declareVar
(
RegisterArg
arg
)
throws
CodegenException
{
public
String
declareVar
(
RegisterArg
arg
)
{
return
useType
(
arg
.
getType
())
+
" "
+
mgen
.
assignArg
(
arg
);
return
useType
(
arg
.
getType
())
+
" "
+
mgen
.
assignArg
(
arg
);
}
}
...
@@ -237,8 +232,8 @@ public class InsnGen {
...
@@ -237,8 +232,8 @@ public class InsnGen {
break
;
break
;
case
INSTANCE_OF:
case
INSTANCE_OF:
code
.
add
(
"("
).
add
(
arg
(
insn
,
0
)).
add
(
" instanceof "
)
code
.
add
(
'('
).
add
(
arg
(
insn
,
0
)).
add
(
" instanceof "
)
.
add
(
useType
((
ArgType
)
((
IndexInsnNode
)
insn
).
getIndex
())).
add
(
")"
);
.
add
(
useType
((
ArgType
)
((
IndexInsnNode
)
insn
).
getIndex
())).
add
(
')'
);
break
;
break
;
case
CONSTRUCTOR:
case
CONSTRUCTOR:
...
@@ -296,7 +291,7 @@ public class InsnGen {
...
@@ -296,7 +291,7 @@ public class InsnGen {
case
MONITOR_ENTER:
case
MONITOR_ENTER:
if
(
isFallback
())
{
if
(
isFallback
())
{
code
.
add
(
"monitor-enter("
).
add
(
arg
(
insn
.
getArg
(
0
))).
add
(
")"
);
code
.
add
(
"monitor-enter("
).
add
(
arg
(
insn
.
getArg
(
0
))).
add
(
')'
);
}
else
{
}
else
{
state
.
add
(
InsnGenState
.
SKIP
);
state
.
add
(
InsnGenState
.
SKIP
);
}
}
...
@@ -304,7 +299,7 @@ public class InsnGen {
...
@@ -304,7 +299,7 @@ public class InsnGen {
case
MONITOR_EXIT:
case
MONITOR_EXIT:
if
(
isFallback
())
{
if
(
isFallback
())
{
code
.
add
(
"monitor-exit("
).
add
(
arg
(
insn
.
getArg
(
0
))).
add
(
")"
);
code
.
add
(
"monitor-exit("
).
add
(
arg
(
insn
.
getArg
(
0
))).
add
(
')'
);
}
else
{
}
else
{
state
.
add
(
InsnGenState
.
SKIP
);
state
.
add
(
InsnGenState
.
SKIP
);
}
}
...
@@ -358,7 +353,7 @@ public class InsnGen {
...
@@ -358,7 +353,7 @@ public class InsnGen {
}
}
code
.
startLine
(
"default: goto "
+
MethodGen
.
getLabelName
(
sw
.
getDefaultCaseOffset
())
+
";"
);
code
.
startLine
(
"default: goto "
+
MethodGen
.
getLabelName
(
sw
.
getDefaultCaseOffset
())
+
";"
);
code
.
decIndent
();
code
.
decIndent
();
code
.
startLine
(
"}"
);
code
.
startLine
(
'}'
);
state
.
add
(
InsnGenState
.
NO_SEMICOLON
);
state
.
add
(
InsnGenState
.
NO_SEMICOLON
);
break
;
break
;
...
@@ -376,13 +371,13 @@ public class InsnGen {
...
@@ -376,13 +371,13 @@ public class InsnGen {
private
void
filledNewArray
(
InsnNode
insn
,
CodeWriter
code
)
throws
CodegenException
{
private
void
filledNewArray
(
InsnNode
insn
,
CodeWriter
code
)
throws
CodegenException
{
int
c
=
insn
.
getArgsCount
();
int
c
=
insn
.
getArgsCount
();
code
.
add
(
"new "
).
add
(
useType
(
insn
.
getResult
().
getType
()));
code
.
add
(
"new "
).
add
(
useType
(
insn
.
getResult
().
getType
()));
code
.
add
(
"{"
);
code
.
add
(
'{'
);
for
(
int
i
=
0
;
i
<
c
;
i
++)
{
for
(
int
i
=
0
;
i
<
c
;
i
++)
{
code
.
add
(
arg
(
insn
,
i
));
code
.
add
(
arg
(
insn
,
i
));
if
(
i
+
1
<
c
)
if
(
i
+
1
<
c
)
code
.
add
(
", "
);
code
.
add
(
", "
);
}
}
code
.
add
(
"}"
);
code
.
add
(
'}'
);
}
}
private
void
fillArray
(
FillArrayOp
insn
,
CodeWriter
code
)
throws
CodegenException
{
private
void
fillArray
(
FillArrayOp
insn
,
CodeWriter
code
)
throws
CodegenException
{
...
...
src/main/java/jadx/codegen/MethodGen.java
View file @
4e284c4c
...
@@ -133,7 +133,7 @@ public class MethodGen {
...
@@ -133,7 +133,7 @@ public class MethodGen {
}
else
{
}
else
{
argsCode
.
add
(
TypeGen
.
translate
(
classGen
,
arg
.
getType
()));
argsCode
.
add
(
TypeGen
.
translate
(
classGen
,
arg
.
getType
()));
}
}
argsCode
.
add
(
" "
);
argsCode
.
add
(
' '
);
argsCode
.
add
(
makeArgName
(
arg
));
argsCode
.
add
(
makeArgName
(
arg
));
i
++;
i
++;
...
@@ -253,7 +253,7 @@ public class MethodGen {
...
@@ -253,7 +253,7 @@ public class MethodGen {
makeFallbackMethod
(
code
,
mth
);
makeFallbackMethod
(
code
,
mth
);
code
.
decIndent
();
code
.
decIndent
();
code
.
startLine
(
"}"
);
code
.
startLine
(
'}'
);
code
.
startLine
(
"*/"
);
code
.
startLine
(
"*/"
);
}
}
...
...
src/main/java/jadx/codegen/RegionGen.java
View file @
4e284c4c
...
@@ -254,7 +254,7 @@ public class RegionGen extends InsnGen {
...
@@ -254,7 +254,7 @@ public class RegionGen extends InsnGen {
code
.
startLine
(
"} catch ("
);
code
.
startLine
(
"} catch ("
);
code
.
add
(
handler
.
isCatchAll
()
?
"Throwable"
:
useClass
(
handler
.
getCatchType
()));
code
.
add
(
handler
.
isCatchAll
()
?
"Throwable"
:
useClass
(
handler
.
getCatchType
()));
code
.
add
(
' '
);
code
.
add
(
' '
);
code
.
add
(
a
rg
(
handler
.
getArg
()));
code
.
add
(
mgen
.
assignA
rg
(
handler
.
getArg
()));
code
.
add
(
") {"
);
code
.
add
(
") {"
);
makeRegionIndent
(
code
,
region
);
makeRegionIndent
(
code
,
region
);
}
}
...
...
src/main/java/jadx/codegen/TypeGen.java
View file @
4e284c4c
...
@@ -22,6 +22,7 @@ public class TypeGen {
...
@@ -22,6 +22,7 @@ public class TypeGen {
return
stype
.
getLongName
();
return
stype
.
getLongName
();
}
}
@Deprecated
public
static
String
shortString
(
ArgType
type
)
{
public
static
String
shortString
(
ArgType
type
)
{
final
PrimitiveType
stype
=
type
.
getPrimitiveType
();
final
PrimitiveType
stype
=
type
.
getPrimitiveType
();
if
(
stype
==
null
)
if
(
stype
==
null
)
...
...
src/main/java/jadx/dex/info/FieldInfo.java
View file @
4e284c4c
...
@@ -16,7 +16,7 @@ public class FieldInfo {
...
@@ -16,7 +16,7 @@ public class FieldInfo {
return
new
FieldInfo
(
dex
,
index
);
return
new
FieldInfo
(
dex
,
index
);
}
}
pr
otected
FieldInfo
(
DexNode
dex
,
int
ind
)
{
pr
ivate
FieldInfo
(
DexNode
dex
,
int
ind
)
{
FieldId
field
=
dex
.
getFieldId
(
ind
);
FieldId
field
=
dex
.
getFieldId
(
ind
);
this
.
name
=
dex
.
getString
(
field
.
getNameIndex
());
this
.
name
=
dex
.
getString
(
field
.
getNameIndex
());
this
.
type
=
dex
.
getType
(
field
.
getTypeIndex
());
this
.
type
=
dex
.
getType
(
field
.
getTypeIndex
());
...
...
src/main/java/jadx/dex/instructions/IndexInsnNode.java
View file @
4e284c4c
...
@@ -5,7 +5,7 @@ import jadx.utils.InsnUtils;
...
@@ -5,7 +5,7 @@ import jadx.utils.InsnUtils;
public
class
IndexInsnNode
extends
InsnNode
{
public
class
IndexInsnNode
extends
InsnNode
{
pr
otected
final
Object
index
;
pr
ivate
final
Object
index
;
public
IndexInsnNode
(
InsnType
type
,
Object
index
,
int
argCount
)
{
public
IndexInsnNode
(
InsnType
type
,
Object
index
,
int
argCount
)
{
super
(
type
,
argCount
);
super
(
type
,
argCount
);
...
...
src/main/java/jadx/dex/instructions/args/ArgType.java
View file @
4e284c4c
...
@@ -587,10 +587,7 @@ public abstract class ArgType {
...
@@ -587,10 +587,7 @@ public abstract class ArgType {
return
false
;
return
false
;
}
}
// TODO: don't use toString
// TODO: don't use toString
if
(!
toString
().
equals
(
obj
.
toString
()))
{
return
toString
().
equals
(
obj
.
toString
());
return
false
;
}
}
return
true
;
}
}
}
src/main/java/jadx/dex/instructions/args/InsnArg.java
View file @
4e284c4c
...
@@ -72,4 +72,8 @@ public abstract class InsnArg extends Typed {
...
@@ -72,4 +72,8 @@ public abstract class InsnArg extends Typed {
return
false
;
return
false
;
}
}
public
int
getRegNum
()
{
throw
new
UnsupportedOperationException
(
"Must be called from RegisterArg"
);
}
}
}
src/main/java/jadx/dex/instructions/args/RegisterArg.java
View file @
4e284c4c
...
@@ -17,6 +17,7 @@ public class RegisterArg extends InsnArg {
...
@@ -17,6 +17,7 @@ public class RegisterArg extends InsnArg {
this
.
regNum
=
rn
;
this
.
regNum
=
rn
;
}
}
@Override
public
int
getRegNum
()
{
public
int
getRegNum
()
{
return
regNum
;
return
regNum
;
}
}
...
...
src/main/java/jadx/dex/instructions/args/TypedVar.java
View file @
4e284c4c
...
@@ -57,7 +57,7 @@ public class TypedVar {
...
@@ -57,7 +57,7 @@ public class TypedVar {
@Override
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
return
type
.
hashCode
()
*
31
+
(
(
name
==
null
)
?
0
:
name
.
hashCode
());
return
type
.
hashCode
()
*
31
+
(
name
==
null
?
0
:
name
.
hashCode
());
}
}
@Override
@Override
...
@@ -66,12 +66,12 @@ public class TypedVar {
...
@@ -66,12 +66,12 @@ public class TypedVar {
if
(
obj
==
null
)
return
false
;
if
(
obj
==
null
)
return
false
;
if
(
getClass
()
!=
obj
.
getClass
())
return
false
;
if
(
getClass
()
!=
obj
.
getClass
())
return
false
;
TypedVar
other
=
(
TypedVar
)
obj
;
TypedVar
other
=
(
TypedVar
)
obj
;
if
(!
type
.
equals
(
other
.
type
))
return
false
;
if
(
name
==
null
)
{
if
(
name
==
null
)
{
if
(
other
.
name
!=
null
)
return
false
;
if
(
other
.
name
!=
null
)
return
false
;
}
else
if
(!
name
.
equals
(
other
.
name
))
return
false
;
}
else
if
(!
name
.
equals
(
other
.
name
))
{
if
(
type
==
null
)
{
return
false
;
if
(
other
.
type
!=
null
)
return
false
;
}
}
else
if
(!
type
.
equals
(
other
.
type
))
return
false
;
return
true
;
return
true
;
}
}
...
...
src/main/java/jadx/dex/nodes/DexNode.java
View file @
4e284c4c
...
@@ -30,7 +30,7 @@ public class DexNode {
...
@@ -30,7 +30,7 @@ public class DexNode {
private
final
List
<
ClassNode
>
classes
=
new
ArrayList
<
ClassNode
>();
private
final
List
<
ClassNode
>
classes
=
new
ArrayList
<
ClassNode
>();
private
final
String
[]
strings
;
private
final
String
[]
strings
;
public
DexNode
(
RootNode
root
,
InputFile
input
)
throws
IOException
,
DecodeException
{
public
DexNode
(
RootNode
root
,
InputFile
input
)
{
this
.
root
=
root
;
this
.
root
=
root
;
this
.
dexBuf
=
input
.
getDexBuffer
();
this
.
dexBuf
=
input
.
getDexBuffer
();
...
...
src/main/java/jadx/dex/nodes/InsnNode.java
View file @
4e284c4c
...
@@ -71,7 +71,7 @@ public class InsnNode extends AttrNode {
...
@@ -71,7 +71,7 @@ public class InsnNode extends AttrNode {
public
boolean
containsArg
(
RegisterArg
arg
)
{
public
boolean
containsArg
(
RegisterArg
arg
)
{
for
(
InsnArg
a
:
arguments
)
{
for
(
InsnArg
a
:
arguments
)
{
if
(
a
==
arg
||
(
a
.
isRegister
()
&&
((
RegisterArg
)
a
)
.
getRegNum
()
==
arg
.
getRegNum
()))
if
(
a
==
arg
||
(
a
.
isRegister
()
&&
a
.
getRegNum
()
==
arg
.
getRegNum
()))
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
...
src/main/java/jadx/dex/nodes/MethodNode.java
View file @
4e284c4c
...
@@ -100,8 +100,7 @@ public class MethodNode extends AttrNode implements ILoadable {
...
@@ -100,8 +100,7 @@ public class MethodNode extends AttrNode implements ILoadable {
initJumps
(
insnByOffset
);
initJumps
(
insnByOffset
);
if
(
mthCode
.
getDebugInfoOffset
()
>
0
)
{
if
(
mthCode
.
getDebugInfoOffset
()
>
0
)
{
DebugInfoParser
debugInfo
=
new
DebugInfoParser
(
this
,
mthCode
.
getDebugInfoOffset
());
(
new
DebugInfoParser
(
this
,
mthCode
.
getDebugInfoOffset
(),
insnByOffset
)).
process
();
debugInfo
.
process
(
insnByOffset
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
DecodeException
(
this
,
"Load method exception"
,
e
);
throw
new
DecodeException
(
this
,
"Load method exception"
,
e
);
...
...
src/main/java/jadx/dex/visitors/BlockMakerVisitor.java
View file @
4e284c4c
...
@@ -30,6 +30,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
...
@@ -30,6 +30,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
// leave these instructions alone in block node
// leave these instructions alone in block node
private
static
final
Set
<
InsnType
>
separateInsns
=
EnumSet
.
of
(
private
static
final
Set
<
InsnType
>
separateInsns
=
EnumSet
.
of
(
InsnType
.
RETURN
,
InsnType
.
IF
,
InsnType
.
IF
,
InsnType
.
SWITCH
,
InsnType
.
SWITCH
,
InsnType
.
MONITOR_ENTER
,
InsnType
.
MONITOR_ENTER
,
...
@@ -165,12 +166,8 @@ public class BlockMakerVisitor extends AbstractVisitor {
...
@@ -165,12 +166,8 @@ public class BlockMakerVisitor extends AbstractVisitor {
}
}
}
}
}
}
computeDominators
(
mth
);
computeDominators
(
mth
);
markReturnBlocks
(
mth
);
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
markReturnBlocks
(
mth
,
block
);
}
int
i
=
0
;
int
i
=
0
;
while
(
modifyBlocksTree
(
mth
))
{
while
(
modifyBlocksTree
(
mth
))
{
...
@@ -178,6 +175,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
...
@@ -178,6 +175,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
cleanDomTree
(
mth
);
cleanDomTree
(
mth
);
// recalculate dominators tree
// recalculate dominators tree
computeDominators
(
mth
);
computeDominators
(
mth
);
markReturnBlocks
(
mth
);
i
++;
i
++;
if
(
i
>
100
)
if
(
i
>
100
)
...
@@ -273,7 +271,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
...
@@ -273,7 +271,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
BlockNode
idom
=
mth
.
getBasicBlocks
().
get
(
id
);
BlockNode
idom
=
mth
.
getBasicBlocks
().
get
(
id
);
block
.
setIDom
(
idom
);
block
.
setIDom
(
idom
);
idom
.
getDominatesOn
().
add
(
block
);
idom
.
getDominatesOn
().
add
(
block
);
}
else
if
(
block
!=
entryBlock
)
{
}
else
{
throw
new
JadxRuntimeException
(
"Can't find immediate dominator for block "
+
block
throw
new
JadxRuntimeException
(
"Can't find immediate dominator for block "
+
block
+
" in "
+
bs
+
" prec:"
+
block
.
getPredecessors
());
+
" in "
+
bs
+
" prec:"
+
block
.
getPredecessors
());
}
}
...
@@ -284,9 +282,8 @@ public class BlockMakerVisitor extends AbstractVisitor {
...
@@ -284,9 +282,8 @@ public class BlockMakerVisitor extends AbstractVisitor {
private
static
void
markLoops
(
MethodNode
mth
)
{
private
static
void
markLoops
(
MethodNode
mth
)
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
for
(
BlockNode
succ
:
block
.
getSuccessors
())
{
for
(
BlockNode
succ
:
block
.
getSuccessors
())
{
// Every successor that dominates its predecessor
// Every successor that dominates its predecessor is a header of a loop,
// must be the header of a loop.
// block -> succ is a back edge.
// That is, block -> succ is a back edge.
if
(
block
.
getDoms
().
get
(
succ
.
getId
()))
{
if
(
block
.
getDoms
().
get
(
succ
.
getId
()))
{
succ
.
getAttributes
().
add
(
AttributeFlag
.
LOOP_START
);
succ
.
getAttributes
().
add
(
AttributeFlag
.
LOOP_START
);
block
.
getAttributes
().
add
(
AttributeFlag
.
LOOP_END
);
block
.
getAttributes
().
add
(
AttributeFlag
.
LOOP_END
);
...
@@ -299,10 +296,12 @@ public class BlockMakerVisitor extends AbstractVisitor {
...
@@ -299,10 +296,12 @@ public class BlockMakerVisitor extends AbstractVisitor {
}
}
}
}
private
static
void
markReturnBlocks
(
MethodNode
mth
,
BlockNode
block
)
{
private
static
void
markReturnBlocks
(
MethodNode
mth
)
{
if
(
block
.
getInstructions
().
size
()
==
1
)
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
if
(
block
.
getInstructions
().
get
(
0
).
getType
()
==
InsnType
.
RETURN
)
if
(
block
.
getInstructions
().
size
()
==
1
)
{
block
.
getAttributes
().
add
(
AttributeFlag
.
RETURN
);
if
(
block
.
getInstructions
().
get
(
0
).
getType
()
==
InsnType
.
RETURN
)
block
.
getAttributes
().
add
(
AttributeFlag
.
RETURN
);
}
}
}
}
}
...
...
src/main/java/jadx/dex/visitors/BlockProcessingHelper.java
View file @
4e284c4c
...
@@ -45,9 +45,10 @@ public class BlockProcessingHelper {
...
@@ -45,9 +45,10 @@ public class BlockProcessingHelper {
// set correct type for 'move-exception' operation
// set correct type for 'move-exception' operation
RegisterArg
excArg
=
me
.
getResult
();
RegisterArg
excArg
=
me
.
getResult
();
if
(
excHandler
.
isCatchAll
())
if
(
excHandler
.
isCatchAll
())
excArg
.
getTypedVar
().
merg
e
(
ArgType
.
THROWABLE
);
excArg
.
getTypedVar
().
forceSetTyp
e
(
ArgType
.
THROWABLE
);
else
else
excArg
.
getTypedVar
().
merge
(
excHandler
.
getCatchType
().
getType
());
excArg
.
getTypedVar
().
forceSetType
(
excHandler
.
getCatchType
().
getType
());
// excArg.getTypedVar().merge(excHandler.getCatchType().getType());
excHandler
.
setArg
(
excArg
);
excHandler
.
setArg
(
excArg
);
block
.
getAttributes
().
add
(
handlerAttr
);
block
.
getAttributes
().
add
(
handlerAttr
);
...
...
src/main/java/jadx/dex/visitors/ConstInlinerVisitor.java
View file @
4e284c4c
...
@@ -34,7 +34,7 @@ public class ConstInlinerVisitor extends AbstractVisitor {
...
@@ -34,7 +34,7 @@ public class ConstInlinerVisitor extends AbstractVisitor {
}
}
}
}
p
ublic
static
boolean
checkInsn
(
MethodNode
mth
,
BlockNode
block
,
InsnNode
insn
)
{
p
rivate
static
boolean
checkInsn
(
MethodNode
mth
,
BlockNode
block
,
InsnNode
insn
)
{
if
(
insn
.
getType
()
==
InsnType
.
CONST
)
{
if
(
insn
.
getType
()
==
InsnType
.
CONST
)
{
if
(
insn
.
getArgsCount
()
==
1
if
(
insn
.
getArgsCount
()
==
1
&&
insn
.
getArg
(
0
).
isLiteral
()
&&
insn
.
getArg
(
0
).
isLiteral
()
...
...
src/main/java/jadx/dex/visitors/DotGraphVisitor.java
View file @
4e284c4c
...
@@ -75,7 +75,7 @@ public class DotGraphVisitor extends AbstractVisitor {
...
@@ -75,7 +75,7 @@ public class DotGraphVisitor extends AbstractVisitor {
dot
.
add
(
conn
);
dot
.
add
(
conn
);
dot
.
startLine
(
"}"
);
dot
.
startLine
(
'}'
);
dot
.
startLine
();
dot
.
startLine
();
String
fileName
=
Utils
.
escape
(
mth
.
getMethodInfo
().
getShortId
())
String
fileName
=
Utils
.
escape
(
mth
.
getMethodInfo
().
getShortId
())
...
@@ -99,7 +99,7 @@ public class DotGraphVisitor extends AbstractVisitor {
...
@@ -99,7 +99,7 @@ public class DotGraphVisitor extends AbstractVisitor {
processRegion
(
mth
,
c
,
dot
,
conn
);
processRegion
(
mth
,
c
,
dot
,
conn
);
}
}
dot
.
startLine
(
"}"
);
dot
.
startLine
(
'}'
);
}
else
if
(
region
instanceof
BlockNode
)
{
}
else
if
(
region
instanceof
BlockNode
)
{
processBlock
(
mth
,
(
BlockNode
)
region
,
dot
,
conn
);
processBlock
(
mth
,
(
BlockNode
)
region
,
dot
,
conn
);
}
}
...
...
src/main/java/jadx/dex/visitors/MethodInlinerVisitor.java
View file @
4e284c4c
...
@@ -40,8 +40,7 @@ public class MethodInlinerVisitor extends AbstractVisitor {
...
@@ -40,8 +40,7 @@ public class MethodInlinerVisitor extends AbstractVisitor {
if
(
block
.
getInstructions
().
size
()
==
1
)
{
if
(
block
.
getInstructions
().
size
()
==
1
)
{
InsnNode
insn
=
block
.
getInstructions
().
get
(
0
);
InsnNode
insn
=
block
.
getInstructions
().
get
(
0
);
addInlineAttr
(
mth
,
insn
);
addInlineAttr
(
mth
,
insn
);
return
;
}
}
}
}
}
}
}
}
...
...
src/main/java/jadx/utils/BlockUtils.java
View file @
4e284c4c
...
@@ -39,7 +39,7 @@ public class BlockUtils {
...
@@ -39,7 +39,7 @@ public class BlockUtils {
return
list
.
get
(
1
);
return
list
.
get
(
1
);
}
}
p
ublic
static
List
<
BlockNode
>
cleanBlockList
(
List
<
BlockNode
>
list
)
{
p
rivate
static
List
<
BlockNode
>
cleanBlockList
(
List
<
BlockNode
>
list
)
{
List
<
BlockNode
>
ret
=
new
ArrayList
<
BlockNode
>(
list
.
size
());
List
<
BlockNode
>
ret
=
new
ArrayList
<
BlockNode
>(
list
.
size
());
for
(
BlockNode
block
:
list
)
{
for
(
BlockNode
block
:
list
)
{
if
(!
block
.
getAttributes
().
contains
(
AttributeType
.
EXC_HANDLER
))
if
(!
block
.
getAttributes
().
contains
(
AttributeType
.
EXC_HANDLER
))
...
@@ -52,11 +52,8 @@ public class BlockUtils {
...
@@ -52,11 +52,8 @@ public class BlockUtils {
if
(
from
.
getCleanSuccessors
().
contains
(
to
))
if
(
from
.
getCleanSuccessors
().
contains
(
to
))
return
false
;
// already checked
return
false
;
// already checked
if
(!
from
.
getSuccessors
().
contains
(
to
))
return
from
.
getSuccessors
().
contains
(
to
);
return
false
;
// not even successor
}
return
true
;
}
/**
/**
* Remove exception handlers from block nodes bitset
* Remove exception handlers from block nodes bitset
...
...
src/main/java/jadx/utils/StringUtils.java
View file @
4e284c4c
...
@@ -22,7 +22,7 @@ public class StringUtils {
...
@@ -22,7 +22,7 @@ public class StringUtils {
return
'\''
+
res
.
toString
()
+
'\''
;
return
'\''
+
res
.
toString
()
+
'\''
;
}
}
p
ublic
static
void
processChar
(
int
c
,
StringBuilder
res
)
{
p
rivate
static
void
processChar
(
int
c
,
StringBuilder
res
)
{
switch
(
c
)
{
switch
(
c
)
{
case
'\n'
:
case
'\n'
:
res
.
append
(
"\\n"
);
res
.
append
(
"\\n"
);
...
...
src/main/java/jadx/utils/Utils.java
View file @
4e284c4c
...
@@ -126,7 +126,7 @@ public class Utils {
...
@@ -126,7 +126,7 @@ public class Utils {
public
static
String
getJadxVersion
()
{
public
static
String
getJadxVersion
()
{
try
{
try
{
Enumeration
<
URL
>
resources
=
Enumeration
<
URL
>
resources
=
new
Utils
().
getClass
()
.
getClassLoader
().
getResources
(
"META-INF/MANIFEST.MF"
);
Utils
.
class
.
getClassLoader
().
getResources
(
"META-INF/MANIFEST.MF"
);
while
(
resources
.
hasMoreElements
())
{
while
(
resources
.
hasMoreElements
())
{
Manifest
manifest
=
new
Manifest
(
resources
.
nextElement
().
openStream
());
Manifest
manifest
=
new
Manifest
(
resources
.
nextElement
().
openStream
());
String
ver
=
manifest
.
getMainAttributes
().
getValue
(
"jadx-version"
);
String
ver
=
manifest
.
getMainAttributes
().
getValue
(
"jadx-version"
);
...
...
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