Skip to content
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

Fix build_imports #530

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kohnakagawa
Copy link
Contributor

Hi

This pull request fixes the issue (#517).

The current implementation of build_import_table does not check the correspondence between the imported functions and the trampolines. So, if we add an import function entry by add_entry and build IAT by calling build_import_table, its correspondence is shifted back one by one.

I illustrate this situation.

Before adding a new import entry, the correspondence between IAT and trampolines is correct.

図1

However, after adding wcsrchr (illustrated by orange color), its correspondence is incorrect. In this case, when we try to call puts function, _cexit function is called instead.

図2

To fix this issue, I added a new member manually_added_ to ImportEntry class to distinguish whether the entry is manually added or not. If the entry is a manually-added one, linking between the original IAT entry and the trampoline is skipped.

@romainthomas
Copy link
Member

Note: there is this working branch: peimports that tries to improve the way we patch import

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants