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

All: Prepared some headers for C++

This commit is contained in:
Amrsatrio 2023-10-17 14:15:30 +07:00
parent a57471feb2
commit f027a36837
8 changed files with 68 additions and 22 deletions

View File

@ -1619,7 +1619,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
}
else
{
BeginExplorerRestart();
BeginExplorerRestart(NULL);
}
}
Sleep(100);

View File

@ -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);
}
}

View File

@ -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

View File

@ -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

View File

@ -20,6 +20,10 @@
#endif
#define DWMWA_MICA_EFFFECT 1029
#ifdef __cplusplus
extern "C" {
#endif
extern RTL_OSVERSIONINFOW global_rovi;
extern DWORD32 global_ubr;
@ -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

View File

@ -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);
@ -199,6 +199,8 @@ __declspec(dllexport) CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPS
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
const wchar_t TestToastXML[] =
@ -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);
@ -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];
@ -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)

View File

@ -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,
@ -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))
@ -297,7 +304,7 @@ inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt(
pwszValue,
0,
NULL,
pvData,
(LPBYTE)pvData,
pcbData
);
RegCloseKey(hKey);
@ -324,7 +331,7 @@ inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt(
pwszValue,
0,
NULL,
pvData,
(LPBYTE)pvData,
pcbData
);
RegCloseKey(hKey);
@ -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)
{
@ -535,6 +542,7 @@ inline void BeginExplorerRestart()
RmShutdown(RmSession, RmForceShutdown, 0);
}
}
return 0;
}
// restarts the explorer
inline void FinishExplorerRestart()
@ -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)
@ -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;
@ -810,3 +819,7 @@ inline PVOID FindPattern(PVOID pBase, SIZE_T dwSize, LPCSTR lpPattern, LPCSTR lp
return NULL;
}
#endif
#ifdef __cplusplus
}
#endif

View File

@ -673,7 +673,7 @@ int WINAPI wWinMain(
}
else
{
BeginExplorerRestart();
BeginExplorerRestart(NULL);
}
}
}