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
7d983f28
Commit
7d983f28
authored
Jun 16, 2018
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix catch block argument if move-exception instruction is missing (#295)
parent
3b2b5417
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
12 deletions
+22
-12
BlockExceptionHandler.java
.../core/dex/visitors/blocksmaker/BlockExceptionHandler.java
+21
-10
ProcessTryCatchRegions.java
...adx/core/dex/visitors/regions/ProcessTryCatchRegions.java
+1
-2
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockExceptionHandler.java
View file @
7d983f28
package
jadx
.
core
.
dex
.
visitors
.
blocksmaker
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
jadx.core.dex.attributes.AFlag
;
import
jadx.core.dex.attributes.AType
;
import
jadx.core.dex.instructions.InsnType
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.NamedArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.nodes.BlockNode
;
import
jadx.core.dex.nodes.InsnNode
;
...
...
@@ -19,6 +23,8 @@ import jadx.core.utils.InstructionRemover;
public
class
BlockExceptionHandler
extends
AbstractVisitor
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
BlockExceptionHandler
.
class
);
@Override
public
void
visit
(
MethodNode
mth
)
{
if
(
mth
.
isNoCode
())
{
...
...
@@ -47,20 +53,22 @@ public class BlockExceptionHandler extends AbstractVisitor {
}
InsnNode
me
=
block
.
getInstructions
().
get
(
0
);
ExcHandlerAttr
handlerAttr
=
me
.
get
(
AType
.
EXC_HANDLER
);
if
(
handlerAttr
==
null
||
me
.
getType
()
!=
InsnType
.
MOVE_EXCEPTION
)
{
if
(
handlerAttr
==
null
)
{
return
;
}
ExceptionHandler
excHandler
=
handlerAttr
.
getHandler
();
block
.
addAttr
(
handlerAttr
);
// set correct type for 'move-exception' operation
ArgType
type
=
excHandler
.
isCatchAll
()
?
ArgType
.
THROWABLE
:
excHandler
.
getCatchType
().
getType
();
RegisterArg
resArg
=
me
.
getResult
();
resArg
=
InsnArg
.
reg
(
resArg
.
getRegNum
(),
type
);
me
.
setResult
(
resArg
);
me
.
add
(
AFlag
.
DONT_INLINE
);
excHandler
.
setArg
(
resArg
);
ArgType
argType
=
excHandler
.
isCatchAll
()
?
ArgType
.
THROWABLE
:
excHandler
.
getCatchType
().
getType
();
if
(
me
.
getType
()
==
InsnType
.
MOVE_EXCEPTION
)
{
// set correct type for 'move-exception' operation
RegisterArg
resArg
=
InsnArg
.
reg
(
me
.
getResult
().
getRegNum
(),
argType
);
me
.
setResult
(
resArg
);
me
.
add
(
AFlag
.
DONT_INLINE
);
excHandler
.
setArg
(
resArg
);
}
else
{
// handler arguments not used
excHandler
.
setArg
(
new
NamedArg
(
"unused"
,
argType
));
}
}
private
static
void
processExceptionHandlers
(
MethodNode
mth
,
BlockNode
block
)
{
...
...
@@ -147,5 +155,8 @@ public class BlockExceptionHandler extends AbstractVisitor {
break
;
}
}
if
(
handler
.
getHandlerBlock
()
==
null
)
{
LOG
.
warn
(
"Exception handler block not set for {}, mth: {}"
,
handler
,
mth
);
}
}
}
jadx-core/src/main/java/jadx/core/dex/visitors/regions/ProcessTryCatchRegions.java
View file @
7d983f28
...
...
@@ -86,8 +86,7 @@ public class ProcessTryCatchRegions extends AbstractRegionVisitor {
if
(
domBlocks
.
size
()
!=
1
)
{
domBlock
=
BlockUtils
.
getTopBlock
(
domBlocks
);
if
(
domBlock
==
null
)
{
throw
new
JadxRuntimeException
(
"Exception block dominator not found, method:"
+
mth
+
". bs: "
+
domBlocks
);
throw
new
JadxRuntimeException
(
"Exception block dominator not found, method:"
+
mth
+
", dom blocks: "
+
domBlocks
);
}
}
else
{
domBlock
=
domBlocks
.
get
(
0
);
...
...
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