Browse Source

Improved behavior regarding symbols

pull/492/head
Valentin Radu 4 years ago
parent
commit
8db73cc2cc
  1. 12
      ExplorerPatcher/dllmain.c
  2. 2
      ExplorerPatcher/settings.reg
  3. 83
      ExplorerPatcher/symbols.c
  4. 1
      ExplorerPatcher/symbols.h

12
ExplorerPatcher/dllmain.c

@ -72,7 +72,7 @@ DWORD bShowUpdateToast = FALSE;
DWORD bToolbarSeparators = FALSE; DWORD bToolbarSeparators = FALSE;
DWORD bTaskbarAutohideOnDoubleClick = FALSE; DWORD bTaskbarAutohideOnDoubleClick = FALSE;
DWORD dwOrbStyle = 0; DWORD dwOrbStyle = 0;
DWORD bEnableSymbolDownload = FALSE; DWORD bEnableSymbolDownload = TRUE;
HMODULE hModule = NULL; HMODULE hModule = NULL;
HANDLE hDelayedInjectionThread = NULL; HANDLE hDelayedInjectionThread = NULL;
HANDLE hIsWinXShown = NULL; HANDLE hIsWinXShown = NULL;
@ -5417,17 +5417,13 @@ DWORD Inject(BOOL bIsExplorer)
); );
if (LoadSymbols(&symbols_PTRS, hModule)) if (LoadSymbols(&symbols_PTRS, hModule))
{ {
if (!bEnableSymbolDownload) if (bEnableSymbolDownload)
{ {
printf("Unable to load symbols; the program may have limited functionality.\n"); printf("Attempting to download symbol data; for now, the program may have limited functionality.\n");
}
else
{
printf("Symbols have to be (re)downloaded...\n");
DownloadSymbolsParams* params = malloc(sizeof(DownloadSymbolsParams)); DownloadSymbolsParams* params = malloc(sizeof(DownloadSymbolsParams));
params->hModule = hModule; params->hModule = hModule;
params->bVerbose = FALSE;
CreateThread(0, 0, DownloadSymbols, params, 0, 0); CreateThread(0, 0, DownloadSymbols, params, 0, 0);
return 0;
} }
} }
else else

2
ExplorerPatcher/settings.reg

@ -367,7 +367,7 @@
@="" @=""
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher] [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher]
;b Enable symbols download * ;b Enable symbols download *
"EnableSymbolDownload"=dword:00000000 "EnableSymbolDownload"=dword:00000001
;i Do not hook Start menu from main Explorer process (permanently disabled) * ;i Do not hook Start menu from main Explorer process (permanently disabled) *
"HookStartMenu"=dword:00000001 "HookStartMenu"=dword:00000001
;c 12 Supplementary delay at logon * ;c 12 Supplementary delay at logon *

83
ExplorerPatcher/symbols.c

