1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-30 18:24:36 +01:00
ExplorerPatcher/ep_setup_patch/ep_setup_patch.c
Valentin Radu 92dadf6374 * 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
2021-11-14 18:37:16 +02:00

69 lines
2.0 KiB
C

#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;
}