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
ffe739b7
Unverified
Commit
ffe739b7
authored
Aug 22, 2018
by
skylot
Committed by
GitHub
Aug 22, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #343 from Donlon/master
Solve unreplaced fields names when deobfuscation is on (#241)
parents
ff7df381
bd05be6f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
19 deletions
+64
-19
JadxDecompiler.java
jadx-core/src/main/java/jadx/api/JadxDecompiler.java
+1
-1
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+12
-10
InsnDecoder.java
...src/main/java/jadx/core/dex/instructions/InsnDecoder.java
+5
-0
ClassNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
+0
-1
DexNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/DexNode.java
+31
-0
RootNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/RootNode.java
+14
-6
InsnUtils.java
jadx-core/src/main/java/jadx/core/utils/InsnUtils.java
+1
-1
No files found.
jadx-core/src/main/java/jadx/api/JadxDecompiler.java
View file @
ffe739b7
...
...
@@ -42,7 +42,7 @@ import jadx.core.xmlgen.ResourcesSaver;
* jadx.load();
* jadx.save();
* </code></pre>
*
<p/>
*
* Instead of 'save()' you can iterate over decompiled classes:
* <pre><code>
* for(JavaClass cls : jadx.getClasses()) {
...
...
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
ffe739b7
...
...
@@ -137,13 +137,7 @@ public class InsnGen {
private
void
instanceField
(
CodeWriter
code
,
FieldInfo
field
,
InsnArg
arg
)
throws
CodegenException
{
ClassNode
pCls
=
mth
.
getParentClass
();
FieldNode
fieldNode
=
pCls
.
searchField
(
field
);
while
(
fieldNode
==
null
&&
pCls
.
getParentClass
()
!=
pCls
&&
pCls
.
getParentClass
()
!=
null
)
{
pCls
=
pCls
.
getParentClass
();
fieldNode
=
pCls
.
searchField
(
field
);
}
FieldNode
fieldNode
=
pCls
.
dex
().
root
().
deepResolveField
(
field
);
if
(
fieldNode
!=
null
)
{
FieldReplaceAttr
replace
=
fieldNode
.
get
(
AType
.
FIELD_REPLACE
);
if
(
replace
!=
null
)
{
...
...
@@ -163,7 +157,11 @@ public class InsnGen {
if
(
fieldNode
!=
null
)
{
code
.
attachAnnotation
(
fieldNode
);
}
code
.
add
(
field
.
getAlias
());
if
(
fieldNode
==
null
)
{
code
.
add
(
field
.
getAlias
());
}
else
{
code
.
add
(
fieldNode
.
getAlias
());
}
}
public
static
void
makeStaticFieldAccess
(
CodeWriter
code
,
FieldInfo
field
,
ClassGen
clsGen
)
{
...
...
@@ -176,11 +174,15 @@ public class InsnGen {
}
code
.
add
(
'.'
);
}
FieldNode
fieldNode
=
clsGen
.
getClassNode
().
dex
().
resolveField
(
field
);
FieldNode
fieldNode
=
clsGen
.
getClassNode
().
dex
().
r
oot
().
deepR
esolveField
(
field
);
if
(
fieldNode
!=
null
)
{
code
.
attachAnnotation
(
fieldNode
);
}
code
.
add
(
field
.
getAlias
());
if
(
fieldNode
==
null
)
{
code
.
add
(
field
.
getAlias
());
}
else
{
code
.
add
(
fieldNode
.
getAlias
());
}
}
protected
void
staticField
(
CodeWriter
code
,
FieldInfo
field
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/InsnDecoder.java
View file @
ffe739b7
...
...
@@ -2,7 +2,9 @@ package jadx.core.dex.instructions;
import
java.io.EOFException
;
import
com.android.dex.ClassData
;
import
com.android.dex.Code
;
import
com.android.dex.FieldId
;
import
com.android.dx.io.OpcodeInfo
;
import
com.android.dx.io.Opcodes
;
import
com.android.dx.io.instructions.DecodedInstruction
;
...
...
@@ -10,6 +12,9 @@ import com.android.dx.io.instructions.FillArrayDataPayloadDecodedInstruction;
import
com.android.dx.io.instructions.PackedSwitchPayloadDecodedInstruction
;
import
com.android.dx.io.instructions.ShortArrayCodeInput
;
import
com.android.dx.io.instructions.SparseSwitchPayloadDecodedInstruction
;
import
jadx.core.dex.info.ClassInfo
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.FieldNode
;
import
org.jetbrains.annotations.NotNull
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
View file @
ffe739b7
...
...
@@ -323,7 +323,6 @@ public class ClassNode extends LineAttrNode implements ILoadable, IDexNode {
return
null
;
}
@TestOnly
public
FieldNode
searchFieldByName
(
String
name
)
{
for
(
FieldNode
f
:
fields
)
{
if
(
f
.
getName
().
equals
(
name
))
{
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/DexNode.java
View file @
ffe739b7
...
...
@@ -95,6 +95,7 @@ public class DexNode implements IDexNode {
return
resolveClass
(
ClassInfo
.
fromType
(
root
,
type
));
}
@Deprecated
@Nullable
public
MethodNode
resolveMethod
(
@NotNull
MethodInfo
mth
)
{
ClassNode
cls
=
resolveClass
(
mth
.
getDeclClass
());
...
...
@@ -134,6 +135,7 @@ public class DexNode implements IDexNode {
return
null
;
}
@Deprecated
@Nullable
public
FieldNode
resolveField
(
FieldInfo
field
)
{
ClassNode
cls
=
resolveClass
(
field
.
getDeclClass
());
...
...
@@ -143,6 +145,35 @@ public class DexNode implements IDexNode {
return
null
;
}
@Nullable
FieldNode
deepResolveField
(
@NotNull
ClassNode
cls
,
FieldInfo
fieldInfo
)
{
FieldNode
field
=
cls
.
searchFieldByName
(
fieldInfo
.
getName
());
if
(
field
!=
null
)
{
return
field
;
}
FieldNode
found
;
ArgType
superClass
=
cls
.
getSuperClass
();
if
(
superClass
!=
null
)
{
ClassNode
superNode
=
resolveClass
(
superClass
);
if
(
superNode
!=
null
)
{
found
=
deepResolveField
(
superNode
,
fieldInfo
);
if
(
found
!=
null
)
{
return
found
;
}
}
}
for
(
ArgType
iFaceType
:
cls
.
getInterfaces
())
{
ClassNode
iFaceNode
=
resolveClass
(
iFaceType
);
if
(
iFaceNode
!=
null
)
{
found
=
deepResolveField
(
iFaceNode
,
fieldInfo
);
if
(
found
!=
null
)
{
return
found
;
}
}
}
return
null
;
}
public
DexFile
getDexFile
()
{
return
file
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/RootNode.java
View file @
ffe739b7
...
...
@@ -5,6 +5,8 @@ import java.io.InputStream;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.android.dex.Dex
;
import
jadx.core.dex.info.FieldInfo
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.slf4j.Logger
;
...
...
@@ -84,12 +86,9 @@ public class RootNode {
}
ResTableParser
parser
=
new
ResTableParser
();
try
{
ResourcesLoader
.
decodeStream
(
arsc
,
new
ResourcesLoader
.
ResourceDecoder
()
{
@Override
public
ResContainer
decode
(
long
size
,
InputStream
is
)
throws
IOException
{
parser
.
decode
(
is
);
return
null
;
}
ResourcesLoader
.
decodeStream
(
arsc
,
(
size
,
is
)
->
{
parser
.
decode
(
is
);
return
null
;
});
}
catch
(
JadxException
e
)
{
LOG
.
error
(
"Failed to parse '.arsc' file"
,
e
);
...
...
@@ -184,6 +183,15 @@ public class RootNode {
return
cls
.
dex
().
deepResolveMethod
(
cls
,
mth
.
makeSignature
(
false
));
}
@Nullable
public
FieldNode
deepResolveField
(
@NotNull
FieldInfo
field
)
{
ClassNode
cls
=
resolveClass
(
field
.
getDeclClass
());
if
(
cls
==
null
)
{
return
null
;
}
return
cls
.
dex
().
deepResolveField
(
cls
,
field
);
}
public
List
<
DexNode
>
getDexNodes
()
{
return
dexNodes
;
}
...
...
jadx-core/src/main/java/jadx/core/utils/InsnUtils.java
View file @
ffe739b7
...
...
@@ -78,7 +78,7 @@ public class InsnUtils {
return
((
ConstClassNode
)
insn
).
getClsType
();
case
SGET:
FieldInfo
f
=
(
FieldInfo
)
((
IndexInsnNode
)
insn
).
getIndex
();
FieldNode
fieldNode
=
dex
.
resolveField
(
f
);
FieldNode
fieldNode
=
dex
.
r
oot
().
deepR
esolveField
(
f
);
if
(
fieldNode
==
null
)
{
LOG
.
warn
(
"Field {} not found in dex {}"
,
f
,
dex
);
return
null
;
...
...
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