[WIP] Basic C++ support for windows #918
Closed
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.
This PR is based on #917. Complete that one first.
#377 mentions that a simple hello world from C++ on windows, causes a crash.
Demo Code + Crash
HelloWorld.Cpp build with vs2019 for x86 (32 bit)
Invocation using qiling before applying this PR (dev branch).
The reason for this crash is, that
std::cout
is not initialized.std::cout
is usually initialized by the dll entry point of msvcp140d.dll.There are two ways of fixing this:
This PR focuses on the 2nd approach. The supplied changes patch some windows API functions so that the DllMain of msvcp140d.dll runs through and does not longer crash. This will intialize
std::cout
and prevent the crash inmain()
.In the current state of the PR "hello world" does not appear on the console yet. However, the sample application does no longer crash and instead terminates successfully after running main with exit code 0 🥳 .
New output
generated by qiling after applying this PRNote that uncaught_exception is a getter. There is no exception happening.
Next Steps:
std::cout
to the console.Checklist
Which kind of PR do you create?
Coding convention?
Extra tests?
Changelog?
Target branch?
One last thing