mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-23 23:21:08 +01:00
* Acessing "Properties" is done via right click on taskbar, both on Windows 10, and 11 styles
* Support for automatic updates * Implemented setup program * Fixed issue where setting the Windows 10 taskbar to one of the screen edges crashed the Windows 11 taskbar if enabled * System tray icons are now left intact when switching between Windows 10 and Windows 11 taskbars, and after build updates
This commit is contained in:
parent
05efe53f83
commit
92dadf6374
@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30002.166
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExplorerPatcher", "ExplorerPatcher\ExplorerPatcher.vcxproj", "{DB3E4319-2969-42B6-B7E8-BB57AA8C9FA9}"
|
||||
EndProject
|
||||
@ -9,6 +9,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ep_generate_release_descrip
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ep_generate_release_name", "ep_generate_release_name\ep_generate_release_name.vcxproj", "{78D0C3CF-25C0-41D4-9359-0E9AB72B9874}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ep_setup", "ep_setup\ep_setup.vcxproj", "{2FD40B09-F224-4E9A-B2FE-A22B50B2DEBF}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{DB3E4319-2969-42B6-B7E8-BB57AA8C9FA9} = {DB3E4319-2969-42B6-B7E8-BB57AA8C9FA9}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ep_setup_patch", "ep_setup_patch\ep_setup_patch.vcxproj", "{0C13E5F3-106B-4836-A7C2-8E5808A6ED78}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{2FD40B09-F224-4E9A-B2FE-A22B50B2DEBF} = {2FD40B09-F224-4E9A-B2FE-A22B50B2DEBF}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|amd64 = Debug|amd64
|
||||
@ -37,6 +47,18 @@ Global
|
||||
{78D0C3CF-25C0-41D4-9359-0E9AB72B9874}.Release|amd64.ActiveCfg = Release|x64
|
||||
{78D0C3CF-25C0-41D4-9359-0E9AB72B9874}.Release|amd64.Build.0 = Release|x64
|
||||
{78D0C3CF-25C0-41D4-9359-0E9AB72B9874}.Release|IA-32.ActiveCfg = Release|Win32
|
||||
{2FD40B09-F224-4E9A-B2FE-A22B50B2DEBF}.Debug|amd64.ActiveCfg = Debug|x64
|
||||
{2FD40B09-F224-4E9A-B2FE-A22B50B2DEBF}.Debug|amd64.Build.0 = Debug|x64
|
||||
{2FD40B09-F224-4E9A-B2FE-A22B50B2DEBF}.Debug|IA-32.ActiveCfg = Debug|Win32
|
||||
{2FD40B09-F224-4E9A-B2FE-A22B50B2DEBF}.Release|amd64.ActiveCfg = Release|x64
|
||||
{2FD40B09-F224-4E9A-B2FE-A22B50B2DEBF}.Release|amd64.Build.0 = Release|x64
|
||||
{2FD40B09-F224-4E9A-B2FE-A22B50B2DEBF}.Release|IA-32.ActiveCfg = Release|Win32
|
||||
{0C13E5F3-106B-4836-A7C2-8E5808A6ED78}.Debug|amd64.ActiveCfg = Debug|x64
|
||||
{0C13E5F3-106B-4836-A7C2-8E5808A6ED78}.Debug|amd64.Build.0 = Debug|x64
|
||||
{0C13E5F3-106B-4836-A7C2-8E5808A6ED78}.Debug|IA-32.ActiveCfg = Debug|Win32
|
||||
{0C13E5F3-106B-4836-A7C2-8E5808A6ED78}.Release|amd64.ActiveCfg = Release|x64
|
||||
{0C13E5F3-106B-4836-A7C2-8E5808A6ED78}.Release|amd64.Build.0 = Release|x64
|
||||
{0C13E5F3-106B-4836-A7C2-8E5808A6ED78}.Release|IA-32.ActiveCfg = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -51,8 +51,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 22000,318,36,1
|
||||
PRODUCTVERSION 22000,318,36,1
|
||||
FILEVERSION 22000,318,37,0
|
||||
PRODUCTVERSION 22000,318,37,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@ -69,12 +69,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "VALINET Solutions SRL"
|
||||
VALUE "FileDescription", "ExplorerPatcher"
|
||||
VALUE "FileVersion", "22000.318.36.1"
|
||||
VALUE "FileVersion", "22000.318.37.0"
|
||||
VALUE "InternalName", "ExplorerPatcher.dll"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2006-2021 VALINET Solutions SRL. All rights reserved."
|
||||
VALUE "OriginalFilename", "ExplorerPatcher.dll"
|
||||
VALUE "ProductName", "ExplorerPatcher"
|
||||
VALUE "ProductVersion", "22000.318.36.1"
|
||||
VALUE "ProductVersion", "22000.318.37.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
@ -267,6 +267,12 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="updates.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="utility.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@ -298,6 +304,7 @@
|
||||
<ClInclude Include="StartupSound.h" />
|
||||
<ClInclude Include="symbols.h" />
|
||||
<ClInclude Include="TaskbarCenter.h" />
|
||||
<ClInclude Include="updates.h" />
|
||||
<ClInclude Include="utility.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -108,6 +108,9 @@
|
||||
<ClInclude Include="queryversion.h">
|
||||
<Filter>Header Files\internal</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="updates.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="ExplorerPatcher.rc">
|
||||
@ -175,6 +178,9 @@
|
||||
<ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_window.c">
|
||||
<Filter>Source Files\sws</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="updates.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="settings.reg">
|
||||
|
File diff suppressed because it is too large
Load Diff
593
ExplorerPatcher/updates.c
Normal file
593
ExplorerPatcher/updates.c
Normal file
@ -0,0 +1,593 @@
|
||||
#include "updates.h"
|
||||
|
||||
BOOL IsUpdatePolicy(LPCWSTR wszDataStore, DWORD dwUpdatePolicy)
|
||||
{
|
||||
HKEY hKey = NULL;
|
||||
DWORD dwSize = 0;
|
||||
DWORD dwQueriedPolicy = 0;
|
||||
BOOL bIsPolicyMatch = (dwUpdatePolicy == UPDATE_POLICY_AUTO);
|
||||
|
||||
RegCreateKeyExW(
|
||||
HKEY_CURRENT_USER,
|
||||
wszDataStore,
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_READ | KEY_WOW64_64KEY,
|
||||
NULL,
|
||||
&hKey,
|
||||
NULL
|
||||
);
|
||||
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
hKey = NULL;
|
||||
}
|
||||
if (hKey)
|
||||
{
|
||||
dwSize = sizeof(DWORD);
|
||||
RegQueryValueExW(
|
||||
hKey,
|
||||
TEXT("UpdatePolicy"),
|
||||
0,
|
||||
NULL,
|
||||
&dwQueriedPolicy,
|
||||
&dwSize
|
||||
);
|
||||
RegCloseKey(hKey);
|
||||
bIsPolicyMatch = (dwQueriedPolicy == dwUpdatePolicy);
|
||||
}
|
||||
return bIsPolicyMatch;
|
||||
}
|
||||
|
||||
void IsUpdateAvailableHelperCallback(
|
||||
HINTERNET hInternet,
|
||||
struct IsUpdateAvailableParameters* params,
|
||||
DWORD dwInternetStatus,
|
||||
INTERNET_ASYNC_RESULT* lpvStatusInformation,
|
||||
DWORD dwStatusInformationLength
|
||||
)
|
||||
{
|
||||
if (dwInternetStatus == INTERNET_STATUS_REQUEST_COMPLETE)
|
||||
{
|
||||
params->hInternet = lpvStatusInformation->dwResult;
|
||||
SetEvent(params->hEvent);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL IsUpdateAvailableHelper(char* url, char* szCheckAgainst, DWORD dwUpdateTimeout, BOOL* lpFail)
|
||||
{
|
||||
BOOL bIsUpdateAvailable = FALSE;
|
||||
|
||||
struct IsUpdateAvailableParameters params;
|
||||
params.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
|
||||
if (!params.hEvent)
|
||||
{
|
||||
return bIsUpdateAvailable;
|
||||
}
|
||||
|
||||
HINTERNET hInternet = NULL;
|
||||
if (hInternet = InternetOpenA(
|
||||
UPDATES_USER_AGENT,
|
||||
INTERNET_OPEN_TYPE_PRECONFIG,
|
||||
NULL,
|
||||
NULL,
|
||||
INTERNET_FLAG_ASYNC
|
||||
))
|
||||
{
|
||||
InternetSetOptionA(hInternet, INTERNET_OPTION_CONNECT_TIMEOUT, &dwUpdateTimeout, sizeof(DWORD));
|
||||
if (InternetSetStatusCallbackA(hInternet, IsUpdateAvailableHelperCallback) != INTERNET_INVALID_STATUS_CALLBACK)
|
||||
{
|
||||
HINTERNET hConnect = InternetOpenUrlA(
|
||||
hInternet,
|
||||
url,
|
||||
NULL,
|
||||
0,
|
||||
INTERNET_FLAG_RAW_DATA |
|
||||
INTERNET_FLAG_RELOAD |
|
||||
INTERNET_FLAG_RESYNCHRONIZE |
|
||||
INTERNET_FLAG_NO_COOKIES |
|
||||
INTERNET_FLAG_NO_UI |
|
||||
INTERNET_FLAG_NO_CACHE_WRITE,
|
||||
¶ms
|
||||
);
|
||||
if (!hConnect && GetLastError() == ERROR_IO_PENDING)
|
||||
{
|
||||
if (WaitForSingleObject(params.hEvent, dwUpdateTimeout) == WAIT_OBJECT_0)
|
||||
{
|
||||
hConnect = params.hInternet;
|
||||
}
|
||||
}
|
||||
if (hConnect)
|
||||
{
|
||||
if (szCheckAgainst)
|
||||
{
|
||||
BOOL bRet = FALSE;
|
||||
DWORD dwRead = 0;
|
||||
char hash[DOSMODE_OFFSET + UPDATES_HASH_SIZE + 1];
|
||||
ZeroMemory(hash, DOSMODE_OFFSET + UPDATES_HASH_SIZE + 1);
|
||||
if (bRet = InternetReadFile(
|
||||
hConnect,
|
||||
hash,
|
||||
DOSMODE_OFFSET + UPDATES_HASH_SIZE,
|
||||
&dwRead
|
||||
) && dwRead == DOSMODE_OFFSET + UPDATES_HASH_SIZE)
|
||||
{
|
||||
#ifdef UPDATES_VERBOSE_OUTPUT
|
||||
printf("[Updates] Hash of remote file is \"%s\" (%s).\n", DOSMODE_OFFSET + hash, (hash[0] == 0x4D && hash[1] == 0x5A) ? "valid" : "invalid");
|
||||
#endif
|
||||
if (hash[0] == 0x4D && hash[1] == 0x5A && _stricmp(DOSMODE_OFFSET + hash, szCheckAgainst))
|
||||
{
|
||||
bIsUpdateAvailable = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lpFail) *lpFail = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WCHAR wszPath[MAX_PATH];
|
||||
ZeroMemory(wszPath, MAX_PATH * sizeof(WCHAR));
|
||||
SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszPath);
|
||||
wcscat_s(wszPath, MAX_PATH, _T(APP_RELATIVE_PATH));
|
||||
BOOL bRet = CreateDirectoryW(wszPath, NULL);
|
||||
if (bRet || (!bRet && GetLastError() == ERROR_ALREADY_EXISTS))
|
||||
{
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\Update for " _T(PRODUCT_NAME) L" from ");
|
||||
WCHAR wszURL[MAX_PATH];
|
||||
ZeroMemory(wszURL, MAX_PATH * sizeof(WCHAR));
|
||||
MultiByteToWideChar(
|
||||
CP_UTF8,
|
||||
MB_PRECOMPOSED,
|
||||
url,
|
||||
-1,
|
||||
wszURL,
|
||||
MAX_PATH
|
||||
);
|
||||
if (wszURL[95])
|
||||
{
|
||||
wszURL[94] = L'.';
|
||||
wszURL[95] = L'.';
|
||||
wszURL[96] = L'.';
|
||||
wszURL[97] = L'e';
|
||||
wszURL[98] = L'x';
|
||||
wszURL[99] = L'e';
|
||||
wszURL[100] = 0;
|
||||
}
|
||||
for (unsigned int i = 0; i < wszURL; ++i)
|
||||
{
|
||||
if (!wszURL[i])
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (wszURL[i] == L'/')
|
||||
{
|
||||
wszURL[i] = L'\u2215';
|
||||
}
|
||||
else if (wszURL[i] == L':')
|
||||
{
|
||||
wszURL[i] = L'\ua789';
|
||||
}
|
||||
}
|
||||
wcscat_s(wszPath, MAX_PATH, wszURL);
|
||||
#ifdef UPDATES_VERBOSE_OUTPUT
|
||||
wprintf(L"[Updates] Download path is \"%s\".\n", wszPath);
|
||||
#endif
|
||||
|
||||
BOOL bRet = DeleteFileW(wszPath);
|
||||
if (bRet || (!bRet && GetLastError() == ERROR_FILE_NOT_FOUND))
|
||||
{
|
||||
FILE* f = NULL;
|
||||
if (!_wfopen_s(
|
||||
&f,
|
||||
wszPath,
|
||||
L"wb"
|
||||
) && f)
|
||||
{
|
||||
BYTE* buffer = (BYTE*)malloc(UPDATES_BUFSIZ);
|
||||
if (buffer != NULL)
|
||||
{
|
||||
DWORD dwRead = 0;
|
||||
bRet = FALSE;
|
||||
while (bRet = InternetReadFile(
|
||||
hConnect,
|
||||
buffer,
|
||||
UPDATES_BUFSIZ,
|
||||
&dwRead
|
||||
))
|
||||
{
|
||||
if (dwRead == 0)
|
||||
{
|
||||
bIsUpdateAvailable = TRUE;
|
||||
#ifdef UPDATES_VERBOSE_OUTPUT
|
||||
printf("[Updates] Downloaded finished.\n");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
#ifdef UPDATES_VERBOSE_OUTPUT
|
||||
printf("[Updates] Downloaded %d bytes.\n", dwRead);
|
||||
#endif
|
||||
fwrite(
|
||||
buffer,
|
||||
sizeof(BYTE),
|
||||
dwRead,
|
||||
f
|
||||
);
|
||||
dwRead = 0;
|
||||
}
|
||||
free(buffer);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
if (bIsUpdateAvailable)
|
||||
{
|
||||
bIsUpdateAvailable = FALSE;
|
||||
#ifdef UPDATES_VERBOSE_OUTPUT
|
||||
printf(
|
||||
"[Updates] In order to install this update for the product \""
|
||||
PRODUCT_NAME
|
||||
"\", please allow the elevation request.\n"
|
||||
);
|
||||
#endif
|
||||
SHELLEXECUTEINFO ShExecInfo = { 0 };
|
||||
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
|
||||
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
|
||||
ShExecInfo.hwnd = NULL;
|
||||
ShExecInfo.lpVerb = L"runas";
|
||||
ShExecInfo.lpFile = wszPath;
|
||||
ShExecInfo.lpParameters = L"/update_silent";
|
||||
ShExecInfo.lpDirectory = NULL;
|
||||
ShExecInfo.nShow = SW_SHOW;
|
||||
ShExecInfo.hInstApp = NULL;
|
||||
if (ShellExecuteExW(&ShExecInfo) && ShExecInfo.hProcess)
|
||||
{
|
||||
WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
|
||||
DWORD dwExitCode = 0;
|
||||
if (GetExitCodeProcess(ShExecInfo.hProcess, &dwExitCode) && !dwExitCode)
|
||||
{
|
||||
bIsUpdateAvailable = TRUE;
|
||||
#ifdef UPDATES_VERBOSE_OUTPUT
|
||||
printf("[Updates] Update successful, File Explorer will probably restart momentarly.\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLastError(dwExitCode);
|
||||
#ifdef UPDATES_VERBOSE_OUTPUT
|
||||
printf("[Updates] Update failed because the following error has occured: %d.\n", dwExitCode);
|
||||
#endif
|
||||
}
|
||||
CloseHandle(ShExecInfo.hProcess);
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD dwError = GetLastError();
|
||||
if (dwError == ERROR_CANCELLED)
|
||||
{
|
||||
#ifdef UPDATES_VERBOSE_OUTPUT
|
||||
printf("[Updates] Update failed because the elevation request was denied.\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef UPDATES_VERBOSE_OUTPUT
|
||||
printf("[Updates] Update failed because the following error has occured: %d.\n", GetLastError());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
InternetCloseHandle(hConnect);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lpFail) *lpFail = TRUE;
|
||||
}
|
||||
}
|
||||
InternetCloseHandle(hInternet);
|
||||
}
|
||||
|
||||
CloseHandle(params.hEvent);
|
||||
|
||||
return bIsUpdateAvailable;
|
||||
}
|
||||
|
||||
BOOL IsUpdateAvailable(LPCWSTR wszDataStore, char* szCheckAgainst, BOOL* lpFail)
|
||||
{
|
||||
HKEY hKey = NULL;
|
||||
DWORD dwSize = 0;
|
||||
DWORD dwQueriedPolicy = 0;
|
||||
BOOL bIsPolicyMatch = FALSE;
|
||||
CHAR szUpdateURL[MAX_PATH];
|
||||
ZeroMemory(szUpdateURL, MAX_PATH * sizeof(CHAR));
|
||||
strcat_s(szUpdateURL, MAX_PATH, "https://github.com/valinet/ExplorerPatcher/releases/latest/download/");
|
||||
#ifdef UPDATES_VERBOSE_OUTPUT
|
||||
printf("[Updates] Checking against hash \"%s\"\n", szCheckAgainst);
|
||||
#endif
|
||||
DWORD dwUpdateTimeout = UPDATES_DEFAULT_TIMEOUT;
|
||||
|
||||
RegCreateKeyExW(
|
||||
HKEY_CURRENT_USER,
|
||||
wszDataStore,
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_READ | KEY_WOW64_64KEY,
|
||||
NULL,
|
||||
&hKey,
|
||||
NULL
|
||||
);
|
||||
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
hKey = NULL;
|
||||
}
|
||||
if (hKey)
|
||||
{
|
||||
dwSize = MAX_PATH;
|
||||
RegQueryValueExA(
|
||||
hKey,
|
||||
"UpdateURL",
|
||||
0,
|
||||
NULL,
|
||||
szUpdateURL,
|
||||
&dwSize
|
||||
);
|
||||
strcat_s(szUpdateURL, MAX_PATH, SETUP_UTILITY_NAME);
|
||||
dwSize = sizeof(DWORD);
|
||||
RegQueryValueExA(
|
||||
hKey,
|
||||
"UpdateTimeout",
|
||||
0,
|
||||
NULL,
|
||||
&dwUpdateTimeout,
|
||||
&dwSize
|
||||
);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
#ifdef UPDATES_VERBOSE_OUTPUT
|
||||
printf("[Updates] Update URL: %s\n", szUpdateURL);
|
||||
#endif
|
||||
return IsUpdateAvailableHelper(szUpdateURL, szCheckAgainst, dwUpdateTimeout, lpFail);
|
||||
}
|
||||
|
||||
BOOL UpdateProduct(LPCWSTR wszDataStore)
|
||||
{
|
||||
HKEY hKey = NULL;
|
||||
DWORD dwSize = 0;
|
||||
DWORD dwQueriedPolicy = 0;
|
||||
BOOL bIsPolicyMatch = FALSE;
|
||||
CHAR szUpdateURL[MAX_PATH];
|
||||
ZeroMemory(szUpdateURL, MAX_PATH * sizeof(CHAR));
|
||||
strcat_s(szUpdateURL, MAX_PATH, "https://github.com/valinet/ExplorerPatcher/releases/latest/download/");
|
||||
|
||||
DWORD dwUpdateTimeout = UPDATES_DEFAULT_TIMEOUT;
|
||||
|
||||
RegCreateKeyExW(
|
||||
HKEY_CURRENT_USER,
|
||||
wszDataStore,
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_READ | KEY_WOW64_64KEY,
|
||||
NULL,
|
||||
&hKey,
|
||||
NULL
|
||||
);
|
||||
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
hKey = NULL;
|
||||
}
|
||||
if (hKey)
|
||||
{
|
||||
dwSize = MAX_PATH;
|
||||
RegQueryValueExA(
|
||||
hKey,
|
||||
"UpdateURL",
|
||||
0,
|
||||
NULL,
|
||||
szUpdateURL,
|
||||
&dwSize
|
||||
);
|
||||
strcat_s(szUpdateURL, MAX_PATH, SETUP_UTILITY_NAME);
|
||||
dwSize = sizeof(DWORD);
|
||||
RegQueryValueExA(
|
||||
hKey,
|
||||
"UpdateTimeout",
|
||||
0,
|
||||
NULL,
|
||||
&dwUpdateTimeout,
|
||||
&dwSize
|
||||
);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
#ifdef UPDATES_VERBOSE_OUTPUT
|
||||
printf("[Updates] Update URL: %s\n", szUpdateURL);
|
||||
#endif
|
||||
return IsUpdateAvailableHelper(szUpdateURL, NULL, dwUpdateTimeout, NULL);
|
||||
}
|
||||
|
||||
BOOL InstallUpdatesIfAvailable(DWORD dwOperation, DWORD bAllocConsole, DWORD dwUpdatePolicy)
|
||||
{
|
||||
if (bAllocConsole)
|
||||
{
|
||||
switch (dwUpdatePolicy)
|
||||
{
|
||||
default:
|
||||
case UPDATE_POLICY_AUTO:
|
||||
{
|
||||
dwUpdatePolicy = UPDATE_POLICY_AUTO;
|
||||
printf("[Updates] Configured update policy on this system: \"Install updates automatically\".\n");
|
||||
break;
|
||||
}
|
||||
case UPDATE_POLICY_NOTIFY:
|
||||
{
|
||||
printf("[Updates] Configured update policy on this system: \"Check for updates but let me choose whether to download and install them\".\n");
|
||||
break;
|
||||
}
|
||||
case UPDATE_POLICY_MANUAL:
|
||||
{
|
||||
printf("[Updates] Configured update policy on this system: \"Manually check for updates\".\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dwOperation == UPDATES_OP_INSTALL)
|
||||
{
|
||||
const wchar_t UpdateAvailableXML[] =
|
||||
L"<toast displayTimestamp=\"2021-08-29T00:00:00.000Z\" scenario=\"reminder\" "
|
||||
L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher/releases/latest\" duration=\"short\">\r\n"
|
||||
L" <visual>\r\n"
|
||||
L" <binding template=\"ToastGeneric\">\r\n"
|
||||
L" <text><![CDATA[Downloading and installing updates]]></text>\r\n"
|
||||
L" <text><![CDATA[An installation screen will show as soon as the download completes.]]></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";
|
||||
HRESULT hr = S_OK;
|
||||
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml = NULL;
|
||||
hr = String2IXMLDocument(
|
||||
UpdateAvailableXML,
|
||||
wcslen(UpdateAvailableXML),
|
||||
&inputXml,
|
||||
#ifdef DEBUG
|
||||
stdout
|
||||
#else
|
||||
NULL
|
||||
#endif
|
||||
);
|
||||
hr = ShowToastMessage(
|
||||
inputXml,
|
||||
APPID,
|
||||
sizeof(APPID) / sizeof(TCHAR) - 1,
|
||||
#ifdef DEBUG
|
||||
stdout
|
||||
#else
|
||||
NULL
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
WCHAR dllName[MAX_PATH];
|
||||
GetModuleFileNameW(hModule, dllName, MAX_PATH);
|
||||
wprintf(L"[Updates] Path to module: %s\n", dllName);
|
||||
|
||||
CHAR hash[100];
|
||||
ZeroMemory(hash, 100 * sizeof(CHAR));
|
||||
ComputeFileHash(dllName, hash, 100);
|
||||
|
||||
BOOL bFail = FALSE;
|
||||
if (IsUpdateAvailable(_T(REGPATH), hash, &bFail))
|
||||
{
|
||||
printf("[Updates] An update is available.\n");
|
||||
if ((dwOperation == UPDATES_OP_DEFAULT && dwUpdatePolicy == UPDATE_POLICY_AUTO) || (dwOperation == UPDATES_OP_INSTALL))
|
||||
{
|
||||
UpdateProduct(_T(REGPATH));
|
||||
}
|
||||
else if ((dwOperation == UPDATES_OP_DEFAULT && dwUpdatePolicy == UPDATE_POLICY_NOTIFY) || (dwOperation == UPDATES_OP_CHECK))
|
||||
{
|
||||
const wchar_t UpdateAvailableXML[] =
|
||||
L"<toast displayTimestamp=\"2021-08-29T00:00:00.000Z\" scenario=\"reminder\" "
|
||||
L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher/releases/latest\" duration=\"long\">\r\n"
|
||||
L" <visual>\r\n"
|
||||
L" <binding template=\"ToastGeneric\">\r\n"
|
||||
L" <text><![CDATA[An update is available]]></text>\r\n"
|
||||
L" <text><![CDATA[Right click the taskbar, choose \"Properties\", then \"Updates\" - \"Install latest version\". Click here to learn more about this 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";
|
||||
HRESULT hr = S_OK;
|
||||
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml = NULL;
|
||||
hr = String2IXMLDocument(
|
||||
UpdateAvailableXML,
|
||||
wcslen(UpdateAvailableXML),
|
||||
&inputXml,
|
||||
#ifdef DEBUG
|
||||
stdout
|
||||
#else
|
||||
NULL
|
||||
#endif
|
||||
);
|
||||
hr = ShowToastMessage(
|
||||
inputXml,
|
||||
APPID,
|
||||
sizeof(APPID) / sizeof(TCHAR) - 1,
|
||||
#ifdef DEBUG
|
||||
stdout
|
||||
#else
|
||||
NULL
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bFail)
|
||||
{
|
||||
printf("[Updates] Unable to check for updates because the remote server is unavailable.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("[Updates] No updates are available.\n");
|
||||
}
|
||||
if (dwOperation == UPDATES_OP_CHECK || dwOperation == UPDATES_OP_INSTALL)
|
||||
{
|
||||
const wchar_t UpdateAvailableXML[] =
|
||||
L"<toast displayTimestamp=\"2021-08-29T00:00:00.000Z\" scenario=\"reminder\" "
|
||||
L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher/releases/latest\" duration=\"short\">\r\n"
|
||||
L" <visual>\r\n"
|
||||
L" <binding template=\"ToastGeneric\">\r\n"
|
||||
L" <text><![CDATA[No updates are available]]></text>\r\n"
|
||||
L" <text><![CDATA[Please check back later.]]></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 UpdateAvailableXML2[] =
|
||||
L"<toast displayTimestamp=\"2021-08-29T00:00:00.000Z\" scenario=\"reminder\" "
|
||||
L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher/releases/latest\" duration=\"short\">\r\n"
|
||||
L" <visual>\r\n"
|
||||
L" <binding template=\"ToastGeneric\">\r\n"
|
||||
L" <text><![CDATA[Unable to check for updates]]></text>\r\n"
|
||||
L" <text><![CDATA[Make sure that you are connected to the Internet and that the remote server is online.]]></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";
|
||||
HRESULT hr = S_OK;
|
||||
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml = NULL;
|
||||
hr = String2IXMLDocument(
|
||||
bFail ? UpdateAvailableXML2 : UpdateAvailableXML,
|
||||
wcslen(bFail ? UpdateAvailableXML2 : UpdateAvailableXML),
|
||||
&inputXml,
|
||||
#ifdef DEBUG
|
||||
stdout
|
||||
#else
|
||||
NULL
|
||||
#endif
|
||||
);
|
||||
hr = ShowToastMessage(
|
||||
inputXml,
|
||||
APPID,
|
||||
sizeof(APPID) / sizeof(TCHAR) - 1,
|
||||
#ifdef DEBUG
|
||||
stdout
|
||||
#else
|
||||
NULL
|
||||
#endif
|
||||
);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
39
ExplorerPatcher/updates.h
Normal file
39
ExplorerPatcher/updates.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef _H_UPDATES_H_
|
||||
#define _H_UPDATES_H_
|
||||
#include <Windows.h>
|
||||
#include <stdio.h>
|
||||
#include <Wininet.h>
|
||||
#pragma comment(lib, "Wininet.lib")
|
||||
#include <shlobj_core.h>
|
||||
#include "utility.h"
|
||||
|
||||
extern HMODULE hModule;
|
||||
|
||||
#define UPDATES_VERBOSE_OUTPUT
|
||||
|
||||
#define UPDATE_POLICY_AUTO 0
|
||||
#define UPDATE_POLICY_NOTIFY 1
|
||||
#define UPDATE_POLICY_MANUAL 2
|
||||
#define UPDATE_POLICY_DEFAULT UPDATE_POLICY_NOTIFY
|
||||
|
||||
#define UPDATES_OP_DEFAULT 0
|
||||
#define UPDATES_OP_CHECK 1
|
||||
#define UPDATES_OP_INSTALL 2
|
||||
|
||||
#define UPDATES_USER_AGENT "ExplorerPatcher"
|
||||
#define UPDATES_FORM_HEADERS "Content-Type: text/plain;\r\n"
|
||||
#define UPDATES_HASH_SIZE 32
|
||||
#define UPDATES_BUFSIZ 10240
|
||||
#define UPDATES_DEFAULT_TIMEOUT 600
|
||||
|
||||
typedef struct IsUpdateAvailableParameters
|
||||
{
|
||||
HINTERNET hInternet;
|
||||
HANDLE hEvent;
|
||||
};
|
||||
|
||||
BOOL IsUpdatePolicy(LPCWSTR wszDataStore, DWORD dwUpdatePolicy);
|
||||
BOOL IsUpdateAvailable(LPCWSTR wszDataStore, char* szCheckAgainst);
|
||||
BOOL UpdateProduct(LPCWSTR wszDataStore);
|
||||
BOOL InstallUpdatesIfAvailable(DWORD dwOperation, DWORD bAllocConsole, DWORD dwUpdatePolicy);
|
||||
#endif
|
525
ep_setup/ep_setup.c
Normal file
525
ep_setup/ep_setup.c
Normal file
@ -0,0 +1,525 @@
|
||||
#include <Windows.h>
|
||||
#pragma comment(linker,"\"/manifestdependency:type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
|
||||
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#include <stdio.h>
|
||||
#include <Shlwapi.h>
|
||||
#pragma comment(lib, "Shlwapi.lib")
|
||||
#include "resource.h"
|
||||
#include "../ExplorerPatcher/utility.h"
|
||||
|
||||
BOOL SetupUninstallEntry(BOOL bInstall, WCHAR* wszPath)
|
||||
{
|
||||
DWORD dwLastError = ERROR_SUCCESS;
|
||||
HKEY hKey = NULL;
|
||||
|
||||
if (bInstall)
|
||||
{
|
||||
|
||||
if (!dwLastError)
|
||||
{
|
||||
dwLastError = RegCreateKeyExW(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" _T(EP_CLSID) L"_" _T(PRODUCT_NAME),
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_WRITE | KEY_WOW64_64KEY,
|
||||
NULL,
|
||||
&hKey,
|
||||
NULL
|
||||
);
|
||||
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
hKey = NULL;
|
||||
}
|
||||
if (hKey)
|
||||
{
|
||||
if (!dwLastError)
|
||||
{
|
||||
dwLastError = RegSetValueExW(
|
||||
hKey,
|
||||
L"UninstallString",
|
||||
0,
|
||||
REG_SZ,
|
||||
wszPath,
|
||||
(wcslen(wszPath) + 1) * sizeof(wchar_t)
|
||||
);
|
||||
}
|
||||
if (!dwLastError)
|
||||
{
|
||||
dwLastError = RegSetValueExW(
|
||||
hKey,
|
||||
L"DisplayName",
|
||||
0,
|
||||
REG_SZ,
|
||||
_T(PRODUCT_NAME),
|
||||
(wcslen(_T(PRODUCT_NAME)) + 1) * sizeof(wchar_t)
|
||||
);
|
||||
}
|
||||
if (!dwLastError)
|
||||
{
|
||||
dwLastError = RegSetValueExW(
|
||||
hKey,
|
||||
L"Publisher",
|
||||
0,
|
||||
REG_SZ,
|
||||
_T(PRODUCT_PUBLISHER),
|
||||
(wcslen(_T(PRODUCT_PUBLISHER)) + 1) * sizeof(wchar_t)
|
||||
);
|
||||
}
|
||||
if (!dwLastError)
|
||||
{
|
||||
DWORD dw1 = TRUE;
|
||||
dwLastError = RegSetValueExW(
|
||||
hKey,
|
||||
L"NoModify",
|
||||
0,
|
||||
REG_DWORD,
|
||||
&dw1,
|
||||
sizeof(DWORD)
|
||||
);
|
||||
}
|
||||
if (!dwLastError)
|
||||
{
|
||||
DWORD dw1 = TRUE;
|
||||
dwLastError = RegSetValueExW(
|
||||
hKey,
|
||||
L"NoRepair",
|
||||
0,
|
||||
REG_DWORD,
|
||||
&dw1,
|
||||
sizeof(DWORD)
|
||||
);
|
||||
}
|
||||
if (!dwLastError)
|
||||
{
|
||||
PathRemoveFileSpecW(wszPath);
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\" _T(PRODUCT_NAME) L".amd64.dll");
|
||||
HMODULE hEP = LoadLibraryExW(wszPath, NULL, LOAD_LIBRARY_AS_DATAFILE);
|
||||
if (hEP)
|
||||
{
|
||||
DWORD dwLeftMost = 0;
|
||||
DWORD dwSecondLeft = 0;
|
||||
DWORD dwSecondRight = 0;
|
||||
DWORD dwRightMost = 0;
|
||||
|
||||
QueryVersionInfo(hEP, VS_VERSION_INFO, &dwLeftMost, &dwSecondLeft, &dwSecondRight, &dwRightMost);
|
||||
|
||||
WCHAR wszBuf[20];
|
||||
swprintf_s(wszBuf, 20, L"%d.%d.%d.%d", dwLeftMost, dwSecondLeft, dwSecondRight, dwRightMost);
|
||||
|
||||
if (!dwLastError)
|
||||
{
|
||||
dwLastError = RegSetValueExW(
|
||||
hKey,
|
||||
L"DisplayVersion",
|
||||
0,
|
||||
REG_SZ,
|
||||
wszBuf,
|
||||
(wcslen(wszBuf) + 1) * sizeof(wchar_t)
|
||||
);
|
||||
if (!dwLastError)
|
||||
{
|
||||
dwLastError = RegSetValueExW(
|
||||
hKey,
|
||||
L"VersionMajor",
|
||||
0,
|
||||
REG_DWORD,
|
||||
&dwSecondRight,
|
||||
sizeof(DWORD)
|
||||
);
|
||||
if (!dwLastError)
|
||||
{
|
||||
dwLastError = RegSetValueExW(
|
||||
hKey,
|
||||
L"VersionMinor",
|
||||
0,
|
||||
REG_DWORD,
|
||||
&dwRightMost,
|
||||
sizeof(DWORD)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FreeLibrary(hEP);
|
||||
}
|
||||
}
|
||||
if (!dwLastError)
|
||||
{
|
||||
GetWindowsDirectoryW(wszPath, MAX_PATH);
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\explorer.exe");
|
||||
dwLastError = RegSetValueExW(
|
||||
hKey,
|
||||
L"DisplayIcon",
|
||||
0,
|
||||
REG_SZ,
|
||||
wszPath,
|
||||
(wcslen(wszPath) + 1) * sizeof(wchar_t)
|
||||
);
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!dwLastError)
|
||||
{
|
||||
dwLastError = RegOpenKeyW(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" _T(EP_CLSID) L"_" _T(PRODUCT_NAME),
|
||||
&hKey
|
||||
);
|
||||
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
hKey = NULL;
|
||||
}
|
||||
if (hKey)
|
||||
{
|
||||
dwLastError = RegDeleteTreeW(
|
||||
hKey,
|
||||
0
|
||||
);
|
||||
RegCloseKey(hKey);
|
||||
if (!dwLastError)
|
||||
{
|
||||
RegDeleteKeyW(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" _T(EP_CLSID) L"_" _T(PRODUCT_NAME)
|
||||
);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return !dwLastError;
|
||||
}
|
||||
|
||||
BOOL InstallResource(BOOL bInstall, HMODULE hModule, int res, WCHAR* wszPath)
|
||||
{
|
||||
if (PathFileExistsW(wszPath))
|
||||
{
|
||||
WCHAR wszReplace[MAX_PATH];
|
||||
wcscpy_s(wszReplace, MAX_PATH, wszPath);
|
||||
PathRemoveExtensionW(wszReplace);
|
||||
wcscat_s(wszReplace, MAX_PATH, L".prev");
|
||||
BOOL bRet = DeleteFileW(wszReplace);
|
||||
if (bRet || (!bRet && GetLastError() == ERROR_FILE_NOT_FOUND))
|
||||
{
|
||||
if (!MoveFileW(wszPath, wszReplace))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (res == 0)
|
||||
{
|
||||
if (bInstall)
|
||||
{
|
||||
wchar_t path[MAX_PATH];
|
||||
GetModuleFileNameW(hModule, path, MAX_PATH);
|
||||
return CopyFileW(path, wszPath, FALSE);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
HRSRC hRscr = FindResource(
|
||||
hModule,
|
||||
MAKEINTRESOURCE(res),
|
||||
RT_RCDATA
|
||||
);
|
||||
if (!hRscr)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
HGLOBAL hgRscr = LoadResource(
|
||||
hModule,
|
||||
hRscr
|
||||
);
|
||||
if (!hgRscr)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
void* pRscr = LockResource(hgRscr);
|
||||
DWORD cbRscr = SizeofResource(
|
||||
hModule,
|
||||
hRscr
|
||||
);
|
||||
if (bInstall)
|
||||
{
|
||||
HANDLE hFile = CreateFileW(
|
||||
wszPath,
|
||||
GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL
|
||||
);
|
||||
if (!hFile)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
DWORD dwNumberOfBytesWritten = 0;
|
||||
if (!WriteFile(
|
||||
hFile,
|
||||
pRscr,
|
||||
cbRscr,
|
||||
&dwNumberOfBytesWritten,
|
||||
NULL
|
||||
))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
int WINAPI wWinMain(
|
||||
_In_ HINSTANCE hInstance,
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nShowCmd
|
||||
)
|
||||
{
|
||||
BOOL bOk = TRUE, bInstall = TRUE, bWasShellExt = FALSE;
|
||||
|
||||
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||
|
||||
if (!IsAppRunningAsAdminMode())
|
||||
{
|
||||
WCHAR wszPath[MAX_PATH];
|
||||
ZeroMemory(wszPath, ARRAYSIZE(wszPath));
|
||||
if (GetModuleFileNameW(NULL, wszPath, ARRAYSIZE(wszPath)))
|
||||
{
|
||||
SHELLEXECUTEINFOW sei;
|
||||
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFOW));
|
||||
sei.cbSize = sizeof(sei);
|
||||
sei.lpVerb = L"runas";
|
||||
sei.lpFile = wszPath;
|
||||
sei.lpParameters = lpCmdLine;
|
||||
sei.hwnd = NULL;
|
||||
sei.nShow = SW_NORMAL;
|
||||
if (!ShellExecuteExW(&sei))
|
||||
{
|
||||
DWORD dwError = GetLastError();
|
||||
if (dwError == ERROR_CANCELLED)
|
||||
{
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
int argc = 0;
|
||||
LPWSTR* wargv = CommandLineToArgvW(
|
||||
lpCmdLine,
|
||||
&argc
|
||||
);
|
||||
|
||||
WCHAR wszPath[MAX_PATH];
|
||||
ZeroMemory(wszPath, MAX_PATH * sizeof(WCHAR));
|
||||
if (bOk)
|
||||
{
|
||||
bOk = GetWindowsDirectoryW(wszPath, MAX_PATH);
|
||||
}
|
||||
if (bOk)
|
||||
{
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\dxgi.dll");
|
||||
bInstall = !FileExistsW(wszPath) || (argc >= 1 && !_wcsicmp(wargv[0], L"/update_silent"));
|
||||
}
|
||||
if (!bInstall)
|
||||
{
|
||||
if (MessageBoxW(
|
||||
NULL,
|
||||
L"Are you sure you want to remove " _T(PRODUCT_NAME) L" from your computer?",
|
||||
_T(PRODUCT_NAME),
|
||||
MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION
|
||||
) == IDNO)
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszPath);
|
||||
wcscat_s(wszPath, MAX_PATH, _T(APP_RELATIVE_PATH));
|
||||
bOk = CreateDirectoryW(wszPath, NULL);
|
||||
if (bOk || (!bOk && GetLastError() == ERROR_ALREADY_EXISTS))
|
||||
{
|
||||
bOk = TRUE;
|
||||
|
||||
GetSystemDirectoryW(wszPath, MAX_PATH);
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\taskkill.exe");
|
||||
ShellExecuteW(
|
||||
NULL,
|
||||
L"open",
|
||||
wszPath,
|
||||
L"/f /im explorer.exe",
|
||||
NULL,
|
||||
SW_SHOWMINIMIZED
|
||||
);
|
||||
|
||||
if (bOk)
|
||||
{
|
||||
SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszPath);
|
||||
wcscat_s(wszPath, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(SETUP_UTILITY_NAME));
|
||||
bOk = InstallResource(bInstall, hInstance, 0, wszPath);
|
||||
}
|
||||
if (bOk)
|
||||
{
|
||||
if (!bInstall)
|
||||
{
|
||||
HKEY hKey;
|
||||
RegOpenKeyExW(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Classes\\CLSID\\" TEXT(EP_CLSID) L"\\InProcServer32",
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_READ,
|
||||
&hKey
|
||||
);
|
||||
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
hKey = NULL;
|
||||
}
|
||||
if (hKey)
|
||||
{
|
||||
bWasShellExt = TRUE;
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
if (bWasShellExt)
|
||||
{
|
||||
WCHAR wszArgs[MAX_PATH];
|
||||
wszArgs[0] = L'/';
|
||||
wszArgs[1] = L'u';
|
||||
wszArgs[2] = L' ';
|
||||
wszArgs[3] = L'"';
|
||||
SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszArgs + 4);
|
||||
wcscat_s(wszArgs, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(PRODUCT_NAME) L".amd64.dll\"");
|
||||
wprintf(L"%s\n", wszArgs);
|
||||
WCHAR wszApp[MAX_PATH * 2];
|
||||
GetSystemDirectoryW(wszApp, MAX_PATH * 2);
|
||||
wcscat_s(wszApp, MAX_PATH * 2, L"\\regsvr32.exe");
|
||||
wprintf(L"%s\n", wszApp);
|
||||
SHELLEXECUTEINFOW sei;
|
||||
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFOW));
|
||||
sei.cbSize = sizeof(sei);
|
||||
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
|
||||
sei.hwnd = NULL;
|
||||
sei.hInstApp = NULL;
|
||||
sei.lpVerb = NULL;
|
||||
sei.lpFile = wszApp;
|
||||
sei.lpParameters = wszArgs;
|
||||
sei.hwnd = NULL;
|
||||
sei.nShow = SW_NORMAL;
|
||||
if (ShellExecuteExW(&sei) && sei.hProcess)
|
||||
{
|
||||
WaitForSingleObject(sei.hProcess, INFINITE);
|
||||
DWORD dwExitCode = 0;
|
||||
GetExitCodeProcess(sei.hProcess, &dwExitCode);
|
||||
SetLastError(dwExitCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bOk)
|
||||
{
|
||||
SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszPath);
|
||||
wcscat_s(wszPath, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(PRODUCT_NAME) L".IA-32.dll");
|
||||
bOk = InstallResource(bInstall, hInstance, IDR_EP_IA32, wszPath);
|
||||
}
|
||||
if (bOk)
|
||||
{
|
||||
PathRemoveFileSpecW(wszPath);
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\" _T(PRODUCT_NAME) L".amd64.dll");
|
||||
bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath);
|
||||
}
|
||||
if (bOk)
|
||||
{
|
||||
bOk = GetWindowsDirectoryW(wszPath, MAX_PATH);
|
||||
}
|
||||
if (bOk)
|
||||
{
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\dxgi.dll");
|
||||
bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath);
|
||||
}
|
||||
if (bOk)
|
||||
{
|
||||
bOk = GetWindowsDirectoryW(wszPath, MAX_PATH);
|
||||
}
|
||||
if (bOk)
|
||||
{
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\SystemApps\\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\\dxgi.dll");
|
||||
bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath);
|
||||
}
|
||||
if (bOk)
|
||||
{
|
||||
SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszPath);
|
||||
wcscat_s(wszPath, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(SETUP_UTILITY_NAME));
|
||||
bOk = SetupUninstallEntry(bInstall, wszPath);
|
||||
}
|
||||
|
||||
if (bOk)
|
||||
{
|
||||
if (!bInstall)
|
||||
{
|
||||
if (bWasShellExt)
|
||||
{
|
||||
if (MessageBoxW(
|
||||
NULL,
|
||||
L"Please reboot the computer to complete the uninstall.\n\nDo you want to reboot now?",
|
||||
_T(PRODUCT_NAME),
|
||||
MB_YESNO | MB_DEFBUTTON1 | MB_ICONQUESTION
|
||||
) == IDYES)
|
||||
{
|
||||
SystemShutdown(TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBoxW(
|
||||
NULL,
|
||||
L"Uninstall completed. Thank you for using " _T(PRODUCT_NAME) L".",
|
||||
_T(PRODUCT_NAME),
|
||||
MB_ICONASTERISK | MB_OK | MB_DEFBUTTON1
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//ZZRestartExplorer(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
if (!bOk && !(argc >= 1 && !_wcsicmp(wargv[0], L"/update_silent")))
|
||||
{
|
||||
MessageBoxW(
|
||||
NULL,
|
||||
L"An error has occured when attempting to service the product. Please reboot the computer and try again.",
|
||||
_T(PRODUCT_NAME),
|
||||
MB_ICONERROR | MB_OK | MB_DEFBUTTON1
|
||||
);
|
||||
}
|
||||
|
||||
GetWindowsDirectoryW(wszPath, MAX_PATH);
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\explorer.exe");
|
||||
Sleep(1000);
|
||||
ShellExecuteW(
|
||||
NULL,
|
||||
L"open",
|
||||
wszPath,
|
||||
NULL,
|
||||
NULL,
|
||||
SW_SHOWNORMAL
|
||||
);
|
||||
}
|
||||
|
||||
return GetLastError();
|
||||
}
|
110
ep_setup/ep_setup.rc
Normal file
110
ep_setup/ep_setup.rc
Normal file
@ -0,0 +1,110 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United States) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2021,11,13,1
|
||||
PRODUCTVERSION 2021,11,13,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "VALINET Solutions SRL"
|
||||
VALUE "FileDescription", "ExplorerPatcher Setup Program"
|
||||
VALUE "FileVersion", "2021.11.13.1"
|
||||
VALUE "InternalName", "ep_setup.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2006-2021 VALINET Solutions SRL. All rights reserved."
|
||||
VALUE "OriginalFilename", "ep_setup.exe"
|
||||
VALUE "ProductName", "ExplorerPatcher"
|
||||
VALUE "ProductVersion", "2021.11.13.1"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RCDATA
|
||||
//
|
||||
|
||||
IDR_EP_AMD64 RCDATA "..\\build\\Release\\ExplorerPatcher.amd64.dll"
|
||||
|
||||
IDR_EP_IA32 RCDATA "..\\build\\Release\\ExplorerPatcher.IA-32.dll"
|
||||
|
||||
#endif // English (United States) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
172
ep_setup/ep_setup.vcxproj
Normal file
172
ep_setup/ep_setup.vcxproj
Normal file
@ -0,0 +1,172 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{2fd40b09-f224-4e9a-b2fe-a22b50b2debf}</ProjectGuid>
|
||||
<RootNamespace>epsetup</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(Configuration)</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(Configuration)</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(Configuration)</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(Configuration)</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\ExplorerPatcher\utility.c" />
|
||||
<ClCompile Include="ep_setup.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\ExplorerPatcher\utility.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="ep_setup.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\build\Release\ExplorerPatcher.amd64.dll" />
|
||||
<None Include="..\build\Release\ExplorerPatcher.IA-32.dll" />
|
||||
<None Include="applicat.bin" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
45
ep_setup/ep_setup.vcxproj.filters
Normal file
45
ep_setup/ep_setup.vcxproj.filters
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ep_setup.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ExplorerPatcher\utility.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ExplorerPatcher\utility.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="ep_setup.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\build\Release\ExplorerPatcher.amd64.dll" />
|
||||
<None Include="..\build\Release\ExplorerPatcher.IA-32.dll" />
|
||||
<None Include="applicat.bin">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
17
ep_setup/resource.h
Normal file
17
ep_setup/resource.h
Normal file
@ -0,0 +1,17 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by ep_setup.rc
|
||||
//
|
||||
#define IDR_EP_AMD64 103
|
||||
#define IDR_EP_IA32 104
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 105
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
69
ep_setup_patch/ep_setup_patch.c
Normal file
69
ep_setup_patch/ep_setup_patch.c
Normal file
@ -0,0 +1,69 @@
|
||||
#include <Windows.h>
|
||||
#include <Shlwapi.h>
|
||||
#pragma comment(lib, "Shlwapi.lib")
|
||||
#include "../ExplorerPatcher/utility.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
WCHAR wszPath[MAX_PATH];
|
||||
GetModuleFileNameW(GetModuleHandle(NULL), wszPath, MAX_PATH);
|
||||
PathRemoveFileSpecW(wszPath);
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\" _T(PRODUCT_NAME) L".amd64.dll");
|
||||
|
||||
CHAR hash[100];
|
||||
ZeroMemory(hash, 100);
|
||||
ComputeFileHash(wszPath, hash, 100);
|
||||
|
||||
PathRemoveFileSpecW(wszPath);
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\" _T(SETUP_UTILITY_NAME));
|
||||
|
||||
HANDLE hFile = CreateFileW(wszPath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
HANDLE hFileMapping = CreateFileMappingW(hFile, NULL, PAGE_READWRITE, 0, 0, NULL);
|
||||
if (hFileMapping == 0)
|
||||
{
|
||||
CloseHandle(hFile);
|
||||
return 2;
|
||||
}
|
||||
|
||||
char* lpFileBase = MapViewOfFile(hFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);
|
||||
if (lpFileBase == 0)
|
||||
{
|
||||
CloseHandle(hFileMapping);
|
||||
CloseHandle(hFile);
|
||||
return 3;
|
||||
}
|
||||
|
||||
memcpy(lpFileBase + DOSMODE_OFFSET, hash, strlen(hash));
|
||||
|
||||
UnmapViewOfFile(lpFileBase);
|
||||
CloseHandle(hFileMapping);
|
||||
CloseHandle(hFile);
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
SHELLEXECUTEINFO ShExecInfo = { 0 };
|
||||
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
|
||||
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
|
||||
ShExecInfo.hwnd = NULL;
|
||||
ShExecInfo.lpVerb = L"runas";
|
||||
ShExecInfo.lpFile = wszPath;
|
||||
ShExecInfo.lpParameters = L"/update_silent";
|
||||
ShExecInfo.lpDirectory = NULL;
|
||||
ShExecInfo.nShow = SW_SHOW;
|
||||
ShExecInfo.hInstApp = NULL;
|
||||
if (ShellExecuteExW(&ShExecInfo) && ShExecInfo.hProcess)
|
||||
{
|
||||
WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
|
||||
DWORD dwExitCode = 0;
|
||||
GetExitCodeProcess(ShExecInfo.hProcess, &dwExitCode);
|
||||
return dwExitCode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
163
ep_setup_patch/ep_setup_patch.vcxproj
Normal file
163
ep_setup_patch/ep_setup_patch.vcxproj
Normal file
@ -0,0 +1,163 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{0c13e5f3-106b-4836-a7c2-8e5808a6ed78}</ProjectGuid>
|
||||
<RootNamespace>epsetuppatch</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(Configuration)</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(Configuration)</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(Configuration)</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(Configuration)</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\ExplorerPatcher\utility.c" />
|
||||
<ClCompile Include="ep_setup_patch.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\ExplorerPatcher\utility.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
30
ep_setup_patch/ep_setup_patch.vcxproj.filters
Normal file
30
ep_setup_patch/ep_setup_patch.vcxproj.filters
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ep_setup_patch.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ExplorerPatcher\utility.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\ExplorerPatcher\utility.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user