Skip to content
This repository has been archived by the owner on Nov 18, 2023. It is now read-only.

Commit

Permalink
Merge branch 'valinet:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
creeper-0910 authored Oct 21, 2023
2 parents f7cef6a + 67b7a27 commit 83a6ad7
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ExplorerPatcher/GUI.c
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
}
else
{
BeginExplorerRestart();
BeginExplorerRestart(NULL);
}
}
Sleep(100);
Expand Down
8 changes: 4 additions & 4 deletions ExplorerPatcher/StartMenuSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static std::vector<winrt::guid> GlobalStartData_GetPlacesFromRegistry()
std::vector<winrt::guid> places;

DWORD dwSize;
HRESULT hr = RegGetValueW(
LSTATUS lRes = RegGetValueW(
HKEY_CURRENT_USER,
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Start",
L"VisiblePlaces",
Expand All @@ -35,11 +35,11 @@ static std::vector<winrt::guid> GlobalStartData_GetPlacesFromRegistry()
nullptr,
&dwSize
);
if (FAILED(hr) || dwSize == 0)
if (lRes != ERROR_SUCCESS || dwSize == 0)
return places;

places.resize(dwSize / sizeof(winrt::guid));
hr = RegGetValueW(
lRes = RegGetValueW(
HKEY_CURRENT_USER,
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Start",
L"VisiblePlaces",
Expand All @@ -48,7 +48,7 @@ static std::vector<winrt::guid> GlobalStartData_GetPlacesFromRegistry()
places.data(),
&dwSize
);
if (FAILED(hr))
if (lRes != ERROR_SUCCESS)
places.clear();

return places;
Expand Down
8 changes: 4 additions & 4 deletions ExplorerPatcher/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -11001,16 +11001,16 @@ BOOL FixStartMenuAnimation(LPMODULEINFO mi)
}

DWORD dwOldProtect = 0;
if (VirtualProtect(match7a + 11, 3, PAGE_EXECUTE_READWRITE, &dwOldProtect))
if (VirtualProtect(match7a + 11, 1, PAGE_EXECUTE_READWRITE, &dwOldProtect))
{
match7a[0] = 0xEB;
VirtualProtect(match7a + 11, 3, dwOldProtect, &dwOldProtect);
VirtualProtect(match7a + 11, 1, dwOldProtect, &dwOldProtect);

dwOldProtect = 0;
if (VirtualProtect(match7b + 11, 3, PAGE_EXECUTE_READWRITE, &dwOldProtect))
if (VirtualProtect(match7b + 11, 1, PAGE_EXECUTE_READWRITE, &dwOldProtect))
{
match7b[0] = 0xEB;
VirtualProtect(match7b + 11, 3, dwOldProtect, &dwOldProtect);
VirtualProtect(match7b + 11, 1, dwOldProtect, &dwOldProtect);
}
}

Expand Down
10 changes: 10 additions & 0 deletions ExplorerPatcher/fmemopen.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,15 @@
#include <fcntl.h>
#include <windows.h>
#include <sys/stat.h>

#ifdef __cplusplus
extern "C" {
#endif

FILE* fmemopen(void* buf, size_t len, const char* type);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions ExplorerPatcher/getline.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;

#ifdef __cplusplus
extern "C" {
#endif

ssize_t getdelim(char** buf, size_t* bufsiz, int delimiter, FILE* fp);

ssize_t getline(char** buf, size_t* bufsiz, FILE* fp);

#ifdef __cplusplus
}
#endif

#endif
9 changes: 9 additions & 0 deletions ExplorerPatcher/osutility.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#endif
#define DWMWA_MICA_EFFFECT 1029

#ifdef __cplusplus
extern "C" {
#endif

extern RTL_OSVERSIONINFOW global_rovi;
extern DWORD32 global_ubr;

Expand Down Expand Up @@ -94,4 +98,9 @@ inline BOOL IsWindows11Version22H2Build2361OrHigher()
if (global_rovi.dwBuildNumber > 22621) return TRUE;
return global_rovi.dwBuildNumber == 22621 && global_ubr >= 2361;
}

#ifdef __cplusplus
}
#endif

#endif
18 changes: 12 additions & 6 deletions ExplorerPatcher/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ LRESULT CALLBACK BalloonWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
return 0;
}

__declspec(dllexport) CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
__declspec(dllexport) int CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
{
TCHAR* lpwszCmdLine = calloc((strlen(lpszCmdLine) + 1), sizeof(TCHAR));
if (!lpwszCmdLine) exit(0);
Expand Down Expand Up @@ -199,6 +199,8 @@ __declspec(dllexport) CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPS
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return 0;
}

const wchar_t TestToastXML[] =
Expand All @@ -212,7 +214,7 @@ 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";
__declspec(dllexport) CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
__declspec(dllexport) int CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
{
TCHAR* lpwszCmdLine = calloc((strlen(lpszCmdLine) + 1), sizeof(TCHAR));
if (!lpwszCmdLine) exit(0);
Expand Down Expand Up @@ -252,9 +254,10 @@ __declspec(dllexport) CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, LPSTR
free(buffer);
}
free(lpwszCmdLine);
return 0;
}

