Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create disable-edge-window-tab-manager #786

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions mods/disable-edge-window-tab-manager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// ==WindhawkMod==

Check warning on line 1 in mods/disable-edge-window-tab-manager.cpp

View workflow job for this annotation

GitHub Actions / Test changed files

Filename should end with .wh.cpp
// @id disable-edge-window-tab-manager
// @name Disable EdgeWindowTabManager
// @description Blocks the WindowTabManager feature of Microsoft Edge
// @version 0.1
// @author ilyfairy
// @github https://github.com/ilyfairy
// @homepage https://github.com/ilyfairy
// @include msedge.exe
// ==/WindhawkMod==

// ==WindhawkModReadme==
/*
# DisableEdgeWindowTabManager
see https://github.com/gexgd0419/EdgeWindowTabManagerBlock

But EdgeWindowTabManagerBlock has some problems,
for example, unable to start msedge through VSCode: `unable to attach to browser`
*/
// ==/WindhawkModReadme==


#include <windhawk_api.h>
#include <wrl.h>

using WindowsGetStringRawBufferFunc = PCWSTR (*) (HSTRING string, UINT32* length);
WindowsGetStringRawBufferFunc MyWindowsGetStringRawBuffer;

bool IsRoClassBlocked(HSTRING activatableClassId)
{
PCWSTR pszClassId = MyWindowsGetStringRawBuffer(activatableClassId, nullptr);
if (wcscmp(pszClassId, L"WindowsUdk.UI.Shell.WindowTabManager") == 0
|| wcscmp(pszClassId, L"Windows.UI.Shell.WindowTabManager") == 0) // case sensitive
return true;

return false;
}

using RoGetActivationFactoryFunc = HRESULT (*)(HSTRING activatableClassId, REFIID id, void** factory);
RoGetActivationFactoryFunc RoGetActivationFactoryOriginFunc;

HRESULT RoGetActivationFactoryHook(HSTRING activatableClassId, REFIID id, void** factory) {
if(IsRoClassBlocked(activatableClassId)) {
Wh_Log(L"IsRoClassBlocked");
return E_ACCESSDENIED;
}
auto result = RoGetActivationFactoryOriginFunc(activatableClassId, id, factory);
return result;
}


BOOL Wh_ModInit() {
Wh_Log(L"Init");

auto comBase = LoadLibrary(L"combase.dll");
MyWindowsGetStringRawBuffer = (WindowsGetStringRawBufferFunc)GetProcAddress(comBase, "WindowsGetStringRawBuffer");
// Wh_Log(L"WindowsGetStringRawBuffer: 0x%X", MyWindowsGetStringRawBuffer);

auto RoGetActivationFactory = GetProcAddress(comBase, "RoGetActivationFactory");
// Wh_Log(L"RoGetActivationFactory: 0x%X", RoGetActivationFactory);
Wh_SetFunctionHook((void*)RoGetActivationFactory, (void*)RoGetActivationFactoryHook, (void**)&RoGetActivationFactoryOriginFunc);

return TRUE;
}

// The mod is being unloaded, free all allocated resources.
void Wh_ModUninit() {
Wh_Log(L"Uninit");
}

// The mod setting were changed, reload them.
void Wh_ModSettingsChanged() {

}
Loading