Skip to content

Commit

Permalink
Merge branch 'main' into logon-logoff-shutdown-restored
Browse files Browse the repository at this point in the history
  • Loading branch information
TorutheRedFox authored Sep 12, 2024
2 parents d5976e8 + 9379315 commit cd4a043
Show file tree
Hide file tree
Showing 9 changed files with 1,030 additions and 186 deletions.
2 changes: 2 additions & 0 deletions .github/pr_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
'https://twitter.com/learn_more': 'https://github.com/learn-more',
'https://twitter.com/realgam3': 'https://github.com/realgam3',
'https://twitter.com/teknixstuff': 'https://github.com/teknixstuff',
'https://twitter.com/kawaipure': 'https://github.com/kawapure',
'https://twitter.com/TorutheRedFox': 'https://github.com/TorutheRedFox',
}

MOD_METADATA_PARAMS = {
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ jobs:
fetch-depth: 0
- name: Install dependencies
run: npm install
- name: Install global dependencies
run: npm install -g ts-node
- name: Prepare static content
run: ts-node deploy.ts
run: npx tsx deploy.ts
- name: Deploy
uses: peaceiris/actions-gh-pages@v4
with:
Expand Down
71 changes: 71 additions & 0 deletions mods/fix-strips.wh.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// ==WindhawkMod==
// @id fix-strips
// @name FixStrips WH Port
// @description Port of the fixstrips AHK script that fixes some classic theme issues with Explorer7
// @version 1.0
// @author OliveIsTyping
// @github https://github.com/OliviaIsTyping
// @include explorer.exe
// @compilerOptions -lcomdlg32
// ==/WindhawkMod==

// ==WindhawkModReadme==
/*
## NOTE:
This mod fixes the presence of the DWM window frame around the taskbar when using classic theme with [Explorer7](https://winclassic.net/thread/2588/explorer7-windows-explorer-10-11). You may need to restart explorer.exe when enabling the mod to see the changes take effect.
## Before
![Before](https://raw.githubusercontent.com/OliviaIsTyping/images/main/fixstrips-before.png)
## After
![After](https://raw.githubusercontent.com/OliviaIsTyping/images/main/fixstrips-after.png)
Credits to [@Anixx](https://github.com/Anixx) for the original AHK Script
*/
// ==/WindhawkModReadme==

// ==WindhawkModSettings==

// ==/WindhawkModSettings==
#include <windows.h>

using CreateWindowExW_t = decltype(&CreateWindowExW);
CreateWindowExW_t CreateWindowExW_Orig;
HWND WINAPI CreateWindowExW_Hook(DWORD dwExStyle,LPCWSTR lpClassName,LPCWSTR lpWindowName,DWORD dwStyle,int X,int Y,int nWidth,int nHeight,HWND hWndParent,
HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam) {

wchar_t wszClassName[200];
ZeroMemory(wszClassName, 200);
//Add WS_DLGFRAME to Shell_TrayWnd
if ((((ULONG_PTR)lpClassName & ~(ULONG_PTR)0xffff) != 0) && !wcscmp(lpClassName, L"Shell_TrayWnd"))
{
dwStyle |= WS_DLGFRAME;
}
HWND hWnd = CreateWindowExW_Orig(dwExStyle,lpClassName,lpWindowName,dwStyle,X,Y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam);

//Remove WS_DLGFRAME from Shell_TrayWnd (dont ask why it works but it does :D)
if ((((ULONG_PTR)lpClassName & ~(ULONG_PTR)0xffff) != 0) && !wcscmp(lpClassName, L"Shell_TrayWnd"))
{
SetWindowLongPtrW(hWnd,GWL_STYLE,GetWindowLongPtrW(hWnd, GWL_STYLE) & ~WS_DLGFRAME);
}

return hWnd;
}


// The mod is being initialized, load settings, hook functions, and do other initialization stuff if required.
BOOL Wh_ModInit() {
Wh_Log(L"Init");

Wh_SetFunctionHook((void*)CreateWindowExW,
(void*)CreateWindowExW_Hook,
(void**)&CreateWindowExW_Orig);
return TRUE;
}

// The mod is being unloaded, free all allocated resources.
void Wh_ModUninit() {
Wh_Log(L"Uninit");
}
61 changes: 55 additions & 6 deletions mods/notifications-placement.wh.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// ==WindhawkMod==
// @id notifications-placement
// @name Customize Windows 11 notifications placement
// @name Customize Windows notifications placement
// @description Move notifications to another monitor or another corner of the screen
// @version 1.0
// @version 1.0.1
// @author m417z
// @github https://github.com/m417z
// @twitter https://twitter.com/m417z
Expand All @@ -23,11 +23,11 @@

// ==WindhawkModReadme==
/*
# Customize Windows 11 notifications placement
# Customize Windows notifications placement
Move notifications to another monitor or another corner of the screen.
Only Windows 11 is supported.
Only Windows 10 64-bit and Windows 11 are supported.
![Screenshot](https://i.imgur.com/4PxMvLg.png)
*/
Expand Down Expand Up @@ -60,6 +60,7 @@ Only Windows 11 is supported.

#include <atomic>
#include <string>
#include <unordered_set>
#include <vector>

std::atomic<bool> g_unloading;
Expand Down Expand Up @@ -173,9 +174,57 @@ bool IsTargetCoreWindow(HWND hWnd) {
return false;
}

WCHAR szWindowText[32];
// The window title is locale-dependent, and unfortunately I didn't find a
// simpler way to identify the target window.
// String source: Windows.UI.ShellCommon.<locale>.pri
// String resource: \ActionCenter\AC_ToastCenter_Title
// The strings were collected from here:
// https://github.com/m417z/windows-language-files
static const std::unordered_set<std::wstring> newNotificationStrings = {
L"Jakinarazpen berria",
L"Jauns paziņojums",
L"Naujas pranešimas",
L"Neue Benachrichtigung",
L"New notification",
L"Nieuwe melding",
L"Notificació nova",
L"Notificación nueva",
L"Notificare nouă",
L"Nouvelle notification",
L"Nova notificação",
L"Nova notificación",
L"Nova obavijesti",
L"Nové oznámení",
L"Nové oznámenie",
L"Novo obaveštenje",
L"Novo obvestilo",
L"Nowe powiadomienie",
L"Nueva notificación",
L"Nuova notifica",
L"Ny meddelelse",
L"Ny varsling",
L"Nytt meddelande",
L"Pemberitahuan baru",
L"Thông báo mới",
L"Új értesítés",
L"Uus teatis",
L"Uusi ilmoitus",
L"Yeni bildirim",
L"Νέα ειδοποίηση",
L"Нове сповіщення",
L"Ново известие",
L"Новое уведомление",
L"הודעה חדשה",
L"\u200f\u200fإعلام جديد",
L"การแจ้งให้ทราบใหม่",
L"새 알림",
L"新しい通知",
L"新通知",
};

WCHAR szWindowText[256];
if (GetWindowText(hWnd, szWindowText, ARRAYSIZE(szWindowText)) == 0 ||
wcscmp(szWindowText, L"New notification") != 0) {
!newNotificationStrings.contains(szWindowText)) {
return false;
}

Expand Down
119 changes: 52 additions & 67 deletions mods/old-this-pc-commands.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @id old-this-pc-commands
// @name Old This PC Commands
// @description Makes "Open Settings", "System properties", etc. in This PC use Control Panel instead of Settings
// @version 1.0.0
// @version 1.0.1
// @author aubymori
// @github https://github.com/aubymori
// @include explorer.exe
Expand All @@ -28,40 +28,33 @@ to `ExplorerFrame.dll` takes place to remove the redirect.

#include <initguid.h>
#include <windhawk_utils.h>
#include <shlobj.h>
#include <shobjidl.h>
#include <ocidl.h>

DEFINE_GUID(IID_IUnknown, 0x00000000, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46);
DEFINE_GUID(IID_OpenControlPanel, 0xD11AD862, 0x66DE, 0x4DF4, 0xBF,0x6C, 0x1F,0x56,0x21,0x99,0x6A,0xF1);
DEFINE_GUID(IID_IServiceProvider, 0x6D5140C1, 0x7436, 0x11CE, 0x80,0x34, 0x00,0xAA,0x00,0x60,0x09,0xFA);
DEFINE_GUID(SID_STopLevelBrowser, 0x4c96be40, 0x915C, 0x11CF, 0x99,0xD3, 0x00,0xAA,0x00,0x4A,0xE8,0x37);

HRESULT (*COpenControlPanel_Open)(void *pThis, LPCWSTR lpPage, LPCWSTR lpSubPage, IUnknown *pu);

HRESULT OpenCplPage(IUnknown *pu, LPCWSTR lpPage, LPCWSTR lpSubPage)
HRESULT OpenCplPage(IUnknown *punk, LPCWSTR lpPage, LPCWSTR lpSubPage)
{
IObjectWithSite *pows;
HRESULT hr = pu->QueryInterface(IID_IObjectWithSite, (void **)&pows);
HRESULT hr = punk->QueryInterface(IID_IObjectWithSite, (void **)&pows);
if (SUCCEEDED(hr))
{
IUnknown *pu2;
hr = pows->GetSite(IID_IUnknown, (void **)&pu2);
IUnknown *punk2;
hr = pows->GetSite(IID_PPV_ARGS(&punk2));
if (SUCCEEDED(hr))
{
void *pocp;
IOpenControlPanel *pocp = nullptr;
hr = CoCreateInstance(
CLSID_OpenControlPanel,
NULL,
CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER,
IID_OpenControlPanel,
&pocp
IID_PPV_ARGS(&pocp)
);
if (SUCCEEDED(hr))
{
hr = COpenControlPanel_Open(pocp, lpPage, lpSubPage, pu2);
hr = pocp->Open(lpPage, lpSubPage, punk2);
pocp->Release();
}
punk2->Release();
}
pows->Release();
}
return hr;
}
Expand All @@ -71,52 +64,79 @@ typedef HRESULT (*CDrivesViewCallback__OnEventPunkSite)(IUnknown *, IUnknown *,

CDrivesViewCallback__OnEventPunkSite CDrivesViewCallback__OnOpenSystemSettingsPunkSite_orig;
HRESULT CDrivesViewCallback__OnOpenSystemSettingsPunkSite_hook(
IUnknown *pu,
IUnknown *pu2,
IUnknown *punk,
IUnknown *punkRibbon,
IShellItemArray *psia,
IBindCtx *pbctx
)
{
HRESULT hr = OpenCplPage(pu, NULL, NULL);
HRESULT hr = OpenCplPage(punk, NULL, NULL);
if (!SUCCEEDED(hr))
{
hr = OpenCplPage(pu2, NULL, NULL);
hr = OpenCplPage(punkRibbon, NULL, NULL);
}
return hr;
}

CDrivesViewCallback__OnEventPunkSite CDrivesViewCallback__OnSystemPropertiesPunkSite_orig;
HRESULT CDrivesViewCallback__OnSystemPropertiesPunkSite_hook(
IUnknown *pu,
IUnknown *pu2,
IUnknown *punk,
IUnknown *punkRibbon,
IShellItemArray *psia,
IBindCtx *pbctx
)
{
HRESULT hr = OpenCplPage(pu, L"Microsoft.System", NULL);
HRESULT hr = OpenCplPage(punk, L"Microsoft.System", NULL);
if (!SUCCEEDED(hr))
{
hr = OpenCplPage(pu2, L"Microsoft.System", NULL);
hr = OpenCplPage(punkRibbon, L"Microsoft.System", NULL);
}
return hr;
}

CDrivesViewCallback__OnEventPunkSite CDrivesViewCallback__OnAddRemoveProgramsPunkSite_orig;
HRESULT CDrivesViewCallback__OnAddRemoveProgramsPunkSite_hook(
IUnknown *pu,
IUnknown *pu2,
IUnknown *punk,
IUnknown *punkRibbon,
IShellItemArray *psia,
IBindCtx *pbctx
)
{
HRESULT hr = OpenCplPage(pu, L"Microsoft.ProgramsAndFeatures", NULL);
HRESULT hr = OpenCplPage(punk, L"Microsoft.ProgramsAndFeatures", NULL);
if (!SUCCEEDED(hr))
{
hr = OpenCplPage(pu2, L"Microsoft.ProgramsAndFeatures", NULL);
hr = OpenCplPage(punkRibbon, L"Microsoft.ProgramsAndFeatures", NULL);
}
return hr;
}

const WindhawkUtils::SYMBOL_HOOK shell32DllHooks[] = {
{
{
L"public: static long __cdecl CDrivesViewCallback::_OnOpenSystemSettingsPunkSite(struct IUnknown *,struct IUnknown *,struct IShellItemArray *,struct IBindCtx *)"
},
&CDrivesViewCallback__OnOpenSystemSettingsPunkSite_orig,
CDrivesViewCallback__OnOpenSystemSettingsPunkSite_hook,
false
},
{
{
L"public: static long __cdecl CDrivesViewCallback::_OnSystemPropertiesPunkSite(struct IUnknown *,struct IUnknown *,struct IShellItemArray *,struct IBindCtx *)"
},
&CDrivesViewCallback__OnSystemPropertiesPunkSite_orig,
CDrivesViewCallback__OnSystemPropertiesPunkSite_hook,
false
},
{
{
L"public: static long __cdecl CDrivesViewCallback::_OnAddRemoveProgramsPunkSite(struct IUnknown *,struct IUnknown *,struct IShellItemArray *,struct IBindCtx *)"
},
&CDrivesViewCallback__OnAddRemoveProgramsPunkSite_orig,
CDrivesViewCallback__OnAddRemoveProgramsPunkSite_hook,
false
}
};

BOOL Wh_ModInit(void)
{
HMODULE hShell32 = LoadLibraryW(L"shell32.dll");
Expand All @@ -126,45 +146,10 @@ BOOL Wh_ModInit(void)
return FALSE;
}

const WindhawkUtils::SYMBOL_HOOK hooks[] = {
{
{
L"public: virtual long __cdecl COpenControlPanel::Open(unsigned short const *,unsigned short const *,struct IUnknown *)"
},
&COpenControlPanel_Open,
nullptr,
false
},
{
{
L"public: static long __cdecl CDrivesViewCallback::_OnOpenSystemSettingsPunkSite(struct IUnknown *,struct IUnknown *,struct IShellItemArray *,struct IBindCtx *)"
},
&CDrivesViewCallback__OnOpenSystemSettingsPunkSite_orig,
CDrivesViewCallback__OnOpenSystemSettingsPunkSite_hook,
false
},
{
{
L"public: static long __cdecl CDrivesViewCallback::_OnSystemPropertiesPunkSite(struct IUnknown *,struct IUnknown *,struct IShellItemArray *,struct IBindCtx *)"
},
&CDrivesViewCallback__OnSystemPropertiesPunkSite_orig,
CDrivesViewCallback__OnSystemPropertiesPunkSite_hook,
false
},
{
{
L"public: static long __cdecl CDrivesViewCallback::_OnAddRemoveProgramsPunkSite(struct IUnknown *,struct IUnknown *,struct IShellItemArray *,struct IBindCtx *)"
},
&CDrivesViewCallback__OnAddRemoveProgramsPunkSite_orig,
CDrivesViewCallback__OnAddRemoveProgramsPunkSite_hook,
false
}
};

if (!WindhawkUtils::HookSymbols(
hShell32,
hooks,
ARRAYSIZE(hooks)
shell32DllHooks,
ARRAYSIZE(shell32DllHooks)
))
{
Wh_Log(L"Failed to hook one or more symbol functions in shell32.dll");
Expand Down
Loading

0 comments on commit cd4a043

Please sign in to comment.