__declspec(dllexport) CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
__declspec(dllexport) int CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
{
Sleep(100);
TCHAR wszExplorerPath[MAX_PATH + 1];
Expand Down Expand Up @@ -283,18 +286,21 @@ __declspec(dllexport) CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance,
),
0
);
return 0;
}

__declspec(dllexport) CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
__declspec(dllexport) int CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
{
Sleep(2000);
ZZLaunchExplorer(hWnd, hInstance, lpszCmdLine, nCmdShow);
return 0;
}

__declspec(dllexport) CALLBACK ZZRestartExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
__declspec(dllexport) int CALLBACK ZZRestartExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
{
BeginExplorerRestart();
BeginExplorerRestart(NULL);
FinishExplorerRestart();
return 0;
}

void* ReadFromFile(wchar_t* wszFileName, DWORD* dwSize)
Expand Down
33 changes: 23 additions & 10 deletions ExplorerPatcher/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,25 @@
#include <restartmanager.h>
#pragma comment(lib, "Rstrtmgr.lib")
#define _LIBVALINET_INCLUDE_UNIVERSAL
#ifndef __cplusplus
#include <valinet/universal/toast/toast.h>
#endif
#include "osutility.h"
#include "queryversion.h"
#pragma comment(lib, "Psapi.lib")
#include <activscp.h>
#include <netlistmgr.h>
#include <Psapi.h>

#include "def.h"

#define WM_MSG_GUI_SECTION WM_USER + 1
#define WM_MSG_GUI_SECTION_GET 1

#ifdef __cplusplus
extern "C" {
#endif

DEFINE_GUID(CLSID_ImmersiveShell,
0xc2f03a33,
0x21f5, 0x47fa, 0xb4, 0xbb,
Expand Down Expand Up @@ -245,15 +252,15 @@ void printf_guid(GUID guid);

LRESULT CALLBACK BalloonWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

__declspec(dllexport) CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
__declspec(dllexport) int CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);

__declspec(dllexport) CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
__declspec(dllexport) int CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);

__declspec(dllexport) CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
__declspec(dllexport) int CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);

__declspec(dllexport) CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
__declspec(dllexport) int CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);

__declspec(dllexport) CALLBACK ZZRestartExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
__declspec(dllexport) int CALLBACK ZZRestartExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
Expand Down Expand Up @@ -297,7 +304,7 @@ inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt(
pwszValue,
0,
NULL,
pvData,
(LPBYTE)pvData,
pcbData
);
RegCloseKey(hKey);
Expand All @@ -324,7 +331,7 @@ inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt(
pwszValue,
0,
NULL,
pvData,
(LPBYTE)pvData,
pcbData
);
RegCloseKey(hKey);
Expand Down Expand Up @@ -517,7 +524,7 @@ static DWORD RmSession = -1;
static wchar_t RmSessionKey[CCH_RM_SESSION_KEY + 1];

// shuts down the explorer and is ready for explorer restart
inline void BeginExplorerRestart()
inline DWORD WINAPI BeginExplorerRestart(LPVOID lpUnused)
{
if (RmStartSession(&RmSession, 0, RmSessionKey) == ERROR_SUCCESS)
{
Expand All @@ -535,6 +542,7 @@ inline void BeginExplorerRestart()
RmShutdown(RmSession, RmForceShutdown, 0);
}
}
return 0;
}
// restarts the explorer
inline void FinishExplorerRestart()
Expand Down Expand Up @@ -673,8 +681,9 @@ inline BOOL IncrementDLLReferenceCount(HINSTANCE hinst)
HMODULE hMod;
GetModuleHandleExW(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
hinst,
(LPCWSTR)hinst,
&hMod);
return TRUE;
}

inline BOOL WINAPI PatchContextMenuOfNewMicrosoftIME(BOOL* bFound)
Expand Down Expand Up @@ -786,7 +795,7 @@ BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOve

inline BOOL MaskCompare(PVOID pBuffer, LPCSTR lpPattern, LPCSTR lpMask)
{
for (PBYTE value = pBuffer; *lpMask; ++lpPattern, ++lpMask, ++value)
for (PBYTE value = (PBYTE)pBuffer; *lpMask; ++lpPattern, ++lpMask, ++value)
{
if (*lpMask == 'x' && *(LPCBYTE)lpPattern != *value)
return FALSE;
Expand All @@ -810,3 +819,7 @@ inline PVOID FindPattern(PVOID pBase, SIZE_T dwSize, LPCSTR lpPattern, LPCSTR lp
return NULL;
}
#endif

#ifdef __cplusplus
}
#endif
2 changes: 1 addition & 1 deletion ep_setup/ep_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ int WINAPI wWinMain(
}
else
{
BeginExplorerRestart();
BeginExplorerRestart(NULL);
}
}
}
Expand Down

0 comments on commit 83a6ad7

Please sign in to comment.