Skip to content

Commit

Permalink
Updates: Revamped code with rich notification content and proper JSON…
Browse files Browse the repository at this point in the history
… parsing
  • Loading branch information
Amrsatrio committed Jul 14, 2024
1 parent 4799b4b commit 2b9c747
Show file tree
Hide file tree
Showing 9 changed files with 1,452 additions and 1,467 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ jobs:
if ls build/Release/ep_taskbar.*.amd64.dll 1> /dev/null 2>&1; then
mkdir -p build/Release/x64
for file in build/Release/ep_taskbar.*.amd64.dll; do
cp "$file" "build/Release/x64/$(basename "$file" .amd64.dll).dll"
mv "$file" "build/Release/x64/$(basename "$file" .amd64.dll).dll"
done
fi
# if ls build/Release/ep_taskbar.*.arm64.dll 1> /dev/null 2>&1; then
# mkdir -p build/Release/ARM64
# for file in build/Release/ep_taskbar.*.arm64.dll; do
# cp "$file" "build/Release/ARM64/$(basename "$file" .arm64.dll).dll"
# done
# fi
if ls build/Release/ep_taskbar.*.arm64.dll 1> /dev/null 2>&1; then
mkdir -p build/Release/ARM64
for file in build/Release/ep_taskbar.*.arm64.dll; do
mv "$file" "build/Release/ARM64/$(basename "$file" .arm64.dll).dll"
done
fi
- name: Build funchook amd64
shell: powershell
Expand Down
2 changes: 1 addition & 1 deletion ExplorerPatcher/ExplorerPatcher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
<ClCompile Include="TaskbarCenter.c">
<ExcludedFromBuild Condition="'$(WithMainPatcher)'!='true'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="updates.c">
<ClCompile Include="updates.cpp">
<ExcludedFromBuild Condition="'$(WithMainPatcher)'!='true'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="utility.c">
Expand Down
2 changes: 1 addition & 1 deletion ExplorerPatcher/def.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#else
#define SETUP_UTILITY_NAME "ep_setup.arm64.exe"
#endif
#define TOAST_BUFSIZ 1024
#define TOAST_BUFSIZ 1536
#define SEH_REGPATH "Control Panel\\Quick Actions\\Control Center\\QuickActionsStateCapture\\ExplorerPatcher"
#define EP_SETUP_HELPER_SWITCH "/CreateExplorerShellUnelevatedAfterServicing"
#define EP_DWM_SERVICENAME "ep_dwm_" EP_CLSID_LITE
Expand Down
191 changes: 0 additions & 191 deletions ExplorerPatcher/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,197 +246,6 @@ HRESULT WINAPI _DllGetClassObject(
DEFINE_GUID(CLSID_EPStart10,
0x9717d01, 0x5d10, 0x4fb5, 0xbd, 0x5, 0x46, 0x38, 0xb, 0x51, 0x65, 0xaa);

#pragma region "Updates"
#if WITH_MAIN_PATCHER
DWORD CheckForUpdatesThread(LPVOID timeout)
{
HRESULT hr = S_OK;
HSTRING_HEADER header_AppIdHString;
HSTRING AppIdHString = NULL;
HSTRING_HEADER header_ToastNotificationManagerHString;
HSTRING ToastNotificationManagerHString = NULL;
__x_ABI_CWindows_CUI_CNotifications_CIToastNotificationManagerStatics* toastStatics = NULL;
__x_ABI_CWindows_CUI_CNotifications_CIToastNotifier* notifier = NULL;
HSTRING_HEADER header_ToastNotificationHString;
HSTRING ToastNotificationHString = NULL;
__x_ABI_CWindows_CUI_CNotifications_CIToastNotificationFactory* notifFactory = NULL;
__x_ABI_CWindows_CUI_CNotifications_CIToastNotification* toast = NULL;

while (TRUE)
{
HWND hShell_TrayWnd = FindWindowExW(
NULL,
NULL,
L"Shell_TrayWnd",
NULL
);
if (hShell_TrayWnd)
{
Sleep(timeout);
break;
}
Sleep(100);
}
printf("[Updates] Starting daemon.\n");

if (SUCCEEDED(hr))
{
hr = RoInitialize(RO_INIT_MULTITHREADED);
}
if (SUCCEEDED(hr))
{
hr = WindowsCreateStringReference(
APPID,
(UINT32)(sizeof(APPID) / sizeof(TCHAR) - 1),
&header_AppIdHString,
&AppIdHString
);
}
if (SUCCEEDED(hr))
{
hr = WindowsCreateStringReference(
RuntimeClass_Windows_UI_Notifications_ToastNotificationManager,
(UINT32)(sizeof(RuntimeClass_Windows_UI_Notifications_ToastNotificationManager) / sizeof(wchar_t) - 1),
&header_ToastNotificationManagerHString,
&ToastNotificationManagerHString
);
}
if (SUCCEEDED(hr))
{
hr = RoGetActivationFactory(
ToastNotificationManagerHString,
&UIID_IToastNotificationManagerStatics,
(LPVOID*)&toastStatics
);
}
if (SUCCEEDED(hr))
{
hr = toastStatics->lpVtbl->CreateToastNotifierWithId(
toastStatics,
AppIdHString,
&notifier
);
}
if (SUCCEEDED(hr))
{
hr = WindowsCreateStringReference(
RuntimeClass_Windows_UI_Notifications_ToastNotification,
(UINT32)(sizeof(RuntimeClass_Windows_UI_Notifications_ToastNotification) / sizeof(wchar_t) - 1),
&header_ToastNotificationHString,
&ToastNotificationHString
);
}
if (SUCCEEDED(hr))
{
hr = RoGetActivationFactory(
ToastNotificationHString,
&UIID_IToastNotificationFactory,
(LPVOID*)&notifFactory
);
}

HANDLE hEvents[2];
hEvents[0] = CreateEventW(NULL, FALSE, FALSE, L"EP_Ev_CheckForUpdates_" _T(EP_CLSID));
hEvents[1] = CreateEventW(NULL, FALSE, FALSE, L"EP_Ev_InstallUpdates_" _T(EP_CLSID));
if (hEvents[0] && hEvents[1])
{
if (bShowUpdateToast)
{
ShowUpdateSuccessNotification(hModule, notifier, notifFactory, &toast);

HKEY hKey = NULL;

RegCreateKeyExW(
HKEY_CURRENT_USER,
TEXT(REGPATH),
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_READ | KEY_WOW64_64KEY | KEY_WRITE,
NULL,
&hKey,
NULL
);
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
{
hKey = NULL;
}
if (hKey)
{
bShowUpdateToast = FALSE;
RegSetValueExW(
hKey,
TEXT("IsUpdatePending"),
0,
REG_DWORD,
&bShowUpdateToast,
sizeof(DWORD)
);
RegCloseKey(hKey);
}
}
if (dwUpdatePolicy != UPDATE_POLICY_MANUAL)
{
InstallUpdatesIfAvailable(hModule, notifier, notifFactory, &toast, UPDATES_OP_DEFAULT, bAllocConsole, dwUpdatePolicy);
}
DWORD dwRet = 0;
while (TRUE)
{
switch (WaitForMultipleObjects(2, hEvents, FALSE, INFINITE))
{
case WAIT_OBJECT_0:
{
InstallUpdatesIfAvailable(hModule, notifier, notifFactory, &toast, UPDATES_OP_CHECK, bAllocConsole, dwUpdatePolicy);
break;
}
case WAIT_OBJECT_0 + 1:
{
InstallUpdatesIfAvailable(hModule, notifier, notifFactory, &toast, UPDATES_OP_INSTALL, bAllocConsole, dwUpdatePolicy);
break;
}
default:
{
break;
}
}
}
CloseHandle(hEvents[0]);
CloseHandle(hEvents[1]);
}

if (toast)
{
toast->lpVtbl->Release(toast);
}
if (notifFactory)
{
notifFactory->lpVtbl->Release(notifFactory);
}
if (ToastNotificationHString)
{
WindowsDeleteString(ToastNotificationHString);
}
if (notifier)
{
notifier->lpVtbl->Release(notifier);
}
if (toastStatics)
{
toastStatics->lpVtbl->Release(toastStatics);
}
if (ToastNotificationManagerHString)
{
WindowsDeleteString(ToastNotificationManagerHString);
}
if (AppIdHString)
{
WindowsDeleteString(AppIdHString);
}
}
#endif
#pragma endregion


#pragma region "Generics"
#if WITH_MAIN_PATCHER
HWND GetMonitorInfoFromPointForTaskbarFlyoutActivation(POINT ptCursor, DWORD dwFlags, LPMONITORINFO lpMi)
Expand Down
Loading

0 comments on commit 2b9c747

Please sign in to comment.