1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-27 17:00:59 +01:00

Setup: Revised the method for bundling files in the setup binary.

Now with preserved file names, compression, and encryption.
This commit is contained in:
Amrsatrio 2024-07-23 23:40:54 +07:00
parent 1fcd7d7322
commit 30579b0238
12 changed files with 1935 additions and 252 deletions

View File

@ -86,6 +86,11 @@ jobs:
run: |
nuget restore ExplorerPatcher.sln
- name: Setup dependency projects
shell: cmd
run: |
GenerateDependencyProjects.bat
# - name: Download ep_taskbar
# uses: robinraju/release-downloader@v1
# with:
@ -113,26 +118,6 @@ jobs:
# done
# fi
- name: Build funchook amd64
shell: powershell
run: |
cd libs/funchook
md build
cd build
cmake -G "Visual Studio 17 2022" -A x64 -DFUNCHOOK_CPU=x86 ..
(gc .\funchook-static.vcxproj) -replace '<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>', '<RuntimeLibrary>MultiThreaded</RuntimeLibrary>' | Out-File .\funchook-static.vcxproj
cmake --build . --config Release
- name: Build funchook arm64
shell: powershell
run: |
cd libs/funchook
md build-arm64
cd build-arm64
cmake -G "Visual Studio 17 2022" -A ARM64 -DFUNCHOOK_CPU=arm64 -DFUNCHOOK_DISASM=capstone -DFUNCHOOK_BUILD_TESTS=OFF ..
(gc .\funchook-static.vcxproj) -replace '<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>', '<RuntimeLibrary>MultiThreaded</RuntimeLibrary>' | Out-File .\funchook-static.vcxproj
cmake --build . --config Release
- name: Build EP IA-32
if: github.event.inputs.config == ''
working-directory: ${{env.GITHUB_WORKSPACE}}

View File

@ -139,7 +139,6 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)libs\funchook\build\Release\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<DelayLoadDLLs>Winmm.dll</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
@ -173,7 +172,7 @@
<CallingConvention>Cdecl</CallingConvention>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(SolutionDir)libs\funchook\build\Release\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)libs\funchook\build-$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='ARM64'">
@ -182,7 +181,7 @@
<CallingConvention>Cdecl</CallingConvention>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(SolutionDir)libs\funchook\build-arm64\Release\;$(SolutionDir)libs\funchook\build-arm64\_deps\capstone-build\Release\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)libs\funchook\build-$(Platform)\$(Configuration)\;$(SolutionDir)libs\funchook\build-arm64\_deps\capstone-build\Release\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='ARM64EC'">
@ -308,6 +307,9 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="..\GenerateDependencyProjects.bat" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.230824.2\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.230824.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
@ -318,4 +320,7 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.230824.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.230824.2\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
</Target>
<Target Name="BuildDependencies" BeforeTargets="PrepareForBuild">
<Exec Command="cmake --build . --config $(Configuration)" WorkingDirectory="$(SolutionDir)libs\funchook\build-$(Platform)" Condition="'$(WithMainPatcher)'=='true'" />
</Target>
</Project>

View File

@ -0,0 +1,10 @@
rmdir /s /q libs\funchook\build
rmdir /s /q libs\funchook\build-x64
rmdir /s /q libs\funchook\build-arm64
rmdir /s /q libs\zlib\build-x64
rmdir /s /q libs\zlib\build-arm64
cmake libs/funchook -Blibs/funchook/build-x64 -G "Visual Studio 17 2022" -A x64 -D"CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DFUNCHOOK_CPU=x86 -DFUNCHOOK_BUILD_TESTS=OFF
cmake libs/funchook -Blibs/funchook/build-arm64 -G "Visual Studio 17 2022" -A ARM64 -D"CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DFUNCHOOK_CPU=arm64 -DFUNCHOOK_DISASM=capstone -DFUNCHOOK_BUILD_TESTS=OFF
cmake libs/zlib -Blibs/zlib/build-x64 -G "Visual Studio 17 2022" -A x64 -D"CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW
cmake libs/zlib -Blibs/zlib/build-arm64 -G "Visual Studio 17 2022" -A ARM64 -D"CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW

View File

@ -120,12 +120,12 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
<Link>
<AdditionalLibraryDirectories>$(SolutionDir)libs\funchook\build\Release\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)libs\funchook\build-x64\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='ARM64'">
<Link>
<AdditionalLibraryDirectories>$(SolutionDir)libs\funchook\build-arm64\Release\;$(SolutionDir)libs\funchook\build-arm64\_deps\capstone-build\Release\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)libs\funchook\build-arm64\$(Configuration)\;$(SolutionDir)libs\funchook\build-arm64\_deps\capstone-build\Release\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@ -168,4 +168,7 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
</Target>
<Target Name="BuildDependencies" BeforeTargets="PrepareForBuild">
<Exec Command="cmake --build . --config $(Configuration)" WorkingDirectory="$(SolutionDir)libs\funchook\build-$(Platform)" />
</Target>
</Project>

View File

