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
fde431d1
Commit
fde431d1
authored
Nov 27, 2013
by
skylot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3 from 13-beta2/master
Core fix
parents
b44a1e3a
272e0d37
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
7 deletions
+62
-7
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+2
-0
BlockMakerVisitor.java
...c/main/java/jadx/core/dex/visitors/BlockMakerVisitor.java
+0
-1
ModVisitor.java
...core/src/main/java/jadx/core/dex/visitors/ModVisitor.java
+12
-0
RegionMaker.java
...main/java/jadx/core/dex/visitors/regions/RegionMaker.java
+36
-6
TestLoopCondition.java
.../src/test/java/jadx/tests/internal/TestLoopCondition.java
+12
-0
No files found.
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
fde431d1
...
...
@@ -148,6 +148,8 @@ public class InsnGen {
String
thisClass
=
mth
.
getParentClass
().
getFullName
();
if
(
thisClass
.
startsWith
(
field
.
getDeclClass
().
getFullName
()))
{
return
field
.
getName
();
}
else
if
(
field
.
getDeclClass
().
getFullName
().
startsWith
(
mth
.
getParentClass
().
getPackage
()
+
".R"
))
{
return
field
.
getDeclClass
().
getNameWithoutPackage
()
+
'.'
+
field
.
getName
();
}
else
{
return
useClass
(
field
.
getDeclClass
())
+
'.'
+
field
.
getName
();
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/BlockMakerVisitor.java
View file @
fde431d1
...
...
@@ -353,7 +353,6 @@ public class BlockMakerVisitor extends AbstractVisitor {
// splice return block if several predecessors presents
for
(
BlockNode
block
:
mth
.
getExitBlocks
())
{
if
(
block
.
getInstructions
().
size
()
==
1
&&
block
.
getInstructions
().
get
(
0
).
getArgsCount
()
>
0
&&
!
block
.
getInstructions
().
get
(
0
).
getAttributes
().
contains
(
AttributeType
.
CATCH_BLOCK
)
&&
!
block
.
getAttributes
().
contains
(
AttributeFlag
.
SYNTHETIC
))
{
List
<
BlockNode
>
preds
=
new
ArrayList
<
BlockNode
>(
block
.
getPredecessors
());
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ModVisitor.java
View file @
fde431d1
...
...
@@ -86,6 +86,18 @@ public class ModVisitor extends AbstractVisitor {
}
else
{
replaceInsn
(
block
,
i
,
co
);
}
}
else
{
if
(
inv
.
getArgsCount
()
>
0
)
{
for
(
int
j
=
0
;
j
<
inv
.
getArgsCount
();
j
++)
{
InsnArg
arg
=
inv
.
getArg
(
j
);
if
(
arg
.
isLiteral
())
{
f
=
parentClass
.
getConstFieldByLiteralArg
((
LiteralArg
)
arg
);
if
(
f
!=
null
)
{
arg
.
wrapInstruction
(
new
IndexInsnNode
(
InsnType
.
SGET
,
f
.
getFieldInfo
(),
0
));
}
}
}
}
}
break
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java
View file @
fde431d1
...
...
@@ -265,10 +265,10 @@ public class RegionMaker {
&&
r
.
getInstructions
().
size
()
>
0
&&
r
.
getInstructions
().
get
(
0
).
getType
()
==
InsnType
.
RETURN
)
{
next
.
getAttributes
().
add
(
new
ForceReturnAttr
(
r
.
getInstructions
().
get
(
0
)));
}
else
{
}
/*/
else {
next.getAttributes().add(AttributeFlag.BREAK);
stack.addExit(r);
}
}
/**/
}
else
{
stack
.
addExit
(
next
);
}
...
...
@@ -492,8 +492,10 @@ public class RegionMaker {
IfCondition
nestedCondition
=
IfCondition
.
fromIfNode
(
nestedIfInsn
);
if
(
isPathExists
(
bElse
,
nestedIfBlock
))
{
// else branch
if
(
bThen
!=
nbThen
)
{
if
(
bThen
!=
nbElse
)
{
if
(
bThen
!=
nbThen
&&
!
isEqualReturns
(
bThen
,
nbThen
))
{
if
(
bThen
!=
nbElse
&&
!
isEqualReturns
(
bThen
,
nbElse
))
{
// not connected conditions
break
;
}
...
...
@@ -503,8 +505,10 @@ public class RegionMaker {
condition
=
IfCondition
.
merge
(
Mode
.
OR
,
condition
,
nestedCondition
);
}
else
{
// then branch
if
(
bElse
!=
nbElse
)
{
if
(
bElse
!=
nbThen
)
{
if
(
bElse
!=
nbElse
&&
!
isEqualReturns
(
bElse
,
nbElse
))
{
if
(
bElse
!=
nbThen
&&
!
isEqualReturns
(
bElse
,
nbThen
))
{
// not connected conditions
break
;
}
...
...
@@ -516,6 +520,8 @@ public class RegionMaker {
result
=
new
IfInfo
();
result
.
setCondition
(
condition
);
nestedIfBlock
.
getAttributes
().
add
(
AttributeFlag
.
SKIP
);
bThen
.
getAttributes
().
add
(
AttributeFlag
.
SKIP
);
if
(
merged
!=
null
)
{
merged
.
add
(
nestedIfBlock
);
}
...
...
@@ -683,4 +689,28 @@ public class RegionMaker {
handler
.
getHandlerRegion
().
getAttributes
().
add
(
excHandlerAttr
);
}
private
boolean
isEqualReturns
(
BlockNode
b1
,
BlockNode
b2
)
{
if
(
b1
==
b2
)
{
return
true
;
}
if
(
b1
==
null
||
b2
==
null
)
{
return
false
;
}
if
(
b1
.
getInstructions
().
size
()
+
b2
.
getInstructions
().
size
()
!=
2
)
{
return
false
;
}
if
(!
b1
.
getAttributes
().
contains
(
AttributeFlag
.
RETURN
)
||
!
b2
.
getAttributes
().
contains
(
AttributeFlag
.
RETURN
))
{
return
false
;
}
if
(
b1
.
getInstructions
().
get
(
0
).
getArgsCount
()
>
0
)
{
if
(
b1
.
getInstructions
().
get
(
0
).
getArg
(
0
)
!=
b2
.
getInstructions
().
get
(
0
).
getArg
(
0
))
{
return
false
;
}
}
return
true
;
}
}
jadx-core/src/test/java/jadx/tests/internal/TestLoopCondition.java
View file @
fde431d1
...
...
@@ -39,6 +39,16 @@ public class TestLoopCondition extends InternalJadxTest {
}
return
i
;
}
private
void
testMoreComplexIfInLoop
(
java
.
util
.
ArrayList
<
String
>
list
)
throws
Exception
{
for
(
int
i
=
0
;
i
!=
16
&&
i
<
255
;
i
++)
{
list
.
set
(
i
,
"ABC"
);
if
(
i
==
128
)
{
return
;
}
list
.
set
(
i
,
"DEF"
);
}
}
}
@Test
...
...
@@ -50,5 +60,7 @@ public class TestLoopCondition extends InternalJadxTest {
assertThat
(
code
,
containsString
(
"i < f.length()"
));
assertThat
(
code
,
containsString
(
"while (a && i < 10) {"
));
assertThat
(
code
,
containsString
(
"list.set(i, \"ABC\")"
));
assertThat
(
code
,
containsString
(
"list.set(i, \"DEF\")"
));
}
}
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