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

initterm crash when loading unreal engine binaries #42

Open
maximegmd opened this issue Mar 18, 2022 · 1 comment
Open

initterm crash when loading unreal engine binaries #42

maximegmd opened this issue Mar 18, 2022 · 1 comment

Comments

@maximegmd
Copy link
Contributor

maximegmd commented Mar 18, 2022

Using the sample loader project on an Unreal Engine 4 compiled binary crashes with a null access within the initterm call in __scrt_common_main_seh.

So far I haven't been able to locate the cause of this, I have tried disabling reloc but had no success.

Note that the function called by initterm uses TLS, I am thinking that maybe run_tls_callbacks may not work correctly or that some additional TLS code is required.

@hasherezade
Copy link
Owner

Hi! The best would be if you could share the binary, so that I can have a look at it. You can send it to my e-mail: hasherezade-at-pm.me

Is it 32 or 64 bit?
You are right that there may be something wrong with how TLS callbacks are executed, but I also suspect it may be related to exceptions handler.
During the manual load (as libPEconv does) the exception handlers are not installed - so they also need to be set up manually. I implemented it for 64-bit targets (although it is not enabled in the default loader). You can see it in this sample code:

if (!peconv::setup_exceptions(loaded_pe, v_size)) {

Which is a part of a testcase 18:

case 18: return tests::test_load_with_exception_table(test_arg);

For the 32-bit targets I didn't implement it yet (it is very different than in 64-bit, the same APIs are not available).

But if your application is 64bit we can make a test, and check if running it with exceptions table installed could help.
Just compile libPEConv along with test cases, and then run:

tests.exe 18 {your_app.exe}

This will load your app via loader with exceptions table set up.
Please let me know what is the result.

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