From 3099b59e6e4eabbb929888ba12a42ceab2e2b29c Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Sat, 30 Oct 2021 07:17:25 +0300 Subject: [PATCH] Small fixes, fixed compilation --- ExplorerPatcher/ExplorerPatcher.rc | 8 +++---- ExplorerPatcher/ExplorerPatcher.vcxproj | 1 + ExplorerPatcher/dllmain.c | 31 +++++++++++++++++++++++++ ExplorerPatcher/settings.reg | 4 +++- ExplorerPatcher/utility.c | 10 ++++---- 5 files changed, 44 insertions(+), 10 deletions(-) diff --git a/ExplorerPatcher/ExplorerPatcher.rc b/ExplorerPatcher/ExplorerPatcher.rc index ddcf15f..33d0c0c 100644 --- a/ExplorerPatcher/ExplorerPatcher.rc +++ b/ExplorerPatcher/ExplorerPatcher.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 22000,258,32,0 - PRODUCTVERSION 22000,258,32,0 + FILEVERSION 22000,282,32,0 + PRODUCTVERSION 22000,282,32,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -69,12 +69,12 @@ BEGIN BEGIN VALUE "CompanyName", "VALINET Solutions SRL" VALUE "FileDescription", "ExplorerPatcher" - VALUE "FileVersion", "22000.258.32.0" + VALUE "FileVersion", "22000.282.32.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.258.32.0" + VALUE "ProductVersion", "22000.282.32.0" END END BLOCK "VarFileInfo" diff --git a/ExplorerPatcher/ExplorerPatcher.vcxproj b/ExplorerPatcher/ExplorerPatcher.vcxproj index a025fea..f4f2c8e 100644 --- a/ExplorerPatcher/ExplorerPatcher.vcxproj +++ b/ExplorerPatcher/ExplorerPatcher.vcxproj @@ -183,6 +183,7 @@ $(SolutionDir)libs\funchook\include;$(SolutionDir)libs\libvalinet;$(SolutionDir)libs\funchook\distorm\include;$(SolutionDir)libs\Detours\include;%(AdditionalIncludeDirectories) MultiThreadedDebug StdCall + $(SolutionDir)debug.h Console diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index d5ede2e..25d6373 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -2674,6 +2674,37 @@ void WINAPI LoadSettings(BOOL bIsExplorer) &bAllocConsole, &dwSize ); + DWORD bMemcheck = FALSE; + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("Memcheck"), + 0, + NULL, + &bMemcheck, + &dwSize + ); + if (bMemcheck) + { +#if defined(DEBUG) | defined(_DEBUG) + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT); + _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT); + _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT); + _CrtDumpMemoryLeaks(); +#endif + bMemcheck = FALSE; + RegSetValueExW( + hKey, + TEXT("Memcheck"), + 0, + REG_DWORD, + &bMemcheck, + sizeof(DWORD) + ); + } dwSize = sizeof(DWORD); RegQueryValueExW( hKey, diff --git a/ExplorerPatcher/settings.reg b/ExplorerPatcher/settings.reg index afc852f..5ea8e23 100644 --- a/ExplorerPatcher/settings.reg +++ b/ExplorerPatcher/settings.reg @@ -166,7 +166,7 @@ "IncludeWallpaper"=dword:00000001 ;b Always show on primary monitor "PrimaryOnly"=dword:00000000 -;b Show windows only on current monitor +;b Show windows only from current monitor "PerMonitor"=dword:00000000 ;c 3 Theme ;x 2 Mica (default) @@ -285,6 +285,8 @@ [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher] ;b Enable console * "AllocConsole"=dword:00000000 +;b Dump memory leaks +"Memcheck"=dword:00000000 ;c 12 Supplimentary delay at logon * ;x 0 None (default) ;x 300 300 ms diff --git a/ExplorerPatcher/utility.c b/ExplorerPatcher/utility.c index 301046d..3fc68b9 100644 --- a/ExplorerPatcher/utility.c +++ b/ExplorerPatcher/utility.c @@ -423,16 +423,16 @@ void* ReadFromFile(wchar_t* wszFileName, DWORD* dwSize) HANDLE hImage = CreateFileW(wszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hImage) { - DWORD dwFileSize; + LARGE_INTEGER dwFileSize; GetFileSizeEx(hImage, &dwFileSize); - if (dwFileSize) + if (dwFileSize.LowPart) { - void* pImage = malloc(dwFileSize); + void* pImage = malloc(dwFileSize.LowPart); if (pImage) { DWORD dwNumberOfBytesRead = 0; - ReadFile(hImage, pImage, dwFileSize, &dwNumberOfBytesRead, NULL); - if (dwFileSize == dwNumberOfBytesRead) + ReadFile(hImage, pImage, dwFileSize.LowPart, &dwNumberOfBytesRead, NULL); + if (dwFileSize.LowPart == dwNumberOfBytesRead) { ok = pImage; *dwSize = dwNumberOfBytesRead;