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

Commit 83a6ad7

Browse files
authored
Merge branch 'valinet:master' into master
2 parents f7cef6a + 67b7a27 commit 83a6ad7

File tree

9 files changed

+72
-26
lines changed

9 files changed

+72
-26
lines changed

ExplorerPatcher/GUI.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
16191619
}
16201620
else
16211621
{
1622-
BeginExplorerRestart();
1622+
BeginExplorerRestart(NULL);
16231623
}
16241624
}
16251625
Sleep(100);

ExplorerPatcher/StartMenuSettings.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static std::vector<winrt::guid> GlobalStartData_GetPlacesFromRegistry()
2626
std::vector<winrt::guid> places;
2727

2828
DWORD dwSize;
29-
HRESULT hr = RegGetValueW(
29+
LSTATUS lRes = RegGetValueW(
3030
HKEY_CURRENT_USER,
3131
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Start",
3232
L"VisiblePlaces",
@@ -35,11 +35,11 @@ static std::vector<winrt::guid> GlobalStartData_GetPlacesFromRegistry()
3535
nullptr,
3636
&dwSize
3737
);
38-
if (FAILED(hr) || dwSize == 0)
38+
if (lRes != ERROR_SUCCESS || dwSize == 0)
3939
return places;
4040

4141
places.resize(dwSize / sizeof(winrt::guid));
42-
hr = RegGetValueW(
42+
lRes = RegGetValueW(
4343
HKEY_CURRENT_USER,
4444
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Start",
4545
L"VisiblePlaces",
@@ -48,7 +48,7 @@ static std::vector<winrt::guid> GlobalStartData_GetPlacesFromRegistry()
4848
places.data(),
4949
&dwSize
5050
);
51-
if (FAILED(hr))
51+
if (lRes != ERROR_SUCCESS)
5252
places.clear();
5353

5454
return places;

ExplorerPatcher/dllmain.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -11001,16 +11001,16 @@ BOOL FixStartMenuAnimation(LPMODULEINFO mi)
1100111001
}
1100211002

1100311003
DWORD dwOldProtect = 0;
11004-
if (VirtualProtect(match7a + 11, 3, PAGE_EXECUTE_READWRITE, &dwOldProtect))
11004+
if (VirtualProtect(match7a + 11, 1, PAGE_EXECUTE_READWRITE, &dwOldProtect))
1100511005
{
1100611006
match7a[0] = 0xEB;
11007-
VirtualProtect(match7a + 11, 3, dwOldProtect, &dwOldProtect);
11007+
VirtualProtect(match7a + 11, 1, dwOldProtect, &dwOldProtect);
1100811008

1100911009
dwOldProtect = 0;
11010-
if (VirtualProtect(match7b + 11, 3, PAGE_EXECUTE_READWRITE, &dwOldProtect))
11010+
if (VirtualProtect(match7b + 11, 1, PAGE_EXECUTE_READWRITE, &dwOldProtect))
1101111011
{
1101211012
match7b[0] = 0xEB;
11013-
VirtualProtect(match7b + 11, 3, dwOldProtect, &dwOldProtect);
11013+
VirtualProtect(match7b + 11, 1, dwOldProtect, &dwOldProtect);
1101411014
}
1101511015
}
1101611016

ExplorerPatcher/fmemopen.h

+10
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,15 @@
55
#include <fcntl.h>
66
#include <windows.h>
77
#include <sys/stat.h>
8+
9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
813
FILE* fmemopen(void* buf, size_t len, const char* type);
14+
15+
#ifdef __cplusplus
16+
}
17+
#endif
18+
919
#endif

ExplorerPatcher/getline.h

+8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@
55
#include <BaseTsd.h>
66
typedef SSIZE_T ssize_t;
77

