diff --git a/BUILD.gn b/BUILD.gn index 72097fb..a338eed 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -7,12 +7,12 @@ import("//build/config/win/manifest.gni") # Main executable executable("xp_activate32") { configs -= [ - #"//build/config/win:console", - #"//build/config/win:nominmax", + "//build/config/win:console", + "//build/config/win:nominmax", ] configs += [ - #"//build/config/win:windowed", + "//build/config/win:windowed", ":xp_activate32_config", ] @@ -32,7 +32,7 @@ source_set("xp_activate32_sources") { configs -= [ "//build/config/win:nominmax", ] # Must explicitly set this for sources - #configs += [ "//build/config/win:windowed", ] + configs += [ "//build/config/win:windowed", ] configs += [ ":xp_activate32_config", diff --git a/src/xp_activate32.cc b/src/xp_activate32.cc index 6285416..5691bd5 100644 --- a/src/xp_activate32.cc +++ b/src/xp_activate32.cc @@ -972,7 +972,27 @@ INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) return FALSE; } -int main() { +int WINAPI wWinMain(_In_ HINSTANCE hInstance, + _In_opt_ HINSTANCE hPrevInstance, + _In_ WCHAR *pCmdLine, + _In_ INT nCmdShow) { + UNREFERENCED_PARAMETER(hPrevInstance); + + // Allow and allocate conhost + if (!AllocConsole()) { + return 1; + } + // File handler pointer to a dummy file, possibly an actual logfile + FILE* fNonExistFile = fDummyFile; + freopen_s(&fNonExistFile, "CONOUT$", "w", stdout); + freopen_s(&fNonExistFile, "CONOUT$", "w", stderr); + + LPWSTR cmdLine = GetCommandLineW(); + if (cmdLine == nullptr || cmdLine == NULL) { + std::wcerr << L"GetCommandLineW failed!" << std::endl; + return 1; + } + std::wstring welcome_str = L"Welcome to XP_Activate32 ver. " + getVersionW(); std::wcout << welcome_str << std::endl; INITCOMMONCONTROLSEX cc = {sizeof(INITCOMMONCONTROLSEX), ICC_STANDARD_CLASSES}; @@ -989,7 +1009,7 @@ int main() { hIcon[i] = getDialogIcon(false, 194, x, y); } - INT_PTR status = DialogBox(NULL, MAKEINTRESOURCE(100), NULL, &DialogProc); + INT_PTR status = DialogBoxW(NULL, MAKEINTRESOURCE(100), NULL, &DialogProc); for (i = 0; i < 2; i++) { DestroyIcon(hIcon[i]); diff --git a/src/xp_activate32.h b/src/xp_activate32.h index 3921855..a80030a 100644 --- a/src/xp_activate32.h +++ b/src/xp_activate32.h @@ -93,12 +93,6 @@ static void PutIdToSystem(HWND hDlg); INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -std::wstring getVersionW(); - -HANDLE LoadImageFromDLL(UINT resourceId, - UINT imgType, - int width, - int height, - UINT flags); +static FILE* fDummyFile; #endif // XP_ACTIVATE32_H_ diff --git a/xp_activate32.vcxproj b/xp_activate32.vcxproj index f9e9288..478e2f8 100644 --- a/xp_activate32.vcxproj +++ b/xp_activate32.vcxproj @@ -74,13 +74,13 @@ Level3 true - WIN32;_WIN32;DEBUG;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_WIN32;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false MultiThreadedDebug stdcpp17 - Console + Windows 5.01 true true @@ -93,13 +93,13 @@ true true true - WIN32;_WIN32;NDEBUG;_NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_WIN32;NDEBUG;_NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false MultiThreaded stdcpp17 - Console + Windows 5.01 true true @@ -112,13 +112,13 @@ Level3 true - WIN32;_WIN32;WIN64;_WIN64;DEBUG;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_WIN32;WIN64;_WIN64;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false MultiThreadedDebug stdcpp17 - Console + Windows 5.02 true true @@ -131,13 +131,13 @@ true true true - WIN32;_WIN32;WIN64;_WIN64;NDEBUG;_NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_WIN32;WIN64;_WIN64;NDEBUG;_NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false MultiThreaded stdcpp17 - Console + Windows 5.02 true true