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
07402ba4
Commit
07402ba4
authored
Oct 19, 2013
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix "null" enum field
parent
d6069820
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
2 deletions
+43
-2
RegisterArg.java
...ain/java/jadx/core/dex/instructions/args/RegisterArg.java
+24
-1
DexNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/DexNode.java
+9
-0
EnumVisitor.java
...ore/src/main/java/jadx/core/dex/visitors/EnumVisitor.java
+4
-1
TestEnum.java
jadx-samples/src/main/java/jadx/samples/TestEnum.java
+6
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/instructions/args/RegisterArg.java
View file @
07402ba4
package
jadx
.
core
.
dex
.
instructions
.
args
;
import
jadx.core.dex.attributes.AttributeType
;
import
jadx.core.dex.info.FieldInfo
;
import
jadx.core.dex.instructions.ConstClassNode
;
import
jadx.core.dex.instructions.ConstStringNode
;
import
jadx.core.dex.instructions.IndexInsnNode
;
import
jadx.core.dex.instructions.InsnType
;
import
jadx.core.dex.nodes.DexNode
;
import
jadx.core.dex.nodes.FieldNode
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.nodes.parser.FieldValueAttr
;
import
jadx.core.dex.visitors.InstructionRemover
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
RegisterArg
extends
InsnArg
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
RegisterArg
.
class
);
protected
final
int
regNum
;
public
RegisterArg
(
int
rn
)
{
...
...
@@ -45,7 +56,7 @@ public class RegisterArg extends InsnArg {
*
* @return LiteralArg, String or ArgType
*/
public
Object
getConstValue
()
{
public
Object
getConstValue
(
DexNode
dex
)
{
InsnNode
parInsn
=
getAssignInsn
();
if
(
parInsn
!=
null
)
{
InsnType
insnType
=
parInsn
.
getType
();
...
...
@@ -56,6 +67,18 @@ public class RegisterArg extends InsnArg {
return
((
ConstStringNode
)
parInsn
).
getString
();
case
CONST_CLASS:
return
((
ConstClassNode
)
parInsn
).
getClsType
();
case
SGET:
FieldInfo
f
=
(
FieldInfo
)
((
IndexInsnNode
)
parInsn
).
getIndex
();
FieldNode
fieldNode
=
dex
.
resolveField
(
f
);
if
(
fieldNode
!=
null
)
{
FieldValueAttr
attr
=
(
FieldValueAttr
)
fieldNode
.
getAttributes
().
get
(
AttributeType
.
FIELD_VALUE
);
if
(
attr
!=
null
)
{
return
attr
.
getValue
();
}
}
else
{
LOG
.
warn
(
"Field {} not found in dex {}"
,
f
,
dex
);
}
break
;
}
}
return
null
;
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/DexNode.java
View file @
07402ba4
package
jadx
.
core
.
dex
.
nodes
;
import
jadx.core.dex.info.ClassInfo
;
import
jadx.core.dex.info.FieldInfo
;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.utils.exceptions.DecodeException
;
...
...
@@ -64,6 +65,14 @@ public class DexNode {
return
null
;
}
public
FieldNode
resolveField
(
FieldInfo
field
)
{
ClassNode
cls
=
resolveClass
(
field
.
getDeclClass
());
if
(
cls
!=
null
)
{
return
cls
.
searchField
(
field
);
}
return
null
;
}
public
Map
<
Object
,
FieldNode
>
getConstFields
()
{
return
constFields
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/EnumVisitor.java
View file @
07402ba4
...
...
@@ -117,7 +117,10 @@ public class EnumVisitor extends AbstractVisitor {
RegisterArg
nameArg
=
(
RegisterArg
)
insn
.
getArg
(
0
);
// InsnArg pos = insn.getArg(1);
// TODO add check: pos == j
String
name
=
(
String
)
nameArg
.
getConstValue
();
String
name
=
(
String
)
nameArg
.
getConstValue
(
cls
.
dex
());
if
(
name
==
null
)
{
throw
new
JadxException
(
"Unknown enum field name: "
+
cls
);
}
EnumField
field
=
new
EnumField
(
name
,
insn
.
getArgsCount
()
-
2
);
attr
.
getFields
().
add
(
field
);
...
...
jadx-samples/src/main/java/jadx/samples/TestEnum.java
View file @
07402ba4
...
...
@@ -11,6 +11,12 @@ public class TestEnum extends AbstractTest {
NORTH
,
SOUTH
,
EAST
,
WEST
}
public
static
final
String
DOG
=
"DOG"
;
public
enum
Animal
{
CAT
,
DOG
}
private
static
int
three
=
3
;
public
enum
Numbers
{
...
...
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