8+
#ifdef __cplusplus
9+
extern "C" {
10+
#endif
11+
812
ssize_t getdelim(char** buf, size_t* bufsiz, int delimiter, FILE* fp);
913

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

16+
#ifdef __cplusplus
17+
}
18+
#endif
19+
1220
#endif

ExplorerPatcher/osutility.h

+9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#endif
2121
#define DWMWA_MICA_EFFFECT 1029
2222

23+
#ifdef __cplusplus
24+
extern "C" {
25+
#endif
26+
2327
extern RTL_OSVERSIONINFOW global_rovi;
2428
extern DWORD32 global_ubr;
2529

@@ -94,4 +98,9 @@ inline BOOL IsWindows11Version22H2Build2361OrHigher()
9498
if (global_rovi.dwBuildNumber > 22621) return TRUE;
9599
return global_rovi.dwBuildNumber == 22621 && global_ubr >= 2361;
96100
}
101+
102+
#ifdef __cplusplus
103+
}
104+
#endif
105+
97106
#endif

ExplorerPatcher/utility.c

+12-6
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ LRESULT CALLBACK BalloonWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
163163
return 0;
164164
}
165165

166-
__declspec(dllexport) CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
166+
__declspec(dllexport) int CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
167167
{
168168
TCHAR* lpwszCmdLine = calloc((strlen(lpszCmdLine) + 1), sizeof(TCHAR));
169169
if (!lpwszCmdLine) exit(0);
@@ -199,6 +199,8 @@ __declspec(dllexport) CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPS
199199
TranslateMessage(&msg);
200200
DispatchMessage(&msg);
201201
}
202+
203+
return 0;
202204
}
203205

204206
const wchar_t TestToastXML[] =
@@ -212,7 +214,7 @@ L" </binding>\r\n"
212214
L" </visual>\r\n"
213215
L" <audio src=\"ms-winsoundevent:Notification.Default\" loop=\"false\" silent=\"false\"/>\r\n"
214216
L"</toast>\r\n";
215-
__declspec(dllexport) CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
217+
__declspec(dllexport) int CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
216218
{
217219
TCHAR* lpwszCmdLine = calloc((strlen(lpszCmdLine) + 1), sizeof(TCHAR));
218220
if (!lpwszCmdLine) exit(0);
@@ -252,9 +254,10 @@ __declspec(dllexport) CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, LPSTR
252254
free(buffer);
253255
}
254256
free(lpwszCmdLine);
257+
return 0;
255258
}
256259

257-
__declspec(dllexport) CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
260+
__declspec(dllexport) int CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
258261
{
259262
Sleep(100);
260263
TCHAR wszExplorerPath[MAX_PATH + 1];
@@ -283,18 +286,21 @@ __declspec(dllexport) CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance,
283286
),
284287
0
285288
);
289+
return 0;
286290
}
287291

288-
__declspec(dllexport) CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
292+
__declspec(dllexport) int CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
289293
{
290294
Sleep(2000);
291295
ZZLaunchExplorer(hWnd, hInstance, lpszCmdLine, nCmdShow);
296+
return 0;
292297
}
293298

294-
__declspec(dllexport) CALLBACK ZZRestartExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
299+
__declspec(dllexport) int CALLBACK ZZRestartExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
295300
{
296-
BeginExplorerRestart();
301+
BeginExplorerRestart(NULL);
297302
FinishExplorerRestart();
303+
return 0;
298304
}
299305

300306
void* ReadFromFile(wchar_t* wszFileName, DWORD* dwSize)

ExplorerPatcher/utility.h

+23-10
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,25 @@
1515
#include <restartmanager.h>
1616
#pragma comment(lib, "Rstrtmgr.lib")
1717
#define _LIBVALINET_INCLUDE_UNIVERSAL
18+
#ifndef __cplusplus
1819
#include <valinet/universal/toast/toast.h>
20+
#endif
1921
#include "osutility.h"
2022
#include "queryversion.h"
2123
#pragma comment(lib, "Psapi.lib")
2224
#include <activscp.h>
2325
#include <netlistmgr.h>
26+
#include <Psapi.h>
2427

