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"
|
2024-06-21 11:36:18 +04:00
|
|
|
#include "ui/gl/gl_detection.h"
|
2020-07-02 21:01:25 +04:00
|
|
|
|
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
|
|
|
|
2024-06-21 11:36:18 +04:00
|
|
|
#ifdef DESKTOP_APP_USE_ANGLE
|
2021-07-20 17:10:23 +03:00
|
|
|
bool DirectXResolveCompiler();
|
2024-06-21 11:36:18 +04:00
|
|
|
#endif // DESKTOP_APP_USE_ANGLE
|
2021-07-20 17:10:23 +03:00
|
|
|
|
2016-06-16 15:59:54 +03:00
|
|
|
namespace Platform {
|
|
|
|
namespace Dlls {
|
2021-07-01 00:15:56 +03:00
|
|
|
namespace {
|
2016-06-16 15:59:54 +03:00
|
|
|
|
2021-07-01 00:15:56 +03:00
|
|
|
struct SafeIniter {
|
|
|
|
SafeIniter();
|
|
|
|
};
|
2016-08-14 21:55:59 +03:00
|
|
|
|
2021-07-01 00:15:56 +03:00
|
|
|
SafeIniter::SafeIniter() {
|
|
|
|
base::Platform::InitDynamicLibraries();
|
2016-06-16 15:59:54 +03:00
|
|
|
|
2021-07-01 00:15:56 +03:00
|
|
|
const auto LibShell32 = LoadLibrary(L"shell32.dll");
|
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);
|
2016-06-16 15:59:54 +03:00
|
|
|
|
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)) {
|
2021-09-28 21:11:35 +04:00
|
|
|
// const auto LibUxTheme = LoadLibrary(L"uxtheme.dll");
|
2020-07-24 16:15:32 +04:00
|
|
|
// 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-07-01 00:15:56 +03:00
|
|
|
const auto LibPropSys = LoadLibrary(L"propsys.dll");
|
2021-06-30 18:20:49 +03:00
|
|
|
LOAD_SYMBOL(LibPropSys, PSStringFromPropertyKey);
|
2016-06-16 15:59:54 +03:00
|
|
|
|
2021-07-01 00:15:56 +03:00
|
|
|
const auto LibPsApi = LoadLibrary(L"psapi.dll");
|
2021-05-10 18:27:23 +04:00
|
|
|
LOAD_SYMBOL(LibPsApi, GetProcessMemoryInfo);
|
2020-07-24 16:15:32 +04:00
|
|
|
|
2021-07-01 00:15:56 +03:00
|
|
|
const auto LibUser32 = LoadLibrary(L"user32.dll");
|
2021-05-10 18:27:23 +04:00
|
|
|
LOAD_SYMBOL(LibUser32, SetWindowCompositionAttribute);
|
2016-06-16 15:59:54 +03:00
|
|
|
}
|
|
|
|
|
2021-07-01 00:15:56 +03:00
|
|
|
SafeIniter kSafeIniter;
|
|
|
|
|
|
|
|
} // namespace
|
2021-07-20 17:10:23 +03:00
|
|
|
|
|
|
|
void CheckLoadedModules() {
|
2024-06-21 11:36:18 +04:00
|
|
|
#ifdef DESKTOP_APP_USE_ANGLE
|
2021-07-20 17:10:23 +03:00
|
|
|
if (DirectXResolveCompiler()) {
|
|
|
|
auto LibD3DCompiler = HMODULE();
|
|
|
|
if (GetModuleHandleEx(0, L"d3dcompiler_47.dll", &LibD3DCompiler)) {
|
|
|
|
constexpr auto kMaxPathLong = 32767;
|
|
|
|
auto path = std::array<WCHAR, kMaxPathLong + 1>{ 0 };
|
|
|
|
const auto length = GetModuleFileName(
|
|
|
|
LibD3DCompiler,
|
|
|
|
path.data(),
|
|
|
|
kMaxPathLong);
|
|
|
|
if (length > 0 && length < kMaxPathLong) {
|
|
|
|
LOG(("Using DirectX compiler '%1'."
|
|
|
|
).arg(QString::fromWCharArray(path.data())));
|
|
|
|
} else {
|
|
|
|
LOG(("Error: Could not resolve DirectX compiler path."));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
LOG(("Error: Could not resolve DirectX compiler module."));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
LOG(("Error: Could not resolve DirectX compiler library."));
|
|
|
|
}
|
2024-06-21 11:36:18 +04:00
|
|
|
#endif // DESKTOP_APP_USE_ANGLE
|
2021-07-20 17:10:23 +03:00
|
|
|
}
|
|
|
|
|
2016-06-16 15:59:54 +03:00
|
|
|
} // namespace Dlls
|
|
|
|
} // namespace Platform
|