From ff0cebc7cc6560a1353ff4a975971fbb158cbf6a Mon Sep 17 00:00:00 2001 From: Bruce Date: Mon, 24 Feb 2025 13:33:46 +0800 Subject: [PATCH] Console App: Remove Codes about Store Logo and Base 64 --- .../AppInstallerConsole.vcxproj | 9 +- .../AppInstallerConsole.vcxproj.filters | 3 - AppInstallerConsole/base64logo.h | 291 ------------------ AppInstallerConsole/main.cpp | 3 +- AppInstallerConsole/pkginfo.h | 62 ++-- 5 files changed, 33 insertions(+), 335 deletions(-) delete mode 100644 AppInstallerConsole/base64logo.h diff --git a/AppInstallerConsole/AppInstallerConsole.vcxproj b/AppInstallerConsole/AppInstallerConsole.vcxproj index 83c7c41..8ce2e7d 100644 --- a/AppInstallerConsole/AppInstallerConsole.vcxproj +++ b/AppInstallerConsole/AppInstallerConsole.vcxproj @@ -71,14 +71,14 @@ true - E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\AppLauncher;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\Base64Img;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\CertificateManager;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PackageManagerAdd;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PriReader2;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ShoutcutCreater;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ToastNotification;$(IncludePath) + E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\AppLauncher;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\CertificateManager;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PackageManagerAdd;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PriReader2;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ShoutcutCreater;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ToastNotification;$(IncludePath) true false - E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\AppLauncher;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\Base64Img;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\CertificateManager;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PackageManagerAdd;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PriReader2;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ShoutcutCreater;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ToastNotification;$(IncludePath) + E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\AppLauncher;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\CertificateManager;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PackageManagerAdd;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PriReader2;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ShoutcutCreater;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ToastNotification;$(IncludePath) false @@ -95,7 +95,7 @@ Console true - shlwapi.lib;dwmapi.lib;crypt32.lib;$(OutDir)PackageManager.lib;$(OutDir)AppLauncher.lib;$(OutDir)Base64Img.lib;$(OutDir)ToastNotification.lib;$(OutDir)PriReader2.lib;$(OutDir)CertificateManager.lib;%(AdditionalDependencies) + shlwapi.lib;dwmapi.lib;crypt32.lib;$(OutDir)PackageManager.lib;$(OutDir)AppLauncher.lib;$(OutDir)ToastNotification.lib;$(OutDir)PriReader2.lib;$(OutDir)CertificateManager.lib;%(AdditionalDependencies) RequireAdministrator @@ -129,7 +129,7 @@ true true true - shlwapi.lib;dwmapi.lib;crypt32.lib;$(OutDir)PackageManager.lib;$(OutDir)AppLauncher.lib;$(OutDir)Base64Img.lib;$(OutDir)ToastNotification.lib;$(OutDir)PriReader2.lib;$(OutDir)CertificateManager.lib;%(AdditionalDependencies) + shlwapi.lib;dwmapi.lib;crypt32.lib;$(OutDir)PackageManager.lib;$(OutDir)AppLauncher.lib;$(OutDir)ToastNotification.lib;$(OutDir)PriReader2.lib;$(OutDir)CertificateManager.lib;%(AdditionalDependencies) RequireAdministrator @@ -152,7 +152,6 @@ - diff --git a/AppInstallerConsole/AppInstallerConsole.vcxproj.filters b/AppInstallerConsole/AppInstallerConsole.vcxproj.filters index 9e7106d..51da774 100644 --- a/AppInstallerConsole/AppInstallerConsole.vcxproj.filters +++ b/AppInstallerConsole/AppInstallerConsole.vcxproj.filters @@ -15,9 +15,6 @@ - - 头文件 - 头文件 diff --git a/AppInstallerConsole/base64logo.h b/AppInstallerConsole/base64logo.h deleted file mode 100644 index 7457968..0000000 --- a/AppInstallerConsole/base64logo.h +++ /dev/null @@ -1,291 +0,0 @@ -#pragma once -#include "Base64Img.h" -#include -#include -#include -#include "pkgcode.h" -#include "priread.h" - -std::string GetFileNameWithoutExtension (LPCSTR filePath) -{ - char pathCopy [MAX_PATH]; - lstrcpynA (pathCopy, filePath, MAX_PATH); - char *fileName = PathFindFileNameA (pathCopy); - PathRemoveExtensionA (fileName); - return std::string (fileName); -} -std::wstring GetFileNameWithoutExtension (LPCWSTR filePath) -{ - wchar_t pathCopy [MAX_PATH]; - lstrcpynW (pathCopy, filePath, MAX_PATH); - wchar_t *fileName = PathFindFileNameW (pathCopy); - PathRemoveExtensionW (fileName); - return std::wstring (fileName); -} -std::string GetFileNameWithoutExtension (const std::string &filePath) -{ - return GetFileNameWithoutExtension (filePath.c_str ()); -} -std::wstring GetFileNameWithoutExtension (const std::wstring &filePath) -{ - return GetFileNameWithoutExtension (filePath.c_str ()); -} - -std::string GetLogoBase64FromReader (PackageReader &reader, IStream **getOutput = NULL) -{ - if (!&reader) return std::string (""); - if (!reader.isAvailable ()) return std::string (""); - std::wstring logoPath = reader.getPropertyLogo (); - if (logoPath.empty () || logoPath.length () == 0) return std::string (""); - PriReader pri (reader.getPriFileStream ()); - if (pri.isAvailable ()) - { - std::wstring logoPathFromPri = pri.findFilePathValue (logoPath); - if (!logoPathFromPri.empty () && logoPath.length () > 0) logoPath = logoPathFromPri; - } - IStream *imgfile = reader.extractFileToStream (logoPath); - if (getOutput) *getOutput = imgfile; - if (!imgfile) - { - std::wstring fileName = GetFileNameWithoutExtension (logoPath); - IAppxPackageReader *appxreader = reader.getAppxPackageReader (); - CComPtr fe = NULL; - HRESULT hr = appxreader->GetPayloadFiles (&fe); - if (SUCCEEDED (hr) && fe) - { - std::vector files; - BOOL hasCurrent = FALSE; - hr = fe->GetHasCurrent (FALSE); - while (SUCCEEDED (hr) && hasCurrent) - { - CComPtr ifile = NULL; - hr = fe->GetCurrent (&ifile); - if (SUCCEEDED (hr) && ifile) - { - LPWSTR lpstr = NULL; - if (SUCCEEDED (ifile->GetName (&lpstr)) && lpstr) - { - std::wstring strWillSearch = StringToUpper (StringTrim (lpstr)); - std::wstring strWillToSearch = StringToUpper (StringTrim (fileName)); - if (StrStrW (strWillSearch.c_str (), strWillToSearch.c_str ())) - { - bool isFind = LabelEqual (PathFindExtensionW (lpstr), L".png"); - if (!isFind) isFind = LabelEqual (PathFindExtensionW (lpstr), L".jpg"); - if (!isFind) isFind = LabelEqual (PathFindExtensionW (lpstr), L".jpeg"); - if (!isFind) isFind = LabelEqual (PathFindExtensionW (lpstr), L".bmp"); - if (isFind) - { - std::wstring temp (L""); - if (lpstr) temp += lpstr; - if (temp.length () > 0) push_no_repeat (files, temp); - } - } - } - } - } - bool isFindSuit = false; - { - std::map scaleFiles; - std::wregex pattern (L"(scale-(\\d+))"); - for (auto it : files) - { - if (StrStrW (it.c_str (), L"contrast-")) continue; - std::wsmatch match; - if (std::regex_search (it, match, pattern)) - { - int temp = StrToIntW (match [1].str ().c_str ()); - if (!temp) - { - scaleFiles [temp] = it; - } - } - } - if (scaleFiles.find (GetDPI ()) != scaleFiles.end ()) - { - isFindSuit = true; - logoPath = scaleFiles [GetDPI ()]; - } - else - { - bool isFindScale = false; - for (auto it : scaleFiles) - { - if (it.first >= GetDPI ()) - { - isFindScale = true; - logoPath = scaleFiles [GetDPI ()]; - break; - } - } - if (!isFindScale) - { - for (auto it : scaleFiles) - { - if (it.first >= 100) - { - isFindScale = true; - logoPath = scaleFiles [GetDPI ()]; - break; - } - } - } - if (!isFindScale) - { - for (auto it : scaleFiles) - { - isFindScale = true; - logoPath = scaleFiles [GetDPI ()]; - break; - } - } - isFindSuit = isFindScale; - } - } - if (!isFindSuit) - { - std::map scaleFiles; - std::wregex pattern (L"(scale-(\\d+))"); - for (auto it : files) - { - if (StrStrW (it.c_str (), L"contrast-white")) continue; - std::wsmatch match; - if (std::regex_search (it, match, pattern)) - { - int temp = StrToIntW (match [1].str ().c_str ()); - if (!temp) - { - scaleFiles [temp] = it; - } - } - } - if (scaleFiles.find (GetDPI ()) != scaleFiles.end ()) - { - isFindSuit = true; - logoPath = scaleFiles [GetDPI ()]; - } - else - { - bool isFindScale = false; - for (auto it : scaleFiles) - { - if (it.first >= GetDPI ()) - { - isFindScale = true; - logoPath = scaleFiles [GetDPI ()]; - break; - } - } - if (!isFindScale) - { - for (auto it : scaleFiles) - { - if (it.first >= 100) - { - isFindScale = true; - logoPath = scaleFiles [GetDPI ()]; - break; - } - } - } - if (!isFindScale) - { - for (auto it : scaleFiles) - { - isFindScale = true; - logoPath = scaleFiles [GetDPI ()]; - break; - } - } - isFindSuit = isFindScale; - } - } - if (!isFindSuit) - { - std::map scaleFiles; - std::wregex pattern (L"(scale-(\\d+))"); - for (auto it : files) - { - if (StrStrW (it.c_str (), L"contrast-black")) continue; - std::wsmatch match; - if (std::regex_search (it, match, pattern)) - { - int temp = StrToIntW (match [1].str ().c_str ()); - if (!temp) - { - scaleFiles [temp] = it; - } - } - } - if (scaleFiles.find (GetDPI ()) != scaleFiles.end ()) - { - isFindSuit = true; - logoPath = scaleFiles [GetDPI ()]; - } - else - { - bool isFindScale = false; - for (auto it : scaleFiles) - { - if (it.first >= GetDPI ()) - { - isFindScale = true; - logoPath = scaleFiles [GetDPI ()]; - break; - } - } - if (!isFindScale) - { - for (auto it : scaleFiles) - { - if (it.first >= 100) - { - isFindScale = true; - logoPath = scaleFiles [GetDPI ()]; - break; - } - } - } - if (!isFindScale) - { - for (auto it : scaleFiles) - { - isFindScale = true; - logoPath = scaleFiles [GetDPI ()]; - break; - } - } - isFindSuit = isFindScale; - } - } - if (!isFindSuit) - { - for (auto it : files) - { - logoPath = std::wstring (L"") + it; - break; - } - } - } - imgfile = reader.extractFileToStream (logoPath); - } - if (getOutput) *getOutput = imgfile; - if (!imgfile) return std::string (""); - std::string b64res (""); - LPSTR szRes = StreamToBase64 (imgfile); - if (!getOutput) - { - if (imgfile) - { - imgfile->Release (); - imgfile = NULL; - } - } - if (!szRes) return b64res; - if (szRes) b64res += szRes; - free (szRes); - if (b64res.length () > 0) - { - b64res = "data:image/png;base64," + b64res; - } - return b64res; -} \ No newline at end of file diff --git a/AppInstallerConsole/main.cpp b/AppInstallerConsole/main.cpp index ef1f3e1..494efde 100644 --- a/AppInstallerConsole/main.cpp +++ b/AppInstallerConsole/main.cpp @@ -15,7 +15,6 @@ #include "resource.h" #include "res2.h" #include "PackageManager.h" -#include "base64logo.h" #include "AppLauncher.h" #include "ToastNotification.h" #include "pkginfo.h" @@ -509,8 +508,8 @@ void TaskInstallPackage () { ReadPackageInfo (); wcout << StrPrintFormatW (GetRCString_cpp (PAGE_2_TITLE).c_str (), g_pkgInfo.getPropertyName ().c_str ()) << endl; - wcout << GetRCString_cpp (PAGE_2_INSTALL); LoadCert (); + wcout << GetRCString_cpp (PAGE_2_INSTALL); InstallPackage (); } else diff --git a/AppInstallerConsole/pkginfo.h b/AppInstallerConsole/pkginfo.h index 158b750..33a9635 100644 --- a/AppInstallerConsole/pkginfo.h +++ b/AppInstallerConsole/pkginfo.h @@ -26,8 +26,6 @@ struct PackageInfomation std::wstring name = L""; std::wstring description = L""; std::wstring publisher = L""; - std::string logoBase64 = ""; - CComPtr logoStream = NULL; } properties; std::vector applications; std::vector capabilities; @@ -59,37 +57,38 @@ struct PackageInfomation reader.getIdentityProcessorArchitecture (this->identities.architectures); reader.getResourceLanguages (this->resources.languages); std::sort (this->resources.languages.begin (), this->resources.languages.end ()); - if (pri.create (reader.getPriFileStream ())) + this->properties.name = reader.getPropertyName (); + this->properties.publisher = reader.getPropertyPublisher (); + this->properties.description = reader.getPropertyDescription (); + if (isMsResourceLabel (this->properties.name) || + isMsResourceLabel (this->properties.publisher) || + isMsResourceLabel (this->properties.description)) { - std::wstring temp = reader.getPropertyName (); - if (isMsResourceLabel (temp)) + if (pri.create (reader.getPriFileStream ())) { - std::wstring getres = pri.findStringValue (temp); - if (!getres.empty () && getres.length () > 0) temp = std::wstring (L"") + getres; + std::wstring temp = this->properties.name; + if (isMsResourceLabel (temp)) + { + std::wstring getres = pri.findStringValue (temp); + if (!getres.empty () && getres.length () > 0) temp = std::wstring (L"") + getres; + } + this->properties.name = temp; + temp = this->properties.publisher; + if (isMsResourceLabel (temp)) + { + std::wstring getres = pri.findStringValue (temp); + if (!getres.empty () && getres.length () > 0) temp = std::wstring (L"") + getres; + } + this->properties.description = temp; + temp = this->properties.description; + if (isMsResourceLabel (temp)) + { + std::wstring getres = pri.findStringValue (temp); + if (!getres.empty () && getres.length () > 0) temp = std::wstring (L"") + getres; + } + this->properties.publisher = temp; } - this->properties.name = temp; - temp = reader.getPropertyDescription (); - if (isMsResourceLabel (temp)) - { - std::wstring getres = pri.findStringValue (temp); - if (!getres.empty () && getres.length () > 0) temp = std::wstring (L"") + getres; - } - this->properties.description = temp; - temp = reader.getPropertyPublisher (); - if (isMsResourceLabel (temp)) - { - std::wstring getres = pri.findStringValue (temp); - if (!getres.empty () && getres.length () > 0) temp = std::wstring (L"") + getres; - } - this->properties.publisher = temp; } - else - { - this->properties.name = reader.getPropertyName (); - this->properties.description = reader.getPropertyDescription (); - this->properties.publisher = reader.getPropertyPublisher (); - } - this->properties.logoBase64 = GetLogoBase64FromReader (reader, &this->properties.logoStream); this->prerequisites.osMinVersion = reader.getPrerequisiteOSMinVersion (); reader.getApplications (this->applications); reader.getCapabilities (capabilities); @@ -105,8 +104,6 @@ struct PackageInfomation this->properties.name = L""; this->properties.description = L""; this->properties.publisher = L""; - this->properties.logoBase64 = ""; - if (this->properties.logoStream) { this->properties.logoStream.Release (); this->properties.logoStream = nullptr; } this->resources.languages.clear (); this->prerequisites.osMinVersion = VERSION (0); this->applications.clear (); @@ -138,9 +135,6 @@ struct PackageInfomation std::wstring getPropertyName () { return this->properties.name; } std::wstring getPropertyDescription () { return this->properties.description; } std::wstring getPropertyPublisher () { return this->properties.publisher; } - std::string getPropertyLogoBase64 () { return this->properties.logoBase64; } - // ÎÞÐèÊÖ¶¯ÊÍ·Å - IStream *getPropertyLogoIStream () { return this->properties.logoStream; } // ʧ°Ü·µ»Ø¶¼Îª 0 µÄ°æ±¾ºÅ VERSION getPrerequisiteOSMinVersion () { return this->prerequisites.osMinVersion; } // Åжϵ±Ç°°üÊÇ·ñΪӦÓðü¶ø²»ÊÇ×ÊÔ´°ü»òÒÀÀµÏî¡£Èç¹ûΪÀ¦°ó°üµÄ»°ÅжÏÊÇ·ñ×Ó°üÖдæÔÚÓ¦Óðü¡£