-
Notifications
You must be signed in to change notification settings - Fork 282
Fix callback chaining for _initterm function table walking #277
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
Draft
williballenthin
wants to merge
5
commits into
master
Choose a base branch
from
worktree-fix-initterm-107
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+64
−13
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
44e0ef1
ci: add permissions
williballenthin 1d7d0c3
v2.0.0b1
williballenthin dedc300
Merge pull request #263 from mandiant/wb-unicorn2
mr-tz 0c35735
Fix callback chaining and implement _initterm table parsing
williballenthin a08e984
Fix ruff UP031: use f-strings instead of percent format
williballenthin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ on: | |
| pull_request: | ||
| branches: [master] | ||
|
|
||
| permissions: read-all | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| __version__ = "2.0.0a1" | ||
| __version__ = "2.0.0b1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't think these tests add enough value, lets remove the file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| def test_initterm_reports_function_table(config, load_test_bin, run_test): | ||
| """_initterm and _initterm_e should parse the function pointer table | ||
| and include the entries in the API event args.""" | ||
| data = load_test_bin("argv_test_x86.exe.xz") | ||
| report = run_test(config, data) | ||
| ep = report.entry_points | ||
|
|
||
| initterm_events = [] | ||
| for evt in ep[0].events or []: | ||
| if evt.event == "api" and "_initterm" in evt.api_name: | ||
| initterm_events.append(evt) | ||
|
|
||
| assert len(initterm_events) > 0, "expected at least one _initterm call" | ||
|
|
||
| for evt in initterm_events: | ||
| assert len(evt.args) == 3, f"expected 3 args (pfbegin, pfend, func_table) but got {len(evt.args)}: {evt.args}" | ||
| func_table_str = evt.args[2] | ||
| assert "0x" in func_table_str, f"expected hex addresses in func table: {func_table_str}" | ||
|
|
||
|
|
||
| def test_initterm_does_not_crash_emulation(config, load_test_bin, run_test): | ||
| """_initterm should not crash the emulation - main() should still execute.""" | ||
| data = load_test_bin("argv_test_x86.exe.xz") | ||
| report = run_test(config, data, argv=["arg1"]) | ||
| ep = report.entry_points | ||
|
|
||
| printfs = [] | ||
| for evt in ep[0].events or []: | ||
| if evt.event == "api" and "__stdio_common_vfprintf" in evt.api_name: | ||
| printfs.append(evt) | ||
|
|
||
| assert len(printfs) > 0, "main() should have executed and called printf" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this nesting doesn't seem correct. why is
if run.api_callbackstested twice?