@ -7,6 +7,13 @@ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#pragma comment(lib, "Shlwapi.lib")
#include "resources/resource.h"
#include "../ExplorerPatcher/utility.h"
#include "../version.h"
#include <zlib.h>
#include <minizip/unzip.h>
#ifdef WITH_ENCRYPTION
#include "rijndael-alg-fst.c" // Include the C file for __forceinline to work
#endif
#pragma comment(lib, "zlibstatic.lib")
BOOL SetupShortcut(BOOL bInstall, WCHAR* wszPath, WCHAR* wszArguments)
{
@ -290,7 +297,190 @@ BOOL SetupUninstallEntry(BOOL bInstall, WCHAR* wszPath)
return !dwLastError;
}
BOOL InstallResourceHelper(BOOL bInstall, HMODULE hModule, HRSRC hRscr, WCHAR* wszPath)
typedef struct
{
PBYTE base;
ZPOS64_T size;
ZPOS64_T curOffset;
} MemoryBuffer;
void MemoryBuffer_Destroy(MemoryBuffer** mem)
{
if (*mem)
{
if ((*mem)->base)
free((*mem)->base);
free(*mem);
*mem = NULL;
}
}
voidpf ZCALLBACK MemOpenFile(voidpf opaque, const void* filename, int mode)
{
MemoryBuffer* pMem = (MemoryBuffer*)opaque;
return pMem;
}
uLong ZCALLBACK MemReadFile(voidpf opaque, voidpf stream, void* buf, uLong size)
{
MemoryBuffer* pMem = (MemoryBuffer*)stream;
uLong toRead = size;
if (pMem->curOffset + toRead > pMem->size)
{
toRead = pMem->size - pMem->curOffset;
}
if (toRead > 0)
{
memcpy(buf, pMem->base + pMem->curOffset, toRead);
pMem->curOffset += toRead;
}
return toRead;
}
uLong ZCALLBACK MemWriteFile(voidpf opaque, voidpf stream, const void* buf, uLong size)
{
return 0;
}
ZPOS64_T ZCALLBACK MemTellFile(voidpf opaque, voidpf stream)
{
MemoryBuffer* pMem = (MemoryBuffer*)stream;
return pMem->curOffset;
}
long ZCALLBACK MemSeekFile(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
{
MemoryBuffer* pMem = (MemoryBuffer*)stream;
ZPOS64_T newOffset;
switch (origin)
{
case ZLIB_FILEFUNC_SEEK_CUR:
newOffset = pMem->curOffset + offset;
break;
case ZLIB_FILEFUNC_SEEK_END:
newOffset = pMem->size + offset;
break;
case ZLIB_FILEFUNC_SEEK_SET:
newOffset = offset;
break;
default:
return -1;
}
if (newOffset > pMem->size)
{
return -1;
}
pMem->curOffset = newOffset;
return 0;
}
int ZCALLBACK MemCloseFile(voidpf opaque, voidpf stream)
{
return 0;
}
int ZCALLBACK MemErrorFile(voidpf opaque, voidpf stream)
{
return 0;
}
void FillMemoryFileIOFunctions(zlib_filefunc64_def* pFileFunc, MemoryBuffer* pMem)
{
pFileFunc->zopen64_file = MemOpenFile;
pFileFunc->zread_file = MemReadFile;
pFileFunc->zwrite_file = MemWriteFile;
pFileFunc->ztell64_file = MemTellFile;
pFileFunc->zseek64_file = MemSeekFile;
pFileFunc->zclose_file = MemCloseFile;
pFileFunc->zerror_file = MemErrorFile;
pFileFunc->opaque = pMem;
}
#define AES_KEYBITS 256
#define KEYLENGTH( keybits ) ( ( keybits ) / 8 )
#define RKLENGTH( keybits ) ( ( keybits ) / 8 + 28 )
#define NROUNDS( keybits ) ( ( keybits ) / 32 + 6 )
#if defined(WITH_ENCRYPTION) && !defined(ZIP_ENCRYPTION_KEY)
#define ZIP_ENCRYPTION_KEY 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
#endif
unzFile LoadZipFileFromResources(MemoryBuffer** outMem)
{
*outMem = NULL;
HRSRC hRsrc = FindResourceW(NULL, MAKEINTRESOURCE(IDR_EP_ZIP), RT_RCDATA);
if (!hRsrc)
{
return NULL;
}
HGLOBAL hGlobal = LoadResource(NULL, hRsrc);
if (!hGlobal)
{
return NULL;
}
PBYTE pRsrc = (PBYTE)LockResource(hGlobal);
DWORD cbRsrc = SizeofResource(NULL, hRsrc);
if (!pRsrc || !cbRsrc)
{
return NULL;
}
#ifdef WITH_ENCRYPTION
if ((cbRsrc % 16) != 0)
{
return NULL;
}
#endif
MemoryBuffer* pMem = (MemoryBuffer*)malloc(sizeof(MemoryBuffer));
if (!pMem)
{
return NULL;
}
pMem->base = (PBYTE)malloc(cbRsrc);
pMem->size = cbRsrc;
pMem->curOffset = 0;
if (!pMem->base)
{
free(pMem);
return NULL;
}
*outMem = pMem;
#ifdef WITH_ENCRYPTION
BYTE keyBytes[32] = { ZIP_ENCRYPTION_KEY };
UINT rk[RKLENGTH(AES_KEYBITS)] = { 0 };
int nrounds = rijndaelKeySetupDec(rk, keyBytes, AES_KEYBITS);
// Decrypt the data a block at a time
for (UINT offset = 0; offset < cbRsrc; offset += 16)
{
rijndaelDecrypt(rk, nrounds, pRsrc + offset, pMem->base + offset);
}
#else
memcpy(mem->base, pRsrc, cbRsrc);
#endif
zlib_filefunc64_def fileFunc = { 0 };
FillMemoryFileIOFunctions(&fileFunc, pMem);
return unzOpen2_64(NULL, &fileFunc);
}
BOOL InstallResourceHelper(BOOL bInstall, HMODULE hModule, unzFile zipFile, const WCHAR* wszPath)
{
WCHAR wszReplace[MAX_PATH];
wcscpy_s(wszReplace, MAX_PATH, wszPath);
@ -313,7 +503,7 @@ BOOL InstallResourceHelper(BOOL bInstall, HMODULE hModule, HRSRC hRscr, WCHAR* w
return FALSE;
}
}
if (!hRscr)
if (!zipFile)
{
if (bInstall)
{
@ -323,85 +513,81 @@ BOOL InstallResourceHelper(BOOL bInstall, HMODULE hModule, HRSRC hRscr, WCHAR* w
}
return TRUE;
}
else
if (!bInstall)
{
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;
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,
(char*)pRscr + offset,
cbRscr - offset,
&dwNumberOfBytesWritten,
NULL
))
{
return FALSE;
}
CloseHandle(hFile);
}
return TRUE;
}
unz_file_info64 fileInfo = { 0 };
// Caller (InstallResource) has already called unzOpenCurrentFile
if (unzGetCurrentFileInfo64(zipFile, &fileInfo, NULL, 0, NULL, 0, NULL, 0) != UNZ_OK)
{
return FALSE;
}
BOOL bRet = FALSE;
void* pRscr = malloc(fileInfo.uncompressed_size);
DWORD cbRscr = fileInfo.uncompressed_size;
if (pRscr)
{
if (unzReadCurrentFile(zipFile, pRscr, cbRscr) == cbRscr)
{
HANDLE hFile = CreateFileW(wszPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile)
{
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;
}
}
bRet = WriteFile(hFile, (char*)pRscr + offset, cbRscr - offset, &dwNumberOfBytesWritten, NULL);
CloseHandle(hFile);
}
}
free(pRscr);
}
// Caller (InstallResource) will call unzCloseCurrentFile
return bRet;
}
BOOL InstallResource(BOOL bInstall, HMODULE hInstance, int res, LPCWSTR pwszDirectory, LPCWSTR pwszFileName)
__declspec(noinline) BOOL InstallResource(BOOL bInstall, HMODULE hInstance, unzFile zipFile, const char* pszFileNameInZip, LPCWSTR pwszDirectory, LPCWSTR pwszFileName)
{
BOOL bOk = TRUE;
HRSRC hRscr = NULL;
if (res == 0 || ((hRscr = FindResourceW(hInstance, MAKEINTRESOURCE(res), RT_RCDATA))))
if (bInstall && zipFile && pszFileNameInZip)
{
WCHAR wszPath[MAX_PATH];
wcscpy_s(wszPath, MAX_PATH, pwszDirectory);
wcscat_s(wszPath, MAX_PATH, L"\\");
wcscat_s(wszPath, MAX_PATH, pwszFileName);
bOk = InstallResourceHelper(bInstall, hInstance, hRscr, wszPath);
int resultLocateFile = unzLocateFile(zipFile, pszFileNameInZip, 0);
if (resultLocateFile != UNZ_OK)
{
return resultLocateFile == UNZ_END_OF_LIST_OF_FILE; // Don't touch this file, we don't pack this file in the setup
}
if (unzOpenCurrentFile(zipFile) != UNZ_OK)
{
return FALSE;
}
}
return bOk;
WCHAR wszPath[MAX_PATH];
wcscpy_s(wszPath, MAX_PATH, pwszDirectory);
wcscat_s(wszPath, MAX_PATH, L"\\");
wcscat_s(wszPath, MAX_PATH, pwszFileName);
BOOL bRet = InstallResourceHelper(bInstall, hInstance, zipFile, wszPath);
if (bInstall && zipFile && pszFileNameInZip)
unzCloseCurrentFile(zipFile);
return bRet;
}
BOOL DeleteResource(LPCWSTR pwszDirectory, LPCWSTR pwszFileName)
@ -459,13 +645,13 @@ BOOL DownloadResource(BOOL bInstall, LPCWSTR pwszURL, DWORD dwSize, LPCSTR chash
return bOk;
}
void ProcessTaskbarDlls(BOOL* bInOutOk, BOOL bInstall, BOOL bExtractMode, HINSTANCE hInstance, WCHAR wszPath[260])
void ProcessTaskbarDlls(BOOL* bInOutOk, BOOL bInstall, BOOL bExtractMode, HINSTANCE hInstance, unzFile zipFile, WCHAR wszPath[260])
{
LPCWSTR pwszTaskbarDllName = bExtractMode ? NULL : PickTaskbarDll();
if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.2.dll")), hInstance, IDR_EP_TASKBAR_2, wszPath, L"ep_taskbar.2.dll");
if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.3.dll")), hInstance, IDR_EP_TASKBAR_3, wszPath, L"ep_taskbar.3.dll");
if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.4.dll")), hInstance, IDR_EP_TASKBAR_4, wszPath, L"ep_taskbar.4.dll");
if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.5.dll")), hInstance, IDR_EP_TASKBAR_5, wszPath, L"ep_taskbar.5.dll");
if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.2.dll")), hInstance, zipFile, "ep_taskbar.2.dll", wszPath, L"ep_taskbar.2.dll");
if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.3.dll")), hInstance, zipFile, "ep_taskbar.3.dll", wszPath, L"ep_taskbar.3.dll");
if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.4.dll")), hInstance, zipFile, "ep_taskbar.4.dll", wszPath, L"ep_taskbar.4.dll");
if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.5.dll")), hInstance, zipFile, "ep_taskbar.5.dll", wszPath, L"ep_taskbar.5.dll");
}
int WINAPI wWinMain(
@ -501,19 +687,26 @@ int WINAPI wWinMain(
{
GetCurrentDirectoryW(MAX_PATH, wszPath);
}
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_IA32, wszPath, _T(PRODUCT_NAME) L".IA-32.dll");
MemoryBuffer* pMem;
unzFile zipFile = LoadZipFileFromResources(&pMem);
bOk = zipFile != NULL;
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".IA-32.dll", wszPath, _T(PRODUCT_NAME) L".IA-32.dll");
#if defined(_M_X64)
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath, _T(PRODUCT_NAME) L".amd64.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".amd64.dll", wszPath, _T(PRODUCT_NAME) L".amd64.dll");
#elif defined(_M_ARM64)
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath, _T(PRODUCT_NAME) L".arm64.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".arm64.dll", wszPath, _T(PRODUCT_NAME) L".arm64.dll");
#endif
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_DWM, wszPath, L"ep_dwm.exe");
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_WEATHER, wszPath, L"ep_weather_host.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_WEATHER_STUB, wszPath, L"ep_weather_host_stub.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_MS_WEBVIEW2_LOADER, wszPath, L"WebView2Loader.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_STARTMENU, wszPath, L"wincorlib.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_GUI, wszPath, L"ep_gui.dll");
ProcessTaskbarDlls(&bOk, bInstall, TRUE, hInstance, wszPath);
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "ep_dwm.exe", wszPath, L"ep_dwm.exe");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "ep_weather_host.dll", wszPath, L"ep_weather_host.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "ep_weather_host_stub.dll", wszPath, L"ep_weather_host_stub.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "WebView2Loader.dll", wszPath, L"WebView2Loader.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "wincorlib.dll", wszPath, L"wincorlib.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "ep_gui.dll", wszPath, L"ep_gui.dll");
ProcessTaskbarDlls(&bOk, bInstall, TRUE, hInstance, zipFile, wszPath);
if (zipFile)
unzClose(zipFile);
if (pMem)
MemoryBuffer_Destroy(&pMem);
return !bOk;
}
@ -593,6 +786,17 @@ int WINAPI wWinMain(
exit(0);
}
MemoryBuffer* pMem = NULL;
unzFile zipFile = NULL;
if (bInstall)
{
zipFile = LoadZipFileFromResources(&pMem);
if (!zipFile)
{
exit(0);
}
}
DWORD bIsUndockingDisabled = FALSE, dwSize = sizeof(DWORD);
RegGetValueW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell\\Update\\Packages", L"UndockingDisabled", RRF_RT_DWORD, NULL, &bIsUndockingDisabled, &dwSize);
if (bIsUndockingDisabled)
@ -628,23 +832,23 @@ int WINAPI wWinMain(
if (explorerProcessId != 0)
{
HANDLE explorerProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, explorerProcessId);
if (explorerProcess != NULL)
if (explorerProcess != NULL)
{
OpenProcessToken(explorerProcess, TOKEN_QUERY | TOKEN_DUPLICATE | TOKEN_ASSIGN_PRIMARY, &userToken);
CloseHandle(explorerProcess);
}
if (userToken)
if (userToken)
{
HANDLE myToken = INVALID_HANDLE_VALUE;
OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_DUPLICATE | TOKEN_ASSIGN_PRIMARY, &myToken);
if (myToken != INVALID_HANDLE_VALUE)
if (myToken != INVALID_HANDLE_VALUE)
{
DWORD cbSizeNeeded = 0;
SetLastError(0);
if (!GetTokenInformation(userToken, TokenUser, NULL, 0, &cbSizeNeeded) && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
TOKEN_USER* userTokenInfo = malloc(cbSizeNeeded);
if (userTokenInfo)
if (userTokenInfo)
{
if (GetTokenInformation(userToken, TokenUser, userTokenInfo, cbSizeNeeded, &cbSizeNeeded))
{
@ -819,7 +1023,7 @@ int WINAPI wWinMain(
// C:\Program Files\ExplorerPatcher
SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszPath);
wcscat_s(wszPath, MAX_PATH, _T(APP_RELATIVE_PATH));
if (bOk && bInstall) bOk = InstallResource(bInstall, hInstance, 0, wszPath, _T(SETUP_UTILITY_NAME));
if (bOk && bInstall) bOk = InstallResource(bInstall, hInstance, NULL, NULL, wszPath, _T(SETUP_UTILITY_NAME));
if (bOk)
{
if (!bInstall)
@ -881,28 +1085,32 @@ int WINAPI wWinMain(
}
}
}
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_IA32, wszPath, _T(PRODUCT_NAME) L".IA-32.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".IA-32.dll", wszPath, _T(PRODUCT_NAME) L".IA-32.dll");
#if defined(_M_X64)
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath, _T(PRODUCT_NAME) L".amd64.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".amd64.dll", wszPath, _T(PRODUCT_NAME) L".amd64.dll");
#elif defined(_M_ARM64)
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath, _T(PRODUCT_NAME) L".arm64.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".arm64.dll", wszPath, _T(PRODUCT_NAME) L".arm64.dll");
#endif
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_GUI, wszPath, L"ep_gui.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_DWM, wszPath, L"ep_dwm.exe");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "ep_gui.dll", wszPath, L"ep_gui.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "ep_dwm.exe", wszPath, L"ep_dwm.exe");
if (bInstall)
{
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_WEATHER, wszPath, L"ep_weather_host.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_WEATHER_STUB, wszPath, L"ep_weather_host_stub.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_MS_WEBVIEW2_LOADER, wszPath, L"WebView2Loader.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "ep_weather_host.dll", wszPath, L"ep_weather_host.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "ep_weather_host_stub.dll", wszPath, L"ep_weather_host_stub.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "WebView2Loader.dll", wszPath, L"WebView2Loader.dll");
}
ProcessTaskbarDlls(&bOk, bInstall, FALSE, hInstance, wszPath);
ProcessTaskbarDlls(&bOk, bInstall, FALSE, hInstance, zipFile, wszPath);
// --------------------------------------------------------------------------------
// C:\Windows
// + dxgi.dll
if (bOk) GetWindowsDirectoryW(wszPath, MAX_PATH);
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath, L"dxgi.dll");
#if defined(_M_X64)
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".amd64.dll", wszPath, L"dxgi.dll");
#elif defined(_M_ARM64)
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".arm64.dll", wszPath, L"dxgi.dll");
#endif
// --------------------------------------------------------------------------------
@ -917,8 +1125,12 @@ int WINAPI wWinMain(
// - pris2\Windows.UI.ShellCommon.en-US.pri
if (bOk) GetWindowsDirectoryW(wszPath, MAX_PATH);
if (bOk) wcscat_s(wszPath, MAX_PATH, L"\\SystemApps\\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy");
if (bOk) bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath, L"dxgi.dll");
if (bOk) bOk = InstallResource(bInstall && IsWindows11(), hInstance, IDR_EP_STARTMENU, wszPath, L"wincorlib.dll");
#if defined(_M_X64)
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".amd64.dll", wszPath, L"dxgi.dll");
#elif defined(_M_ARM64)
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".arm64.dll", wszPath, L"dxgi.dll");
#endif
if (bOk) bOk = InstallResource(bInstall && IsWindows11(), hInstance, zipFile, "ep_startmenu.dll", wszPath, L"wincorlib.dll");
if (bOk) bOk = DeleteResource(wszPath, L"wincorlib_orig.dll");
if (bOk && IsWindows11() && bInstall)
{
@ -972,7 +1184,11 @@ int WINAPI wWinMain(
// + dxgi.dll
if (bOk) GetWindowsDirectoryW(wszPath, MAX_PATH);
if (bOk) wcscat_s(wszPath, MAX_PATH, L"\\SystemApps\\ShellExperienceHost_cw5n1h2txyewy");
if (bOk && IsWindows11()) bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath, L"dxgi.dll");
#if defined(_M_X64)
if (bOk && IsWindows11()) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".amd64.dll", wszPath, L"dxgi.dll");
#elif defined(_M_ARM64)
if (bOk && IsWindows11()) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".arm64.dll", wszPath, L"dxgi.dll");
#endif
// --------------------------------------------------------------------------------
@ -1208,5 +1424,10 @@ int WINAPI wWinMain(
if (userToken != INVALID_HANDLE_VALUE) CloseHandle(userToken);
}
if (zipFile)
unzClose(zipFile);
if (pMem)
MemoryBuffer_Destroy(&pMem);
return GetLastError();
}

