HACK: Add Version to the propsheet

This commit is contained in:
Dustin Howett 2019-04-22 18:05:04 -07:00
parent 71e19cd825
commit 00db8704b6
9 changed files with 165 additions and 3 deletions

View file

@ -586,6 +586,8 @@ typedef struct _CONSOLE_STATE_INFO {
COLORREF DefaultForeground;
COLORREF DefaultBackground;
BOOL TerminalScrolling;
LPWSTR VersionString;
/* END V2 CONSOLE_STATE_INFO */
} CONSOLE_STATE_INFO, *PCONSOLE_STATE_INFO;

View file

@ -6,7 +6,7 @@
</ClCompile>
<Link>
<ProgramDatabaseFile>$(OutDir)$(TargetName)FullPDB.pdb</ProgramDatabaseFile>
<AdditionalDependencies>onecore_apiset.lib;dwrite.lib;dxgi.lib;d2d1.lib;d3d11.lib;shcore.lib;uxtheme.lib;dwmapi.lib;winmm.lib;pathcch.lib;propsys.lib;uiautomationcore.lib;Shlwapi.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>onecore_apiset.lib;version.lib;dwrite.lib;dxgi.lib;d2d1.lib;d3d11.lib;shcore.lib;uxtheme.lib;dwmapi.lib;winmm.lib;pathcch.lib;propsys.lib;uiautomationcore.lib;Shlwapi.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<!--
There's a property that dictates which libraries are linked by default: MinimalCoreWin.
When it's enabled, only a sparing few libraries are injected into Link.AdditionalDependencies.

View file

@ -80,7 +80,7 @@
</ClCompile>
<Link>
<AllowIsolation>true</AllowIsolation>
<AdditionalManifestDependencies>type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'</AdditionalManifestDependencies>
<!--AdditionalManifestDependencies>type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'</AdditionalManifestDependencies-->
</Link>
</ItemDefinitionGroup>
<!-- Careful reordering these. Some default props (contained in these files) are order sensitive. -->

View file

@ -12,10 +12,47 @@
#include <windows.h>
#include "resource.h"
#ifndef EXTERNAL_BUILD
#include "conhost.rcv"
#ifndef EXTERNAL_BUILD
#include <ntverp.h>
#include <common.ver>
#else
//////////
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1, 0, 0, 2019
PRODUCTVERSION 1, 0, 0, 2019
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", VER_FILEDESCRIPTION_STR
VALUE "FileVersion", "1.0.0-20190111-APPX dev/main-07d84ed8+dirty\0"
VALUE "InternalName", VER_INTERNALNAME_STR
VALUE "OriginalFilename", "OpenConsole.exe"
VALUE "ProductName", "Confans"
VALUE "ProductVersion", "1.0.0-20190111-APPX\0"
END
END
BLOCK "VarFileInfo"
BEGIN
/* The following line should only be modified for localized versions. */
/* It consists of any number of WORD,WORD pairs, with each pair */
/* describing a language,codepage combination supported by the file. */
/* */
/* For example, a file might have values "0x409,1252" indicating that it */
/* supports English language (0x409) in the Windows ANSI codepage (1252). */
VALUE "Translation", 0x409, 1252
END
END
//////////
#endif
IDI_APPICON ICON "..\\..\\..\\res\\console.ico"

View file

@ -299,6 +299,10 @@ void Menu::s_ShowPropertiesDialog(HWND const hwnd, BOOL const Defaults)
{
delete[] allocatedLinkTitle;
}
if (StateInfo.VersionString != nullptr)
{
delete[] StateInfo.VersionString;
}
}
[[nodiscard]]
@ -384,6 +388,47 @@ HRESULT Menu::s_GetConsoleState(CONSOLE_STATE_INFO * const pStateInfo)
pStateInfo->DefaultBackground = gci.GetDefaultBackgroundColor();
pStateInfo->TerminalScrolling = gci.IsTerminalScrolling();
{
HMODULE hSelf = GetModuleHandle(nullptr);
WCHAR moduleFilename[MAX_PATH];
GetModuleFileNameW(hSelf, &moduleFilename[0], MAX_PATH);
DWORD versionLength = GetFileVersionInfoSizeExW(0, moduleFilename, 0);
VS_FIXEDFILEINFO* vinfo{nullptr};
LPWSTR vi{nullptr};
if (versionLength > 0)
{
void* versionData = new uint8_t[versionLength];
if (GetFileVersionInfoExW(0, moduleFilename, 0, versionLength, versionData))
{
UINT vsize;
VerQueryValueW(versionData, L"\\", (LPVOID*)&vinfo, &vsize);
VerQueryValueW(versionData, L"\\StringFileInfo\\040904e4\\FileVersion", (LPVOID*)&vi, &vsize);
//wcscpy_s(pStateInfo->VersionString, 1024, L"1.0.0-get-rekt-son");
}
}
pStateInfo->VersionString = new(std::nothrow) wchar_t[1024]{UNICODE_NULL};
if (nullptr != vinfo)
{
WORD maj, min, rev, bui;
maj = (vinfo->dwFileVersionMS & 0xFFFF0000) >> 16;
min = (vinfo->dwFileVersionMS & 0x0000FFFF);
rev = (vinfo->dwFileVersionLS & 0xFFFF0000) >> 16;
bui = (vinfo->dwFileVersionLS & 0x0000FFFF);
StringCchPrintfW(pStateInfo->VersionString, 1024, L"Version %s (%d.%d.%d.%d)",
vi ? vi : L"UNKNOWN", maj, min, rev, bui);
}
else
{
StringCchPrintfW(pStateInfo->VersionString, 1024, L"Unknown Version (get rekt scrub)!");
}
}
// end console v2 properties
return S_OK;
}

