[Scummvm-git-logs] scummvm master -> b527b573cf2fd25085c0ea2dcd3c83a7182a1b74

bluegr bluegr at gmail.com
Sun Jun 9 12:42:11 CEST 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
b527b573cf WIN32: Let the PE header control showing the console.


Commit: b527b573cf2fd25085c0ea2dcd3c83a7182a1b74
    https://github.com/scummvm/scummvm/commit/b527b573cf2fd25085c0ea2dcd3c83a7182a1b74
Author: Henrik "Henke37" Andersson (henke at henke37.cjb.net)
Date: 2019-06-09T13:42:06+03:00

Commit Message:
WIN32: Let the PE header control showing the console.

This applies DRY to the console config and avoids junk code changes seen by git.

Changed paths:
    backends/platform/sdl/win32/win32.cpp


diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp
index aada5b4..30ebf9d 100644
--- a/backends/platform/sdl/win32/win32.cpp
+++ b/backends/platform/sdl/win32/win32.cpp
@@ -74,9 +74,23 @@ void OSystem_Win32::init() {
 	OSystem_SDL::init();
 }
 
+WORD GetCurrentSubsystem() {
+	// HMODULE is the module base address. And the PIMAGE_DOS_HEADER is located at the beginning.
+	PIMAGE_DOS_HEADER EXEHeader = (PIMAGE_DOS_HEADER)GetModuleHandle(NULL);
+	assert(EXEHeader->e_magic == IMAGE_DOS_SIGNATURE);
+	// PIMAGE_NT_HEADERS is bitness dependant.
+	// Conveniently, since it's for our own process, it's always the correct bitness.
+	// IMAGE_NT_HEADERS has to be found using a byte offset from the EXEHeader,
+	// which requires the ugly cast.
+	PIMAGE_NT_HEADERS PEHeader = (PIMAGE_NT_HEADERS)(((char*)EXEHeader) + EXEHeader->e_lfanew);
+	assert(PEHeader->Signature == IMAGE_NT_SIGNATURE);
+	return PEHeader->OptionalHeader.Subsystem;
+}
+
 void OSystem_Win32::initBackend() {
-	// Console window is enabled by default on Windows
-	ConfMan.registerDefault("console", true);
+	// The console window is enabled for the console subsystem,
+	// since Windows already creates the console window for us
+	ConfMan.registerDefault("console", GetCurrentSubsystem() == IMAGE_SUBSYSTEM_WINDOWS_CUI);
 
 	// Enable or disable the window console window
 	if (ConfMan.getBool("console")) {





More information about the Scummvm-git-logs mailing list