View File

@ -32,6 +32,8 @@
<ProjectGuid>{2fd40b09-f224-4e9a-b2fe-a22b50b2debf}</ProjectGuid>
<RootNamespace>epsetup</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<GitCommitHashShort>0000000</GitCommitHashShort>
<WithEncryption>true</WithEncryption>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -128,11 +130,12 @@
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;$(SolutionDir)libs\zlib;$(SolutionDir)libs\zlib\contrib;$(SolutionDir)libs\zlib\build-$(Platform);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)libs\zlib\build-$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -144,13 +147,14 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;$(SolutionDir)libs\zlib;$(SolutionDir)libs\zlib\contrib;$(SolutionDir)libs\zlib\build-$(Platform);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)libs\zlib\build-$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -160,11 +164,12 @@
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;$(SolutionDir)libs\zlib;$(SolutionDir)libs\zlib\contrib;$(SolutionDir)libs\zlib\build-$(Platform);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)libs\zlib\build-$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -176,13 +181,14 @@
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;$(SolutionDir)libs\zlib;$(SolutionDir)libs\zlib\contrib;$(SolutionDir)libs\zlib\build-$(Platform);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)libs\zlib\build-$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
@ -192,11 +198,12 @@
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;$(SolutionDir)libs\zlib;$(SolutionDir)libs\zlib\contrib;$(SolutionDir)libs\zlib\build-$(Platform);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)libs\zlib\build-$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
@ -208,15 +215,21 @@
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;$(SolutionDir)libs\zlib;$(SolutionDir)libs\zlib\contrib;$(SolutionDir)libs\zlib\build-$(Platform);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)libs\zlib\build-$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(WithEncryption)' == 'true'">
<ClCompile>
<PreprocessorDefinitions>WITH_ENCRYPTION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="Exists('..\build\$(Configuration)\$(Platform)\ep_taskbar.2.dll')">
<ResourceCompile>
<PreprocessorDefinitions>EP_TASKBAR_2_EXISTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -250,10 +263,15 @@
<ItemGroup>
<ClCompile Include="..\ExplorerPatcher\utility.c" />
<ClCompile Include="ep_setup.c" />
<ClCompile Include="..\libs\zlib\contrib\minizip\ioapi.c" />
<ClCompile Include="..\libs\zlib\contrib\minizip\unzip.c">
<PreprocessorDefinitions>NOCRYPT;NOUNCRYPT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\ExplorerPatcher\utility.h" />
<ClInclude Include="resources\resource.h" />
<ClInclude Include="rijndael-alg-fst.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resources\ep_setup.rc">
@ -266,38 +284,104 @@
<ResourceCompile Include="..\ExplorerPatcher-L10N\resources\lang\ep_setup.*.rc" Condition="Exists('..\ExplorerPatcher-L10N\resources\lang')" />
</ItemGroup>
<ItemGroup>
<None Include="..\build\Debug\ep_dwm.exe">
<ExcludedFromBuild Condition="'$(Configuration)'=='Release'">true</ExcludedFromBuild>
</None>
<None Include="..\build\Debug\ep_weather_host.dll">
<ExcludedFromBuild Condition="'$(Configuration)'=='Release'">true</ExcludedFromBuild>
</None>
<None Include="..\build\Debug\ep_weather_host_stub.dll">
<ExcludedFromBuild Condition="'$(Configuration)'=='Release'">true</ExcludedFromBuild>
</None>
<None Include="..\build\Debug\ExplorerPatcher.amd64.dll">
<ExcludedFromBuild Condition="'$(Configuration)'=='Release'">true</ExcludedFromBuild>
</None>
<None Include="..\build\Debug\ExplorerPatcher.IA-32.dll">
<ExcludedFromBuild Condition="'$(Configuration)'=='Release'">true</ExcludedFromBuild>
</None>
<None Include="..\build\Release\ep_dwm.exe">
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug'">true</ExcludedFromBuild>
</None>
<None Include="..\build\Release\ep_weather_host.dll">
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug'">true</ExcludedFromBuild>
</None>
<None Include="..\build\Release\ep_weather_host_stub.dll">
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug'">true</ExcludedFromBuild>
</None>
<None Include="..\build\Release\ExplorerPatcher.amd64.dll">
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug'">true</ExcludedFromBuild>
</None>
<None Include="..\build\Release\ExplorerPatcher.IA-32.dll">
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug'">true</ExcludedFromBuild>
</None>
<None Include="applicat.bin" />
</ItemGroup>
<ItemGroup>
<PackFile Include="..\build\$(Configuration)\$(Platform)\ExplorerPatcher.IA-32.dll" Condition="Exists('..\build\$(Configuration)\$(Platform)\ExplorerPatcher.IA-32.dll')" />
<PackFile Include="..\build\$(Configuration)\$(Platform)\ExplorerPatcher.amd64.dll" Condition="Exists('..\build\$(Configuration)\$(Platform)\ExplorerPatcher.amd64.dll')" />
<PackFile Include="..\build\$(Configuration)\$(Platform)\WebView2Loader.dll" Condition="Exists('..\build\$(Configuration)\$(Platform)\WebView2Loader.dll')" />
<PackFile Include="..\build\$(Configuration)\$(Platform)\ep_dwm.exe" Condition="Exists('..\build\$(Configuration)\$(Platform)\ep_dwm.exe')" />
<PackFile Include="..\build\$(Configuration)\$(Platform)\ep_gui.dll" Condition="Exists('..\build\$(Configuration)\$(Platform)\ep_gui.dll')" />
<PackFile Include="..\build\$(Configuration)\$(Platform)\ep_startmenu.dll" Condition="Exists('..\build\$(Configuration)\$(Platform)\ep_startmenu.dll')" />
<PackFile Include="..\build\$(Configuration)\$(Platform)\ep_taskbar.2.dll" Condition="Exists('..\build\$(Configuration)\$(Platform)\ep_taskbar.2.dll')" />
<PackFile Include="..\build\$(Configuration)\$(Platform)\ep_taskbar.3.dll" Condition="Exists('..\build\$(Configuration)\$(Platform)\ep_taskbar.3.dll')" />
<PackFile Include="..\build\$(Configuration)\$(Platform)\ep_taskbar.4.dll" Condition="Exists('..\build\$(Configuration)\$(Platform)\ep_taskbar.4.dll')" />
<PackFile Include="..\build\$(Configuration)\$(Platform)\ep_taskbar.5.dll" Condition="Exists('..\build\$(Configuration)\$(Platform)\ep_taskbar.5.dll')" />
<PackFile Include="..\build\$(Configuration)\$(Platform)\ep_weather_host.dll" Condition="Exists('..\build\$(Configuration)\$(Platform)\ep_weather_host.dll')" />
<PackFile Include="..\build\$(Configuration)\$(Platform)\ep_weather_host_stub.dll" Condition="Exists('..\build\$(Configuration)\$(Platform)\ep_weather_host_stub.dll')" />
</ItemGroup>
<Target Name="GetCommitHash" AfterTargets="PrepareForBuild">
<Exec Command="git rev-parse --short HEAD" ConsoleToMSBuild="true" Condition="'$(GitCommitHashShort)' == '0000000'">
<Output TaskParameter="ConsoleOutput" PropertyName="GitCommitHashShort" />
</Exec>
<Message Text="Git commit hash: $(GitCommitHashShort)" />
</Target>
<UsingTask TaskName="GenerateAesKey" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Seed ParameterType="System.String" Required="true" />
<EncryptionKey ParameterType="System.String" Output="true" />
<EncryptionKeyCommaSeparated ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
using (System.Security.Cryptography.SHA256 sha256 = System.Security.Cryptography.SHA256.Create())
{
byte[] seedBytes = System.Text.Encoding.UTF8.GetBytes(Seed);
byte[] hashBytes = sha256.ComputeHash(seedBytes);
Random random = new System.Random(System.BitConverter.ToInt32(hashBytes, 0));
byte[] keyBytes = new byte[32];
random.NextBytes(keyBytes);
EncryptionKey = System.BitConverter.ToString(keyBytes).Replace("-", "").ToLowerInvariant();
EncryptionKeyCommaSeparated = "0x" + System.BitConverter.ToString(keyBytes).Replace("-", ",0x");
}
]]>
</Code>
</Task>
</UsingTask>
<Target Name="GenerateAesKey" AfterTargets="GetCommitHash">
<GenerateAesKey Seed="$(GitCommitHashShort)" Condition="'$(WithEncryption)' == 'true'">
<Output TaskParameter="EncryptionKey" PropertyName="ZipEncryptionKey" />
<Output TaskParameter="EncryptionKeyCommaSeparated" PropertyName="ZipEncryptionKeyCommaSeparated" />
</GenerateAesKey>
<ItemGroup Condition="'$(WithEncryption)' == 'true'">
<ClCompile>
<PreprocessorDefinitions>ZIP_ENCRYPTION_KEY=$(ZipEncryptionKeyCommaSeparated);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemGroup>
<Message Text="Generated AES key: 0x$(ZipEncryptionKey)" Condition="'$(WithEncryption)' == 'true'" />
</Target>
<UsingTask TaskName="EncryptFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<OutputFile ParameterType="System.String" />
<EncryptionKey ParameterType="System.String" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
using (System.Security.Cryptography.Aes aes = System.Security.Cryptography.Aes.Create())
{
int numChars = EncryptionKey.Length;
byte[] keyBytes = new byte[numChars / 2];
for (int i = 0; i < numChars; i += 2)
{
keyBytes[i / 2] = System.Convert.ToByte(EncryptionKey.Substring(i, 2), 16);
}
aes.Key = keyBytes;
aes.Mode = System.Security.Cryptography.CipherMode.ECB;
using (System.IO.FileStream inputFileStream = new System.IO.FileStream(OutputFile, System.IO.FileMode.Open, System.IO.FileAccess.Read))
using (System.IO.FileStream outputFileStream = new System.IO.FileStream(OutputFile + ".bin", System.IO.FileMode.Create, System.IO.FileAccess.Write))
using (System.Security.Cryptography.ICryptoTransform encryptor = aes.CreateEncryptor())
using (System.Security.Cryptography.CryptoStream cryptoStream = new System.Security.Cryptography.CryptoStream(outputFileStream, encryptor, System.Security.Cryptography.CryptoStreamMode.Write))
{
inputFileStream.CopyTo(cryptoStream);
}
}
]]>
</Code>
</Task>
</UsingTask>
<Target Name="CreateZip" BeforeTargets="ResourceCompile">
<Copy SourceFiles="@(PackFile)" DestinationFolder="..\build\$(Configuration)\$(Platform)\ep_setup_files" />
<ZipDirectory SourceDirectory="..\build\$(Configuration)\$(Platform)\ep_setup_files" DestinationFile="..\build\$(Configuration)\$(Platform)\ep_setup_files.zip" Overwrite="true" />
<EncryptFile OutputFile="..\build\$(Configuration)\$(Platform)\ep_setup_files.zip" EncryptionKey="$(ZipEncryptionKey)" Condition="'$(WithEncryption)' == 'true'" />
<Copy SourceFiles="..\build\$(Configuration)\$(Platform)\ep_setup_files.zip" DestinationFiles="..\build\$(Configuration)\$(Platform)\ep_setup_files.zip.bin" Condition="'$(WithEncryption)' != 'true'" />
</Target>
<Target Name="BuildDependencies" BeforeTargets="PrepareForBuild">
<Exec Command="cmake --build . --config $(Configuration)" WorkingDirectory="$(SolutionDir)libs\zlib\build-$(Platform)" />
</Target>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -90,71 +90,13 @@ END
// RCDATA
//
IDR_EP_IA32 RCDATA "..\\build\\Release\\Win32\\ExplorerPatcher.IA-32.dll"
#if defined(PLATFORM_AMD64)
IDR_EP_AMD64 RCDATA "..\\build\\Release\\x64\\ExplorerPatcher.amd64.dll"
IDR_EP_DWM RCDATA "..\\build\\Release\\x64\\ep_dwm.exe"
IDR_EP_WEATHER RCDATA "..\\build\\Release\\x64\\ep_weather_host.dll"
IDR_EP_WEATHER_STUB RCDATA "..\\build\\Release\\x64\\ep_weather_host_stub.dll"
IDR_MS_WEBVIEW2_LOADER RCDATA "..\\build\\Release\\x64\\WebView2Loader.dll"
IDR_EP_STARTMENU RCDATA "..\\build\\Release\\x64\\ep_startmenu.dll"
IDR_EP_GUI RCDATA "..\\build\\Release\\x64\\ep_gui.dll"
#if EP_TASKBAR_2_EXISTS
IDR_EP_TASKBAR_2 RCDATA "..\\build\\Release\\x64\\ep_taskbar.2.dll"
#endif
#if EP_TASKBAR_3_EXISTS
IDR_EP_TASKBAR_3 RCDATA "..\\build\\Release\\x64\\ep_taskbar.3.dll"
#endif
#if EP_TASKBAR_4_EXISTS
IDR_EP_TASKBAR_4 RCDATA "..\\build\\Release\\x64\\ep_taskbar.4.dll"
#endif
#if EP_TASKBAR_5_EXISTS
IDR_EP_TASKBAR_5 RCDATA "..\\build\\Release\\x64\\ep_taskbar.5.dll"
#endif
IDR_EP_ZIP RCDATA "..\\build\\Release\\x64\\ep_setup_files.zip.bin"
#elif defined(PLATFORM_ARM64)
IDR_EP_AMD64 RCDATA "..\\build\\Release\\ARM64\\ExplorerPatcher.arm64.dll"
IDR_EP_DWM RCDATA "..\\build\\Release\\ARM64\\ep_dwm.exe"
IDR_EP_WEATHER RCDATA "..\\build\\Release\\ARM64\\ep_weather_host.dll"
IDR_EP_WEATHER_STUB RCDATA "..\\build\\Release\\ARM64\\ep_weather_host_stub.dll"
IDR_MS_WEBVIEW2_LOADER RCDATA "..\\build\\Release\\ARM64\\WebView2Loader.dll"
IDR_EP_STARTMENU RCDATA "..\\build\\Release\\ARM64\\ep_startmenu.dll"
IDR_EP_GUI RCDATA "..\\build\\Release\\ARM64\\ep_gui.dll"
#if EP_TASKBAR_2_EXISTS
IDR_EP_TASKBAR_2 RCDATA "..\\build\\Release\\ARM64\\ep_taskbar.2.dll"
#endif
#if EP_TASKBAR_3_EXISTS
IDR_EP_TASKBAR_3 RCDATA "..\\build\\Release\\ARM64\\ep_taskbar.3.dll"
#endif
#if EP_TASKBAR_4_EXISTS
IDR_EP_TASKBAR_4 RCDATA "..\\build\\Release\\ARM64\\ep_taskbar.4.dll"
#endif
#if EP_TASKBAR_5_EXISTS
IDR_EP_TASKBAR_5 RCDATA "..\\build\\Release\\ARM64\\ep_taskbar.5.dll"
#endif
IDR_EP_ZIP RCDATA "..\\build\\Release\\ARM64\\ep_setup_files.zip.bin"
#endif

