24 changed files with 3567 additions and 3755 deletions
@ -0,0 +1,200 @@
@@ -0,0 +1,200 @@
|
||||
#include "ArchiveMenu.h" |
||||
|
||||
DWORD ArchiveMenuThread(ArchiveMenuThreadParams* params) |
||||
{ |
||||
Sleep(1000); |
||||
printf("Started \"Archive menu\" thread.\n"); |
||||
|
||||
HRESULT hr = CoInitialize(NULL); |
||||
if (FAILED(hr)) |
||||
{ |
||||
return 0; |
||||
} |
||||
|
||||
WNDCLASS wc = { 0 }; |
||||
wc.style = CS_DBLCLKS; |
||||
wc.lpfnWndProc = params->wndProc; |
||||
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); |
||||
wc.hInstance = GetModuleHandle(NULL); |
||||
wc.lpszClassName = L"ArchiveMenuWindowExplorer"; |
||||
wc.hCursor = LoadCursorW(NULL, IDC_ARROW); |
||||
RegisterClass(&wc); |
||||
|
||||
*(params->hWnd) = params->CreateWindowInBand( |
||||
0, |
||||
L"ArchiveMenuWindowExplorer", |
||||
0, |
||||
WS_POPUP, |
||||
0, |
||||
0, |
||||
0, |
||||
0, |
||||
0, |
||||
0, |
||||
GetModuleHandle(NULL), |
||||
NULL, |
||||
7 |
||||
); |
||||
if (!*(params->hWnd)) |
||||
{ |
||||
return 0; |
||||
} |
||||
ITaskbarList* pTaskList = NULL; |
||||
hr = CoCreateInstance( |
||||
&__uuidof_TaskbarList, |
||||
NULL, |
||||
CLSCTX_ALL, |
||||
&__uuidof_ITaskbarList, |
||||
(void**)(&pTaskList) |
||||
); |
||||
if (FAILED(hr)) |
||||
{ |
||||
return 0; |
||||
} |
||||
hr = pTaskList->lpVtbl->HrInit(pTaskList); |
||||
if (FAILED(hr)) |
||||
{ |
||||
return 0; |
||||
} |
||||
ShowWindow(*(params->hWnd), SW_SHOW); |
||||
hr = pTaskList->lpVtbl->DeleteTab(pTaskList, *(params->hWnd)); |
||||
if (FAILED(hr)) |
||||
{ |
||||
return 0; |
||||
} |
||||
hr = pTaskList->lpVtbl->Release(pTaskList); |
||||
if (FAILED(hr)) |
||||
{ |
||||
return 0; |
||||
} |
||||
|
||||
MSG msg = { 0 }; |
||||
while (GetMessage(&msg, NULL, 0, 0)) |
||||
{ |
||||
TranslateMessage(&msg); |
||||
DispatchMessage(&msg); |
||||
} |
||||
|
||||
printf("Ended \"Archive menu\" thread.\n"); |
||||
} |
||||
|
||||
LRESULT CALLBACK ArchiveMenuWndProc( |
||||
_In_ HWND hWnd, |
||||
_In_ UINT uMsg, |
||||
_In_ WPARAM wParam, |
||||
_In_ LPARAM lParam, |
||||
INT64(*ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc)( |
||||
HMENU h1, |
||||
HMENU h2, |
||||
HWND a3, |
||||
unsigned int a4, |
||||
void* data |
||||
), |
||||
void(*ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc)( |
||||
HMENU _this, |
||||
HMENU hWnd, |
||||
HWND a3 |
||||
) |
||||
) |
||||
{ |
||||
LRESULT result; |
||||
|
||||
if (uMsg == WM_COPYDATA) |
||||
{ |
||||
COPYDATASTRUCT* st = lParam; |
||||
HWND srcWnd = wParam; |
||||
|
||||
POINT pt; |
||||
GetCursorPos(&pt); |
||||
|
||||
HWND prevhWnd = GetForegroundWindow(); |
||||
SetForegroundWindow(hWnd); |
||||
|
||||
HMENU hMenu = CreatePopupMenu(); |
||||
|
||||
TCHAR buffer[MAX_PATH + 100]; |
||||
TCHAR filename[MAX_PATH]; |
||||
ZeroMemory(filename, MAX_PATH * sizeof(TCHAR)); |
||||
memcpy(filename, st->lpData, wcslen(st->lpData) * sizeof(TCHAR)); |
||||
PathUnquoteSpacesW(filename); |
||||
PathRemoveExtensionW(filename); |
||||
PathStripPathW(filename); |
||||
wsprintf(buffer, EXTRACT_NAME, filename); |
||||
|
||||
InsertMenu(hMenu, 0, MF_BYPOSITION | MF_STRING, 1, buffer); |
||||
InsertMenu(hMenu, 0, MF_BYPOSITION | MF_STRING, 2, OPEN_NAME); |
||||
|
||||
INT64* unknown_array = calloc(4, sizeof(INT64)); |
||||
ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc( |
||||
hMenu, |
||||
hWnd, |
||||
&(pt), |
||||
0xc, |
||||
unknown_array |
||||
); |
||||
|
||||
BOOL res = TrackPopupMenu( |
||||
hMenu, |
||||
TPM_RETURNCMD, |
||||
pt.x - 15, |
||||
pt.y - 15, |
||||
0, |
||||
hWnd, |
||||
0 |
||||
); |
||||
|
||||
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( |
||||
hMenu, |
||||
hWnd, |
||||
&(pt) |
||||
); |
||||
free(unknown_array); |
||||
SetForegroundWindow(prevhWnd); |
||||
|
||||
if (res == 1 || res == 2) |
||||
{ |
||||
ZeroMemory(buffer, (MAX_PATH + 100) * sizeof(TCHAR)); |
||||
if (res == 2) |
||||
{ |
||||
wsprintf(buffer, OPEN_CMD, st->lpData); |
||||
//wprintf(L"%s\n%s\n\n", st->lpData, buffer);
|
||||
} |
||||
else if (res == 1) |
||||
{ |
||||
TCHAR path[MAX_PATH + 1], path_orig[MAX_PATH + 1]; |
||||
ZeroMemory(path, (MAX_PATH + 1) * sizeof(TCHAR)); |
||||
ZeroMemory(path_orig, (MAX_PATH + 1) * sizeof(TCHAR)); |
||||
memcpy(path, st->lpData, wcslen(st->lpData) * sizeof(TCHAR)); |
||||
memcpy(path_orig, st->lpData, wcslen(st->lpData) * sizeof(TCHAR)); |
||||
PathUnquoteSpacesW(path_orig); |
||||
PathRemoveExtensionW(path_orig); |
||||
wsprintf(buffer, EXTRACT_CMD, path_orig, path); |
||||
//wprintf(L"%s\n%s\n\n", st->lpData, buffer);
|
||||
} |
||||
STARTUPINFO si = { sizeof(si) }; |
||||
PROCESS_INFORMATION pi; |
||||
BOOL b = CreateProcess( |
||||
NULL, |
||||
buffer, |
||||
NULL, |
||||
NULL, |
||||
TRUE, |
||||
CREATE_UNICODE_ENVIRONMENT, |
||||
NULL, |
||||
NULL, |
||||
&si, |
||||
&pi |
||||
); |
||||
CloseHandle(pi.hProcess); |
||||
CloseHandle(pi.hThread); |
||||
} |
||||
DestroyMenu(hMenu); |
||||
ShowWindow(hWnd, SW_HIDE); |
||||
return 0; |
||||
} |
||||
else if (uMsg == WM_CLOSE) |
||||
{ |
||||
return 0; |
||||
} |
||||
return 1; |
||||
} |
||||
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
#ifndef _H_ARCHIVEMENU_H_ |
||||
#define _H_ARCHIVEMENU_H_ |
||||
#include <initguid.h> |
||||
#include <Windows.h> |
||||
#include <Shlobj_core.h> |
||||
|
||||
#define OPEN_NAME L"&Open archive" |
||||
#define EXTRACT_NAME L"&Extract to \"%s\\\"" |
||||
#define OPEN_CMD L"\"C:\\Program Files\\7-Zip\\7zFM.exe\" %s" |
||||
#define EXTRACT_CMD L"\"C:\\Program Files\\7-Zip\\7zG.exe\" x -o\"%s\" -spe %s" |
||||
|
||||
DEFINE_GUID(__uuidof_TaskbarList, |
||||
0x56FDF344, |
||||
0xFD6D, 0x11d0, 0x95, 0x8A, |
||||
0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90 |
||||
); |
||||
DEFINE_GUID(__uuidof_ITaskbarList, |
||||
0x56FDF342, |
||||
0xFD6D, 0x11d0, 0x95, 0x8A, |
||||
0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90 |
||||
); |
||||
|
||||
typedef struct _ArchiveMenuThreadParams |
||||
{ |
||||
HWND* hWnd; |
||||
WNDPROC wndProc; |
||||
HWND(WINAPI* CreateWindowInBand)( |
||||
_In_ DWORD dwExStyle, |
||||
_In_opt_ ATOM atom, |
||||
_In_opt_ LPCWSTR lpWindowName, |
||||
_In_ DWORD dwStyle, |
||||
_In_ int X, |
||||
_In_ int Y, |
||||
_In_ int nWidth, |
||||
_In_ int nHeight, |
||||
_In_opt_ HWND hWndParent, |
||||
_In_opt_ HMENU hMenu, |
||||
_In_opt_ HINSTANCE hInstance, |
||||
_In_opt_ LPVOID lpParam, |
||||
DWORD band |
||||
); |
||||
} ArchiveMenuThreadParams; |
||||
DWORD ArchiveMenuThread(ArchiveMenuThreadParams* params); |
||||
|
||||
LRESULT CALLBACK ArchiveMenuWndProc( |
||||
_In_ HWND hWnd, |
||||
_In_ UINT uMsg, |
||||
_In_ WPARAM wParam, |
||||
_In_ LPARAM lParam, |
||||
INT64(*ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc)( |
||||
HMENU h1, |
||||
HMENU h2, |
||||
HWND a3, |
||||
unsigned int a4, |
||||
void* data |
||||
), |
||||
void(*ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc)( |
||||
HMENU _this, |
||||
HMENU hWnd, |
||||
HWND a3 |
||||
) |
||||
); |
||||
|
||||
#endif |
||||
@ -0,0 +1,121 @@
@@ -0,0 +1,121 @@
|
||||
#include "HideExplorerSearchBar.h" |
||||
|
||||
HWND FindChildWindow( |
||||
HWND hwndParent, |
||||
wchar_t* lpszClass |
||||
) |
||||
{ |
||||
HWND hwnd = FindWindowEx( |
||||
hwndParent, |
||||
NULL, |
||||
lpszClass, |
||||
NULL |
||||
); |
||||
if (hwnd == NULL) |
||||
{ |
||||
HWND hwndChild = FindWindowEx( |
||||
hwndParent, |
||||
NULL, |
||||
NULL, |
||||
NULL |
||||
); |
||||
while (hwndChild != NULL && hwnd == NULL) |
||||
{ |
||||
hwnd = FindChildWindow( |
||||
hwndChild, |
||||
lpszClass |
||||
); |
||||
if (hwnd == NULL) |
||||
{ |
||||
hwndChild = FindWindowEx( |
||||
hwndParent, |
||||
hwndChild, |
||||
NULL, |
||||
NULL |
||||
); |
||||
} |
||||
} |
||||
} |
||||
return hwnd; |
||||
} |
||||
|
||||
VOID HideExplorerSearchBar(HWND hWnd) |
||||
{ |
||||
HWND band = NULL, rebar = NULL; |
||||
band = FindChildWindow( |
||||
hWnd, |
||||
(wchar_t*)L"TravelBand" |
||||
); |
||||
if (!band) |
||||
{ |
||||
return; |
||||
} |
||||
rebar = GetParent(band); |
||||
if (!rebar) |
||||
{ |
||||
return; |
||||
} |
||||
int idx = 0; |
||||
idx = (int)SendMessage( |
||||
rebar, |
||||
RB_IDTOINDEX, |
||||
4, |
||||
0 |
||||
); |
||||
if (idx >= 0) |
||||
{ |
||||
SendMessage( |
||||
rebar, |
||||
RB_SHOWBAND, |
||||
idx, |
||||
FALSE |
||||
); |
||||
} |
||||
idx = (int)SendMessage( |
||||
rebar, |
||||
RB_IDTOINDEX, |
||||
5, |
||||
0 |
||||
); |
||||
if (idx >= 0) |
||||
{ |
||||
SendMessage( |
||||
rebar, |
||||
RB_SHOWBAND, |
||||
idx, |
||||
TRUE |
||||
); |
||||
} |
||||
RedrawWindow( |
||||
rebar, |
||||
NULL, |
||||
NULL, |
||||
RDW_UPDATENOW | RDW_ALLCHILDREN |
||||
); |
||||
} |
||||
|
||||
LRESULT HideExplorerSearchBarSubClass( |
||||
HWND hWnd, |
||||
UINT uMsg, |
||||
WPARAM wParam, |
||||
LPARAM lParam, |
||||
UINT_PTR uIdSubclass, |
||||
DWORD_PTR dwRefData |
||||
) |
||||
{ |
||||
switch (uMsg) |
||||
{ |
||||
case WM_PARENTNOTIFY: |
||||
if ((WORD)wParam == 1) |
||||
{ |
||||
HideExplorerSearchBar(hWnd); |
||||
} |
||||
break; |
||||
|
||||
case WM_DESTROY: |
||||
RemoveWindowSubclass(hWnd, HideExplorerSearchBarSubClass, (UINT_PTR)HideExplorerSearchBarSubClass); |
||||
break; |
||||
} |
||||
|
||||
return DefSubclassProc(hWnd, uMsg, wParam, lParam); |
||||
} |
||||
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
#ifndef _H_HIDEEXPLORERSEARCHBAR_H_ |
||||
#define _H_HIDEEXPLORERSEARCHBAR_H_ |
||||
#include <Windows.h> |
||||
#include <commctrl.h> |
||||
#pragma comment(lib, "Comctl32.lib") |
||||
|
||||
// https://stackoverflow.com/questions/30141592/how-do-i-find-a-handle-inside-a-control
|
||||
HWND FindChildWindow( |
||||
HWND hwndParent, |
||||
wchar_t* lpszClass |
||||
); |
||||
|
||||
// https://github.com/Open-Shell/Open-Shell-Menu/blob/master/Src/ClassicExplorer/ExplorerBHO.cpp
|
||||
VOID HideExplorerSearchBar(HWND hWnd); |
||||
|
||||
LRESULT HideExplorerSearchBarSubClass( |
||||
HWND hWnd, |
||||
UINT uMsg, |
||||
WPARAM wParam, |
||||
LPARAM lParam, |
||||
UINT_PTR uIdSubclass, |
||||
DWORD_PTR dwRefData |
||||
); |
||||
#endif |
||||
@ -0,0 +1,318 @@
@@ -0,0 +1,318 @@
|
||||
#include "SettingsMonitor.h" |
||||
|
||||
DWORD MonitorSettingsChanges(SettingsChangeParameters* params) |
||||
{ |
||||
HMODULE hModule = LoadLibraryW(L"Shlwapi.dll"); |
||||
if (hModule) |
||||
{ |
||||
FARPROC SHRegGetValueFromHKCUHKLMFunc = GetProcAddress(hModule, "SHRegGetValueFromHKCUHKLM"); |
||||
DWORD dwSize = sizeof(DWORD); |
||||
LONG lRes = ERROR_SUCCESS; |
||||
HKEY hKeyCU, hKeyLM; |
||||
|
||||
dwSize = sizeof(DWORD); |
||||
DWORD dwInitialTaskbarAl = 0, dwTaskbarAl = 0, dwInitialTaskbarAlWas = 0; |
||||
if (!SHRegGetValueFromHKCUHKLMFunc || SHRegGetValueFromHKCUHKLMFunc( |
||||
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), |
||||
TEXT("TaskbarAl"), |
||||
SRRF_RT_REG_DWORD, |
||||
NULL, |
||||
&dwInitialTaskbarAl, |
||||
(LPDWORD)(&dwSize) |
||||
) != ERROR_SUCCESS) |
||||
{ |
||||
dwInitialTaskbarAl = 0; |
||||
} |
||||
else |
||||
{ |
||||
dwInitialTaskbarAlWas = 1; |
||||
} |
||||
|
||||
dwSize = sizeof(DWORD); |
||||
DWORD dwInitialMaximumFrequentApps = 6, dwMaximumFrequentApps = 6, dwInitialMaximumFrequentAppsWas = 0; |
||||
if (!SHRegGetValueFromHKCUHKLMFunc || SHRegGetValueFromHKCUHKLMFunc( |
||||
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), |
||||
TEXT("Start_MaximumFrequentApps"), |
||||
SRRF_RT_REG_DWORD, |
||||
NULL, |
||||
&dwInitialMaximumFrequentApps, |
||||
(LPDWORD)(&dwSize) |
||||
) != ERROR_SUCCESS) |
||||
{ |
||||
dwInitialMaximumFrequentApps = 6; |
||||
} |
||||
else |
||||
{ |
||||
dwInitialMaximumFrequentAppsWas = 1; |
||||
} |
||||
|
||||
while (TRUE) |
||||
{ |
||||
lRes = RegOpenKeyExW( |
||||
HKEY_CURRENT_USER, |
||||
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), |
||||
0, |
||||
KEY_READ, |
||||
&hKeyCU |
||||
); |
||||
if (lRes != ERROR_SUCCESS) |
||||
{ |
||||
return 0; |
||||
} |
||||
HANDLE hEvHKCU = CreateEvent(NULL, FALSE, FALSE, NULL); |
||||
RegNotifyChangeKeyValue( |
||||
hKeyCU, |
||||
FALSE, |
||||
REG_NOTIFY_CHANGE_LAST_SET, |
||||
hEvHKCU, |
||||
TRUE |
||||
); |
||||
|
||||
lRes = RegOpenKeyExW( |
||||
HKEY_LOCAL_MACHINE, |
||||
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), |
||||
0, |
||||
KEY_READ, |
||||
&hKeyLM |
||||
); |
||||
if (lRes != ERROR_SUCCESS) |
||||
{ |
||||
return 0; |
||||
} |
||||
HANDLE hEvHKLM = CreateEvent(NULL, FALSE, FALSE, NULL); |
||||
RegNotifyChangeKeyValue( |
||||
hKeyLM, |
||||
FALSE, |
||||
REG_NOTIFY_CHANGE_LAST_SET, |
||||
hEvHKLM, |
||||
TRUE |
||||
); |
||||
printf("!!! Setup monitor %d %d\n", hEvHKCU, hEvHKLM); |
||||
|
||||
HANDLE hEvents[2]; |
||||
hEvents[0] = hEvHKCU; |
||||
hEvents[1] = hEvHKLM; |
||||
DWORD rv = WaitForMultipleObjects( |
||||
2, |
||||
hEvents, |
||||
FALSE, |
||||
INFINITE |
||||
); |
||||
if (rv == WAIT_OBJECT_0) |
||||
{ |
||||
dwSize = sizeof(DWORD); |
||||
lRes = RegQueryValueExW( |
||||
hKeyCU, |
||||
TEXT("TaskbarAl"), |
||||
0, |
||||
NULL, |
||||
&dwTaskbarAl, |
||||
&dwSize |
||||
); |
||||
if (lRes != ERROR_SUCCESS && dwInitialTaskbarAlWas) |
||||
{ |
||||
if (params->TaskbarAlChangedCallback) |
||||
{ |
||||
void* p = 0; |
||||
if (params->TaskbarAlChangedCallbackData) |
||||
{ |
||||
p = params->TaskbarAlChangedCallbackData; |
||||
} |
||||
params->TaskbarAlChangedCallback(p, dwTaskbarAl); |
||||
} |
||||
else |
||||
{ |
||||
exit(0); |
||||
} |
||||
dwInitialTaskbarAl = dwTaskbarAl; |
||||
} |
||||
if (lRes == ERROR_SUCCESS && dwTaskbarAl != dwInitialTaskbarAl) |
||||
{ |
||||
if (params->TaskbarAlChangedCallback) |
||||
{ |
||||
void* p = 0; |
||||
if (params->TaskbarAlChangedCallbackData) |
||||
{ |
||||
p = params->TaskbarAlChangedCallbackData; |
||||
} |
||||
params->TaskbarAlChangedCallback(p, dwTaskbarAl); |
||||
} |
||||
else |
||||
{ |
||||
exit(0); |
||||
} |
||||
dwInitialTaskbarAl = dwTaskbarAl; |
||||
} |
||||
|
||||
if (params->isStartMenuExperienceHost) |
||||
{ |
||||
dwSize = sizeof(DWORD); |
||||
lRes = RegQueryValueExW( |
||||
hKeyCU, |
||||
TEXT("Start_MaximumFrequentApps"), |
||||
0, |
||||
NULL, |
||||
&dwMaximumFrequentApps, |
||||
&dwSize |
||||
); |
||||
if (lRes != ERROR_SUCCESS && dwInitialMaximumFrequentAppsWas) |
||||
{ |
||||
if (params->Start_MaximumRecentAppsChangedCallback) |
||||
{ |
||||
void* p = 0; |
||||
if (params->Start_MaximumRecentAppsChangedCallbackData) |
||||
{ |
||||
p = params->Start_MaximumRecentAppsChangedCallbackData; |
||||
} |
||||
params->Start_MaximumRecentAppsChangedCallback(p, dwMaximumFrequentApps); |
||||
} |
||||
else |
||||
{ |
||||
exit(0); |
||||
} |
||||
dwInitialMaximumFrequentApps = dwMaximumFrequentApps; |
||||
} |
||||
if (lRes == ERROR_SUCCESS && dwMaximumFrequentApps != dwInitialMaximumFrequentApps) |
||||
{ |
||||
if (params->Start_MaximumRecentAppsChangedCallback) |
||||
{ |
||||
void* p = 0; |
||||
if (params->Start_MaximumRecentAppsChangedCallbackData) |
||||
{ |
||||
p = params->Start_MaximumRecentAppsChangedCallbackData; |
||||
} |
||||
params->Start_MaximumRecentAppsChangedCallback(p, dwMaximumFrequentApps); |
||||
} |
||||
else |
||||
{ |
||||
exit(0); |
||||
} |
||||
dwInitialMaximumFrequentApps = dwMaximumFrequentApps; |
||||
} |
||||
} |
||||
} |
||||
else if (rv == WAIT_OBJECT_0 + 1) |
||||
{ |
||||
dwSize = sizeof(DWORD); |
||||
lRes = RegQueryValueExW( |
||||
hKeyCU, |
||||
TEXT("TaskbarAl"), |
||||
0, |
||||
NULL, |
||||
&dwTaskbarAl, |
||||
&dwSize |
||||
); |
||||
if (lRes != ERROR_SUCCESS) |
||||
{ |
||||
dwSize = sizeof(DWORD); |
||||
lRes = RegQueryValueExW( |
||||
hKeyLM, |
||||
TEXT("TaskbarAl"), |
||||
0, |
||||
NULL, |
||||
&dwTaskbarAl, |
||||
&dwSize |
||||
); |
||||
if (lRes != ERROR_SUCCESS && dwInitialTaskbarAlWas) |
||||
{ |
||||
if (params->TaskbarAlChangedCallback) |
||||
{ |
||||
void* p = 0; |
||||
if (params->TaskbarAlChangedCallbackData) |
||||
{ |
||||
p = params->TaskbarAlChangedCallbackData; |
||||
} |
||||
params->TaskbarAlChangedCallback(p, dwTaskbarAl); |
||||
} |
||||
else |
||||
{ |
||||
exit(0); |
||||
} |
||||
dwInitialTaskbarAl = dwTaskbarAl; |
||||
} |
||||
if (lRes == ERROR_SUCCESS && dwTaskbarAl != dwInitialTaskbarAl) |
||||
{ |
||||
if (params->TaskbarAlChangedCallback) |
||||
{ |
||||
void* p = 0; |
||||
if (params->TaskbarAlChangedCallbackData) |
||||
{ |
||||
p = params->TaskbarAlChangedCallbackData; |
||||
} |
||||
params->TaskbarAlChangedCallback(p, dwTaskbarAl); |
||||
} |
||||
else |
||||
{ |
||||
exit(0); |
||||
} |
||||
dwInitialTaskbarAl = dwTaskbarAl; |
||||
} |
||||
} |
||||
|
||||
if (params->isStartMenuExperienceHost) |
||||
{ |
||||
dwSize = sizeof(DWORD); |
||||
lRes = RegQueryValueExW( |
||||
hKeyCU, |
||||
TEXT("Start_MaximumFrequentApps"), |
||||
0, |
||||
NULL, |
||||
&dwMaximumFrequentApps, |
||||
&dwSize |
||||
); |
||||
if (lRes != ERROR_SUCCESS) |
||||
{ |
||||
dwSize = sizeof(DWORD); |
||||
lRes = RegQueryValueExW( |
||||
hKeyLM, |
||||
TEXT("Start_MaximumFrequentApps"), |
||||
0, |
||||
NULL, |
||||
&dwMaximumFrequentApps, |
||||
&dwSize |
||||
); |
||||
if (lRes != ERROR_SUCCESS && dwInitialMaximumFrequentAppsWas) |
||||
{ |
||||
if (params->Start_MaximumRecentAppsChangedCallback) |
||||
{ |
||||
void* p = 0; |
||||
if (params->Start_MaximumRecentAppsChangedCallbackData) |
||||
{ |
||||
p = params->Start_MaximumRecentAppsChangedCallbackData; |
||||
} |
||||
params->Start_MaximumRecentAppsChangedCallback(p, dwMaximumFrequentApps); |
||||
} |
||||
else |
||||
{ |
||||
exit(0); |
||||
} |
||||
dwInitialMaximumFrequentApps = dwMaximumFrequentApps; |
||||
} |
||||
if (lRes == ERROR_SUCCESS && dwMaximumFrequentApps != dwInitialMaximumFrequentApps) |
||||
{ |
||||
if (params->Start_MaximumRecentAppsChangedCallback) |
||||
{ |
||||
void* p = 0; |
||||
if (params->Start_MaximumRecentAppsChangedCallbackData) |
||||
{ |
||||
p = params->Start_MaximumRecentAppsChangedCallbackData; |
||||
} |
||||
params->Start_MaximumRecentAppsChangedCallback(p, dwMaximumFrequentApps); |
||||
} |
||||
else |
||||
{ |
||||
exit(0); |
||||
} |
||||
dwInitialMaximumFrequentApps = dwMaximumFrequentApps; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
CloseHandle(hEvHKCU); |
||||
CloseHandle(hEvHKLM); |
||||
RegCloseKey(hKeyCU); |
||||
RegCloseKey(hKeyLM); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
#ifndef _H_SETTINGSMONITOR_H_ |
||||
#define _H_SETTINGSMONITOR_H_ |
||||
#include <Windows.h> |
||||
#include <Shlwapi.h> |
||||
#pragma comment(lib, "Shlwapi.lib") |
||||
|
||||
typedef struct _SettingsChangeParameters |
||||
{ |
||||
BOOL isStartMenuExperienceHost; |
||||
void (*TaskbarAlChangedCallback)(INT64, DWORD); |
||||
void* TaskbarAlChangedCallbackData; |
||||
void (*Start_MaximumRecentAppsChangedCallback)(INT64, DWORD); |
||||
void* Start_MaximumRecentAppsChangedCallbackData; |
||||
} SettingsChangeParameters; |
||||
DWORD MonitorSettingsChanges(SettingsChangeParameters* params); |
||||
#endif |
||||
@ -0,0 +1,192 @@
@@ -0,0 +1,192 @@
|
||||
#include "StartMenu.h" |
||||
|
||||
void OpenStartOnMonitor(HMONITOR monitor) |
||||
{ |
||||
HRESULT hr = S_OK; |
||||
IUnknown* pImmersiveShell = NULL; |
||||
hr = CoCreateInstance( |
||||
&CLSID_ImmersiveShell, |
||||
NULL, |
||||
CLSCTX_NO_CODE_DOWNLOAD | CLSCTX_LOCAL_SERVER, |
||||
&IID_IServiceProvider, |
||||
&pImmersiveShell |
||||
); |
||||
if (SUCCEEDED(hr)) |
||||
{ |
||||
IImmersiveMonitorService* pMonitorService = NULL; |
||||
IUnknown_QueryService( |
||||
pImmersiveShell, |
||||
&SID_IImmersiveMonitorService, |
||||
&IID_IImmersiveMonitorService, |
||||
&pMonitorService |
||||
); |
||||
if (pMonitorService) |
||||
{ |
||||
IUnknown* pMonitor = NULL; |
||||
pMonitorService->lpVtbl->GetFromHandle( |
||||
pMonitorService, |
||||
monitor, |
||||
&pMonitor |
||||
); |
||||
IImmersiveLauncher10RS* pLauncher = NULL; |
||||
IUnknown_QueryService( |
||||
pImmersiveShell, |
||||
&SID_ImmersiveLauncher, |
||||
&IID_IImmersiveLauncher10RS, |
||||
&pLauncher |
||||
); |
||||
if (pLauncher) |
||||
{ |
||||
BOOL bIsVisible = FALSE; |
||||
pLauncher->lpVtbl->IsVisible(pLauncher, &bIsVisible); |
||||
if (SUCCEEDED(hr)) |
||||
{ |
||||
if (!bIsVisible) |
||||
{ |
||||
if (pMonitor) |
||||
{ |
||||
pLauncher->lpVtbl->ConnectToMonitor(pLauncher, pMonitor); |
||||
} |
||||
pLauncher->lpVtbl->ShowStartView(pLauncher, 11, 0); |
||||
} |
||||
else |
||||
{ |
||||
pLauncher->lpVtbl->Dismiss(pLauncher); |
||||
} |
||||
} |
||||
pLauncher->lpVtbl->Release(pLauncher); |
||||
} |
||||
if (pMonitor) |
||||
{ |
||||
pMonitor->lpVtbl->Release(pMonitor); |
||||
} |
||||
pMonitorService->lpVtbl->Release(pMonitorService); |
||||
} |
||||
pImmersiveShell->lpVtbl->Release(pImmersiveShell); |
||||
} |
||||
} |
||||
|
||||
LRESULT CALLBACK OpenStartOnCurentMonitorThreadHook( |
||||
int code, |
||||
WPARAM wParam, |
||||
LPARAM lParam |
||||
) |
||||
{ |
||||
if (code == HC_ACTION && wParam) |
||||
{ |
||||
MSG* msg = (MSG*)lParam; |
||||
if (GetSystemMetrics(SM_CMONITORS) >= 2 && msg->message == WM_SYSCOMMAND && (msg->wParam & 0xFFF0) == SC_TASKLIST) |
||||
{ |
||||
DWORD dwStatus = 0; |
||||
DWORD dwSize = sizeof(DWORD); |
||||
HMODULE hModule = GetModuleHandle(TEXT("Shlwapi.dll")); |
||||
FARPROC SHRegGetValueFromHKCUHKLMFunc = GetProcAddress(hModule, "SHRegGetValueFromHKCUHKLM"); |
||||
if (!SHRegGetValueFromHKCUHKLMFunc || SHRegGetValueFromHKCUHKLMFunc( |
||||
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage"), |
||||
TEXT("MonitorOverride"), |
||||
SRRF_RT_REG_DWORD, |
||||
NULL, |
||||
&dwStatus, |
||||
(LPDWORD)(&dwSize) |
||||
) != ERROR_SUCCESS || dwStatus == 1) |
||||
{ |
||||
goto finish; |
||||
} |
||||
|
||||
DWORD pts = GetMessagePos(); |
||||
POINT pt; |
||||
pt.x = GET_X_LPARAM(pts); |
||||
pt.y = GET_Y_LPARAM(pts); |
||||
HMONITOR monitor = MonitorFromPoint( |
||||
pt, |
||||
MONITOR_DEFAULTTONULL |
||||
); |
||||
OpenStartOnMonitor(monitor); |
||||
|
||||
msg->message = WM_NULL; |
||||
} |
||||
} |
||||
finish: |
||||
return CallNextHookEx(NULL, code, wParam, lParam); |
||||
} |
||||
|
||||
DWORD OpenStartOnCurentMonitorThread(OpenStartOnCurentMonitorThreadParams* unused) |
||||
{ |
||||
HANDLE hEvent = CreateEvent(0, 0, 0, L"ShellDesktopSwitchEvent"); |
||||
if (!hEvent) |
||||
{ |
||||
printf("Failed to start \"Open Start on current monitor\" thread.\n"); |
||||
return 0; |
||||
} |
||||
WaitForSingleObject( |
||||
hEvent, |
||||
INFINITE |
||||
); |
||||
printf("Started \"Open Start on current monitor\" thread.\n"); |
||||
HWND g_ProgWin = FindWindowEx( |
||||
NULL, |
||||
NULL, |
||||
L"Progman", |
||||
NULL |
||||
); |
||||
DWORD progThread = GetWindowThreadProcessId( |
||||
g_ProgWin, |
||||
NULL |
||||
); |
||||
HHOOK g_ProgHook = SetWindowsHookEx( |
||||
WH_GETMESSAGE, |
||||
OpenStartOnCurentMonitorThreadHook, |
||||
NULL, |
||||
progThread |
||||
); |
||||
MSG msg = { 0 }; |
||||
while (GetMessage(&msg, NULL, 0, 0)) |
||||
{ |
||||
TranslateMessage(&msg); |
||||
DispatchMessage(&msg); |
||||
} |
||||
|
||||
printf("Ended \"Open Start on current monitor\" thread.\n"); |
||||
} |
||||
|
||||
DWORD OpenStartAtLogonThread(OpenStartAtLogonThreadParams* unused) |
||||
{ |
||||
HANDLE hEvent = CreateEvent(0, 0, 0, L"ShellDesktopSwitchEvent"); |
||||
if (!hEvent) |
||||
{ |
||||
printf("Failed to start \"Open Start at Logon\" thread.\n"); |
||||
return 0; |
||||
} |
||||
WaitForSingleObject( |
||||
hEvent, |
||||
INFINITE |
||||
); |
||||
printf("Started \"Open Start at Logon\" thread.\n"); |
||||
|
||||
DWORD dwStatus = 0; |
||||
DWORD dwSize = sizeof(DWORD); |
||||
HMODULE hModule = GetModuleHandle(TEXT("Shlwapi")); |
||||
FARPROC SHRegGetValueFromHKCUHKLMFunc = GetProcAddress(hModule, "SHRegGetValueFromHKCUHKLM"); |
||||
if (!SHRegGetValueFromHKCUHKLMFunc || SHRegGetValueFromHKCUHKLMFunc( |
||||
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage"), |
||||
TEXT("OpenAtLogon"), |
||||
SRRF_RT_REG_DWORD, |
||||
NULL, |
||||
&dwStatus, |
||||
(LPDWORD)(&dwSize) |
||||
) != ERROR_SUCCESS || dwStatus == 0) |
||||
{ |
||||
return 0; |
||||
} |
||||
|
||||
POINT pt; |
||||
pt.x = 0; |
||||
pt.y = 0; |
||||
HMONITOR monitor = MonitorFromPoint( |
||||
pt, |
||||
MONITOR_DEFAULTTOPRIMARY |
||||
); |
||||
OpenStartOnMonitor(monitor); |
||||
|
||||
printf("Ended \"Open Start at Logon\" thread.\n"); |
||||
} |
||||
@ -0,0 +1,177 @@
@@ -0,0 +1,177 @@
|
||||
#ifndef _H_STARTMENU_H_ |
||||
#define _H_STARTMENU_H_ |
||||
#include <initguid.h> |
||||
#include <Windows.h> |
||||
#include <windowsx.h> |
||||
#include <Shlwapi.h> |
||||
#pragma comment(lib, "Shlwapi.lib") |
||||
|
||||
DEFINE_GUID(CLSID_ImmersiveShell, |
||||
0xc2f03a33, |
||||
0x21f5, 0x47fa, 0xb4, 0xbb, |
||||
0x15, 0x63, 0x62, 0xa2, 0xf2, 0x39 |
||||
); |
||||
|
||||
DEFINE_GUID(SID_IImmersiveMonitorService, |
||||
0x47094e3a, |
||||
0x0cf2, 0x430f, 0x80, 0x6f, |
||||
0xcf, 0x9e, 0x4f, 0x0f, 0x12, 0xdd |
||||
); |
||||
|
||||
DEFINE_GUID(IID_IImmersiveMonitorService, |
||||
0x4d4c1e64, |
||||
0xe410, 0x4faa, 0xba, 0xfa, |
||||
0x59, 0xca, 0x06, 0x9b, 0xfe, 0xc2 |
||||
); |
||||
|
||||
DEFINE_GUID(SID_ImmersiveLauncher, |
||||
0x6f86e01c, |
||||
0xc649, 0x4d61, 0xbe, 0x23, |
||||
0xf1, 0x32, 0x2d, 0xde, 0xca, 0x9d |
||||
); |
||||
|
||||
DEFINE_GUID(IID_IImmersiveLauncher10RS, |
||||
0xd8d60399, |
||||
0xa0f1, 0xf987, 0x55, 0x51, |
||||
0x32, 0x1f, 0xd1, 0xb4, 0x98, 0x64 |
||||
); |
||||
|
||||
typedef interface IImmersiveMonitorService IImmersiveMonitorService; |
||||
|
||||
typedef struct IImmersiveMonitorServiceVtbl |
||||
{ |
||||
BEGIN_INTERFACE |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* QueryInterface)( |
||||
IImmersiveMonitorService* This, |
||||
/* [in] */ REFIID riid, |
||||
/* [annotation][iid_is][out] */ |
||||
_COM_Outptr_ void** ppvObject); |
||||
|
||||
ULONG(STDMETHODCALLTYPE* AddRef)( |
||||
IImmersiveMonitorService* This); |
||||
|
||||
ULONG(STDMETHODCALLTYPE* Release)( |
||||
IImmersiveMonitorService* This); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* method3)( |
||||
IImmersiveMonitorService* This); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* method4)( |
||||
IImmersiveMonitorService* This); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* method5)( |
||||
IImmersiveMonitorService* This); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* GetFromHandle)( |
||||
IImmersiveMonitorService* This, |
||||
/* [in] */ HMONITOR hMonitor, |
||||
_COM_Outptr_ IUnknown** ppvObject); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* method6)( |
||||
IImmersiveMonitorService* This); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* method7)( |
||||
IImmersiveMonitorService* This); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* QueryService)( |
||||
IImmersiveMonitorService* This, |
||||
HMONITOR hMonitor, |
||||
GUID*, |
||||
GUID*, |
||||
void** ppvObject |
||||
); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* method9)( |
||||
IImmersiveMonitorService* This); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* QueryServiceFromWindow)( |
||||
IImmersiveMonitorService* This, |
||||
HWND hWnd, |
||||
GUID* a3, |
||||
GUID* a4, |
||||
void** ppvObject |
||||
); |
||||
|
||||
END_INTERFACE |
||||
} IImmersiveMonitorServiceVtbl; |
||||
|
||||
interface IImmersiveMonitorService |
||||
{ |
||||
CONST_VTBL struct IImmersiveMonitorServiceVtbl* lpVtbl; |
||||
}; |
||||
|
||||
typedef interface IImmersiveLauncher10RS IImmersiveLauncher10RS; |
||||
|
||||
typedef struct IImmersiveLauncher10RSVtbl |
||||
{ |
||||
BEGIN_INTERFACE |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* QueryInterface)( |
||||
IImmersiveLauncher10RS* This, |
||||
/* [in] */ REFIID riid, |
||||
/* [annotation][iid_is][out] */ |
||||
_COM_Outptr_ void** ppvObject); |
||||
|
||||
ULONG(STDMETHODCALLTYPE* AddRef)( |
||||
IImmersiveLauncher10RS* This); |
||||
|
||||
ULONG(STDMETHODCALLTYPE* Release)( |
||||
IImmersiveLauncher10RS* This); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* ShowStartView)( |
||||
IImmersiveLauncher10RS* This, |
||||
/* [in] */ int method, |
||||
/* [in] */ int flags); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* Dismiss)( |
||||
IImmersiveLauncher10RS* This); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* method5)( |
||||
IImmersiveLauncher10RS* This); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* method6)( |
||||
IImmersiveLauncher10RS* This); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* IsVisible)( |
||||
IImmersiveLauncher10RS* This, |
||||
/* [in] */ BOOL* ret); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* method8)( |
||||
IImmersiveLauncher10RS* This); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* method9)( |
||||
IImmersiveLauncher10RS* This); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* ConnectToMonitor)( |
||||
IImmersiveLauncher10RS* This, |
||||
/* [in] */ IUnknown* monitor); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* GetMonitor)( |
||||
IImmersiveLauncher10RS* This, |
||||
/* [in] */ IUnknown** monitor); |
||||
|
||||
END_INTERFACE |
||||
} IImmersiveLauncher10RSVtbl; |
||||
|
||||
interface IImmersiveLauncher10RS |
||||
{ |
||||
CONST_VTBL struct IImmersiveLauncher10RSVtbl* lpVtbl; |
||||
}; |
||||
|
||||
void OpenStartOnMonitor(HMONITOR monitor); |
||||
|
||||
// Slightly tweaked version of function available in Open Shell
|
||||
// (Open-Shell-Menu\Src\StartMenu\StartMenuHelper\StartMenuHelper.cpp)
|
||||
LRESULT CALLBACK OpenStartOnCurentMonitorThreadHook( |
||||
int code, |
||||
WPARAM wParam, |
||||
LPARAM lParam |
||||
); |
||||
|
||||
typedef DWORD OpenStartOnCurentMonitorThreadParams; |
||||
DWORD OpenStartOnCurentMonitorThread(OpenStartOnCurentMonitorThreadParams* unused); |
||||
|
||||
typedef DWORD OpenStartAtLogonThreadParams; |
||||
DWORD OpenStartAtLogonThread(OpenStartAtLogonThreadParams* unused); |
||||
#endif |
||||
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
#include "StartupSound.h" |
||||
|
||||
DWORD PlayStartupSound(PlayStartupSoundParams* unused) |
||||
{ |
||||
Sleep(2000); |
||||
printf("Started \"Play startup sound\" thread.\n"); |
||||
|
||||
HRESULT hr = CoInitialize(NULL); |
||||
|
||||
// this checks Software\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI\\LogonSoundPlayed
|
||||
// and then plays the startup sound
|
||||
|
||||
AuthUILogonSound* ppv; |
||||
hr = CoCreateInstance( |
||||
&__uuidof_AuthUILogonSound, |
||||
NULL, |
||||
CLSCTX_INPROC_SERVER, |
||||
&__uuidof_IAuthUILogonSound, |
||||
&ppv |
||||
); |
||||
if (SUCCEEDED(hr)) |
||||
{ |
||||
ppv->lpVtbl->PlayIfNecessary(ppv, 1); |
||||
ppv->lpVtbl->Release(ppv); |
||||
} |
||||
|
||||
printf("Ended \"Play startup sound\" thread.\n"); |
||||
return 0; |
||||
} |
||||
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
#ifndef _H_STARTUPSOUND_H_ |
||||
#define _H_STARTUPSOUND_H_ |
||||
#include <initguid.h> |
||||
#include <Windows.h> |
||||
|
||||
DEFINE_GUID(__uuidof_AuthUILogonSound, |
||||
0x0A0D018EE, |
||||
0x1100, 0x4389, 0xAB, 0x44, |
||||
0x46, 0x4F, 0xAF, 0x00, 0x12, 0x88 |
||||
); |
||||
DEFINE_GUID(__uuidof_IAuthUILogonSound, |
||||
0xc35243ea, |
||||
0x4cfc, 0x435a, 0x91, 0xc2, |
||||
0x9d, 0xbd, 0xec, 0xbf, 0xfc, 0x95 |
||||
); |
||||
|
||||
typedef interface AuthUILogonSound AuthUILogonSound; |
||||
|
||||
typedef struct AuthUILogonSoundVtbl |
||||
{ |
||||
BEGIN_INTERFACE |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* QueryInterface)( |
||||
AuthUILogonSound* This, |
||||
/* [in] */ REFIID riid, |
||||
/* [annotation][iid_is][out] */ |
||||
_COM_Outptr_ void** ppvObject); |
||||
|
||||
ULONG(STDMETHODCALLTYPE* AddRef)( |
||||
AuthUILogonSound* This); |
||||
|
||||
ULONG(STDMETHODCALLTYPE* Release)( |
||||
AuthUILogonSound* This); |
||||
|
||||
HRESULT(STDMETHODCALLTYPE* PlayIfNecessary)( |
||||
AuthUILogonSound* This, |
||||
/* [in] */ INT64 a1); |
||||
|
||||
END_INTERFACE |
||||
} AuthUILogonSoundVtbl; |
||||
|
||||
interface AuthUILogonSound |
||||
{ |
||||
CONST_VTBL struct AuthUILogonSoundVtbl* lpVtbl; |
||||
}; |
||||
|
||||
typedef DWORD PlayStartupSoundParams; |
||||
|
||||
DWORD PlayStartupSound(PlayStartupSoundParams* unused); |
||||
#endif |
||||
@ -0,0 +1,120 @@
@@ -0,0 +1,120 @@
|
||||
#ifndef _H_DXGI_IMP_H_ |
||||
#define _H_DXGI_IMP_H_ |
||||
#include <Windows.h> |
||||
static HRESULT(*ApplyCompatResolutionQuirkingFunc)(void*, void*); |
||||
__declspec(dllexport) HRESULT ApplyCompatResolutionQuirking(void* p1, void* p2) |
||||
{ |
||||
return ApplyCompatResolutionQuirkingFunc(p1, p2); |
||||
} |
||||
static HRESULT(*CompatStringFunc)(void*, void*, void*, BOOL); |
||||
__declspec(dllexport) HRESULT CompatString(void* p1, void* p2, void* p3, BOOL p4) |
||||
{ |
||||
return CompatStringFunc(p1, p2, p3, p4); |
||||
} |
||||
static HRESULT(*CompatValueFunc)(void*, void*); |
||||
__declspec(dllexport) HRESULT CompatValue(void* p1, void* p2) |
||||
{ |
||||
return CompatValueFunc(p1, p2); |
||||
} |
||||
static HRESULT(*CreateDXGIFactoryFunc)(void*, void**); |
||||
__declspec(dllexport) HRESULT CreateDXGIFactory(void* p1, void** p2) |
||||
{ |
||||
return CreateDXGIFactoryFunc(p1, p2); |
||||
} |
||||
static HRESULT(*CreateDXGIFactory1Func)(void*, void**); |
||||
__declspec(dllexport) HRESULT CreateDXGIFactory1(void* p1, void** p2) |
||||
{ |
||||
return CreateDXGIFactory1Func(p1, p2); |
||||
} |
||||
static HRESULT(*CreateDXGIFactory2Func)(UINT, void*, void**); |
||||
__declspec(dllexport) HRESULT CreateDXGIFactory2(UINT p1, void* p2, void** p3) |
||||
{ |
||||
return CreateDXGIFactory2Func(p1, p2, p3); |
||||
} |
||||
static HRESULT(*DXGID3D10CreateDeviceFunc)(); |
||||
__declspec(dllexport) HRESULT DXGID3D10CreateDevice() { |
||||
return DXGID3D10CreateDeviceFunc(); |
||||
} |
||||
static HRESULT(*DXGID3D10CreateLayeredDeviceFunc)(); |
||||
__declspec(dllexport) HRESULT DXGID3D10CreateLayeredDevice() |
||||
{ |
||||
return DXGID3D10CreateLayeredDeviceFunc(); |
||||
} |
||||
static HRESULT(*DXGID3D10GetLayeredDeviceSizeFunc)(); |
||||
__declspec(dllexport) HRESULT DXGID3D10GetLayeredDeviceSize() |
||||
{ |
||||
return DXGID3D10GetLayeredDeviceSizeFunc(); |
||||
} |
||||
static HRESULT(*DXGID3D10RegisterLayersFunc)(); |
||||
__declspec(dllexport) HRESULT DXGID3D10RegisterLayers() |
||||
{ |
||||
return DXGID3D10RegisterLayersFunc(); |
||||
} |
||||
static HRESULT(*DXGIDeclareAdapterRemovalSupportFunc)(); |
||||
__declspec(dllexport) HRESULT DXGIDeclareAdapterRemovalSupport() |
||||
{ |
||||
return DXGIDeclareAdapterRemovalSupportFunc(); |
||||
} |
||||
static HRESULT(*DXGIDumpJournalFunc)(void*); |
||||
__declspec(dllexport) HRESULT DXGIDumpJournal(void* p1) |
||||
{ |
||||
return DXGIDumpJournalFunc(p1); |
||||
} |
||||
static HRESULT(*DXGIGetDebugInterface1Func)(UINT, void*, void**); |
||||
__declspec(dllexport) HRESULT DXGIGetDebugInterface1(UINT p1, void* p2, void* p3) |
||||
{ |
||||
return DXGIGetDebugInterface1Func(p1, p2, p3); |
||||
} |
||||
static HRESULT(*DXGIReportAdapterConfigurationFunc)(); |
||||
__declspec(dllexport) HRESULT DXGIReportAdapterConfiguration(void* p1) |
||||
{ |
||||
return DXGIReportAdapterConfigurationFunc(p1); |
||||
} |
||||
static HRESULT(*PIXBeginCaptureFunc)(INT64, void*); |
||||
__declspec(dllexport) HRESULT PIXBeginCapture(INT64 p1, void* p2) |
||||
{ |
||||
return PIXBeginCaptureFunc(p1, p2); |
||||
} |
||||
static HRESULT(*PIXEndCaptureFunc)(); |
||||
__declspec(dllexport) HRESULT PIXEndCapture() |
||||
{ |
||||
return PIXEndCaptureFunc(); |
||||
} |
||||
static HRESULT(*PIXGetCaptureStateFunc)(); |
||||
__declspec(dllexport) HRESULT PIXGetCaptureState() |
||||
{ |
||||
return PIXGetCaptureState(); |
||||
} |
||||
static HRESULT(*SetAppCompatStringPointerFunc)(SIZE_T, void*); |
||||
__declspec(dllexport) HRESULT SetAppCompatStringPointer(SIZE_T p1, void* p2) |
||||
{ |
||||
return SetAppCompatStringPointerFunc(p1, p2); |
||||
} |
||||
static HRESULT(*UpdateHMDEmulationStatusFunc)(char); |
||||
__declspec(dllexport) HRESULT UpdateHMDEmulationStatus(char p1) |
||||
{ |
||||
return UpdateHMDEmulationStatusFunc(p1); |
||||
} |
||||
inline void SetupDXGIImportFunctions(HMODULE hModule) |
||||
{ |
||||
ApplyCompatResolutionQuirkingFunc = (HRESULT(*)(void*, void*))GetProcAddress(hModule, "ApplyCompatResolutionQuirking"); |
||||
CompatStringFunc = (HRESULT(*)(void*, void*, void*, BOOL))GetProcAddress(hModule, "CompatString"); |
||||
CompatValueFunc = (HRESULT(*)(void*, void*))GetProcAddress(hModule, "CompatValue"); |
||||
CreateDXGIFactoryFunc = (HRESULT(*)(void*, void**))GetProcAddress(hModule, "CreateDXGIFactory"); |
||||
CreateDXGIFactory1Func = (HRESULT(*)(void*, void**))GetProcAddress(hModule, "CreateDXGIFactory1"); |
||||
CreateDXGIFactory2Func = (HRESULT(*)(UINT, void*, void**))GetProcAddress(hModule, "CreateDXGIFactory2"); |
||||
DXGID3D10CreateDeviceFunc = (HRESULT(*)())GetProcAddress(hModule, "DXGID3D10CreateDevice"); |
||||
DXGID3D10CreateLayeredDeviceFunc = (HRESULT(*)())GetProcAddress(hModule, "DXGID3D10CreateLayeredDevice"); |
||||
DXGID3D10GetLayeredDeviceSizeFunc = (HRESULT(*)())GetProcAddress(hModule, "DXGID3D10GetLayeredDeviceSize"); |
||||
DXGID3D10RegisterLayersFunc = (HRESULT(*)())GetProcAddress(hModule, "DXGID3D10RegisterLayers"); |
||||
DXGIDeclareAdapterRemovalSupportFunc = (HRESULT(*)())GetProcAddress(hModule, "DXGIDeclareAdapterRemovalSupport"); |
||||
DXGIDumpJournalFunc = (HRESULT(*)(void*))GetProcAddress(hModule, "DXGIDumpJournal"); |
||||
DXGIGetDebugInterface1Func = (HRESULT(*)(UINT, void*, void**))GetProcAddress(hModule, "DXGIGetDebugInterface1"); |
||||
DXGIReportAdapterConfigurationFunc = (HRESULT(*)())GetProcAddress(hModule, "DXGIReportAdapterConfiguration"); |
||||
PIXBeginCaptureFunc = (HRESULT(*)(INT64, void*))GetProcAddress(hModule, "PIXBeginCapture"); |
||||
PIXEndCaptureFunc = (HRESULT(*)())GetProcAddress(hModule, "PIXEndCapture"); |
||||
PIXGetCaptureStateFunc = (HRESULT(*)())GetProcAddress(hModule, "PIXGetCaptureState"); |
||||
SetAppCompatStringPointerFunc = (HRESULT(*)(SIZE_T, void*))GetProcAddress(hModule, "SetAppCompatStringPointer"); |
||||
UpdateHMDEmulationStatusFunc = (HRESULT(*)(char))GetProcAddress(hModule, "UpdateHMDEmulationStatus"); |
||||
} |
||||
#endif |
||||
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
#ifndef _H_HOOKING_H_ |
||||
#define _H_HOOKING_H_ |
||||
#ifndef _M_AMD64 |
||||
#ifndef _M_ARM64 |
||||
#error This application only supports the amd64 or ARM64 architectures. Compilation aborted. |
||||
#endif |
||||
#endif |
||||
#define STRAT_REPLACE_ANY_TYPE_OF_JUMP_WITH_NOP 0 |
||||
#define STRAT_REPLACE_ANY_TYPE_OF_JUMP_WITH_ALWAYS_JUMP 1 |
||||
#define HOOK_WITH_FUNCHOOK 0 |
||||
#define HOOK_WITH_DETOURS 1 |
||||
#define HOW_TO_HOOK HOOK_WITH_FUNCHOOK |
||||
#if HOW_TO_HOOK == HOOK_WITH_FUNCHOOK |
||||
#ifdef _M_ARM64 |
||||
#error Cannot compile for ARM64 using funchook. Change the source to hook with Detours and try again. Compilation aborted. |
||||
#endif |
||||
#include <funchook.h> |
||||
#include <distorm.h> |
||||
#pragma comment(lib, "funchook.lib") |
||||
#pragma comment(lib, "Psapi.lib") // required by funchook
|
||||
#pragma comment(lib, "distorm.lib") |
||||
#elif HOW_TO_HOOK == HOOK_WITH_DETOURS |
||||
#include <detours.h> |
||||
#pragma comment(lib, "detours.lib") |
||||
void* funchook_create(void) |
||||
{ |
||||
return 1; |
||||
} |
||||
int funchook_uninstall( |
||||
void* _this, |
||||
int flags |
||||
) |
||||
{ |
||||
return 0; |
||||
} |
||||
int funchook_destroy(void* _this) |
||||
{ |
||||
return 0; |
||||
} |
||||
int funchook_prepare( |
||||
void* funchook, |
||||
void** target_func, |
||||
void* hook_func |
||||
) |
||||
{ |
||||
DetourTransactionBegin(); |
||||
DetourUpdateThread(GetCurrentThread()); |
||||
DetourAttach(target_func, hook_func); |
||||
return DetourTransactionCommit(); |
||||
} |
||||
int funchook_install( |
||||
void* funchook, |
||||
int flags |
||||
) |
||||
{ |
||||
return 0; |
||||
} |
||||
#endif |
||||
#if HOW_TO_HOOK == HOOK_WITH_FUNCHOOK |
||||
funchook_t* funchook = 0; |
||||
#elif HOW_TO_HOOK == HOOK_WITH_DETOURS |
||||
void* funchook = 0; |
||||
#endif |
||||
#endif |
||||
@ -0,0 +1,641 @@
@@ -0,0 +1,641 @@
|
||||
#include "symbols.h" |
||||
|
||||
const char* twinui_pcshell_SN[TWINUI_PCSHELL_SB_CNT] = { |
||||
TWINUI_PCSHELL_SB_0, |
||||
TWINUI_PCSHELL_SB_1, |
||||
TWINUI_PCSHELL_SB_2, |
||||
TWINUI_PCSHELL_SB_3, |
||||
TWINUI_PCSHELL_SB_4, |
||||
TWINUI_PCSHELL_SB_5, |
||||
TWINUI_PCSHELL_SB_6, |
||||
TWINUI_PCSHELL_SB_7 |
||||
}; |
||||
const char* startdocked_SN[STARTDOCKED_SB_CNT] = { |
||||
STARTDOCKED_SB_0, |
||||
STARTDOCKED_SB_1, |
||||
STARTDOCKED_SB_2, |
||||
STARTDOCKED_SB_3, |
||||
STARTDOCKED_SB_4 |
||||
}; |
||||
|
||||
const wchar_t DownloadSymbolsXML[] = |
||||
L"<toast displayTimestamp=\"2021-08-29T00:00:00.000Z\" scenario=\"reminder\" " |
||||
L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher\" duration=\"short\">\r\n" |
||||
L" <visual>\r\n" |
||||
L" <binding template=\"ToastGeneric\">\r\n" |
||||
L" <text><![CDATA[Unable to find symbols for OS version %s]]></text>\r\n" |
||||
L" <text><![CDATA[Downloading and applying symbol information, please wait...]]></text>\r\n" |
||||
L" <text placement=\"attribution\"><![CDATA[ExplorerPatcher]]></text>\r\n" |
||||
L" </binding>\r\n" |
||||
L" </visual>\r\n" |
||||
L" <audio src=\"ms-winsoundevent:Notification.Default\" loop=\"false\" silent=\"false\"/>\r\n" |
||||
L"</toast>\r\n"; |
||||
|
||||
const wchar_t DownloadOKXML[] = |
||||
L"<toast displayTimestamp=\"2021-08-29T01:00:00.000Z\" scenario=\"reminder\" " |
||||
L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher\" duration=\"short\">\r\n" |
||||
L" <visual>\r\n" |
||||
L" <binding template=\"ToastGeneric\">\r\n" |
||||
L" <text><![CDATA[Symbols downloaded and applied successfully!]]></text>\r\n" |
||||
L" <text><![CDATA[Now, please wait while dynamic Explorer patching is done...]]></text>\r\n" |
||||
L" <text placement=\"attribution\"><![CDATA[ExplorerPatcher]]></text>\r\n" |
||||
L" </binding>\r\n" |
||||
L" </visual>\r\n" |
||||
L" <audio src=\"ms-winsoundevent:Notification.Default\" loop=\"false\" silent=\"false\"/>\r\n" |
||||
L"</toast>\r\n"; |
||||
|
||||
const wchar_t InstallOK[] = |
||||
L"<toast displayTimestamp=\"2021-08-29T01:00:00.000Z\" scenario=\"reminder\" " |
||||
L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher\" duration=\"long\">\r\n" |
||||
L" <visual>\r\n" |
||||
L" <binding template=\"ToastGeneric\">\r\n" |
||||
L" <text><![CDATA[Installation succeeded!]]></text>\r\n" |
||||
L" <text><![CDATA[This notification will not show again until the next OS build update.]]></text>\r\n" |
||||
L" <text placement=\"attribution\"><![CDATA[ExplorerPatcher]]></text>\r\n" |
||||
L" </binding>\r\n" |
||||
L" </visual>\r\n" |
||||
L" <audio src=\"ms-winsoundevent:Notification.Default\" loop=\"false\" silent=\"false\"/>\r\n" |
||||
L"</toast>\r\n"; |
||||
|
||||
DWORD DownloadSymbols(DownloadSymbolsParams* params) |
||||
{ |
||||
TCHAR* wszSettingsPath = params->wszSettingsPath; |
||||
HMODULE hModule = params->hModule; |
||||
|
||||
Sleep(3000); |
||||
|
||||
printf("Started \"Download symbols\" thread.\n"); |
||||
|
||||
RTL_OSVERSIONINFOW rovi; |
||||
DWORD32 ubr = VnGetOSVersionAndUBR(&rovi); |
||||
TCHAR szReportedVersion[MAX_PATH + 1]; |
||||
ZeroMemory( |
||||
szReportedVersion, |
||||
(MAX_PATH + 1) * sizeof(TCHAR) |
||||
); |
||||
wsprintf( |
||||
szReportedVersion, |
||||
L"%d.%d.%d.%d", |
||||
rovi.dwMajorVersion, |
||||
rovi.dwMinorVersion, |
||||
rovi.dwBuildNumber, |
||||
ubr |
||||
); |
||||
|
||||
TCHAR buffer[sizeof(DownloadSymbolsXML) / sizeof(wchar_t) + 30]; |
||||
ZeroMemory( |
||||
buffer, |
||||
(sizeof(DownloadSymbolsXML) / sizeof(wchar_t) + 30) * sizeof(TCHAR) |
||||
); |
||||
wsprintf( |
||||
buffer, |
||||
DownloadSymbolsXML, |
||||
szReportedVersion |
||||
); |
||||
HRESULT hr = S_OK; |
||||
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml = NULL; |
||||
hr = String2IXMLDocument( |
||||
buffer, |
||||
wcslen(buffer), |
||||
&inputXml, |
||||
#ifdef DEBUG |
||||
stdout |
||||
#else |
||||
NULL |
||||
#endif |
||||
); |
||||
hr = ShowToastMessage( |
||||
inputXml, |
||||
APPID, |
||||
sizeof(APPID) / sizeof(TCHAR) - 1, |
||||
#ifdef DEBUG |
||||
stdout |
||||
#else |
||||
NULL |
||||
#endif |
||||
); |
||||
|
||||
DWORD dwRet = 0; |
||||
char szSettingsPath[MAX_PATH + 1]; |
||||
ZeroMemory( |
||||
szSettingsPath, |
||||
(MAX_PATH + 1) * sizeof(char) |
||||
); |
||||
wcstombs_s( |
||||
&dwRet, |
||||
szSettingsPath, |
||||
MAX_PATH + 1, |
||||
wszSettingsPath, |
||||
MAX_PATH + 1 |
||||
); |
||||
PathRemoveFileSpecA(szSettingsPath); |
||||
CreateDirectoryA(szSettingsPath, NULL); |
||||
strcat_s( |
||||
szSettingsPath, |
||||
MAX_PATH + 1, |
||||
"\\" |
||||
); |
||||
|
||||
printf("Downloading to \"%s\".\n", szSettingsPath); |
||||
|
||||
symbols_addr symbols_PTRS; |
||||
ZeroMemory( |
||||
&symbols_PTRS, |
||||
sizeof(symbols_addr) |
||||
); |
||||
|
||||
|
||||
|
||||
|
||||
char twinui_pcshell_sb_dll[MAX_PATH]; |
||||
ZeroMemory( |
||||
twinui_pcshell_sb_dll, |
||||
(MAX_PATH) * sizeof(char) |
||||
); |
||||
GetSystemDirectoryA( |
||||
twinui_pcshell_sb_dll, |
||||
MAX_PATH |
||||
); |
||||
strcat_s( |
||||
twinui_pcshell_sb_dll, |
||||
MAX_PATH, |
||||
"\\" |
||||
); |
||||
strcat_s( |
||||
twinui_pcshell_sb_dll, |
||||
MAX_PATH, |
||||
TWINUI_PCSHELL_SB_NAME |
||||
); |
||||
strcat_s( |
||||
twinui_pcshell_sb_dll, |
||||
MAX_PATH, |
||||
".dll" |
||||
); |
||||
printf("Downloading symbols for \"%s\"...\n", twinui_pcshell_sb_dll); |
||||
if (VnDownloadSymbols( |
||||
NULL, |
||||
twinui_pcshell_sb_dll, |
||||
szSettingsPath, |
||||
MAX_PATH |
||||
)) |
||||
{ |
||||
FreeLibraryAndExitThread( |
||||
hModule, |
||||
4 |
||||
); |
||||
return 4; |
||||
} |
||||
printf("Reading symbols...\n"); |
||||
if (VnGetSymbols( |
||||
szSettingsPath, |
||||
symbols_PTRS.twinui_pcshell_PTRS, |
||||
twinui_pcshell_SN, |
||||
TWINUI_PCSHELL_SB_CNT |
||||
)) |
||||
{ |
||||
printf("Hooking Win+C is not available for this build.\n"); |
||||
if (VnGetSymbols( |
||||
szSettingsPath, |
||||
symbols_PTRS.twinui_pcshell_PTRS, |
||||
twinui_pcshell_SN, |
||||
TWINUI_PCSHELL_SB_CNT - 1 |
||||
)) |
||||
{ |
||||
FreeLibraryAndExitThread( |
||||
hModule, |
||||
5 |
||||
); |
||||
return 5; |
||||
} |
||||
} |
||||
VnWriteUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_0), |
||||
symbols_PTRS.twinui_pcshell_PTRS[0], |
||||
wszSettingsPath |
||||
); |
||||
VnWriteUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_1), |
||||
symbols_PTRS.twinui_pcshell_PTRS[1], |
||||
wszSettingsPath |
||||
); |
||||
VnWriteUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_2), |
||||
symbols_PTRS.twinui_pcshell_PTRS[2], |
||||
wszSettingsPath |
||||
); |
||||
VnWriteUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_3), |
||||
symbols_PTRS.twinui_pcshell_PTRS[3], |
||||
wszSettingsPath |
||||
); |
||||
VnWriteUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_4), |
||||
symbols_PTRS.twinui_pcshell_PTRS[4], |
||||
wszSettingsPath |
||||
); |
||||
VnWriteUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_5), |
||||
symbols_PTRS.twinui_pcshell_PTRS[5], |
||||
wszSettingsPath |
||||
); |
||||
VnWriteUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_6), |
||||
symbols_PTRS.twinui_pcshell_PTRS[6], |
||||
wszSettingsPath |
||||
); |
||||
VnWriteUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_7), |
||||
symbols_PTRS.twinui_pcshell_PTRS[7], |
||||
wszSettingsPath |
||||
); |
||||
|
||||
|
||||
|
||||
char startdocked_sb_dll[MAX_PATH]; |
||||
ZeroMemory( |
||||
startdocked_sb_dll, |
||||
(MAX_PATH) * sizeof(char) |
||||
); |
||||
GetWindowsDirectoryA( |
||||
startdocked_sb_dll, |
||||
MAX_PATH |
||||
); |
||||
strcat_s( |
||||
startdocked_sb_dll, |
||||
MAX_PATH, |
||||
"\\SystemApps\\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\\" |
||||
); |
||||
strcat_s( |
||||
startdocked_sb_dll, |
||||
MAX_PATH, |
||||
STARTDOCKED_SB_NAME |
||||
); |
||||
strcat_s( |
||||
startdocked_sb_dll, |
||||
MAX_PATH, |
||||
".dll" |
||||
); |
||||
printf("Downloading symbols for \"%s\"...\n", startdocked_sb_dll); |
||||
if (VnDownloadSymbols( |
||||
NULL, |
||||
startdocked_sb_dll, |
||||
szSettingsPath, |
||||
MAX_PATH |
||||
)) |
||||
{ |
||||
FreeLibraryAndExitThread( |
||||
hModule, |
||||
6 |
||||
); |
||||
return 6; |
||||
} |
||||
printf("Reading symbols...\n"); |
||||
if (VnGetSymbols( |
||||
szSettingsPath, |
||||
symbols_PTRS.startdocked_PTRS, |
||||
startdocked_SN, |
||||
STARTDOCKED_SB_CNT |
||||
)) |
||||
{ |
||||
printf("error...\n"); |
||||
FreeLibraryAndExitThread( |
||||
hModule, |
||||
7 |
||||
); |
||||
return 7; |
||||
} |
||||
VnWriteUInt( |
||||
TEXT(STARTDOCKED_SB_NAME), |
||||
TEXT(STARTDOCKED_SB_0), |
||||
symbols_PTRS.startdocked_PTRS[0], |
||||
wszSettingsPath |
||||
); |
||||
VnWriteUInt( |
||||
TEXT(STARTDOCKED_SB_NAME), |
||||
TEXT(STARTDOCKED_SB_1), |
||||
symbols_PTRS.startdocked_PTRS[1], |
||||
wszSettingsPath |
||||
); |
||||
VnWriteUInt( |
||||
TEXT(STARTDOCKED_SB_NAME), |
||||
TEXT(STARTDOCKED_SB_2), |
||||
symbols_PTRS.startdocked_PTRS[2], |
||||
wszSettingsPath |
||||
); |
||||
VnWriteUInt( |
||||
TEXT(STARTDOCKED_SB_NAME), |
||||
TEXT(STARTDOCKED_SB_3), |
||||
symbols_PTRS.startdocked_PTRS[3], |
||||
wszSettingsPath |
||||
); |
||||
VnWriteUInt( |
||||
TEXT(STARTDOCKED_SB_NAME), |
||||
TEXT(STARTDOCKED_SB_4), |
||||
symbols_PTRS.startdocked_PTRS[4], |
||||
wszSettingsPath |
||||
); |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VnWriteString( |
||||
TEXT("OS"), |
||||
TEXT("Build"), |
||||
szReportedVersion, |
||||
wszSettingsPath |
||||
); |
||||
|
||||
if (symbols_PTRS.twinui_pcshell_PTRS[0]) |
||||
{ |
||||
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml = NULL; |
||||
HRESULT hr = String2IXMLDocument( |
||||
InstallOK, |
||||
wcslen(InstallOK), |
||||
&inputXml, |
||||
#ifdef DEBUG |
||||
stdout |
||||
#else |
||||
NULL |
||||
#endif |
||||
); |
||||
hr = ShowToastMessage( |
||||
inputXml, |
||||
APPID, |
||||
sizeof(APPID) / sizeof(TCHAR) - 1, |
||||
#ifdef DEBUG |
||||
stdout |
||||
#else |
||||
NULL |
||||
#endif |
||||
); |
||||
} |
||||
else |
||||
{ |
||||
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml2 = NULL; |
||||
hr = String2IXMLDocument( |
||||
DownloadOKXML, |
||||
wcslen(DownloadOKXML), |
||||
&inputXml2, |
||||
#ifdef DEBUG |
||||
stdout |
||||
#else |
||||
NULL |
||||
#endif |
||||
); |
||||
hr = ShowToastMessage( |
||||
inputXml2, |
||||
APPID, |
||||
sizeof(APPID) / sizeof(TCHAR) - 1, |
||||
#ifdef DEBUG |
||||
stdout |
||||
#else |
||||
NULL |
||||
#endif |
||||
); |
||||
} |
||||
|
||||
Sleep(4000); |
||||
|
||||
TCHAR wszExplorerPath[MAX_PATH + 1]; |
||||
wszExplorerPath[0] = L'\"'; |
||||
GetSystemDirectory(wszExplorerPath + 1, MAX_PATH); |
||||
wcscat_s(wszExplorerPath, MAX_PATH + 1, L"\\rundll32.exe\" \""); |
||||
GetModuleFileName(hModule, wszExplorerPath + wcslen(wszExplorerPath), MAX_PATH - wcslen(wszExplorerPath)); |
||||
wcscat_s(wszExplorerPath, MAX_PATH, L"\",ZZLaunchExplorer"); |
||||
wprintf(L"Command to launch: \" %s \"\n.", wszExplorerPath); |
||||
STARTUPINFO si = { sizeof(si) }; |
||||
PROCESS_INFORMATION pi; |
||||
BOOL b = CreateProcess( |
||||
NULL, |
||||
wszExplorerPath, |
||||
NULL, |
||||
NULL, |
||||
TRUE, |
||||
CREATE_UNICODE_ENVIRONMENT, |
||||
NULL, |
||||
NULL, |
||||
&si, |
||||
&pi |
||||
); |
||||
|
||||
FreeConsole(); |
||||
TerminateProcess( |
||||
OpenProcess( |
||||
PROCESS_TERMINATE, |
||||
FALSE, |
||||
GetCurrentProcessId() |
||||
), |
||||
EXIT_CODE_EXPLORER |
||||
); |
||||
} |
||||
|
||||
BOOL LoadSymbols(symbols_addr* symbols_PTRS, TCHAR* wszSettingsPath) |
||||
{ |
||||
symbols_PTRS->twinui_pcshell_PTRS[0] = VnGetUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_0), |
||||
0, |
||||
wszSettingsPath |
||||
); |
||||
symbols_PTRS->twinui_pcshell_PTRS[1] = VnGetUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_1), |
||||
0, |
||||
wszSettingsPath |
||||
); |
||||
symbols_PTRS->twinui_pcshell_PTRS[2] = VnGetUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_2), |
||||
0, |
||||
wszSettingsPath |
||||
); |
||||
symbols_PTRS->twinui_pcshell_PTRS[3] = VnGetUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_3), |
||||
0, |
||||
wszSettingsPath |
||||
); |
||||
symbols_PTRS->twinui_pcshell_PTRS[4] = VnGetUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_4), |
||||
0, |
||||
wszSettingsPath |
||||
); |
||||
symbols_PTRS->twinui_pcshell_PTRS[5] = VnGetUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_5), |
||||
0, |
||||
wszSettingsPath |
||||
); |
||||
symbols_PTRS->twinui_pcshell_PTRS[6] = VnGetUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_6), |
||||
0, |
||||
wszSettingsPath |
||||
); |
||||
symbols_PTRS->twinui_pcshell_PTRS[7] = VnGetUInt( |
||||
TEXT(TWINUI_PCSHELL_SB_NAME), |
||||
TEXT(TWINUI_PCSHELL_SB_7), |
||||
0, |
||||
wszSettingsPath |
||||
); |
||||
HKEY hKeySettings; |
||||
DWORD dwDisposition; |
||||
|
||||
RegCreateKeyExW( |
||||
HKEY_CURRENT_USER, |
||||
TEXT(REGPATH_OTHERS) L"\\" TEXT(STARTDOCKED_SB_NAME), |
||||
0, |
||||
NULL, |
||||
REG_OPTION_NON_VOLATILE, |
||||
KEY_WRITE, |
||||
NULL, |
||||
&hKeySettings, |
||||
&dwDisposition |
||||
); |
||||
symbols_PTRS->startdocked_PTRS[0] = VnGetUInt( |
||||
TEXT(STARTDOCKED_SB_NAME), |
||||
TEXT(STARTDOCKED_SB_0), |
||||
0, |
||||
wszSettingsPath |
||||
); |
||||
if (hKeySettings) |
||||
{ |
||||
RegSetValueExW( |
||||
hKeySettings, |
||||
TEXT(STARTDOCKED_SB_0), |
||||
0, |
||||
REG_DWORD, |
||||
&(symbols_PTRS->startdocked_PTRS[0]), |
||||
sizeof(DWORD) |
||||
); |
||||
} |
||||
symbols_PTRS->startdocked_PTRS[1] = VnGetUInt( |
||||
TEXT(STARTDOCKED_SB_NAME), |
||||
TEXT(STARTDOCKED_SB_1), |
||||
0, |
||||
wszSettingsPath |
||||
); |
||||
if (hKeySettings) |
||||
{ |
||||
RegSetValueExW( |
||||
hKeySettings, |
||||
TEXT(STARTDOCKED_SB_1), |
||||
0, |
||||
REG_DWORD, |
||||
&(symbols_PTRS->startdocked_PTRS[1]), |
||||
sizeof(DWORD) |
||||
); |
||||
} |
||||
symbols_PTRS->startdocked_PTRS[2] = VnGetUInt( |
||||
TEXT(STARTDOCKED_SB_NAME), |
||||
TEXT(STARTDOCKED_SB_2), |
||||
0, |
||||
wszSettingsPath |
||||
); |
||||
if (hKeySettings) |
||||
{ |
||||
RegSetValueExW( |
||||
hKeySettings, |
||||
TEXT(STARTDOCKED_SB_2), |
||||
0, |
||||
REG_DWORD, |
||||
&(symbols_PTRS->startdocked_PTRS[2]), |
||||
sizeof(DWORD) |
||||
); |
||||
} |
||||
symbols_PTRS->startdocked_PTRS[3] = VnGetUInt( |
||||
TEXT(STARTDOCKED_SB_NAME), |
||||
TEXT(STARTDOCKED_SB_3), |
||||
0, |
||||
wszSettingsPath |
||||
); |
||||
if (hKeySettings) |
||||
{ |
||||
RegSetValueExW( |
||||
hKeySettings, |
||||
TEXT(STARTDOCKED_SB_3), |
||||
0, |
||||
REG_DWORD, |
||||
&(symbols_PTRS->startdocked_PTRS[3]), |
||||
sizeof(DWORD) |
||||
); |
||||
} |
||||
symbols_PTRS->startdocked_PTRS[4] = VnGetUInt( |
||||
TEXT(STARTDOCKED_SB_NAME), |
||||
TEXT(STARTDOCKED_SB_4), |
||||
0, |
||||
wszSettingsPath |
||||
); |
||||
if (hKeySettings) |
||||
{ |
||||
RegSetValueExW( |
||||
hKeySettings, |
||||
TEXT(STARTDOCKED_SB_4), |
||||
0, |
||||
REG_DWORD, |
||||
&(symbols_PTRS->startdocked_PTRS[4]), |
||||
sizeof(DWORD) |
||||
); |
||||
} |
||||
if (hKeySettings) |
||||
{ |
||||
RegCloseKey(hKeySettings); |
||||
} |
||||
|
||||
BOOL bNeedToDownload = FALSE; |
||||
for (UINT i = 0; i < sizeof(symbols_addr) / sizeof(DWORD); ++i) |
||||
{ |
||||
if (!((DWORD*)symbols_PTRS)[i] && |
||||
(((DWORD*)symbols_PTRS) + i) != symbols_PTRS->twinui_pcshell_PTRS + TWINUI_PCSHELL_SB_CNT - 1 |
||||
) |
||||
{ |
||||
bNeedToDownload = TRUE; |
||||
} |
||||
} |
||||
RTL_OSVERSIONINFOW rovi; |
||||
DWORD32 ubr = VnGetOSVersionAndUBR(&rovi); |
||||
TCHAR szReportedVersion[MAX_PATH + 1]; |
||||
ZeroMemory( |
||||
szReportedVersion, |
||||
(MAX_PATH + 1) * sizeof(TCHAR) |
||||
); |
||||
TCHAR szStoredVersion[MAX_PATH + 1]; |
||||
ZeroMemory( |
||||
szStoredVersion, |
||||
(MAX_PATH + 1) * sizeof(TCHAR) |
||||
); |
||||
wsprintf( |
||||
szReportedVersion, |
||||
L"%d.%d.%d.%d", |
||||
rovi.dwMajorVersion, |
||||
rovi.dwMinorVersion, |
||||
rovi.dwBuildNumber, |
||||
ubr |
||||
); |
||||
VnGetString( |
||||
TEXT("OS"), |
||||
TEXT("Build"), |
||||
szStoredVersion, |
||||
MAX_PATH, |
||||
MAX_PATH, |
||||
NULL, |
||||
wszSettingsPath |
||||
); |
||||
if (!bNeedToDownload) |
||||
{ |
||||
bNeedToDownload = wcscmp(szReportedVersion, szStoredVersion); |
||||
} |
||||
return bNeedToDownload; |
||||
} |
||||
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
#ifndef _H_SYMBOLS_H_ |
||||
#define _H_SYMBOLS_H_ |
||||
#include <Windows.h> |
||||
#define _LIBVALINET_INCLUDE_UNIVERSAL |
||||
#include <valinet/universal/toast/toast.h> |
||||
#include <valinet/utility/osversion.h> |
||||
#include <roapi.h> |
||||
#include "utility.h" |
||||
|
||||
#define EXIT_CODE_EXPLORER 1 |
||||
#define REGPATH_OTHERS "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ExplorerPatcher" |
||||
|
||||
#define SYMBOLS_RELATIVE_PATH "\\ExplorerPatcher\\settings.ini" |
||||
#define TWINUI_PCSHELL_SB_NAME "twinui.pcshell" |
||||
#define TWINUI_PCSHELL_SB_0 "CImmersiveContextMenuOwnerDrawHelper::s_ContextMenuWndProc" |
||||
#define TWINUI_PCSHELL_SB_1 "CLauncherTipContextMenu::GetMenuItemsAsync" |
||||
#define TWINUI_PCSHELL_SB_2 "ImmersiveContextMenuHelper::ApplyOwnerDrawToMenu" |
||||
#define TWINUI_PCSHELL_SB_3 "ImmersiveContextMenuHelper::RemoveOwnerDrawFromMenu" |
||||
#define TWINUI_PCSHELL_SB_4 "CLauncherTipContextMenu::_ExecuteShutdownCommand" |
||||
#define TWINUI_PCSHELL_SB_5 "CLauncherTipContextMenu::_ExecuteCommand" |
||||
#define TWINUI_PCSHELL_SB_6 "CLauncherTipContextMenu::ShowLauncherTipContextMenu" |
||||
#define TWINUI_PCSHELL_SB_7 "winrt::Windows::Internal::Shell::implementation::MeetAndChatManager::OnMessage" // should be always last
|
||||
#define TWINUI_PCSHELL_SB_CNT 8 |
||||
#define STARTDOCKED_SB_NAME "StartDocked" |
||||
#define STARTDOCKED_SB_0 "StartDocked::LauncherFrame::ShowAllApps" // UNUSED
|
||||
#define STARTDOCKED_SB_1 "StartDocked::LauncherFrame::ShowAllApps" |
||||
#define STARTDOCKED_SB_2 "StartDocked::LauncherFrame::OnVisibilityChanged" |
||||
#define STARTDOCKED_SB_3 "StartDocked::SystemListPolicyProvider::GetMaximumFrequentApps" |
||||
#define STARTDOCKED_SB_4 "StartDocked::StartSizingFrame::StartSizingFrame" |
||||
#define STARTDOCKED_SB_CNT 5 |
||||
#pragma pack(push, 1) |
||||
typedef struct symbols_addr |
||||
{ |
||||
DWORD twinui_pcshell_PTRS[TWINUI_PCSHELL_SB_CNT]; |
||||
DWORD startdocked_PTRS[STARTDOCKED_SB_CNT]; |
||||
} symbols_addr; |
||||
#pragma pack(pop) |
||||
|
||||
typedef struct _DownloadSymbolsParams |
||||
{ |
||||
TCHAR* wszSettingsPath; |
||||
HMODULE hModule; |
||||
} DownloadSymbolsParams; |
||||
DWORD DownloadSymbols(DownloadSymbolsParams* params); |
||||
|
||||
BOOL LoadSymbols(symbols_addr* symbols_PTRS, TCHAR* wszSettingsPath); |
||||
#endif |
||||
@ -0,0 +1,358 @@
@@ -0,0 +1,358 @@
|
||||
#include "utility.h" |
||||
|
||||
#pragma region "Weird stuff" |
||||
INT64 nimpl4_1(INT64 a1, DWORD* a2) |
||||
{ |
||||
*a2 = 1; |
||||
return 0; |
||||
} |
||||
INT64 nimpl4_0(INT64 a1, DWORD* a2) |
||||
{ |
||||
*a2 = 0; |
||||
return 0; |
||||
} |
||||
__int64 __fastcall nimpl2(__int64 a1, uintptr_t* a2) |
||||
{ |
||||
__int64 v2; // rax
|
||||
|
||||
v2 = a1 + 8; |
||||
if (!a1) |
||||
v2 = 0i64; |
||||
|
||||
*a2 = v2; |
||||
return 0i64; |
||||
} |
||||
ULONG nimpl3() |
||||
{ |
||||
return 1; |
||||
} |
||||
HRESULT nimpl() |
||||
{ |
||||
return E_NOTIMPL; |
||||
} |
||||
HRESULT nimpl1(__int64 a1, uintptr_t* a2, uintptr_t* a3) |
||||
{ |
||||
__int64 v4 = a1; // rcx
|
||||
|
||||
if (*a2 != 0x5FADCA5C34A95314i64 || a2[1] != 0xC1661118901A7CAEui64) |
||||
return E_NOTIMPL; |
||||
|
||||
*a3 = v4; |
||||
return S_OK; |
||||
} |
||||
HRESULT nimpl1_2(__int64 a1, uintptr_t* a2, uintptr_t* a3) |
||||
{ |
||||
__int64 v4 = a1 - sizeof(__int64); // rcx
|
||||
|
||||
if (*a2 != 0x5FADCA5C34A95314i64 || a2[1] != 0xC1661118901A7CAEui64) |
||||
return E_NOTIMPL; |
||||
|
||||
*a3 = v4; |
||||
return S_OK; |
||||
} |
||||
HRESULT nimpl1_3(__int64 a1, uintptr_t* a2, uintptr_t* a3) |
||||
{ |
||||
__int64 v4 = a1 - 2 * sizeof(__int64); // rcx
|
||||
|
||||
if (*a2 != 0x5FADCA5C34A95314i64 || a2[1] != 0xC1661118901A7CAEui64) |
||||
return E_NOTIMPL; |
||||
|
||||
*a3 = v4; |
||||
return S_OK; |
||||
} |
||||
__int64 nimpl4(__int64 a1, __int64 a2, __int64 a3, BYTE* a4) |
||||
{ |
||||
*a4 = 0; |
||||
return 0i64; |
||||
} |
||||
const IActivationFactoryVtbl _IActivationFactoryVtbl = { |
||||
.QueryInterface = nimpl1, |
||||
.AddRef = nimpl3, |
||||
.Release = nimpl3, |
||||
.GetIids = nimpl, |
||||
.GetRuntimeClassName = nimpl, |
||||
.GetTrustLevel = nimpl, |
||||
.ActivateInstance = nimpl2 |
||||
}; |
||||
const IActivationFactoryVtbl _IActivationFactoryVtbl2 = { |
||||
.QueryInterface = nimpl1_2, |
||||
.AddRef = nimpl3, |
||||
.Release = nimpl3, |
||||
.GetIids = nimpl, |
||||
.GetRuntimeClassName = nimpl, |
||||
.GetTrustLevel = nimpl, |
||||
.ActivateInstance = nimpl |
||||
}; |
||||
const IActivationFactoryVtbl _IActivationFactoryVtbl3 = { |
||||
.QueryInterface = nimpl1_3, |
||||
.AddRef = nimpl3, |
||||
.Release = nimpl3, |
||||
.GetIids = nimpl, |
||||
.GetRuntimeClassName = nimpl, |
||||
.GetTrustLevel = nimpl, |
||||
.ActivateInstance = nimpl4 |
||||
}; |
||||
const IActivationFactoryAA XamlExtensionsFactory = { |
||||
.lpVtbl = &_IActivationFactoryVtbl, |
||||
.lpVtbl2 = &_IActivationFactoryVtbl2, |
||||
.lpVtbl3 = &_IActivationFactoryVtbl3 |
||||
}; |
||||
#pragma endregion |
||||
|
||||
void printf_guid(GUID guid) |
||||
{ |
||||
printf("Guid = {%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}\n", |
||||
guid.Data1, guid.Data2, guid.Data3, |
||||
guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], |
||||
guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); |
||||
} |
||||
|
||||
LRESULT CALLBACK BalloonWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) |
||||
{ |
||||
if (msg == WM_CREATE) |
||||
{ |
||||
LPCREATESTRUCT lpCs = lParam; |
||||
|
||||
NOTIFYICONDATA ni = { 0 }; |
||||
ni.cbSize = sizeof(ni); |
||||
ni.hWnd = hWnd; |
||||
ni.uID = 1; |
||||
ni.uFlags = NIF_INFO; |
||||
ni.dwInfoFlags = NIIF_INFO; |
||||
ni.uTimeout = 2000; |
||||
_tcscpy_s(ni.szInfo, _countof(ni.szInfo), lpCs->lpCreateParams); |
||||
_tcscpy_s(ni.szInfoTitle, _countof(ni.szInfoTitle), _T("ExplorerPatcher")); |
||||
|
||||
Shell_NotifyIcon(NIM_ADD, &ni); |
||||
|
||||
free(lpCs->lpCreateParams); |
||||
|
||||
exit(0); |
||||
} |
||||
else |
||||
{ |
||||
return DefWindowProc(hWnd, msg, wParam, lParam); |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
__declspec(dllexport) CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow) |
||||
{ |
||||
TCHAR* lpwszCmdLine = calloc((strlen(lpszCmdLine) + 1), sizeof(TCHAR)); |
||||
if (!lpwszCmdLine) exit(0); |
||||
size_t numChConv = 0; |
||||
mbstowcs_s(&numChConv, lpwszCmdLine, strlen(lpszCmdLine) + 1, lpszCmdLine, strlen(lpszCmdLine) + 1); |
||||
|
||||
WNDCLASSEX wc; |
||||
HWND hwnd; |
||||
MSG msg; |
||||
|
||||
wc.cbSize = sizeof(WNDCLASSEX); |
||||
wc.style = 0; |
||||
wc.lpfnWndProc = BalloonWndProc; |
||||
wc.cbClsExtra = 0; |
||||
wc.cbWndExtra = 0; |
||||
wc.hInstance = hInstance; |
||||
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); |
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW); |
||||
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); |
||||
wc.lpszMenuName = NULL; |
||||
wc.lpszClassName = L"ExplorerPatcherBalloon"; |
||||
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); |
||||
|
||||
if (!RegisterClassEx(&wc)) { |
||||
return 0; |
||||
} |
||||
|
||||
hwnd = CreateWindowEx(0, L"ExplorerPatcherBalloon", L"", |
||||
0, 0, 0, 0, 0, |
||||
HWND_MESSAGE, NULL, hInstance, lpwszCmdLine); |
||||
|
||||
while (GetMessage(&msg, NULL, 0, 0) > 0) { |
||||
TranslateMessage(&msg); |
||||
DispatchMessage(&msg); |
||||
} |
||||
} |
||||
|
||||
const wchar_t TestToastXML[] = |
||||
L"<toast displayTimestamp=\"2021-08-29T00:00:00.000Z\" scenario=\"reminder\" " |
||||
L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher\" duration=\"%s\">\r\n" |
||||
L" <visual>\r\n" |
||||
L" <binding template=\"ToastGeneric\">\r\n" |
||||
L" <text><![CDATA[%s]]></text>\r\n" |
||||
L" <text placement=\"attribution\"><![CDATA[ExplorerPatcher]]></text>\r\n" |
||||
L" </binding>\r\n" |
||||
L" </visual>\r\n" |
||||
L" <audio src=\"ms-winsoundevent:Notification.Default\" loop=\"false\" silent=\"false\"/>\r\n" |
||||
L"</toast>\r\n"; |
||||
__declspec(dllexport) CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow) |
||||
{ |
||||
TCHAR* lpwszCmdLine = calloc((strlen(lpszCmdLine) + 1), sizeof(TCHAR)); |
||||
if (!lpwszCmdLine) exit(0); |
||||
size_t numChConv = 0; |
||||
mbstowcs_s(&numChConv, lpwszCmdLine, strlen(lpszCmdLine) + 1, lpszCmdLine, strlen(lpszCmdLine) + 1); |
||||
TCHAR* buffer = calloc((sizeof(TestToastXML) / sizeof(wchar_t) + strlen(lpszCmdLine) + 10), sizeof(TCHAR)); |
||||
if (buffer) |
||||
{ |
||||
wsprintf( |
||||
buffer, |
||||
TestToastXML, |
||||
L"short", |
||||
lpwszCmdLine |
||||
); |
||||
HRESULT hr = S_OK; |
||||
__x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml = NULL; |
||||
hr = String2IXMLDocument( |
||||
buffer, |
||||
wcslen(buffer), |
||||
&inputXml, |
||||
#ifdef DEBUG |
||||
stdout |
||||
#else |
||||
NULL |
||||
#endif |
||||
); |
||||
hr = ShowToastMessage( |
||||
inputXml, |
||||
APPID, |
||||
sizeof(APPID) / sizeof(TCHAR) - 1, |
||||
#ifdef DEBUG |
||||
stdout |
||||
#else |
||||
NULL |
||||
#endif |
||||
); |
||||
free(buffer); |
||||
} |
||||
free(lpwszCmdLine); |
||||
} |
||||
|
||||
__declspec(dllexport) CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow) |
||||
{ |
||||
Sleep(100); |
||||
TCHAR wszExplorerPath[MAX_PATH + 1]; |
||||
GetWindowsDirectory(wszExplorerPath, MAX_PATH + 1); |
||||
wcscat_s(wszExplorerPath, MAX_PATH + 1, L"\\explorer.exe"); |
||||
STARTUPINFO si = { sizeof(si) }; |
||||
PROCESS_INFORMATION pi; |
||||
BOOL b = CreateProcess( |
||||
NULL, |
||||
wszExplorerPath, |
||||
NULL, |
||||
NULL, |
||||
TRUE, |
||||
CREATE_UNICODE_ENVIRONMENT, |
||||
NULL, |
||||
NULL, |
||||
&si, |
||||
&pi |
||||
); |
||||
FreeConsole(); |
||||
TerminateProcess( |
||||
OpenProcess( |
||||
PROCESS_TERMINATE, |
||||
FALSE, |
||||
GetCurrentProcessId() |
||||
), |
||||
0 |
||||
); |
||||
} |
||||
|
||||
__declspec(dllexport) CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow) |
||||
{ |
||||
Sleep(2000); |
||||
ZZLaunchExplorer(hWnd, hInstance, lpszCmdLine, nCmdShow); |
||||
} |
||||
|
||||
POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight) |
||||
{ |
||||
if (lpBottom) *lpBottom = FALSE; |
||||
if (lpRight) *lpRight = FALSE; |
||||
POINT point; |
||||
point.x = 0; |
||||
point.y = 0; |
||||
POINT ptCursor; |
||||
GetCursorPos(&ptCursor); |
||||
MONITORINFO mi; |
||||
mi.cbSize = sizeof(MONITORINFO); |
||||
HWND hWnd = GetMonitorInfoFromPointForTaskbarFlyoutActivation( |
||||
ptCursor, |
||||
MONITOR_DEFAULTTOPRIMARY, |
||||
&mi |
||||
); |
||||
if (hWnd) |
||||
{ |
||||
RECT rc; |
||||
GetWindowRect(hWnd, &rc); |
||||
if (rc.left - mi.rcMonitor.left == 0) |
||||
{ |
||||
if (bUseRcWork) |
||||
{ |
||||
point.x = mi.rcWork.left; |
||||
} |
||||
else |
||||
{ |
||||
point.x = mi.rcMonitor.left; |
||||
} |
||||
if (rc.top - mi.rcMonitor.top == 0) |
||||
{ |
||||
if (bUseRcWork) |
||||
{ |
||||
point.y = mi.rcWork.top; |
||||
} |
||||
else |
||||
{ |
||||
point.y = mi.rcMonitor.top; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
if (lpBottom) *lpBottom = TRUE; |
||||
if (bUseRcWork) |
||||
{ |
||||
point.y = mi.rcWork.bottom; |
||||
} |
||||
else |
||||
{ |
||||
point.y = mi.rcMonitor.bottom; |
||||
} |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
if (lpRight) *lpRight = TRUE; |
||||
if (bUseRcWork) |
||||
{ |
||||
point.x = mi.rcWork.right; |
||||
} |
||||
else |
||||
{ |
||||
point.x = mi.rcMonitor.right; |
||||
} |
||||
if (rc.top - mi.rcMonitor.top == 0) |
||||
{ |
||||
if (bUseRcWork) |
||||
{ |
||||
point.y = mi.rcWork.top; |
||||
} |
||||
else |
||||
{ |
||||
point.y = mi.rcMonitor.top; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
if (lpBottom) *lpBottom = TRUE; |
||||
if (bUseRcWork) |
||||
{ |
||||
point.y = mi.rcWork.bottom; |
||||
} |
||||
else |
||||
{ |
||||
point.y = mi.rcMonitor.bottom; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return point; |
||||
} |
||||
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
#ifndef _H_UTILITY_H_ |
||||
#define _H_UTILITY_H_ |
||||
#include <Windows.h> |
||||
#include <tchar.h> |
||||
#include <windows.data.xml.dom.h> |
||||
#include <Shlobj_core.h> |
||||
#define _LIBVALINET_INCLUDE_UNIVERSAL |
||||
#include <valinet/universal/toast/toast.h> |
||||
|
||||
#define APPID L"Microsoft.Windows.Explorer" |
||||
|
||||
#pragma region "Weird stuff" |
||||
INT64 nimpl4_1(INT64 a1, DWORD* a2); |
||||
INT64 nimpl4_0(INT64 a1, DWORD* a2); |
||||
__int64 __fastcall nimpl2(__int64 a1, uintptr_t* a2); |
||||
ULONG nimpl3(); |
||||
HRESULT nimpl(); |
||||
HRESULT nimpl1(__int64 a1, uintptr_t* a2, uintptr_t* a3); |
||||
HRESULT nimpl1_2(__int64 a1, uintptr_t* a2, uintptr_t* a3); |
||||
HRESULT nimpl1_3(__int64 a1, uintptr_t* a2, uintptr_t* a3); |
||||
__int64 nimpl4(__int64 a1, __int64 a2, __int64 a3, BYTE* a4); |
||||
typedef struct _IActivationFactoryAA |
||||
{ |
||||
CONST_VTBL struct IActivationFactoryVtbl* lpVtbl; |
||||
struct IActivationFactoryVtbl* lpVtbl2; |
||||
struct IActivationFactoryVtbl* lpVtbl3; |
||||
} IActivationFactoryAA; |
||||
extern const IActivationFactoryAA XamlExtensionsFactory; |
||||
#pragma endregion |
||||
|
||||
// https://stackoverflow.com/questions/1672677/print-a-guid-variable
|
||||
void printf_guid(GUID guid); |
||||
|
||||
LRESULT CALLBACK BalloonWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); |
||||
|
||||
__declspec(dllexport) CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow); |
||||
|
||||
__declspec(dllexport) CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow); |
||||
|
||||
__declspec(dllexport) CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow); |
||||
|
||||
__declspec(dllexport) CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow); |
||||
|
||||
POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight); |
||||
#endif |
||||
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
[General] |
||||
AllocConsole=0 |
||||
HideExplorerSearchBar=0 |
||||
HideControlCenterButton=0 |
||||
MicaEffectOnTitlebar=0 |
||||
SkinMenus=1 |
||||
SkinIcons=1 |
||||
[twinui.pcshell] |
||||
CImmersiveContextMenuOwnerDrawHelper::s_ContextMenuWndProc=2183030 |
||||
CLauncherTipContextMenu::GetMenuItemsAsync=6072240 |
||||
ImmersiveContextMenuHelper::ApplyOwnerDrawToMenu=6242504 |
||||
ImmersiveContextMenuHelper::RemoveOwnerDrawFromMenu=6244560 |
||||
CLauncherTipContextMenu::_ExecuteShutdownCommand=6131272 |
||||
CLauncherTipContextMenu::_ExecuteCommand=6130436 |
||||
CLauncherTipContextMenu::ShowLauncherTipContextMenu=6077440 |
||||
winrt::Windows::Internal::Shell::implementation::MeetAndChatManager::OnMessage=313504 |
||||
[StartDocked] |
||||
StartDocked::LauncherFrame::ShowAllApps=1609404 |
||||
StartDocked::LauncherFrame::OnVisibilityChanged=1601824 |
||||
StartDocked::SystemListPolicyProvider::GetMaximumFrequentApps=15376 |
||||
StartDocked::StartSizingFrame::StartSizingFrame=1444588 |
||||
[OS] |
||||
Build=10.0.22000.194 |
||||
Loading…
Reference in new issue