Skip to content

Commit

Permalink
All: Last minute fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Amrsatrio committed Feb 15, 2024
1 parent 88212b3 commit 36ebe5a
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 22 deletions.
121 changes: 101 additions & 20 deletions ExplorerPatcher/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -4089,7 +4089,7 @@ HRESULT stobject_CoCreateInstanceHook(
LPVOID* ppv
)
{
if (global_rovi.dwBuildNumber >= 25000 && IsEqualGUID(rclsid, &CLSID_NetworkTraySSO))
if (global_rovi.dwBuildNumber >= 25000 && IsEqualGUID(rclsid, &CLSID_NetworkTraySSO) && bOldTaskbar)
{
wchar_t szPath[MAX_PATH];
ZeroMemory(szPath, sizeof(szPath));
Expand Down Expand Up @@ -10209,9 +10209,12 @@ DWORD InjectBasicFunctions(BOOL bIsExplorer, BOOL bInstall)
#ifdef _WIN64
MODULEINFO mi;
GetModuleInformation(GetCurrentProcess(), hExplorerFrame, &mi, sizeof(MODULEINFO));
if (global_rovi.dwBuildNumber >= 19041 && bShrinkExplorerAddressBar)
if (bShrinkExplorerAddressBar)
{
PatchAddressBarSizing(&mi);
if ((global_rovi.dwBuildNumber >= 19041 && global_rovi.dwBuildNumber <= 19045 && global_ubr < 3754) || IsWindows11())
{
PatchAddressBarSizing(&mi);
}
}
#endif
VnPatchIAT(hExplorerFrame, "api-ms-win-core-com-l1-1-0.dll", "CoCreateInstance", ExplorerFrame_CoCreateInstanceHook);
Expand Down Expand Up @@ -11872,20 +11875,17 @@ void PrepareAlternateTaskbarImplementation(symbols_addr* symbols_PTRS)
return;
}

explorer_TrayUI_CreateInstanceFunc = GetProcAddress(hMyTaskbar, "EP_TrayUI_CreateInstance");

typedef DWORD (*GetVersion_t)();
GetVersion_t GetVersion = (GetVersion_t)GetProcAddress(hMyTaskbar, "GetVersion");
if (GetVersion)
DWORD version = GetVersion ? GetVersion() : 0;
if (version != 1)
{
DWORD version = GetVersion();
if (version != 1)
{
wprintf(L"[TB] Version mismatch: %d\n", version);
return;
}
wprintf(L"[TB] '%s' with version %d is not compatible\n", pszTaskbarDll, version);
return;
}

explorer_TrayUI_CreateInstanceFunc = GetProcAddress(hMyTaskbar, "EP_TrayUI_CreateInstance");

typedef void (*CopyExplorerSymbols_t)(symbols_addr* symbols);
CopyExplorerSymbols_t CopyExplorerSymbols = (CopyExplorerSymbols_t)GetProcAddress(hMyTaskbar, "CopyExplorerSymbols");
if (CopyExplorerSymbols)
Expand Down Expand Up @@ -12698,7 +12698,7 @@ DWORD Inject(BOOL bIsExplorer)
VnPatchIAT(hStobject, "user32.dll", "TrackPopupMenu", stobject_TrackPopupMenuHook);
VnPatchIAT(hStobject, "user32.dll", "TrackPopupMenuEx", stobject_TrackPopupMenuExHook);
}
if (global_rovi.dwBuildNumber >= 25000)
if (global_rovi.dwBuildNumber >= 25000 && bOldTaskbar)
{
PatchStobject(hStobject);
}
Expand Down Expand Up @@ -14511,16 +14511,91 @@ BOOL SEH_GetProductInfo(DWORD dwOSMajorVersion, DWORD dwOSMinorVersion, DWORD dw

void InjectShellExperienceHostFor22H2OrHigher() {
#ifdef _WIN64
HKEY hKey;
if (RegOpenKeyW(HKEY_CURRENT_USER, _T(SEH_REGPATH), &hKey) != ERROR_SUCCESS) return;
RegCloseKey(hKey);
HMODULE hQA = LoadLibraryW(L"Windows.UI.QuickActions.dll");
//if (hQA) VnPatchIAT(hQA, "api-ms-win-core-sysinfo-l1-2-0.dll", "GetProductInfo", SEH_GetProductInfo);
//if (hQA) VnPatchIAT(hQA, "ntdll.dll", "RtlGetDeviceFamilyInfoEnum", SEH_RtlGetDeviceFamilyInfoEnum);
//if (hQA) VnPatchIAT(hQA, "api-ms-win-core-registry-l1-1-0.dll", "RegGetValueW", SEH_RegGetValueW);
if (!IsWindows11Version22H2Build1413OrHigher())
{
HKEY hKey;
if (RegOpenKeyW(HKEY_CURRENT_USER, _T(SEH_REGPATH), &hKey) == ERROR_SUCCESS)
{
RegCloseKey(hKey);
HMODULE hQA = LoadLibraryW(L"Windows.UI.QuickActions.dll");
if (hQA) VnPatchIAT(hQA, "api-ms-win-core-sysinfo-l1-2-0.dll", "GetProductInfo", SEH_GetProductInfo);
// if (hQA) VnPatchIAT(hQA, "ntdll.dll", "RtlGetDeviceFamilyInfoEnum", SEH_RtlGetDeviceFamilyInfoEnum);
// if (hQA) VnPatchIAT(hQA, "api-ms-win-core-registry-l1-1-0.dll", "RegGetValueW", SEH_RegGetValueW);
}
}
#endif
}

HRESULT SHRegGetBOOLWithREGSAM(HKEY key, LPCWSTR subKey, LPCWSTR value, REGSAM regSam, BOOL* data)
{
DWORD dwType = REG_NONE;
DWORD dwData;
DWORD cbData = 4;
LSTATUS lRes = RegGetValueW(
key,
subKey,
value,
((regSam & 0x100) << 8) | RRF_RT_REG_DWORD | RRF_RT_REG_SZ | RRF_NOEXPAND,
&dwType,
&dwData,
&cbData
);
if (lRes != ERROR_SUCCESS)
{
if (lRes == ERROR_MORE_DATA)
return HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
if (lRes > 0)
return HRESULT_FROM_WIN32(lRes);
return lRes;
}

if (dwType == REG_DWORD)
{
if (dwData > 1)
return HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
*data = dwData == 1;
}
else
{
if (cbData != 4 || (WCHAR)dwData != L'0' && (WCHAR)dwData != L'1')
return HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
*data = (WCHAR)dwData == L'1';
}

return S_OK;
}

bool IsUserOOBE()
{
BOOL b = FALSE;
SHRegGetBOOLWithREGSAM(
HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\OOBE",
L"LaunchUserOOBE",
0,
&b
);
return b;
}

bool IsCredentialReset()
{
BOOL b = FALSE;
SHRegGetBOOLWithREGSAM(
HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\CFL\\ExperienceManagerData",
L"LaunchCflScenario",
0,
&b
);
return b;
}

bool IsUserOOBEOrCredentialReset()
{
return IsUserOOBE() || IsCredentialReset();
}

#define DLL_INJECTION_METHOD_DXGI 0
#define DLL_INJECTION_METHOD_COM 1
#define DLL_INJECTION_METHOD_START_INJECTION 2
Expand Down Expand Up @@ -14608,6 +14683,12 @@ HRESULT EntryPoint(DWORD dwMethod)
bIsExplorerProcess = bIsThisExplorer;
if (bIsThisExplorer)
{
if (IsUserOOBEOrCredentialReset())
{
IncrementDLLReferenceCount(hModule);
bInstanced = TRUE;
return E_NOINTERFACE;
}
BOOL desktopExists = IsDesktopWindowAlreadyPresent();
#ifdef _WIN64
if (!desktopExists && CrashCounterHandleEntryPoint())
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ That's it. It's that simple.

## Uninstalling

* Right click the taskbar then click "Properties" or search for "ExplorerPatcher", and go to "Uninstall" section or
* Use "Programs and Features" in Control Panel, or "Apps and features" in the Settings app or
* Run `ep_setup.exe /uninstall` or
* Rename `ep_setup.exe` to `ep_uninstall.exe` and run that.
Expand All @@ -25,6 +26,6 @@ That's it. It's that simple.

## Donate

If you find this project essential to your daily life, please consider donating to support the development through the [Sponsor](#sponsor-button) button at the top of this page, so that we can continue to keep supporting newer Windows builds.
If you find this project essential to your daily life, please consider donating to support the development through the [Sponsor](?sponsor) button at the top of this page, so that we can continue to keep supporting newer Windows builds.

[Read more](https://github.com/valinet/ExplorerPatcher/wiki)
2 changes: 1 addition & 1 deletion ep_gui/GUI.c
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ static void GUI_UpdateLanguages()

DWORD GUI_GetTaskbarStyle()
{
DWORD dwRes = IsWindows11() ? 0 : 1;
DWORD dwRes = 1;
DWORD dwSize = sizeof(DWORD);
RegGetValueW(HKEY_CURRENT_USER, _T(REGPATH), L"OldTaskbar", RRF_RT_DWORD, NULL, &dwRes, &dwSize);
if (dwRes >= 2 && !DoesTaskbarDllExist())
Expand Down

0 comments on commit 36ebe5a

Please sign in to comment.