2016-06-16 15:59:54 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-06-16 15:59:54 +03:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-06-16 15:59:54 +03:00
|
|
|
*/
|
|
|
|
#include "platform/win/windows_dlls.h"
|
|
|
|
|
2020-07-02 21:01:25 +04:00
|
|
|
#include "base/platform/win/base_windows_safe_library.h"
|
|
|
|
|
2019-06-03 13:48:36 +03:00
|
|
|
#include <VersionHelpers.h>
|
2018-07-28 13:50:28 +03:00
|
|
|
#include <QtCore/QSysInfo>
|
|
|
|
|
2021-05-10 18:27:23 +04:00
|
|
|
#define LOAD_SYMBOL(lib, name) ::base::Platform::LoadMethod(lib, #name, name)
|
2021-04-19 19:41:14 +04:00
|
|
|
|
2016-06-16 15:59:54 +03:00
|
|
|
namespace Platform {
|
|
|
|
namespace Dlls {
|
|
|
|
|
2020-07-02 21:01:25 +04:00
|
|
|
using base::Platform::SafeLoadLibrary;
|
|
|
|
using base::Platform::LoadMethod;
|
2016-08-14 21:55:59 +03:00
|
|
|
|
|
|
|
void init() {
|
|
|
|
static bool inited = false;
|
|
|
|
if (inited) return;
|
|
|
|
inited = true;
|
|
|
|
|
2021-06-30 18:20:49 +03:00
|
|
|
base::Platform::CheckDynamicLibraries();
|
|
|
|
|
2020-07-02 21:01:25 +04:00
|
|
|
// Remove the current directory from the DLL search order.
|
2021-06-30 18:20:49 +03:00
|
|
|
SetDllDirectory(L"");
|
2020-07-02 21:01:25 +04:00
|
|
|
|
2021-06-30 18:20:49 +03:00
|
|
|
const auto required = {
|
|
|
|
u"secur32.dll"_q,
|
|
|
|
u"winmm.dll"_q,
|
|
|
|
u"ws2_32.dll"_q,
|
|
|
|
u"user32.dll"_q,
|
|
|
|
u"gdi32.dll"_q,
|
|
|
|
u"advapi32.dll"_q,
|
|
|
|
u"shell32.dll"_q,
|
|
|
|
u"ole32.dll"_q,
|
|
|
|
u"oleaut32.dll"_q,
|
|
|
|
u"shlwapi.dll"_q,
|
|
|
|
u"iphlpapi.dll"_q,
|
|
|
|
u"gdiplus.dll"_q,
|
|
|
|
u"version.dll"_q,
|
|
|
|
u"dwmapi.dll"_q,
|
|
|
|
u"crypt32.dll"_q,
|
|
|
|
u"bcrypt.dll"_q,
|
|
|
|
u"imm32.dll"_q,
|
|
|
|
u"netapi32.dll"_q,
|
|
|
|
u"userenv.dll"_q,
|
|
|
|
u"wtsapi32.dll"_q,
|
|
|
|
u"propsys.dll"_q,
|
|
|
|
u"psapi.dll"_q,
|
|
|
|
u"uxtheme.dll"_q,
|
|
|
|
};
|
|
|
|
const auto optional = {
|
2020-07-02 21:01:25 +04:00
|
|
|
u"dbghelp.dll"_q,
|
|
|
|
u"dbgcore.dll"_q,
|
|
|
|
u"winsta.dll"_q,
|
|
|
|
u"uxtheme.dll"_q,
|
|
|
|
u"igdumdim32.dll"_q,
|
|
|
|
u"amdhdl32.dll"_q,
|
|
|
|
u"combase.dll"_q,
|
|
|
|
u"rstrtmgr.dll"_q,
|
2021-06-30 13:44:28 +03:00
|
|
|
u"d3d9.dll"_q,
|
2021-05-08 13:22:47 +04:00
|
|
|
u"d3d11.dll"_q,
|
|
|
|
u"dxgi.dll"_q,
|
2021-06-30 18:20:49 +03:00
|
|
|
u"profapi.dll"_q,
|
|
|
|
u"cryptbase.dll"_q,
|
2020-07-02 21:01:25 +04:00
|
|
|
};
|
2021-06-30 18:20:49 +03:00
|
|
|
for (const auto &lib : required) {
|
|
|
|
SafeLoadLibrary(lib, true);
|
|
|
|
}
|
|
|
|
for (const auto &lib : optional) {
|
2020-07-02 21:01:25 +04:00
|
|
|
SafeLoadLibrary(lib);
|
2016-08-14 21:55:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-16 15:59:54 +03:00
|
|
|
void start() {
|
2016-08-14 21:55:59 +03:00
|
|
|
init();
|
2016-06-16 15:59:54 +03:00
|
|
|
|
2020-07-02 21:01:25 +04:00
|
|
|
const auto LibShell32 = SafeLoadLibrary(u"shell32.dll"_q);
|
2021-05-10 18:27:23 +04:00
|
|
|
LOAD_SYMBOL(LibShell32, SHAssocEnumHandlers);
|
|
|
|
LOAD_SYMBOL(LibShell32, SHCreateItemFromParsingName);
|
|
|
|
LOAD_SYMBOL(LibShell32, SHOpenWithDialog);
|
|
|
|
LOAD_SYMBOL(LibShell32, OpenAs_RunDLL);
|
|
|
|
LOAD_SYMBOL(LibShell32, SHQueryUserNotificationState);
|
|
|
|
LOAD_SYMBOL(LibShell32, SHChangeNotify);
|
|
|
|
LOAD_SYMBOL(LibShell32, SetCurrentProcessExplicitAppUserModelID);
|
2016-06-16 15:59:54 +03:00
|
|
|
|
2020-07-02 21:01:25 +04:00
|
|
|
const auto LibUxTheme = SafeLoadLibrary(u"uxtheme.dll"_q);
|
2021-05-10 18:27:23 +04:00
|
|
|
LOAD_SYMBOL(LibUxTheme, SetWindowTheme);
|
2020-07-24 16:15:32 +04:00
|
|
|
//if (IsWindows10OrGreater()) {
|
|
|
|
// static const auto kSystemVersion = QOperatingSystemVersion::current();
|
|
|
|
// static const auto kMinor = kSystemVersion.minorVersion();
|
|
|
|
// static const auto kBuild = kSystemVersion.microVersion();
|
|
|
|
// if (kMinor > 0 || (kMinor == 0 && kBuild >= 17763)) {
|
|
|
|
// if (kBuild < 18362) {
|
2021-05-10 18:27:23 +04:00
|
|
|
// LOAD_SYMBOL(LibUxTheme, AllowDarkModeForApp, 135);
|
2020-07-24 16:15:32 +04:00
|
|
|
// } else {
|
2021-05-10 18:27:23 +04:00
|
|
|
// LOAD_SYMBOL(LibUxTheme, SetPreferredAppMode, 135);
|
2020-07-24 16:15:32 +04:00
|
|
|
// }
|
2021-05-10 18:27:23 +04:00
|
|
|
// LOAD_SYMBOL(LibUxTheme, AllowDarkModeForWindow, 133);
|
|
|
|
// LOAD_SYMBOL(LibUxTheme, RefreshImmersiveColorPolicyState, 104);
|
|
|
|
// LOAD_SYMBOL(LibUxTheme, FlushMenuThemes, 136);
|
2020-07-24 16:15:32 +04:00
|
|
|
// }
|
|
|
|
//}
|
2016-08-15 01:53:47 +03:00
|
|
|
|
2021-06-30 18:20:49 +03:00
|
|
|
const auto LibWtsApi32 = SafeLoadLibrary(u"wtsapi32.dll"_q);
|
|
|
|
LOAD_SYMBOL(LibWtsApi32, WTSRegisterSessionNotification);
|
|
|
|
LOAD_SYMBOL(LibWtsApi32, WTSUnRegisterSessionNotification);
|
2016-06-16 15:59:54 +03:00
|
|
|
|
2021-06-30 18:20:49 +03:00
|
|
|
const auto LibPropSys = SafeLoadLibrary(u"propsys.dll"_q);
|
|
|
|
LOAD_SYMBOL(LibPropSys, PropVariantToString);
|
|
|
|
LOAD_SYMBOL(LibPropSys, PSStringFromPropertyKey);
|
2016-06-16 15:59:54 +03:00
|
|
|
|
2021-06-30 18:20:49 +03:00
|
|
|
const auto LibDwmApi = SafeLoadLibrary(u"dwmapi.dll"_q);
|
|
|
|
LOAD_SYMBOL(LibDwmApi, DwmIsCompositionEnabled);
|
|
|
|
LOAD_SYMBOL(LibDwmApi, DwmSetWindowAttribute);
|
2018-11-12 11:50:40 +04:00
|
|
|
|
2020-07-02 21:01:25 +04:00
|
|
|
const auto LibPsApi = SafeLoadLibrary(u"psapi.dll"_q);
|
2021-05-10 18:27:23 +04:00
|
|
|
LOAD_SYMBOL(LibPsApi, GetProcessMemoryInfo);
|
2020-07-24 16:15:32 +04:00
|
|
|
|
|
|
|
const auto LibUser32 = SafeLoadLibrary(u"user32.dll"_q);
|
2021-05-10 18:27:23 +04:00
|
|
|
LOAD_SYMBOL(LibUser32, SetWindowCompositionAttribute);
|
2016-06-16 15:59:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Dlls
|
|
|
|
} // namespace Platform
|