diff --git a/.gitignore b/.gitignore index 2728a7d..bd051b0 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,5 @@ dkms.conf /progmgr/RCa10968 /progmgr/icons/Thumbs.db /bin/ +/misc/supermiumman.png +/bin.7z diff --git a/misc/superman.ico b/misc/superman.ico new file mode 100644 index 0000000..8b32423 Binary files /dev/null and b/misc/superman.ico differ diff --git a/progmgr/desktop.c b/progmgr/desktop.c index 28b46c9..41e4a1b 100644 --- a/progmgr/desktop.c +++ b/progmgr/desktop.c @@ -6,4 +6,131 @@ Only visible as the default shell. LICENSE INFORMATION - MIT License, see LICENSE.txt in the root folder -\* * * * * * * */ \ No newline at end of file +\* * * * * * * */ + +/* Headers */ +#include "progmgr.h" +#include "resource.h" +// #define WIN32_LEAN_AND_MEAN +#include + +/* Variables */ +HWND hWndDesktop; +RECT rcRoot; + +/* Functions */ + +/* * * *\ + CreateDesktopWindow - + Creates the invisible desktop window. + RETURNS - + True if successful, false if unsuccessful. +\* * * */ +BOOL CreateDesktopWindow() +{ + MSG msg = { 0 }; + WNDCLASSEX wc = { 0 }; + WCHAR szBuffer[MAX_PATH]; + WCHAR szClass[16]; + + // If we fail, we shouldn't be here anyways. + //if (GetShellWindow()) + // return FALSE; + + // Get size of the root HWND + GetWindowRect(GetDesktopWindow(), &rcRoot); + + // Load the window class string + LoadString(hAppInstance, IDS_DTCLASS, szClass, ARRAYSIZE(szClass)); + + // Refresh the wallpaper... + SystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, szBuffer, 0); + SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, szBuffer, SPIF_SENDCHANGE); + + // Reset the work area (removes dead-space after switching from another shell) + // May have unintended consequences. Doesn't work with multiple monitors. + SystemParametersInfo(SPI_SETWORKAREA, 0, &rcRoot, SPIF_SENDCHANGE); + + // Register the desktop window + wc.cbSize = sizeof(WNDCLASSEX); + wc.lpfnWndProc = DeskWndProc; + wc.hInstance = hAppInstance; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)(30); + wc.style = CS_NOCLOSE; + wc.lpszClassName = szClass; + if (!RegisterClassEx(&wc)) + return FALSE; + + if (!CreateWindowEx(WS_EX_TOOLWINDOW, wc.lpszClassName, NULL, WS_VISIBLE, + rcRoot.left, rcRoot.top, rcRoot.right - rcRoot.left, rcRoot.bottom - rcRoot.top, + NULL, NULL, hAppInstance, NULL)); + return 2; + + while (GetMessage(&msg, NULL, 0, 0) > 0) + { + DispatchMessage(&msg); + } + + return TRUE; +} + +/* * * *\ + DeskWndProc - + Program Manager's desktop window procedure. + RETURNS - + Zero if nothing, otherwise returns the good stuff. +\* * * */ +LRESULT CALLBACK DeskWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + + case WM_CREATE: + // Populate hWndDesktop + hWndDesktop = hWnd; + + // Set the window position to shell + SetShellWindow(hWndDesktop); + ShowWindow(hWndDesktop, SW_MAXIMIZE); + + // Strip the border from the desktop window + SetWindowLongPtr(hWndDesktop, GWL_STYLE, WS_POPUP); + + // Size the window to take up the primary monitor's desktop + SetWindowPos(hWndDesktop, HWND_BOTTOM, + rcRoot.left, rcRoot.top, rcRoot.right - rcRoot.left, rcRoot.bottom - rcRoot.top, + SWP_FRAMECHANGED | SWP_NOACTIVATE); + + // Finally, bring Program Manager to the foreground. + SetWindowPos(hWndProgMgr, HWND_TOP, + 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + + break; + + case WM_ACTIVATE: + case WM_DPICHANGED: + case WM_DISPLAYCHANGE: + case WM_DEVICECHANGE: + // Get size of the root HWND + GetWindowRect(GetDesktopWindow(), &rcRoot); + SetWindowPos(hWndDesktop, HWND_BOTTOM, + rcRoot.left, rcRoot.top, rcRoot.right - rcRoot.left, rcRoot.bottom - rcRoot.top, + SWP_NOACTIVATE); + break; + + case WM_WINDOWPOSCHANGING: + case WM_SYSCOMMAND: + case WM_COMMAND: + break; + + case WM_DESTROY: + case WM_CLOSE: + break; + + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; + +} \ No newline at end of file diff --git a/progmgr/lang/res_en-US.rc b/progmgr/lang/res_en-US.rc index e5f759e..d4df298 100644 Binary files a/progmgr/lang/res_en-US.rc and b/progmgr/lang/res_en-US.rc differ diff --git a/progmgr/progmgr.c b/progmgr/progmgr.c index e8a90dd..8bb4f53 100644 --- a/progmgr/progmgr.c +++ b/progmgr/progmgr.c @@ -49,7 +49,6 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi WCHAR szUsername[UNLEN + 1] = L""; DWORD dwUsernameLen = UNLEN; WCHAR szWindowTitle[UNLEN + ARRAYSIZE(szAppTitle) + 4] = L""; - RECT rWorkArea; hAppInstance = hInstance; @@ -59,6 +58,9 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi LoadString(hAppInstance, IDS_WEBSITE, szWebsite, ARRAYSIZE(szWebsite)); GetUserNameEx(NameSamCompatible, szUsername, &dwUsernameLen); + // Get Desktop background color + //CreateSolidBrush(GetBackgroundColor + // Register the Frame Window wc.lpfnWndProc = WndProc; wc.hInstance = hAppInstance; @@ -95,12 +97,18 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi StringCchCat(szWindowTitle, ARRAYSIZE(szWindowTitle), L" - "); StringCchCat(szWindowTitle, ARRAYSIZE(szWindowTitle), szUsername); } - + if (!CreateWindow(wc.lpszClassName, szWindowTitle, WS_OVERLAPPEDWINDOW | WS_VISIBLE, - rcMainWindow.left, rcMainWindow.top, rcMainWindow.right - rcMainWindow.left, rcMainWindow.bottom - rcMainWindow.top, - 0, 0, hAppInstance, NULL)) + 20, 20, 340, 220, 0, 0, hAppInstance, NULL)) return 2; + // Set the window size, but only if it's valid + if ((rcMainWindow.left != rcMainWindow.right) && (rcMainWindow.top != rcMainWindow.bottom)) + SetWindowPos(hWndProgMgr, NULL, + rcMainWindow.left, rcMainWindow.top, + rcMainWindow.right - rcMainWindow.left, + rcMainWindow.bottom - rcMainWindow.top, SWP_NOZORDER); + // Load the menus... hMenu = GetMenu(hWndProgMgr); hSystemMenu = GetSystemMenu(hWndProgMgr, FALSE); @@ -130,14 +138,9 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi LoadString(hAppInstance, IDS_TASKMGR, szBuffer, ARRAYSIZE(szBuffer)); InsertMenu(hSystemMenu, 6, MF_BYPOSITION | MF_STRING, IDM_TASKMGR, szBuffer); - - // Refresh the wallpaper... - SystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, szBuffer, 0); - SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, szBuffer, SPIF_SENDCHANGE); - - // Reset the work area (removes dead-space after switching from another shell) - // May have unintended consequences. - SystemParametersInfo(SPI_SETWORKAREA, 0, (PVOID)&rWorkArea, SPIF_SENDCHANGE); + + // Create the desktop window... + CreateDesktopWindow(); } while (GetMessage(&msg, NULL, 0, 0) > 0) diff --git a/progmgr/progmgr.h b/progmgr/progmgr.h index 2c2a0e6..b778786 100644 --- a/progmgr/progmgr.h +++ b/progmgr/progmgr.h @@ -40,9 +40,13 @@ extern WCHAR szProgMgr[]; extern WCHAR szWebsite[64]; /* Function Prototypes */ -// SHELLINT.C +// DESKTOP.C +BOOL CreateDesktopWindow(); +LRESULT CALLBACK DeskWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); +// SYSINT.C BOOL RunFileDlg(HWND hWndOwner, HICON hIcon, LPWSTR lpszDir, LPWSTR lpszTitle, LPWSTR lpszDesc, DWORD dwFlags); BOOL ExitWindowsDialog(HWND hWndOwner); +BOOL SetShellWindow(HWND hWndShell); // WNDPROC.C LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK CmdProc(HWND hWnd, WPARAM wParam, LPARAM lParam); diff --git a/progmgr/progmgr.vcxproj b/progmgr/progmgr.vcxproj index ed5bcd1..6c7888d 100644 --- a/progmgr/progmgr.vcxproj +++ b/progmgr/progmgr.vcxproj @@ -167,7 +167,7 @@ - + diff --git a/progmgr/progmgr.vcxproj.filters b/progmgr/progmgr.vcxproj.filters index 59b4f0b..29e22ec 100644 --- a/progmgr/progmgr.vcxproj.filters +++ b/progmgr/progmgr.vcxproj.filters @@ -38,7 +38,7 @@ Source Files - + Source Files diff --git a/progmgr/registry.c b/progmgr/registry.c index a923e1f..0bb31ba 100644 --- a/progmgr/registry.c +++ b/progmgr/registry.c @@ -78,7 +78,7 @@ BOOL IsProgMgrDefaultShell() HKEY hKeyWinlogon; WCHAR szShell[HKEYMAXLEN] = L""; DWORD dwType; - DWORD dwBufferSize = 0; + DWORD dwBufferSize = sizeof(szShell); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WINLOGON_KEY, 0, KEY_READ, &hKeyWinlogon) == ERROR_SUCCESS) @@ -134,7 +134,7 @@ BOOL SaveConfig() (bSaveSettings && PMS_SAVESETTINGS) * PMS_SAVESETTINGS; if (!RegSetValueEx(hKeySettings, pszSettingsMask, 0, REG_DWORD, - &dwSettingsMask, sizeof(dwSettingsMask)) == ERROR_SUCCESS) + (const BYTE*)&dwSettingsMask, sizeof(dwSettingsMask)) == ERROR_SUCCESS) bConfigStatus = FALSE; // Get and save window position @@ -143,7 +143,7 @@ BOOL SaveConfig() CopyRect(&rcWindow, &wpProgMgr.rcNormalPosition); if (!RegSetValueEx(hKeySettings, pszSettingsWindow, 0, REG_BINARY, - &rcWindow, sizeof(rcWindow)) == ERROR_SUCCESS) + (const BYTE*)&rcWindow, sizeof(rcWindow)) == ERROR_SUCCESS) bConfigStatus = FALSE; return bConfigStatus; @@ -165,7 +165,7 @@ BOOL LoadConfig() // Load settings bitmask if (!RegQueryValueEx(hKeySettings, pszSettingsMask, 0, &dwType, - &dwSettingsMask, &dwBufferSize) == ERROR_SUCCESS) + (LPBYTE)&dwSettingsMask, &dwBufferSize) == ERROR_SUCCESS) bConfigStatus = FALSE; // Apply bitmask to booleans @@ -177,7 +177,7 @@ BOOL LoadConfig() // Load window position... and apply it! if (!RegQueryValueEx(hKeySettings, pszSettingsWindow, 0, &dwType, - &rcMainWindow, &dwRectBufferSize) == ERROR_SUCCESS) + (LPBYTE)&rcMainWindow, &dwRectBufferSize) == ERROR_SUCCESS) bConfigStatus = FALSE; return bConfigStatus; diff --git a/progmgr/resource.h b/progmgr/resource.h index 583b773..6706025 100644 Binary files a/progmgr/resource.h and b/progmgr/resource.h differ diff --git a/progmgr/shellint.c b/progmgr/sysint.c similarity index 72% rename from progmgr/shellint.c rename to progmgr/sysint.c index b95dc68..dfac13b 100644 --- a/progmgr/shellint.c +++ b/progmgr/sysint.c @@ -1,8 +1,8 @@ /* * * * * * * *\ - SHELLINT.C - + SYSINT.C - Copyright (c) 2023 freedom7341, Freedom Desktop DESCRIPTION - - Program Manager's shell interface functions. + Program Manager's system interface functions. LICENSE INFORMATION - MIT License, see LICENSE.txt in the root folder \* * * * * * * */ @@ -33,8 +33,10 @@ BOOL RunFileDlg(HWND hWndOwner, { FARPROC fLib = GetProcAddress(hLib, MAKEINTRESOURCEA(61)); if (fLib(hWndOwner, hIcon, lpszDir, lpszTitle, lpszDesc, dwFlags)) + { FreeLibrary(hLib); return TRUE; + } } return FALSE; @@ -54,8 +56,32 @@ BOOL ExitWindowsDialog(HWND hWndOwner) { FARPROC fLib = GetProcAddress(hLib, (LPCSTR)60); if (fLib(hWndOwner)) + { FreeLibrary(hLib); return TRUE; + } + } + + return FALSE; +} + +/* * * *\ + SetShellWindow - + Sets a window as the shell window. + RETURNS - + True if successful, false if unsuccessful. +\* * * */ +BOOL SetShellWindow(HWND hWndShell) +{ + HMODULE hLib = GetModuleHandle(L"user32.dll"); + + if (hLib) + { + FARPROC fLib = GetProcAddress(hLib, "SetShellWindow"); + if (fLib(hWndShell)) + { + return TRUE; + } } return FALSE; diff --git a/progmgr/wndproc.c b/progmgr/wndproc.c index d491c76..5156f4b 100644 --- a/progmgr/wndproc.c +++ b/progmgr/wndproc.c @@ -83,6 +83,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) goto WndProcDefault; case WM_CLOSE: + if (GetShellWindow()) + SetShellWindow(0); PostQuitMessage(0); break;