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
8a706193
Commit
8a706193
authored
Nov 03, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix indexed loop checks
parent
9d77f5f5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
2 deletions
+103
-2
LoopRegionVisitor.java
...ava/jadx/core/dex/visitors/regions/LoopRegionVisitor.java
+4
-2
TestArith3.java
...rc/test/java/jadx/tests/integration/arith/TestArith3.java
+43
-0
TestVariables5.java
...java/jadx/tests/integration/variables/TestVariables5.java
+56
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/regions/LoopRegionVisitor.java
View file @
8a706193
...
...
@@ -104,8 +104,10 @@ public class LoopRegionVisitor extends AbstractVisitor implements IRegionVisitor
return
false
;
}
// can't make loop if argument from increment instruction is assign in loop
for
(
InsnArg
iArg
:
incrInsn
.
getArguments
())
{
if
(
iArg
.
isRegister
()
&&
assignOnlyInLoop
(
mth
,
loopRegion
,
(
RegisterArg
)
iArg
))
{
List
<
RegisterArg
>
args
=
new
LinkedList
<
RegisterArg
>();
incrInsn
.
getRegisterArgs
(
args
);
for
(
RegisterArg
iArg
:
args
)
{
if
(
assignOnlyInLoop
(
mth
,
loopRegion
,
(
RegisterArg
)
iArg
))
{
return
false
;
}
}
...
...
jadx-core/src/test/java/jadx/tests/integration/arith/TestArith3.java
0 → 100644
View file @
8a706193
package
jadx
.
tests
.
integration
.
arith
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
hamcrest
.
CoreMatchers
.
not
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestArith3
extends
IntegrationTest
{
public
static
class
TestCls
{
private
int
vp
;
private
void
test
(
byte
[]
buffer
)
{
int
n
=
((
buffer
[
3
]
&
255
)
+
4
)
+
((
buffer
[
2
]
&
15
)
<<
8
);
while
(
n
+
4
<
buffer
.
length
)
{
int
c
=
buffer
[
n
]
&
255
;
int
p
=
(
buffer
[
n
+
2
]
&
255
)
+
((
buffer
[
n
+
1
]
&
31
)
<<
8
);
int
len
=
(
buffer
[
n
+
4
]
&
255
)
+
((
buffer
[
n
+
3
]
&
15
)
<<
8
);
switch
(
c
)
{
case
27
:
this
.
vp
=
p
;
break
;
}
n
+=
len
+
5
;
}
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"while (n + 4 < buffer.length) {"
));
assertThat
(
code
,
containsOne
(
"n += len + 5;"
));
assertThat
(
code
,
not
(
containsString
(
"; n += len + 5) {"
)));
}
}
jadx-core/src/test/java/jadx/tests/integration/variables/TestVariables5.java
0 → 100644
View file @
8a706193
package
jadx
.
tests
.
integration
.
variables
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
hamcrest
.
CoreMatchers
.
not
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
TestVariables5
extends
IntegrationTest
{
public
static
class
TestCls
{
public
String
f
=
"str//ing"
;
private
boolean
enabled
;
private
void
testIfInLoop
()
{
int
j
=
0
;
for
(
int
i
=
0
;
i
<
f
.
length
();
i
++)
{
char
ch
=
f
.
charAt
(
i
);
if
(
ch
==
'/'
)
{
j
++;
if
(
j
==
2
)
{
setEnabled
(
true
);
return
;
}
}
}
setEnabled
(
false
);
}
private
void
setEnabled
(
boolean
b
)
{
this
.
enabled
=
b
;
}
public
void
check
()
{
setEnabled
(
false
);
testIfInLoop
();
assertTrue
(
enabled
);
}
}
@Test
public
void
test
()
{
noDebugInfo
();
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
not
(
containsString
(
"int i2++;"
)));
assertThat
(
code
,
containsOne
(
"int i = 0;"
));
assertThat
(
code
,
containsOne
(
"i++;"
));
}
}
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