2528
#include "def.h"
2629

2730
#define WM_MSG_GUI_SECTION WM_USER + 1
2831
#define WM_MSG_GUI_SECTION_GET 1
2932

33+
#ifdef __cplusplus
34+
extern "C" {
35+
#endif
36+
3037
DEFINE_GUID(CLSID_ImmersiveShell,
3138
0xc2f03a33,
3239
0x21f5, 0x47fa, 0xb4, 0xbb,
@@ -245,15 +252,15 @@ void printf_guid(GUID guid);
245252

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

248-
__declspec(dllexport) CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
255+
__declspec(dllexport) int CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
249256

250-
__declspec(dllexport) CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
257+
__declspec(dllexport) int CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
251258

252-
__declspec(dllexport) CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
259+
__declspec(dllexport) int CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
253260

254-
__declspec(dllexport) CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
261+
__declspec(dllexport) int CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
255262

256-
__declspec(dllexport) CALLBACK ZZRestartExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
263+
__declspec(dllexport) int CALLBACK ZZRestartExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
257264

258265
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
259266
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
@@ -297,7 +304,7 @@ inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt(
297304
pwszValue,
298305
0,
299306
NULL,
300-
pvData,
307+
(LPBYTE)pvData,
301308
pcbData
302309
);
303310
RegCloseKey(hKey);
@@ -324,7 +331,7 @@ inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt(
324331
pwszValue,
325332
0,
326333
NULL,
327-
pvData,
334+
(LPBYTE)pvData,
328335
pcbData
329336
);
330337
RegCloseKey(hKey);
@@ -517,7 +524,7 @@ static DWORD RmSession = -1;
517524
static wchar_t RmSessionKey[CCH_RM_SESSION_KEY + 1];
518525

519526
// shuts down the explorer and is ready for explorer restart
520-
inline void BeginExplorerRestart()
527+
inline DWORD WINAPI BeginExplorerRestart(LPVOID lpUnused)
521528
{
522529
if (RmStartSession(&RmSession, 0, RmSessionKey) == ERROR_SUCCESS)
523530
{
@@ -535,6 +542,7 @@ inline void BeginExplorerRestart()
535542
RmShutdown(RmSession, RmForceShutdown, 0);
536543
}
537544
}
545+
return 0;
538546
}
539547
// restarts the explorer
540548
inline void FinishExplorerRestart()
@@ -673,8 +681,9 @@ inline BOOL IncrementDLLReferenceCount(HINSTANCE hinst)
673681
HMODULE hMod;
674682
GetModuleHandleExW(
675683
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
676-
hinst,
684+
(LPCWSTR)hinst,
677685
&hMod);
686+
return TRUE;
678687
}
679688

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

787796
inline BOOL MaskCompare(PVOID pBuffer, LPCSTR lpPattern, LPCSTR lpMask)
788797
{
789-
for (PBYTE value = pBuffer; *lpMask; ++lpPattern, ++lpMask, ++value)
798+
for (PBYTE value = (PBYTE)pBuffer; *lpMask; ++lpPattern, ++lpMask, ++value)
790799
{
791800
if (*lpMask == 'x' && *(LPCBYTE)lpPattern != *value)
792801
return FALSE;
@@ -810,3 +819,7 @@ inline PVOID FindPattern(PVOID pBase, SIZE_T dwSize, LPCSTR lpPattern, LPCSTR lp
810819
return NULL;
811820
}
812821
#endif
822+
823+
#ifdef __cplusplus
824+
}
825+
#endif

ep_setup/ep_setup.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ int WINAPI wWinMain(
673673
}
674674
else
675675
{
676-
BeginExplorerRestart();
676+
BeginExplorerRestart(NULL);
677677
}
678678
}
679679
}

0 commit comments

Comments
 (0)