Skip to content

Commit

Permalink
L10N: Localized Updates and Symbols notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Amrsatrio committed Nov 11, 2023
1 parent a74f27b commit b5b0b21
Show file tree
Hide file tree
Showing 13 changed files with 317 additions and 231 deletions.
8 changes: 2 additions & 6 deletions ExplorerPatcher/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ RTL_OSVERSIONINFOW global_rovi;
DWORD32 global_ubr;
#endif
#include <featurestagingapi.h>
#include "../ep_gui/resources/EPCrashMessageResources.h"

#define WINX_ADJUST_X 5
#define WINX_ADJUST_Y 5
Expand Down Expand Up @@ -200,6 +199,7 @@ BOOL g_bIsDesktopRaised = FALSE;

#include "utility.h"
#include "resource.h"
#include "../ep_gui/resources/EPSharedResources.h"
#ifdef USE_PRIVATE_INTERFACES
#include "ep_private.h"
#endif
Expand Down Expand Up @@ -11183,11 +11183,7 @@ DWORD InformUserAboutCrash(LPVOID unused)
CrashCounterSettings cfg;
GetCrashCounterSettings(&cfg);

wchar_t epGuiPath[MAX_PATH];
ZeroMemory(epGuiPath, sizeof(epGuiPath));
SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, epGuiPath);
wcscat_s(epGuiPath, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\ep_gui.dll");
HMODULE hEPGui = LoadLibraryExW(epGuiPath, NULL, LOAD_LIBRARY_AS_DATAFILE);
HMODULE hEPGui = LoadGuiModule();
if (!hEPGui)
{
return 0; // Can't load the strings, nothing to display
Expand Down
234 changes: 128 additions & 106 deletions ExplorerPatcher/symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,18 @@ const char* startui_SN[STARTUI_SB_CNT] = {
STARTUI_SB_0
};

const wchar_t DownloadSymbolsXML[] =
L"<toast scenario=\"reminder\" "
L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher\" duration=\"short\">\r\n"
L" <visual>\r\n"
L" <binding template=\"ToastGeneric\">\r\n"
L" <text><![CDATA[Unable to find symbols for OS build %s]]></text>\r\n"
L" <text><![CDATA[Downloading and applying symbol information, please wait...]]></text>\r\n"
L" <text placement=\"attribution\"><![CDATA[ExplorerPatcher]]></text>\r\n"
L" </binding>\r\n"
L" </visual>\r\n"
L" <audio src=\"ms-winsoundevent:Notification.Default\" loop=\"false\" silent=\"false\"/>\r\n"
L"</toast>\r\n";

const wchar_t DownloadOKXML[] =
L"<toast scenario=\"reminder\" "
L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher\" duration=\"long\">\r\n"
L" <visual>\r\n"
L" <binding template=\"ToastGeneric\">\r\n"
L" <text><![CDATA[Successfully downloaded symbols for OS build %s]]></text>\r\n"
L" <text><![CDATA[Please restart File Explorer to apply the changes and enable additional functionality.]]></text>\r\n"
L" <text placement=\"attribution\"><![CDATA[ExplorerPatcher]]></text>\r\n"
L" </binding>\r\n"
L" </visual>\r\n"
L" <audio src=\"ms-winsoundevent:Notification.Default\" loop=\"false\" silent=\"false\"/>\r\n"
L"</toast>\r\n";

const wchar_t InstallOK[] =
L"<toast scenario=\"reminder\" "
L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher\" duration=\"long\">\r\n"
L" <visual>\r\n"
L" <binding template=\"ToastGeneric\">\r\n"
L" <text><![CDATA[Installation succeeded!]]></text>\r\n"
L" <text><![CDATA[This notification will not show again until the next OS build update.]]></text>\r\n"
L" <text placement=\"attribution\"><![CDATA[ExplorerPatcher]]></text>\r\n"
L" </binding>\r\n"
L" </visual>\r\n"
L" <audio src=\"ms-winsoundevent:Notification.Default\" loop=\"false\" silent=\"false\"/>\r\n"
L"</toast>\r\n";
const wchar_t DownloadNotificationXML[] =
L"<toast scenario=\"reminder\" "
L"activationType=\"protocol\" launch=\"%s\" duration=\"%s\">\r\n"
L" <visual>\r\n"
L" <binding template=\"ToastGeneric\">\r\n"
L" <text><![CDATA[%s]]></text>\r\n"
L" <text><![CDATA[%s]]></text>\r\n"
L" <text placement=\"attribution\"><![CDATA[ExplorerPatcher]]></text>\r\n"
L" </binding>\r\n"
L" </visual>\r\n"
L" <audio src=\"ms-winsoundevent:Notification.Default\" loop=\"false\" silent=\"false\"/>\r\n"
L"</toast>\r\n";

extern INT VnDownloadSymbols(HMODULE hModule, char* dllName, char* szLibPath, UINT sizeLibPath);
extern INT VnGetSymbols(const char* pdb_file, DWORD* addresses, char** symbols, DWORD numOfSymbols);
Expand Down Expand Up @@ -349,34 +323,65 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)

printf("[Symbols] Started \"Download symbols\" thread.\n");

HMODULE hEPGui = LoadGuiModule();

RTL_OSVERSIONINFOW rovi;
DWORD32 ubr = VnGetOSVersionAndUBR(&rovi);
TCHAR szReportedVersion[MAX_PATH + 1];
ZeroMemory(
szReportedVersion,
sizeof(szReportedVersion)
);
wsprintf(
wchar_t szReportedVersion[32];
swprintf_s(
szReportedVersion,
ARRAYSIZE(szReportedVersion),
L"%d.%d.%d.%d",
rovi.dwMajorVersion,
rovi.dwMinorVersion,
rovi.dwBuildNumber,
ubr
);

TCHAR buffer[1000];
ZeroMemory(
buffer,
1000
wchar_t title[100];
wchar_t body[200];
wchar_t titleFormat[100];
wchar_t buffer[1000];
title[0] = 0; body[0] = 0; titleFormat[0] = 0; buffer[0] = 0;

// Don't annoy the user with "Downloading symbols" notification if the symbols aren't available in MS' servers
HKEY hKey = NULL;
DWORD dwDisposition;
RegCreateKeyExW(
HKEY_CURRENT_USER,
TEXT(REGPATH),
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_READ,
NULL,
&hKey,
&dwDisposition
);
wsprintf(
buffer,
DownloadSymbolsXML,
szReportedVersion
wchar_t szLastNotifiedBuild[32];
szLastNotifiedBuild[0] = 0;
DWORD dwSize = sizeof(szLastNotifiedBuild);
RegQueryValueExW(
hKey,
TEXT("SymbolsLastNotifiedOSBuild"),
0,
NULL,
szLastNotifiedBuild,
&dwSize
);
if (params->bVerbose)

BOOL bNewBuild = wcscmp(szLastNotifiedBuild, szReportedVersion) != 0;
if (bNewBuild)
{
if (LoadStringW(hEPGui, IDS_SYM_DL_T, titleFormat, ARRAYSIZE(titleFormat)))
{
swprintf_s(title, ARRAYSIZE(title), titleFormat, szReportedVersion);
}

LoadStringW(hEPGui, IDS_SYM_DL_B, body, ARRAYSIZE(body));

swprintf_s(buffer, ARRAYSIZE(buffer), DownloadNotificationXML, L"https://github.com/valinet/ExplorerPatcher/wiki/Symbols", L"short", title, body);

HRESULT hr = S_OK;
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml = NULL;
hr = String2IXMLDocument(
Expand All @@ -392,14 +397,26 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
hr = ShowToastMessage(
inputXml,
APPID,
sizeof(APPID) / sizeof(TCHAR) - 1,
sizeof(APPID) / sizeof(wchar_t) - 1,
#ifdef DEBUG
stdout
#else
NULL
#endif
);

RegSetValueExW(
hKey,
TEXT("SymbolsLastNotifiedOSBuild"),
0,
REG_SZ,
szReportedVersion,
wcslen(szReportedVersion) * sizeof(wchar_t)
);
}

RegCloseKey(hKey);

wprintf(
L"[Symbols] "
L"Attempting to download symbols for OS version %s.\n",
Expand Down Expand Up @@ -433,81 +450,86 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)

symbols_addr symbols_PTRS;
ZeroMemory(&symbols_PTRS, sizeof(symbols_addr));
BOOL bDownloaded = FALSE;
BOOL bAnySuccess = FALSE, bAllSuccess = TRUE;
if (params->loadResult.bNeedToDownloadTwinuiPcshellSymbols)
{
bDownloaded |= ProcessTwinuiPcshellSymbols(szSettingsPath, symbols_PTRS.twinui_pcshell_PTRS);
BOOL bSuccess = ProcessTwinuiPcshellSymbols(szSettingsPath, symbols_PTRS.twinui_pcshell_PTRS);
bAnySuccess |= bSuccess;
bAllSuccess &= bSuccess;
}
if (params->loadResult.bNeedToDownloadStartDockedSymbols && IsWindows11())
{
bDownloaded |= ProcessStartDockedSymbols(szSettingsPath, symbols_PTRS.startdocked_PTRS);
BOOL bSuccess = ProcessStartDockedSymbols(szSettingsPath, symbols_PTRS.startdocked_PTRS);
bAnySuccess |= bSuccess;
bAllSuccess &= bSuccess;
}
if (params->loadResult.bNeedToDownloadStartUISymbols && rovi.dwBuildNumber >= 18362)
{
bDownloaded |= ProcessStartUISymbols(szSettingsPath, symbols_PTRS.startui_PTRS);
BOOL bSuccess = ProcessStartUISymbols(szSettingsPath, symbols_PTRS.startui_PTRS);
bAnySuccess |= bSuccess;
bAllSuccess &= bSuccess;
}

printf("[Symbols] Finished gathering symbol data.\n");

if (bDownloaded)
title[0] = 0; body[0] = 0;
BOOL bNotify = TRUE;
if (bAllSuccess)
{
if (params->bVerbose)
if (LoadStringW(hEPGui, IDS_SYM_SUCCESS_T, titleFormat, ARRAYSIZE(titleFormat)))
{
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml = NULL;
HRESULT hr = String2IXMLDocument(
InstallOK,
wcslen(InstallOK),
&inputXml,
#ifdef DEBUG
stdout
#else
NULL
#endif
);
hr = ShowToastMessage(
inputXml,
APPID,
sizeof(APPID) / sizeof(TCHAR) - 1,
#ifdef DEBUG
stdout
#else
NULL
#endif
);
Sleep(4000);
exit(0);
swprintf_s(title, ARRAYSIZE(title), titleFormat, szReportedVersion);
}
else
LoadStringW(hEPGui, IDS_SYM_SUCCESS_B, body, ARRAYSIZE(body));
swprintf_s(buffer, ARRAYSIZE(buffer), DownloadNotificationXML, L"https://github.com/valinet/ExplorerPatcher/wiki/Symbols", L"long", title, body);
}
else if (bAnySuccess)
{
if (LoadStringW(hEPGui, IDS_SYM_FAILEDSOME_T, titleFormat, ARRAYSIZE(titleFormat)))
{
wsprintf(
buffer,
DownloadOKXML,
szReportedVersion
);
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml2 = NULL;
HRESULT hr = String2IXMLDocument(
buffer,
wcslen(buffer),
&inputXml2,
swprintf_s(title, ARRAYSIZE(title), titleFormat, szReportedVersion);
}
LoadStringW(hEPGui, IDS_SYM_FAILEDSOME_B, body, ARRAYSIZE(body));
swprintf_s(buffer, ARRAYSIZE(buffer), DownloadNotificationXML, L"https://github.com/valinet/ExplorerPatcher/wiki/Symbols", L"short", title, body);
}
else
{
if (LoadStringW(hEPGui, IDS_SYM_FAILEDALL_T, titleFormat, ARRAYSIZE(titleFormat)))
{
swprintf_s(title, ARRAYSIZE(title), titleFormat, szReportedVersion);
}
LoadStringW(hEPGui, IDS_SYM_FAILEDALL_B, body, ARRAYSIZE(body));
swprintf_s(buffer, ARRAYSIZE(buffer), DownloadNotificationXML, L"https://github.com/valinet/ExplorerPatcher/wiki/Symbols", L"short", title, body);
bNotify = bNewBuild;
}

if (bNotify)
{
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml2 = NULL;
HRESULT hr = String2IXMLDocument(
buffer,
wcslen(buffer),
&inputXml2,
#ifdef DEBUG
stdout
stdout
#else
NULL
NULL
#endif
);
hr = ShowToastMessage(
inputXml2,
APPID,
sizeof(APPID) / sizeof(TCHAR) - 1,
);
hr = ShowToastMessage(
inputXml2,
APPID,
sizeof(APPID) / sizeof(wchar_t) - 1,
#ifdef DEBUG
stdout
stdout
#else
NULL
NULL
#endif
);
}
);
}

FreeLibrary(hEPGui);

printf("[Symbols] Finished \"Download symbols\" thread.\n");
return 0;
}
Expand All @@ -528,7 +550,7 @@ LoadSymbolsResult LoadSymbols(symbols_addr* symbols_PTRS)
CHAR szStoredHash[33];
ZeroMemory(szHash, sizeof(szHash));
ZeroMemory(szStoredHash, sizeof(szStoredHash));
TCHAR wszPath[MAX_PATH];
wchar_t wszPath[MAX_PATH];
BOOL bOffsetsValid;

// Load twinui.pcshell.dll offsets
Expand Down
1 change: 1 addition & 0 deletions ExplorerPatcher/symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <valinet/utility/osversion.h>
#include <roapi.h>
#include "utility.h"
#include "../ep_gui/resources/EPSharedResources.h"

#define EXIT_CODE_EXPLORER 1

Expand Down
Loading

0 comments on commit b5b0b21

Please sign in to comment.