View File

@ -68,11 +68,11 @@ BEGIN
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "VALINET Solutions SRL"
VALUE "CompanyName", "ExplorerPatcher Developers"
VALUE "FileDescription", "ExplorerPatcher Setup Program (Debug Build)"
VER_FILE_STRING
VALUE "InternalName", "ep_setup.exe"
VALUE "LegalCopyright", "Copyright (C) 2006-2024 VALINET Solutions SRL. All rights reserved."
VALUE "LegalCopyright", "(C) 2021-2024 ExplorerPatcher Developers. All rights reserved."
VALUE "OriginalFilename", "ep_setup.exe"
VALUE "ProductName", "ExplorerPatcher"
VER_PRODUCT_STRING
@ -90,21 +90,15 @@ END
// RCDATA
//
IDR_EP_AMD64 RCDATA "..\\build\\Debug\\ExplorerPatcher.amd64.dll"
#if defined(PLATFORM_AMD64)
IDR_EP_IA32 RCDATA "..\\build\\Debug\\ExplorerPatcher.IA-32.dll"
IDR_EP_ZIP RCDATA "..\\build\\Debug\\x64\\ep_setup_files.zip.bin"
IDR_EP_DWM RCDATA "..\\build\\Debug\\ep_dwm.exe"
#elif defined(PLATFORM_ARM64)
IDR_EP_WEATHER RCDATA "..\\build\\Debug\\ep_weather_host.dll"
IDR_EP_ZIP RCDATA "..\\build\\Debug\\ARM64\\ep_setup_files.zip.bin"
IDR_EP_WEATHER_STUB RCDATA "..\\build\\Debug\\ep_weather_host_stub.dll"
IDR_MS_WEBVIEW2_LOADER RCDATA "..\\build\\Debug\\WebView2Loader.dll"
IDR_EP_STARTMENU RCDATA "..\\build\\Debug\\ep_startmenu.dll"
IDR_EP_GUI RCDATA "..\\build\\Debug\\ep_gui.dll"
#endif
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