View file

@ -475,6 +475,45 @@ UINT CALLBACK PropSheetPageProc(_In_ HWND hWnd, _In_ UINT uMsg, _Inout_ LPPROPSH
return 1;
}
INT_PTR WINAPI VersionDlgProc(const HWND hDlg, const UINT wMsg, const WPARAM /*wParam*/, const LPARAM lParam)
{
static bool fHaveInitialized = false;
switch (wMsg) {
case WM_INITDIALOG:
SetDlgItemTextW(hDlg, IDD_VERSION_STRING, gpStateInfo->VersionString);
fHaveInitialized = true;
return TRUE;
case WM_NOTIFY:
{
const PSHNOTIFY * const pshn = (LPPSHNOTIFY)lParam;
switch (pshn->hdr.code) {
case PSN_APPLY:
EndDlgPage(hDlg, !pshn->lParam);
return TRUE;
case PSN_KILLACTIVE:
{
// Fake the dialog proc into thinking the edit control just
// lost focus so it'll update properly
int item = GetDlgCtrlID(GetFocus());
if (item)
{
SendMessage(hDlg, WM_COMMAND, MAKELONG(item, EN_KILLFOCUS), 0);
}
return TRUE;
}
}
}
case WM_VSCROLL:
// Fake the dialog proc into thinking the edit control just
// lost focus so it'll update properly
SendMessage(hDlg, WM_COMMAND, MAKELONG((GetDlgCtrlID((HWND)lParam) - 1), EN_KILLFOCUS), 0);
return TRUE;
}
return false;
}
BOOL PopulatePropSheetPageArray(_Out_writes_(cPsps) PROPSHEETPAGE *pPsp, const size_t cPsps, const BOOL fRegisterCallbacks)
{
BOOL fRet = (cPsps == NUMBER_OF_PAGES);
@ -488,6 +527,9 @@ BOOL PopulatePropSheetPageArray(_Out_writes_(cPsps) PROPSHEETPAGE *pPsp, const s
PROPSHEETPAGE* const pLayoutPage = &(pPsp[LAYOUT_PAGE_INDEX]);
PROPSHEETPAGE* const pColorsPage = &(pPsp[COLORS_PAGE_INDEX]);
PROPSHEETPAGE* const pTerminalPage = &(pPsp[TERMINAL_PAGE_INDEX]);
#ifdef EXTERNAL_BUILD
PROPSHEETPAGE* const pVersionPage = &(pPsp[VERSION_PAGE_INDEX]);
#endif
pOptionsPage->dwSize = sizeof(PROPSHEETPAGE);
pOptionsPage->hInstance = ghInstance;
@ -533,6 +575,15 @@ BOOL PopulatePropSheetPageArray(_Out_writes_(cPsps) PROPSHEETPAGE *pPsp, const s
pTerminalPage->dwFlags = PSP_DEFAULT;
}
#ifdef EXTERNAL_BUILD
pVersionPage->dwSize = sizeof(PROPSHEETPAGE);
pVersionPage->hInstance = ghInstance;
pVersionPage->pszTemplate = MAKEINTRESOURCE(DID_VERSION);
pVersionPage->pfnDlgProc = VersionDlgProc;
pVersionPage->lParam = VERSION_PAGE_INDEX;
pVersionPage->dwFlags = PSP_DEFAULT;
#endif
// Register callbacks if requested (used for file property sheet purposes)
if (fRegisterCallbacks)
{

View file

@ -239,6 +239,12 @@ const unsigned int FONT_PAGE_INDEX = 1;
const unsigned int LAYOUT_PAGE_INDEX = 2;
const unsigned int COLORS_PAGE_INDEX = 3;
const unsigned int TERMINAL_PAGE_INDEX = 4;
const unsigned int VERSION_PAGE_INDEX = 5;
// number of property sheet pages
static const int V1_NUMBER_OF_PAGES = 4;
#ifndef EXTERNAL_BUILD
static const int NUMBER_OF_PAGES = 5;
#else
static const int NUMBER_OF_PAGES = 6;
#endif

View file

@ -620,6 +620,22 @@ BEGIN
IDD_HELP_TERMINAL, "SysLink", WS_TABSTOP, 10, 225, 200, 10
END
#ifdef EXTERNAL_BUILD
// This is the template for the version dialog
DID_VERSION DIALOG 0, 0, 245, 226
CAPTION " Version "
STYLE WS_VISIBLE | WS_CAPTION | WS_CHILD | DS_MODALFRAME
FONT 8,"MS Shell Dlg"
BEGIN
// GROUPBOX text, id, x, y, width, height [, style [, extended-style]]
// CONTROL text, id, class, style, x, y, width, height [, extended-style]
LTEXT "You will, I am certain, be wondering what this tab does.\nI wonder the same!",
IDD_VERSION_STRING, 10, 10, 225, 206, WS_TABSTOP
END
#endif
//
// Strings

View file

@ -157,6 +157,11 @@ Revision History:
#define IDD_TERMINAL_CURSOR_BLUE 631
#define IDD_HELP_TERMINAL 632
#ifdef EXTERNAL_BUILD
#define DID_VERSION 700
#define IDD_VERSION_STRING 701
#endif
#define BM_TRUETYPE_ICON 1000