@ -23,7 +23,7 @@ L"<toast displayTimestamp=\"2021-08-29T00:00:00.000Z\" scenario=\"reminder\" "
L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher\" duration=\"short\">\r\n" L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher\" duration=\"short\">\r\n"
L" <visual>\r\n" L" <visual>\r\n"
L" <binding template=\"ToastGeneric\">\r\n" L" <binding template=\"ToastGeneric\">\r\n"
L" <text><![CDATA[Unable to find symbols for OS version %s]]></text>\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><![CDATA[Downloading and applying symbol information, please wait...]]></text>\r\n"
L" <text placement=\"attribution\"><![CDATA[ExplorerPatcher]]></text>\r\n" L" <text placement=\"attribution\"><![CDATA[ExplorerPatcher]]></text>\r\n"
L" </binding>\r\n" L" </binding>\r\n"
@ -36,8 +36,8 @@ L"<toast displayTimestamp=\"2021-08-29T01:00:00.000Z\" scenario=\"reminder\" "
L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher\" duration=\"short\">\r\n" L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher\" duration=\"short\">\r\n"
L" <visual>\r\n" L" <visual>\r\n"
L" <binding template=\"ToastGeneric\">\r\n" L" <binding template=\"ToastGeneric\">\r\n"
L" <text><![CDATA[Symbols downloaded and applied successfully!]]></text>\r\n" L" <text><![CDATA[Successfully downloaded symbols for OS build %s]]></text>\r\n"
L" <text><![CDATA[Now, please wait while dynamic Explorer patching is done...]]></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" <text placement=\"attribution\"><![CDATA[ExplorerPatcher]]></text>\r\n"
L" </binding>\r\n" L" </binding>\r\n"
L" </visual>\r\n" L" </visual>\r\n"
@ -64,9 +64,9 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
HMODULE hModule = params->hModule; HMODULE hModule = params->hModule;
Sleep(3000); Sleep(6000);
printf("Started \"Download symbols\" thread.\n"); printf("[Symbols] Started \"Download symbols\" thread.\n");
RTL_OSVERSIONINFOW rovi; RTL_OSVERSIONINFOW rovi;
DWORD32 ubr = VnGetOSVersionAndUBR(&rovi); DWORD32 ubr = VnGetOSVersionAndUBR(&rovi);
@ -84,16 +84,18 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
ubr ubr
); );
TCHAR buffer[sizeof(DownloadSymbolsXML) / sizeof(wchar_t) + 30]; TCHAR buffer[1000];
ZeroMemory( ZeroMemory(
buffer, buffer,
(sizeof(DownloadSymbolsXML) / sizeof(wchar_t) + 30) * sizeof(TCHAR) 1000
); );
wsprintf( wsprintf(
buffer, buffer,
DownloadSymbolsXML, DownloadSymbolsXML,
szReportedVersion szReportedVersion
); );
if (params->bVerbose)
{
HRESULT hr = S_OK; HRESULT hr = S_OK;
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml = NULL; __x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml = NULL;
hr = String2IXMLDocument( hr = String2IXMLDocument(
@ -116,6 +118,12 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
NULL NULL
#endif #endif
); );
}
wprintf(
L"[Symbols] "
L"Attempting to download symbols for unknown OS version %s.\n",
szReportedVersion
);
char szSettingsPath[MAX_PATH]; char szSettingsPath[MAX_PATH];
@ -141,7 +149,7 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
MAX_PATH, MAX_PATH,
"\\" "\\"
); );
printf("Downloading to \"%s\".\n", szSettingsPath); printf("[Symbols] Downloading to \"%s\".\n", szSettingsPath);
symbols_addr symbols_PTRS; symbols_addr symbols_PTRS;
ZeroMemory( ZeroMemory(
@ -188,28 +196,36 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
&dwDisposition &dwDisposition
); );
if (!hKey || hKey == INVALID_HANDLE_VALUE) if (!hKey || hKey == INVALID_HANDLE_VALUE)
{
if (params->bVerbose)
{ {
FreeLibraryAndExitThread( FreeLibraryAndExitThread(
hModule, hModule,
9 9
); );
}
return 9; return 9;
} }
printf("Downloading symbols for \"%s\"...\n", twinui_pcshell_sb_dll); printf("[Symbols] Downloading symbols for \"%s\"...\n", twinui_pcshell_sb_dll);
if (VnDownloadSymbols( if (VnDownloadSymbols(
NULL, NULL,
twinui_pcshell_sb_dll, twinui_pcshell_sb_dll,
szSettingsPath, szSettingsPath,
MAX_PATH MAX_PATH
)) ))
{
printf("[Symbols] Symbols for \"%s\" are not available - unable to download.\n", twinui_pcshell_sb_dll);
printf("[Symbols] Please refer to \"https://github.com/valinet/ExplorerPatcher/wiki/Symbols\" for more information.\n");
if (params->bVerbose)
{ {
FreeLibraryAndExitThread( FreeLibraryAndExitThread(
hModule, hModule,
4 4
); );
}
return 4; return 4;
} }
printf("Reading symbols...\n"); printf("[Symbols] Reading symbols...\n");
if (VnGetSymbols( if (VnGetSymbols(
szSettingsPath, szSettingsPath,
symbols_PTRS.twinui_pcshell_PTRS, symbols_PTRS.twinui_pcshell_PTRS,
@ -217,7 +233,7 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
TWINUI_PCSHELL_SB_CNT TWINUI_PCSHELL_SB_CNT
)) ))
{ {
printf("Hooking Win+C is not available for this build.\n"); printf("[Symbols] Hooking Win+C is not available for this build.\n");
DWORD dwZero = 0; DWORD dwZero = 0;
RegSetValueExW( RegSetValueExW(
hKey, hKey,
@ -233,11 +249,15 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
twinui_pcshell_SN, twinui_pcshell_SN,
TWINUI_PCSHELL_SB_CNT - 1 TWINUI_PCSHELL_SB_CNT - 1
)) ))
{
printf("[Symbols] Failure in reading symbols for \"%s\".\n", twinui_pcshell_sb_dll);
if (params->bVerbose)
{ {
FreeLibraryAndExitThread( FreeLibraryAndExitThread(
hModule, hModule,
5 5
); );
}
return 5; return 5;
} }
} }
@ -333,21 +353,26 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
MAX_PATH, MAX_PATH,
".dll" ".dll"
); );
printf("Downloading symbols for \"%s\"...\n", startdocked_sb_dll); printf("[Symbols] Downloading symbols for \"%s\"...\n", startdocked_sb_dll);
if (VnDownloadSymbols( if (VnDownloadSymbols(
NULL, NULL,
startdocked_sb_dll, startdocked_sb_dll,
szSettingsPath, szSettingsPath,
MAX_PATH MAX_PATH
)) ))
{
printf("[Symbols] Symbols for \"%s\" are not available - unable to download.\n", startdocked_sb_dll);
printf("[Symbols] Please refer to \"https://github.com/valinet/ExplorerPatcher/wiki/Symbols\" for more information.\n");
if (params->bVerbose)
{ {
FreeLibraryAndExitThread( FreeLibraryAndExitThread(
hModule, hModule,
6 6
); );
}
return 6; return 6;
} }
printf("Reading symbols...\n"); printf("[Symbols] Reading symbols...\n");
if (VnGetSymbols( if (VnGetSymbols(
szSettingsPath, szSettingsPath,
symbols_PTRS.startdocked_PTRS, symbols_PTRS.startdocked_PTRS,
@ -355,11 +380,14 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
STARTDOCKED_SB_CNT STARTDOCKED_SB_CNT
)) ))
{ {
printf("error...\n"); printf("[Symbols] Failure in reading symbols for \"%s\".\n", startdocked_sb_dll);
if (params->bVerbose)
{
FreeLibraryAndExitThread( FreeLibraryAndExitThread(
hModule, hModule,
7 7
); );
}
return 7; return 7;
} }
RegCreateKeyExW( RegCreateKeyExW(
@ -374,11 +402,14 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
&dwDisposition &dwDisposition
); );
if (!hKey || hKey == INVALID_HANDLE_VALUE) if (!hKey || hKey == INVALID_HANDLE_VALUE)
{
if (params->bVerbose)
{ {
FreeLibraryAndExitThread( FreeLibraryAndExitThread(
hModule, hModule,
8 8
); );
}
return 8; return 8;
} }
RegSetValueExW( RegSetValueExW(
@ -440,11 +471,14 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
&dwDisposition &dwDisposition
); );
if (!hKey || hKey == INVALID_HANDLE_VALUE) if (!hKey || hKey == INVALID_HANDLE_VALUE)
{
if (params->bVerbose)
{ {
FreeLibraryAndExitThread( FreeLibraryAndExitThread(
hModule, hModule,
10 10
); );
}
return 10; return 10;
} }
RegSetValueExW( RegSetValueExW(
@ -458,7 +492,9 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
if (hKey) RegCloseKey(hKey); if (hKey) RegCloseKey(hKey);
if (symbols_PTRS.twinui_pcshell_PTRS[0]) printf("[Symbols] Finished gathering symbol data.\n");
if (params->bVerbose)
{ {
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml = NULL; __x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml = NULL;
HRESULT hr = String2IXMLDocument( HRESULT hr = String2IXMLDocument(
@ -481,13 +517,20 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
NULL NULL
#endif #endif
); );
Sleep(4000);
exit(0);
} }
else else
{ {
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml2 = NULL; wsprintf(
hr = String2IXMLDocument( buffer,
DownloadOKXML, DownloadOKXML,
wcslen(DownloadOKXML), szReportedVersion
);
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml2 = NULL;
HRESULT hr = String2IXMLDocument(
buffer,
wcslen(buffer),
&inputXml2, &inputXml2,
#ifdef DEBUG #ifdef DEBUG
stdout stdout
@ -507,9 +550,7 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
); );
} }
Sleep(4000); printf("[Symbols] Finished \"Download symbols\" thread.\n");
exit(0);
} }
BOOL LoadSymbols(symbols_addr* symbols_PTRS, HMODULE hModule) BOOL LoadSymbols(symbols_addr* symbols_PTRS, HMODULE hModule)

1
ExplorerPatcher/symbols.h

@ -37,6 +37,7 @@ typedef struct symbols_addr
typedef struct _DownloadSymbolsParams typedef struct _DownloadSymbolsParams
{ {
HMODULE hModule; HMODULE hModule;
BOOL bVerbose;
} DownloadSymbolsParams; } DownloadSymbolsParams;
DWORD DownloadSymbols(DownloadSymbolsParams* params); DWORD DownloadSymbols(DownloadSymbolsParams* params);

Loading…
Cancel
Save