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
6a99d004
Commit
6a99d004
authored
Apr 05, 2015
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix enum fields name after obfuscation (fix #51)
parent
f87bf3f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
12 deletions
+23
-12
ClassGen.java
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
+6
-3
EnumClassAttr.java
...in/java/jadx/core/dex/attributes/nodes/EnumClassAttr.java
+7
-6
EnumVisitor.java
...ore/src/main/java/jadx/core/dex/visitors/EnumVisitor.java
+10
-3
No files found.
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
View file @
6a99d004
...
...
@@ -127,9 +127,9 @@ public class ClassGen {
.
remove
(
AccessFlags
.
ACC_STATIC
);
}
// 'static' modifier not allowed for top classes (not inner)
// 'static'
and 'private'
modifier not allowed for top classes (not inner)
if
(!
cls
.
getAlias
().
isInner
())
{
af
=
af
.
remove
(
AccessFlags
.
ACC_STATIC
);
af
=
af
.
remove
(
AccessFlags
.
ACC_STATIC
)
.
remove
(
AccessFlags
.
ACC_PRIVATE
)
;
}
annotationGen
.
addForClass
(
clsCode
);
...
...
@@ -370,7 +370,7 @@ public class ClassGen {
InsnGen
igen
=
null
;
for
(
Iterator
<
EnumField
>
it
=
enumFields
.
getFields
().
iterator
();
it
.
hasNext
();
)
{
EnumField
f
=
it
.
next
();
code
.
startLine
(
f
.
get
Name
());
code
.
startLine
(
f
.
get
Field
().
getAlias
());
ConstructorInsn
constrInsn
=
f
.
getConstrInsn
();
if
(
constrInsn
.
getArgsCount
()
>
f
.
getStartArg
())
{
if
(
igen
==
null
)
{
...
...
@@ -393,6 +393,9 @@ public class ClassGen {
code
.
startLine
();
}
code
.
add
(
';'
);
if
(
isFieldsPresents
())
{
code
.
startLine
();
}
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/attributes/nodes/EnumClassAttr.java
View file @
6a99d004
...
...
@@ -2,6 +2,7 @@ package jadx.core.dex.attributes.nodes;
import
jadx.core.dex.attributes.AType
;
import
jadx.core.dex.attributes.IAttribute
;
import
jadx.core.dex.info.FieldInfo
;
import
jadx.core.dex.instructions.mods.ConstructorInsn
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.MethodNode
;
...
...
@@ -12,19 +13,19 @@ import java.util.List;
public
class
EnumClassAttr
implements
IAttribute
{
public
static
class
EnumField
{
private
final
String
name
;
private
final
FieldInfo
field
;
private
final
ConstructorInsn
constrInsn
;
private
final
int
startArg
;
private
ClassNode
cls
;
public
EnumField
(
String
name
,
ConstructorInsn
co
,
int
startArg
)
{
this
.
name
=
name
;
public
EnumField
(
FieldInfo
field
,
ConstructorInsn
co
,
int
startArg
)
{
this
.
field
=
field
;
this
.
constrInsn
=
co
;
this
.
startArg
=
startArg
;
}
public
String
getName
()
{
return
name
;
public
FieldInfo
getField
()
{
return
field
;
}
public
ConstructorInsn
getConstrInsn
()
{
...
...
@@ -45,7 +46,7 @@ public class EnumClassAttr implements IAttribute {
@Override
public
String
toString
()
{
return
name
+
"("
+
constrInsn
+
") "
+
cls
;
return
field
+
"("
+
constrInsn
+
") "
+
cls
;
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/EnumVisitor.java
View file @
6a99d004
package
jadx
.
core
.
dex
.
visitors
;
import
jadx.core.codegen.TypeGen
;
import
jadx.core.deobf.NameMapper
;
import
jadx.core.dex.attributes.AFlag
;
import
jadx.core.dex.attributes.nodes.EnumClassAttr
;
import
jadx.core.dex.attributes.nodes.EnumClassAttr.EnumField
;
...
...
@@ -138,12 +139,18 @@ public class EnumVisitor extends AbstractVisitor {
if
(!
clsInfo
.
equals
(
classInfo
)
&&
!
constrCls
.
getAccessFlags
().
isEnum
())
{
continue
;
}
FieldInfo
fieldInfo
=
(
FieldInfo
)
((
IndexInsnNode
)
putInsn
).
getIndex
();
String
name
=
getConstString
(
cls
.
dex
(),
co
.
getArg
(
0
));
if
(
name
==
null
)
{
throw
new
JadxException
(
"Unknown enum field name: "
+
cls
);
if
(
name
!=
null
&&
!
fieldInfo
.
getAlias
().
equals
(
name
)
&&
NameMapper
.
isValidIdentifier
(
name
))
{
// LOG.debug("Rename enum field: '{}' to '{}' in {}", fieldInfo.getName(), name, cls);
fieldInfo
.
setAlias
(
name
);
}
EnumField
field
=
new
EnumField
(
name
,
co
,
2
);
EnumField
field
=
new
EnumField
(
fieldInfo
,
co
,
2
);
attr
.
getFields
().
add
(
field
);
if
(!
co
.
getClassType
().
equals
(
classInfo
))
{
// enum contains additional methods
for
(
ClassNode
innerCls
:
cls
.
getInnerClasses
())
{
...
...
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