From 18dc2b41613055f0daf7f6a1d4311368798ea12a Mon Sep 17 00:00:00 2001 From: Igor Pavlov Date: Wed, 2 May 2018 22:28:04 +0100 Subject: 18.05 --- CPP/Windows/Control/Dialog.cpp | 1 + CPP/Windows/Control/Dialog.h | 3 +++ CPP/Windows/MemoryLock.cpp | 25 +++++++++++++++++++++++++ CPP/Windows/MemoryLock.h | 2 ++ CPP/Windows/Registry.cpp | 2 +- 5 files changed, 32 insertions(+), 1 deletion(-) (limited to 'CPP/Windows') diff --git a/CPP/Windows/Control/Dialog.cpp b/CPP/Windows/Control/Dialog.cpp index 9df3ef5e..020694a6 100644 --- a/CPP/Windows/Control/Dialog.cpp +++ b/CPP/Windows/Control/Dialog.cpp @@ -72,6 +72,7 @@ bool CDialog::OnButtonClicked(int buttonID, HWND /* buttonHWND */) { case IDOK: OnOK(); break; case IDCANCEL: OnCancel(); break; + case IDCLOSE: OnClose(); break; case IDHELP: OnHelp(); break; default: return false; } diff --git a/CPP/Windows/Control/Dialog.h b/CPP/Windows/Control/Dialog.h index 59b9f419..33caa5b2 100644 --- a/CPP/Windows/Control/Dialog.h +++ b/CPP/Windows/Control/Dialog.h @@ -105,6 +105,7 @@ public: virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); virtual void OnOK() {}; virtual void OnCancel() {}; + virtual void OnClose() {} virtual bool OnNotify(UINT /* controlID */, LPNMHDR /* lParam */) { return false; } virtual bool OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { return false; } @@ -133,6 +134,7 @@ public: #endif virtual void OnOK() { Destroy(); } virtual void OnCancel() { Destroy(); } + virtual void OnClose() { Destroy(); } }; class CModalDialog: public CDialog @@ -147,6 +149,7 @@ public: bool End(INT_PTR result) { return BOOLToBool(::EndDialog(_window, result)); } virtual void OnOK() { End(IDOK); } virtual void OnCancel() { End(IDCANCEL); } + virtual void OnClose() { End(IDCLOSE); } }; class CDialogChildControl: public NWindows::CWindow diff --git a/CPP/Windows/MemoryLock.cpp b/CPP/Windows/MemoryLock.cpp index b628a03e..8d2134b1 100644 --- a/CPP/Windows/MemoryLock.cpp +++ b/CPP/Windows/MemoryLock.cpp @@ -67,6 +67,31 @@ bool EnablePrivilege(LPCTSTR privilegeName, bool enable) return res; } + + +typedef void (WINAPI * Func_RtlGetVersion) (OSVERSIONINFOEXW *); + +/* + We suppose that Window 10 works incorrectly with "Large Pages" at: + - Windows 10 1703 (15063) + - Windows 10 1709 (16299) +*/ + +unsigned Get_LargePages_RiskLevel() +{ + OSVERSIONINFOEXW vi; + HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll"); + if (!ntdll) + return 0; + Func_RtlGetVersion func = (Func_RtlGetVersion)GetProcAddress(ntdll, "RtlGetVersion"); + if (!func) + return 0; + func(&vi); + return (vi.dwPlatformId == VER_PLATFORM_WIN32_NT + && vi.dwMajorVersion + vi.dwMinorVersion == 10 + && vi.dwBuildNumber <= 16299) ? 1 : 0; +} + #endif }} diff --git a/CPP/Windows/MemoryLock.h b/CPP/Windows/MemoryLock.h index 4a5dafcf..dcaf182e 100644 --- a/CPP/Windows/MemoryLock.h +++ b/CPP/Windows/MemoryLock.h @@ -31,6 +31,8 @@ inline void EnablePrivilege_SymLink() // Do we need to set SE_BACKUP_NAME ? } +unsigned Get_LargePages_RiskLevel(); + #endif }} diff --git a/CPP/Windows/Registry.cpp b/CPP/Windows/Registry.cpp index c000e628..a2893131 100644 --- a/CPP/Windows/Registry.cpp +++ b/CPP/Windows/Registry.cpp @@ -152,7 +152,7 @@ LONG CKey::SetValue(LPCWSTR name, LPCWSTR value) MYASSERT(value != NULL); MYASSERT(_object != NULL); if (g_IsNT) - return RegSetValueExW(_object, name, NULL, REG_SZ, + return RegSetValueExW(_object, name, 0, REG_SZ, (const BYTE * )value, (DWORD)((wcslen(value) + 1) * sizeof(wchar_t))); return SetValue(name == 0 ? 0 : (LPCSTR)GetSystemString(name), value == 0 ? 0 : (LPCSTR)GetSystemString(value)); -- cgit v1.2.3