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

Unclear how to setup and use PeNet #214

Open
aroenai opened this issue Oct 30, 2021 · 2 comments
Open

Unclear how to setup and use PeNet #214

aroenai opened this issue Oct 30, 2021 · 2 comments

Comments

@aroenai
Copy link

aroenai commented Oct 30, 2021

I realize this is probably geared more towards more advanced users but I can't seem to find any information on how to setup a project and use PeNet for changing imports. The https://secanablog.wordpress.com/2020/06/12/add-an-import-to-a-pe-file/ page doesn't go into any detail for any of the environment setup and goes straight to code.

Essentially I'm looking to replace the imports on an old Win32 game to remove the need for calling WinG32.dll and the depreciated WinHelpA api without the need for convoluted DLL injection that can trigger AV.

@secana
Copy link
Owner

secana commented Nov 1, 2021

Hi, here is short "how to add an import" documentation http://secana.github.io/PeNet/articles/imports.html

I'm not sure if replacing the imports will work. Some in the code, a function will call WinHelpA and the loader needs to be able to find it under the same name. As import are resolved on runtime and not statically, you cannot change that in the PE file.

Maybe a much easier approach would be to use the way that Windows searches for DLLs. If you place your own WinG32.dll with an exported stub for WinHelpA in the same directory as the binary you want to patch, it should load your DLL first and resolve the export from there instead of the real DLL in c:\windows\system32. In that case you would not need to change the original binary at all.

@aroenai
Copy link
Author

aroenai commented Nov 1, 2021

That's what I'm doing already ( https://github.com/aroenai/Monopoly95 ), most of the imports are just renamed functions in modern gdi32.dll since this came out in the Win 3.1 Era. I'm not concerned about changing the assembly since I'm already having to make other changes and should have space to modify it so it works with the new imports.

The original question remains though, since you linked to more or less the same article I did, how do I setup a project to use PeNet? You just have code examples without context.

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

No branches or pull requests

2 participants