win handler: Provide a wmain() entry point

Crashpad’s own build always uses wWinMain(), the default entry point for
/subsystem:windows, producing crashpad_handler.exe. crashpad_handler.com
is a /subsystem:console version produced by running editbin on a copy of
crashpad_handler.exe. This leaves the entry point intact, so both copies
use wWinMain(). crashpad_handler.com does not use wmain() as
traditionally used by /subsystem:console programs.

For the in-Chromium build’s tests, it is conveient to produce the
/subsystem:console version, crashpad_handler.com, directly as linker
output, as opposed to using editbin to transform a /subsystem:windows
version. This /subsystem:console version uses the normal wmain() entry
point.

By providing both wWinMain() and wmain(), both build types can be
accommodated.

Bug: chromium:779790
Change-Id: Ieb784db0cc245c6e4c12fb1dd83b8b95e159bdec
Reviewed-on: https://chromium-review.googlesource.com/746161
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
This commit is contained in:
Mark Mentovai 2017-10-31 00:06:31 -04:00
Родитель 81eced5192
Коммит a0f4f294b1
1 изменённых файлов: 13 добавлений и 0 удалений

Просмотреть файл

@ -22,10 +22,13 @@
#endif
#if defined(OS_MACOSX)
int main(int argc, char* argv[]) {
return crashpad::HandlerMain(argc, argv, nullptr);
}
#elif defined(OS_WIN)
namespace {
int HandlerMainAdaptor(int argc, char* argv[]) {
@ -34,7 +37,17 @@ int HandlerMainAdaptor(int argc, char* argv[]) {
} // namespace
// The default entry point for /subsystem:windows. In Crashpads own build, this
// is used by crashpad_handler.exe. Its also used by crashpad_handler.com when
// produced by editbin from a copy of crashpad_handler.exe.
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, wchar_t*, int) {
return crashpad::ToolSupport::Wmain(__argc, __wargv, HandlerMainAdaptor);
}
// The default entry point for /subsystem:console. This is not currently used by
// Crashpads own build, but may be used by other builds.
int wmain(int argc, wchar_t* argv[]) {
return crashpad::ToolSupport::Wmain(argc, argv, HandlerMainAdaptor);
}
#endif // OS_MACOSX