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
2cfc208a
Commit
2cfc208a
authored
Nov 18, 2013
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix constant fields values retrieval
parent
5dc4c28d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
23 deletions
+39
-23
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+1
-1
ClassNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
+36
-20
ProcessVariables.java
...java/jadx/core/dex/visitors/regions/ProcessVariables.java
+2
-2
No files found.
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
2cfc208a
...
...
@@ -402,7 +402,7 @@ public class InsnGen {
/* fallback mode instructions */
case
IF:
assert
isFallback
();
assert
isFallback
()
:
"if insn in not fallback mode"
;
IfNode
ifInsn
=
(
IfNode
)
insn
;
String
cond
=
arg
(
insn
.
getArg
(
0
))
+
" "
+
ifInsn
.
getOp
().
getSymbol
()
+
" "
+
(
ifInsn
.
isZeroCmp
()
?
"0"
:
arg
(
insn
.
getArg
(
1
)));
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
View file @
2cfc208a
...
...
@@ -13,6 +13,7 @@ import jadx.core.dex.info.FieldInfo;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.LiteralArg
;
import
jadx.core.dex.instructions.args.PrimitiveType
;
import
jadx.core.dex.nodes.parser.AnnotationsParser
;
import
jadx.core.dex.nodes.parser.FieldValueAttr
;
import
jadx.core.dex.nodes.parser.StaticValuesParser
;
...
...
@@ -140,10 +141,10 @@ public class ClassNode extends LineAttrNode implements ILoadable {
if
(
accFlags
.
isStatic
()
&&
accFlags
.
isFinal
())
{
FieldValueAttr
fv
=
(
FieldValueAttr
)
f
.
getAttributes
().
get
(
AttributeType
.
FIELD_VALUE
);
if
(
fv
!=
null
&&
fv
.
getValue
()
!=
null
)
{
if
(
accFlags
.
isPublic
())
if
(
accFlags
.
isPublic
())
{
dex
.
getConstFields
().
put
(
fv
.
getValue
(),
f
);
else
constFields
.
put
(
fv
.
getValue
(),
f
);
}
constFields
.
put
(
fv
.
getValue
(),
f
);
}
}
}
...
...
@@ -237,34 +238,49 @@ public class ClassNode extends LineAttrNode implements ILoadable {
return
fields
;
}
public
FieldNode
getConstField
(
Object
o
)
{
public
FieldNode
getConstField
(
Object
obj
)
{
return
getConstField
(
obj
,
true
);
}
public
FieldNode
getConstField
(
Object
obj
,
boolean
searchGlobal
)
{
ClassNode
cn
=
this
;
FieldNode
field
;
do
{
field
=
cn
.
constFields
.
get
(
o
);
field
=
cn
.
constFields
.
get
(
obj
);
}
while
(
field
==
null
&&
(
cn
.
clsInfo
.
getParentClass
()
!=
null
)
&&
(
cn
=
dex
.
resolveClass
(
cn
.
clsInfo
.
getParentClass
()))
!=
null
);
&&
(
cn
.
clsInfo
.
getParentClass
()
!=
null
)
&&
(
cn
=
dex
.
resolveClass
(
cn
.
clsInfo
.
getParentClass
()))
!=
null
);
if
(
field
==
null
)
field
=
dex
.
getConstFields
().
get
(
o
);
if
(
field
==
null
&&
searchGlobal
)
{
field
=
dex
.
getConstFields
().
get
(
obj
);
}
return
field
;
}
public
FieldNode
getConstFieldByLiteralArg
(
LiteralArg
arg
)
{
ArgType
type
=
arg
.
getType
();
PrimitiveType
type
=
arg
.
getType
().
getPrimitiveType
();
if
(
type
==
null
)
{
return
null
;
}
long
literal
=
arg
.
getLiteral
();
if
(
type
.
equals
(
ArgType
.
DOUBLE
))
return
getConstField
(
Double
.
longBitsToDouble
(
literal
));
else
if
(
type
.
equals
(
ArgType
.
FLOAT
))
return
getConstField
(
Float
.
intBitsToFloat
((
int
)
literal
));
else
if
(
Math
.
abs
(
literal
)
>
0x1
)
{
if
(
type
.
equals
(
ArgType
.
INT
))
return
getConstField
((
int
)
literal
);
else
if
(
type
.
equals
(
ArgType
.
LONG
))
return
getConstField
(
literal
);
switch
(
type
)
{
case
BOOLEAN:
return
getConstField
(
literal
==
1
,
false
);
case
CHAR:
return
getConstField
((
char
)
literal
,
Math
.
abs
(
literal
)
>
1
);
case
BYTE:
return
getConstField
((
byte
)
literal
,
Math
.
abs
(
literal
)
>
1
);
case
SHORT:
return
getConstField
((
short
)
literal
,
Math
.
abs
(
literal
)
>
1
);
case
INT:
return
getConstField
((
int
)
literal
,
Math
.
abs
(
literal
)
>
1
);
case
LONG:
return
getConstField
(
literal
,
Math
.
abs
(
literal
)
>
1
);
case
FLOAT:
return
getConstField
(
Float
.
intBitsToFloat
((
int
)
literal
),
true
);
case
DOUBLE:
return
getConstField
(
Double
.
longBitsToDouble
(
literal
),
true
);
}
return
null
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/ProcessVariables.java
View file @
2cfc208a
...
...
@@ -13,9 +13,9 @@ import jadx.core.utils.RegionUtils;
import
jadx.core.utils.exceptions.JadxException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
...
...
@@ -65,7 +65,7 @@ public class ProcessVariables extends AbstractVisitor {
@Override
public
void
visit
(
MethodNode
mth
)
throws
JadxException
{
final
Map
<
RegisterArg
,
Usage
>
usageMap
=
new
HashMap
<
RegisterArg
,
Usage
>();
final
Map
<
RegisterArg
,
Usage
>
usageMap
=
new
Linked
HashMap
<
RegisterArg
,
Usage
>();
// collect all variables usage
IRegionVisitor
collect
=
new
TracedRegionVisitor
()
{
...
...
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