Skip to content

Commit

Permalink
Remove debugger/screen reader/remote session check in CDimmedWindow::…
Browse files Browse the repository at this point in the history
…Create
  • Loading branch information
aubymori committed Oct 31, 2023
1 parent e61b35f commit 22c9bcf
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 40 deletions.
12 changes: 4 additions & 8 deletions ClassicShutdown/ClassicShutdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,9 @@ int WINAPI wWinMain(
g_hMuiInstance = GetMUIModule(g_hAppInstance);
if (!g_hMuiInstance)
{
MessageBoxW(
NULL,
L"Failed to load language resources.\n\nMost likely, you did not copy over files properly.",
L"ClassicShutdown",
MB_ICONERROR
ERRORANDQUIT(
L"Failed to load language resources.\n\nMost likely, you did not copy over files properly."
);
return 1;
}

CDimmedWindow *pDimmedWindow = NULL;
Expand Down Expand Up @@ -241,8 +237,7 @@ int WINAPI wWinMain(
}
else
{
MessageBoxW(NULL, L"Failed to create dim window!", L"ClassicShutdown", MB_ICONERROR);
return 1;
ERRORANDQUIT(L"Failed to create dim window!");
}
}
else
Expand Down Expand Up @@ -327,6 +322,7 @@ int WINAPI wWinMain(
pDlgProc = g_bLogoff ? LogoffDlgProc : ExitWindowsDlgProc;
}


DialogBoxParamW(
g_hMuiInstance,
MAKEINTRESOURCEW(uDlgId),
Expand Down
4 changes: 4 additions & 0 deletions ClassicShutdown/ClassicShutdown.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ void HandleShutdown(HWND hWnd, DWORD dwCode);

#define IsXP(ss) (ss == SS_XPCLASSIC | ss == SS_XPFRIENDLY)

#define ERRORANDQUIT(msg) \
MessageBoxW(NULL, msg, L"ClassicShutdown", MB_ICONERROR); \
return 1;

#define SHTDN_NONE 0
#define SHTDN_LOGOFF 1
#define SHTDN_SHUTDOWN 2
Expand Down
51 changes: 20 additions & 31 deletions ClassicShutdown/DimmedWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ CDimmedWindow::CDimmedWindow (HINSTANCE hInstance) :
_idxSaturation(0),
_hdcDimmed(NULL),
_hbmOldDimmed(NULL),
_hbmDimmed(NULL)
_hbmDimmed(NULL),
_xVirtualScreen(0),
_yVirtualScreen(0),
_cxVirtualScreen(0),
_cyVirtualScreen(0)
{
WNDCLASSEXW wndClassEx;

Expand All @@ -79,7 +83,6 @@ CDimmedWindow::CDimmedWindow (HINSTANCE hInstance) :
wndClassEx.lpfnWndProc = WndProc;
wndClassEx.hInstance = hInstance;
wndClassEx.lpszClassName = s_szWindowClassName;
wndClassEx.hCursor = LoadCursor(NULL, IDC_ARROW);
_atom = RegisterClassExW(&wndClassEx);
}

Expand Down Expand Up @@ -211,37 +214,23 @@ ULONG CDimmedWindow::Release (void)
HWND CDimmedWindow::Create (void)

{
BOOL fScreenReader;
bool fNoDebuggerPresent, fConsoleSession, fNoScreenReaderPresent;

fNoDebuggerPresent = !IsDebuggerPresent();
fConsoleSession = (GetSystemMetrics(SM_REMOTESESSION) == FALSE);
fNoScreenReaderPresent = ((SystemParametersInfoW(SPI_GETSCREENREADER, 0, &fScreenReader, 0) == FALSE) || (fScreenReader == FALSE));
if (fNoDebuggerPresent &&
fConsoleSession &&
fNoScreenReaderPresent)
_xVirtualScreen = GetSystemMetrics(SM_XVIRTUALSCREEN);
_yVirtualScreen = GetSystemMetrics(SM_YVIRTUALSCREEN);
_cxVirtualScreen = GetSystemMetrics(SM_CXVIRTUALSCREEN);
_cyVirtualScreen = GetSystemMetrics(SM_CYVIRTUALSCREEN);
_hwnd = CreateWindowExW(WS_EX_TOPMOST | WS_EX_TOOLWINDOW,
s_szWindowClassName,
NULL,
WS_POPUP,
_xVirtualScreen, _yVirtualScreen,
_cxVirtualScreen, _cyVirtualScreen,
NULL, NULL, _hInstance, this);
if (_hwnd != NULL)
{
_xVirtualScreen = GetSystemMetrics(SM_XVIRTUALSCREEN);
_yVirtualScreen = GetSystemMetrics(SM_YVIRTUALSCREEN);
_cxVirtualScreen = GetSystemMetrics(SM_CXVIRTUALSCREEN);
_cyVirtualScreen = GetSystemMetrics(SM_CYVIRTUALSCREEN);
_hwnd = CreateWindowExW(WS_EX_TOPMOST | WS_EX_TOOLWINDOW,
s_szWindowClassName,
NULL,
WS_POPUP,
_xVirtualScreen, _yVirtualScreen,
_cxVirtualScreen, _cyVirtualScreen,
NULL, NULL, _hInstance, this);
if (_hwnd != NULL)
{
bool fDimmed;
ShowWindow(_hwnd, SW_SHOW);
SetForegroundWindow(_hwnd);

fDimmed = false;
ShowWindow(_hwnd, SW_SHOW);
SetForegroundWindow(_hwnd);

EnableWindow(_hwnd, FALSE);
}
EnableWindow(_hwnd, FALSE);
}
return(_hwnd);
}
Expand Down
2 changes: 1 addition & 1 deletion ClassicShutdown/DimmedWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifndef _DimmedWindow_
#define _DimmedWindow_

#include "unknwn.h"
#include <unknwn.h>

// --------------------------------------------------------------------------
// CDimmedWindow::CDimmedWindow
Expand Down

0 comments on commit 22c9bcf

Please sign in to comment.