From f027a368372ff550472aa12b453791925729b5db Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Tue, 17 Oct 2023 14:15:30 +0700 Subject: [PATCH 1/9] All: Prepared some headers for C++ --- ExplorerPatcher/GUI.c | 2 +- ExplorerPatcher/dllmain.c | 8 ++++---- ExplorerPatcher/fmemopen.h | 10 ++++++++++ ExplorerPatcher/getline.h | 8 ++++++++ ExplorerPatcher/osutility.h | 9 +++++++++ ExplorerPatcher/utility.c | 18 ++++++++++++------ ExplorerPatcher/utility.h | 33 +++++++++++++++++++++++---------- ep_setup/ep_setup.c | 2 +- 8 files changed, 68 insertions(+), 22 deletions(-) diff --git a/ExplorerPatcher/GUI.c b/ExplorerPatcher/GUI.c index c4e7b2b..023e394 100644 --- a/ExplorerPatcher/GUI.c +++ b/ExplorerPatcher/GUI.c @@ -1619,7 +1619,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) } else { - BeginExplorerRestart(); + BeginExplorerRestart(NULL); } } Sleep(100); diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 2ecb141..049f03b 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -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); } } diff --git a/ExplorerPatcher/fmemopen.h b/ExplorerPatcher/fmemopen.h index 3c337ee..630d6df 100644 --- a/ExplorerPatcher/fmemopen.h +++ b/ExplorerPatcher/fmemopen.h @@ -5,5 +5,15 @@ #include #include #include + +#ifdef __cplusplus +extern "C" { +#endif + FILE* fmemopen(void* buf, size_t len, const char* type); + +#ifdef __cplusplus +} +#endif + #endif \ No newline at end of file diff --git a/ExplorerPatcher/getline.h b/ExplorerPatcher/getline.h index 6760bc1..123d973 100644 --- a/ExplorerPatcher/getline.h +++ b/ExplorerPatcher/getline.h @@ -5,8 +5,16 @@ #include 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 \ No newline at end of file diff --git a/ExplorerPatcher/osutility.h b/ExplorerPatcher/osutility.h index 833b648..de3c8be 100644 --- a/ExplorerPatcher/osutility.h +++ b/ExplorerPatcher/osutility.h @@ -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 diff --git a/ExplorerPatcher/utility.c b/ExplorerPatcher/utility.c index c39cfb1..d702a0b 100644 --- a/ExplorerPatcher/utility.c +++ b/ExplorerPatcher/utility.c @@ -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" \r\n" L" \r\n" L"