Pack and deploy d3dcompiler_47.dll.

This commit is contained in:
John Preston 2021-07-20 17:10:23 +03:00
parent 6e90d6ae53
commit 1ce66e5198
6 changed files with 90 additions and 2 deletions

View file

@ -96,6 +96,50 @@ BOOL CALLBACK _ActivateProcess(HWND hWnd, LPARAM lParam) {
return TRUE;
}
void DeleteMyModules() {
constexpr auto kMaxPathLong = 32767;
auto exePath = std::array<WCHAR, kMaxPathLong + 1>{ 0 };
const auto exeLength = GetModuleFileName(
nullptr,
exePath.data(),
kMaxPathLong + 1);
if (!exeLength || exeLength >= kMaxPathLong + 1) {
return;
}
const auto exe = std::wstring(exePath.data());
const auto last1 = exe.find_last_of('\\');
const auto last2 = exe.find_last_of('/');
const auto last = std::max(
(last1 == std::wstring::npos) ? -1 : int(last1),
(last2 == std::wstring::npos) ? -1 : int(last2));
if (last < 0) {
return;
}
const auto modules = exe.substr(0, last + 1) + L"modules";
const auto deleteOne = [&](const wchar_t *name, const wchar_t *arch) {
const auto path = modules + L'\\' + arch + L'\\' + name;
DeleteFile(path.c_str());
};
const auto deleteBoth = [&](const wchar_t *name) {
deleteOne(name, L"x86");
deleteOne(name, L"x64");
};
const auto removeOne = [&](const std::wstring &name) {
const auto path = modules + L'\\' + name;
RemoveDirectory(path.c_str());
};
const auto removeBoth = [&](const std::wstring &name) {
removeOne(L"x86\\" + name);
removeOne(L"x64\\" + name);
};
deleteBoth(L"d3d\\d3dcompiler_47.dll");
removeBoth(L"d3d");
removeOne(L"x86");
removeOne(L"x64");
RemoveDirectory(modules.c_str());
}
} // namespace
void psActivateProcess(uint64 pid) {
@ -133,6 +177,7 @@ void psDoCleanup() {
psAutoStart(false, true);
psSendToMenu(false, true);
AppUserModelId::cleanupShortcut();
DeleteMyModules();
} catch (...) {
}
}
@ -231,6 +276,7 @@ void StartOpenSSL() {
void start() {
StartOpenSSL();
Dlls::CheckLoadedModules();
}
} // namespace ThirdParty

View file

@ -14,6 +14,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#define LOAD_SYMBOL(lib, name) ::base::Platform::LoadMethod(lib, #name, name)
bool DirectXResolveCompiler();
namespace Platform {
namespace Dlls {
namespace {
@ -74,5 +76,30 @@ SafeIniter::SafeIniter() {
SafeIniter kSafeIniter;
} // namespace
void CheckLoadedModules() {
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."));
}
}
} // namespace Dlls
} // namespace Platform

View file

@ -22,6 +22,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Platform {
namespace Dlls {
void CheckLoadedModules();
// UXTHEME.DLL
inline HRESULT(__stdcall *SetWindowTheme)(
HWND hWnd,

View file

@ -206,7 +206,13 @@ if %BuildUWP% equ 0 (
)
)
call Packer.exe -version %VersionForPacker% -path %BinaryName%.exe -path Updater.exe -target %BuildTarget% %AlphaBetaParam%
if %Build64% neq 0 (
set "ModulesFolder=x64"
) else (
set "ModulesFolder=x86"
)
call Packer.exe -version %VersionForPacker% -path %BinaryName%.exe -path Updater.exe -path "modules\!ModulesFolder!\d3d\d3dcompiler_47.dll" -target %BuildTarget% %AlphaBetaParam%
if %errorlevel% neq 0 goto error
if %AlphaVersion% neq 0 (

View file

@ -36,10 +36,14 @@ DisableProgramGroupPage=no
ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode=x64
OutputBaseFilename=tsetup-x64.{#MyAppVersionFull}
#define ArchModulesFolder "x64"
#else
OutputBaseFilename=tsetup.{#MyAppVersionFull}
#define ArchModulesFolder "x86"
#endif
#define ModulesFolder "modules\{#ArchModulesFolder}"
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "it"; MessagesFile: "compiler:Languages\Italian.isl"
@ -58,6 +62,7 @@ Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescrip
[Files]
Source: "{#ReleasePath}\Telegram.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#ReleasePath}\Updater.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#ReleasePath}\{#ModulesFolder}\d3d\d3dcompiler_47.dll; DestDir: "{app}\{#ModulesFolder}\d3d"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
@ -78,6 +83,7 @@ Type: filesandordirs; Name: "{app}\tupdates"
Type: filesandordirs; Name: "{app}\tdata"
Type: filesandordirs; Name: "{app}\tcache"
Type: filesandordirs; Name: "{app}\tdumps"
Type: filesandordirs; Name: "{app}\modules"
Type: dirifempty; Name: "{app}"
Type: files; Name: "{userappdata}\{#MyAppName}\data"
Type: files; Name: "{userappdata}\{#MyAppName}\data_config"
@ -87,6 +93,7 @@ Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\tupdates"
Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\tdata"
Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\tcache"
Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\tdumps"
Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\modules"
Type: dirifempty; Name: "{userappdata}\{#MyAppName}"
[Code]

2
cmake

@ -1 +1 @@
Subproject commit 46a49caa21c16d3cc563798b8c26ba936cdd30e3
Subproject commit fe0d8a184134850bf1476096c09564290188d470