View File

@ -2,18 +2,7 @@
// Microsoft Visual C++ generated include file.
// Used by ep_setup.rc
//
#define IDR_EP_AMD64 103
#define IDR_EP_IA32 104
#define IDR_EP_DWM 105
#define IDR_EP_WEATHER 106
#define IDR_EP_WEATHER_STUB 107
#define IDR_MS_WEBVIEW2_LOADER 201
#define IDR_EP_STARTMENU 108
#define IDR_EP_GUI 109
#define IDR_EP_TASKBAR_2 110
#define IDR_EP_TASKBAR_3 111
#define IDR_EP_TASKBAR_4 112
#define IDR_EP_TASKBAR_5 113
#define IDR_EP_ZIP 103
#define IDS_SETUP_UNSUPPORTED_ARCH 301
#define IDS_SETUP_UNINSTALL_PROMPT 302

1402
ep_setup/rijndael-alg-fst.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
/**
* rijndael-alg-fst.h
*
* @version 3.0 (December 2000)
*
* Optimised ANSI C code for the Rijndael cipher (now AES)
*
* @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
* @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
* @author Paulo Barreto <paulo.barreto@terra.com.br>
*
* This code is hereby placed in the public domain.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __RIJNDAEL_ALG_FST_H
#define __RIJNDAEL_ALG_FST_H
#define MAXKC (256/32)
#define MAXKB (256/8)
#define MAXNR 14
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]);
void rijndaelDecrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 ct[16], u8 pt[16]);
#ifdef INTERMEDIATE_VALUE_KAT
void rijndaelEncryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds);
void rijndaelDecryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds);
#endif /* INTERMEDIATE_VALUE_KAT */
#endif /* __RIJNDAEL_ALG_FST_H */

1
libs/zlib Submodule

@ -0,0 +1 @@
Subproject commit ceadaf28dfa48dbf238a0ddb884d4c543b4170e8