mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-23 23:21:08 +01:00
Updates: Support for ep_make
This commit is contained in:
parent
c41b93b6b4
commit
80592f666d
@ -1 +1 @@
|
||||
Subproject commit a43a9d4cac99373f70526b13487a12b9c15ad72e
|
||||
Subproject commit a57caf12f43374f53b7467cc7b1bc1b3aaa3edcf
|
@ -421,8 +421,15 @@ BOOL IsUpdateAvailableHelper(
|
||||
BOOL bRet = DeleteFileW(wszPath);
|
||||
if (bRet || (!bRet && GetLastError() == ERROR_FILE_NOT_FOUND))
|
||||
{
|
||||
DWORD bIsUsingEpMake = 0, dwSize = sizeof(DWORD);
|
||||
RegGetValueW(HKEY_CURRENT_USER, TEXT(REGPATH), L"UpdateUseLocal", RRF_RT_DWORD, NULL, &bIsUsingEpMake, &dwSize);
|
||||
if (bIsUsingEpMake) {
|
||||
GetSystemDirectoryW(wszPath, MAX_PATH);
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\WindowsPowerShell\\v1.0\\powershell.exe");
|
||||
}
|
||||
|
||||
FILE* f = NULL;
|
||||
if (!_wfopen_s(
|
||||
if (!bIsUsingEpMake && !_wfopen_s(
|
||||
&f,
|
||||
wszPath,
|
||||
L"wb"
|
||||
@ -463,7 +470,7 @@ BOOL IsUpdateAvailableHelper(
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
if (bIsUpdateAvailable)
|
||||
if (bIsUsingEpMake || bIsUpdateAvailable)
|
||||
{
|
||||
bIsUpdateAvailable = FALSE;
|
||||
#ifdef UPDATES_VERBOSE_OUTPUT
|
||||
@ -572,9 +579,9 @@ BOOL IsUpdateAvailableHelper(
|
||||
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
|
||||
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
|
||||
ShExecInfo.hwnd = NULL;
|
||||
ShExecInfo.lpVerb = L"runas";
|
||||
ShExecInfo.lpVerb = bIsUsingEpMake ? L"open" : L"runas";
|
||||
ShExecInfo.lpFile = wszPath;
|
||||
ShExecInfo.lpParameters = L"/update_silent";
|
||||
ShExecInfo.lpParameters = bIsUsingEpMake ? L"iex (irm 'https://raw.githubusercontent.com/valinet/ep_make/master/ep_make_safe.ps1')" : L"/update_silent";
|
||||
ShExecInfo.lpDirectory = NULL;
|
||||
ShExecInfo.nShow = SW_SHOW;
|
||||
ShExecInfo.hInstApp = NULL;
|
||||
@ -1063,7 +1070,9 @@ BOOL InstallUpdatesIfAvailable(
|
||||
|
||||
CHAR hash[100];
|
||||
ZeroMemory(hash, 100 * sizeof(CHAR));
|
||||
ComputeFileHash2(hModule, dllName, hash, 100);
|
||||
GetHardcodedHash(dllName, hash, 100);
|
||||
if (!strcmp(hash, "This")) ComputeFileHash2(hModule, dllName, hash, 100);
|
||||
else printf("[Updates] Using hardcoded hash.\n");
|
||||
|
||||
BOOL bFail = FALSE, bReturnValue = FALSE;
|
||||
dwLeftMost = 0; dwSecondLeft = 0; dwSecondRight = 0; dwRightMost = 0;
|
||||
|
@ -351,6 +351,36 @@ int ComputeFileHash2(HMODULE hModule, LPCWSTR filename, LPSTR hash, DWORD dwHash
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
void GetHardcodedHash(LPCWSTR wszPath, LPSTR hash, DWORD dwHash)
|
||||
{
|
||||
HANDLE hFile = CreateFileW(wszPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
HANDLE hFileMapping = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||
if (hFileMapping == 0)
|
||||
{
|
||||
CloseHandle(hFile);
|
||||
return 2;
|
||||
}
|
||||
|
||||
char* lpFileBase = MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0);
|
||||
if (lpFileBase == 0)
|
||||
{
|
||||
CloseHandle(hFileMapping);
|
||||
CloseHandle(hFile);
|
||||
return 3;
|
||||
}
|
||||
|
||||
memcpy_s(hash, MIN(32, dwHash), lpFileBase + DOSMODE_OFFSET, 32);
|
||||
|
||||
UnmapViewOfFile(lpFileBase);
|
||||
CloseHandle(hFileMapping);
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
void LaunchPropertiesGUI(HMODULE hModule)
|
||||
{
|
||||
//CreateThread(0, 0, ZZGUI, 0, 0, 0);
|
||||
|
@ -273,6 +273,8 @@ int ComputeFileHash(LPCWSTR filename, LPSTR hash, DWORD dwHash);
|
||||
|
||||
int ComputeFileHash2(HMODULE hModule, LPCWSTR filename, LPSTR hash, DWORD dwHash);
|
||||
|
||||
void GetHardcodedHash(LPCWSTR wszPath, LPSTR hash, DWORD dwHash);
|
||||
|
||||
void LaunchPropertiesGUI(HMODULE hModule);
|
||||
|
||||
BOOL SystemShutdown(BOOL reboot);
|
||||
|
@ -349,6 +349,7 @@
|
||||
#define IDS_UPDATES_INSTALL 1814
|
||||
#define IDS_UPDATES_CHANGES 1815
|
||||
#define IDS_UPDATES_LEARN 1816
|
||||
#define IDS_UPDATES_USELOCAL 1817
|
||||
|
||||
#define IDS_ADV 1901
|
||||
#define IDS_ADV_DISCLAIMER 1902
|
||||
|
@ -391,6 +391,7 @@ BEGIN
|
||||
IDS_UPDATES_INSTALL "Update program and restart File Explorer"
|
||||
IDS_UPDATES_CHANGES "Read about changes in the latest releases"
|
||||
IDS_UPDATES_LEARN "Learn more"
|
||||
IDS_UPDATES_USELOCAL "Build updates locally before installing"
|
||||
|
||||
IDS_ADV "Advanced"
|
||||
|
||||
|
@ -713,6 +713,8 @@
|
||||
"UpdatePreferStaging"=dword:00000000
|
||||
;b %R:1807%
|
||||
"UpdateAllowDowngrades"=dword:00000000
|
||||
;b %R:1817%
|
||||
"UpdateUseLocal"=dword:00000000
|
||||
;t %R:1808%
|
||||
;w %R:1809%
|
||||
;%R:1810%
|
||||
|
@ -524,6 +524,8 @@
|
||||
"UpdatePreferStaging"=dword:00000000
|
||||
;b %R:1807%
|
||||
"UpdateAllowDowngrades"=dword:00000000
|
||||
;b %R:1817%
|
||||
"UpdateUseLocal"=dword:00000000
|
||||
;t %R:1808%
|
||||
;w %R:1809%
|
||||
;%R:1810%
|
||||
|
@ -354,10 +354,25 @@ BOOL InstallResourceHelper(BOOL bInstall, HMODULE hModule, HRSRC hRscr, WCHAR* w
|
||||
return FALSE;
|
||||
}
|
||||
DWORD dwNumberOfBytesWritten = 0;
|
||||
int offset = 0;
|
||||
wchar_t wszDxgi[MAX_PATH];
|
||||
if (GetWindowsDirectoryW(wszDxgi, MAX_PATH)) {
|
||||
wcscat_s(wszDxgi, MAX_PATH, L"\\dxgi.dll");
|
||||
if (!wcscmp(wszPath, wszDxgi)) {
|
||||
WCHAR wszOwnPath[MAX_PATH];
|
||||
GetModuleFileNameW(GetModuleHandle(NULL), wszOwnPath, MAX_PATH);
|
||||
CHAR hash[100];
|
||||
GetHardcodedHash(wszOwnPath, hash, 100);
|
||||
WriteFile(hFile, pRscr, DOSMODE_OFFSET, &dwNumberOfBytesWritten, NULL);
|
||||
offset += dwNumberOfBytesWritten;
|
||||
WriteFile(hFile, hash, 32, &dwNumberOfBytesWritten, NULL);
|
||||
offset += dwNumberOfBytesWritten;
|
||||
}
|
||||
}
|
||||
if (!WriteFile(
|
||||
hFile,
|
||||
pRscr,
|
||||
cbRscr,
|
||||
(char*)pRscr + offset,
|
||||
cbRscr - offset,
|
||||
&dwNumberOfBytesWritten,
|
||||
NULL
|
||||
))
|
||||
|
Loading…
Reference in New Issue
Block a user