-
-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not analyzing an x64 SEH handler after RaiseException #2247
Comments
Also of note is that |
Doing |
Looks like for the binary I supplied, this is never entered: Lines 790 to 815 in 56c6e83
Even with enabling |
This change got it working for the test binary: diff --git a/librz/analysis/fcn.c b/librz/analysis/fcn.c
index 35afbbc7a..df76ba572 100644
--- a/librz/analysis/fcn.c
+++ b/librz/analysis/fcn.c
@@ -805,7 +805,7 @@ static RzAnalysisBBEndCause run_basic_block_analysis(RzAnalysisTaskItem *item, R
rz_analysis_function_remove_block(fcn, bb);
}
rz_analysis_block_unref(bb);
- bb = fcn_append_basic_block(analysis, fcn, addr);
+ bb = fcn_append_basic_block(analysis, fcn, bb->jump);
if (!bb) {
gotoBeach(RZ_ANALYSIS_RET_ERROR);
} (Can submit a PR with this if wanted, note that this code also has a stray debugging Using the following command sequence:
(Might want to consider unsetting noreturn on RaiseException by default (And maybe RtlRaiseException?, or others?)) But I still wasn't able to get it to analyze P.S. I'm still getting a constant "Function was modified. Reanalyze?" while entering visual graph on that function, not sure why... Also it might make sense for it to link one opcode before |
Yep. The Like the code in Line 361 in 6af80b3
|
@GustavoLCR did you implement this? |
With latest changes:
P.S. I got |
We will need to add a better test for this as well. |
Your checklist for this pull request - [x] I've read the guidelines for contributing to this repository - [x] I made sure to follow the project's coding style - [ ] I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why. - [ ] I've added tests that prove my fix is effective or that my feature works (if possible) - [ ] I've updated the rizin book with the relevant information (if needed) Detailed description Bin - Load exception information by default Analysis - Make analyzing exception scopes the default - Analyze all exception sources as functions - Do not hack basic blocks flow to add try/catch information Graph - Add an edge pointing to the catch block for each basic block inside the try scope - Add configuration graph.trycatch to control if graphing the exception blocks is enabled Problems 8ff06e9 Is basically copy-pasted logic from block.c This can make graphs a lot noisier Cutter will have to implement its own version of the logic if it wants to copy rizin in showing the connection between the blocks and its catch blocks I didn't add tests yet Test plan Open bins\pe\microsoft_seh_tests\x64\xcpt4.exe for example Optional: idp to load debug info for binary aaa Optional: .iw to show try catch scopes as flags s main Enter visual graph mode, make sure all edges, lines are painted correctly, and that there area now new edges pointing each basic block to its catch block if it is inside a try scope Open file from rizinorg#2247 aaa s main Enter visual graph mode, make sure issue is fixed Closing issues Closes rizinorg#2247
Your checklist for this pull request - [x] I've read the guidelines for contributing to this repository - [x] I made sure to follow the project's coding style - [ ] I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why. - [ ] I've added tests that prove my fix is effective or that my feature works (if possible) - [ ] I've updated the rizin book with the relevant information (if needed) Detailed description Bin - Load exception information by default Analysis - Make analyzing exception scopes the default - Analyze all exception sources as functions - Do not hack basic blocks flow to add try/catch information Graph - Add an edge pointing to the catch block for each basic block inside the try scope - Add configuration graph.trycatch to control if graphing the exception blocks is enabled Problems 8ff06e9 Is basically copy-pasted logic from block.c This can make graphs a lot noisier Cutter will have to implement its own version of the logic if it wants to copy rizin in showing the connection between the blocks and its catch blocks I didn't add tests yet Test plan Open bins\pe\microsoft_seh_tests\x64\xcpt4.exe for example Optional: idp to load debug info for binary aaa Optional: .iw to show try catch scopes as flags s main Enter visual graph mode, make sure all edges, lines are painted correctly, and that there area now new edges pointing each basic block to its catch block if it is inside a try scope Open file from rizinorg#2247 aaa s main Enter visual graph mode, make sure issue is fixed Closing issues Closes rizinorg#2247
Work environment
rizin -v
full output, not truncated (mandatory)Expected behavior
I expect rizin to correctly identify x64 SEH handlers after
RaiseException
and add their relevant basic blocks/ranges to the function.I encountered this while trying to look at
OutputDebugStringA
inkernelbase.dll
.Actual behavior
The function is truncated on
RaiseException
. This happens whether I enableanalysis.trycatch
or not, which I assume is needed to enable analyzing exception handlers?Steps to reproduce the behavior
Binary: main.zip
Additional Logs, screenshots, source code, configuration dump, ...
The text was updated successfully, but these errors were encountered: