Permalink
Browse files

added shellhook, removed console polling

  • Loading branch information...
1 parent e9ceb25 commit 804a6677e2546a77f0dbd2448f1edc4a57329ded @headius committed with headius May 12, 2003
Showing with 40 additions and 28 deletions.
  1. +12 −16 HackItDlg.cpp
  2. +28 −12 ListManager.cpp
View
@@ -31,6 +31,9 @@ using namespace std;
HWND g_hWndDlg;
HWND g_hWndManager;
+FARPROC (__stdcall * RegisterShellHook)(HWND, DWORD) = NULL;
+UINT WM_ShellHook = 0;
+
/////////////////////////////////////////////////////////////////////////////
// AboutDlg dialog used for App About
class AboutDlg
@@ -412,13 +415,17 @@ LRESULT HackItDlg::OnCreate(WPARAM wParam, LPARAM lParam)
m_pHooks = new SystemHooks(m_hWndManager);
+ RegisterShellHook = (FARPROC (__stdcall *)(HWND, DWORD))GetProcAddress(GetModuleHandle("SHELL32.DLL"), (LPCSTR)((long)0xB5));
+ WM_ShellHook = RegisterWindowMessage("SHELLHOOK");
+ if (RegisterShellHook)
+ {
+ RegisterShellHook(NULL, RSH_REGISTER);
+ RegisterShellHook(m_hWndManager, RSH_TASKMAN);
+ }
+
::SetWindowText(m_StatusBar, "Starting up poll timers...");
::RedrawWindow(m_StatusBar, NULL, NULL, RDW_UPDATENOW);
- if (m_Settings.m_ConsolePolling) {
- SetTimer(m_hWndManager, CONSOLE_WINDOW_POLL_TIMER, m_Settings.m_ConsolePollingTime, NULL);
- }
-
if (m_Settings.m_WindowListCleaning) {
SetTimer(m_hWndManager, WINDOW_LIST_CLEANER_TIMER, m_Settings.m_WindowListCleanerTime, NULL);
}
@@ -1518,18 +1525,7 @@ void HackItDlg::Settings()
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, NULL, astring, STRING_BUFFER_SIZE, NULL);
MessageBox(NULL, astring, astring, MB_OK);
} else {
- // apply new settings, make app changes before saving
- if (settings.m_Settings.m_ConsolePolling) {
- SetTimer(m_hWndManager, CONSOLE_WINDOW_POLL_TIMER, m_Settings.m_ConsolePollingTime, NULL);
- } else if (!settings.m_Settings.m_ConsolePolling && m_Settings.m_ConsolePolling) {
- KillTimer(m_hWndManager, CONSOLE_WINDOW_POLL_TIMER);
- }
-
- if (settings.m_Settings.m_ConsolePolling && (settings.m_Settings.m_ConsolePollingTime != m_Settings.m_ConsolePollingTime)) {
- KillTimer(m_hWndManager, CONSOLE_WINDOW_POLL_TIMER);
- SetTimer(m_hWndManager, CONSOLE_WINDOW_POLL_TIMER, m_Settings.m_ConsolePollingTime, NULL);
- }
-
+ // apply new settings, make app changes before saving
if (settings.m_Settings.m_WindowListCleaning && !m_Settings.m_WindowListCleaning) {
SetTimer(m_hWndManager, WINDOW_LIST_CLEANER_TIMER, m_Settings.m_WindowListCleanerTime, NULL);
} else if (!settings.m_Settings.m_WindowListCleaning && m_Settings.m_WindowListCleaning) {
View
@@ -25,6 +25,7 @@
#include "ProcessFunctions.h"
extern int (__stdcall *MySetLayeredWindowAttributes)(struct HWND__ *,unsigned long,unsigned char,unsigned long);
+extern UINT WM_ShellHook;
DWORD WINAPI HackItDlg::ListThreadProc(LPVOID data) {
WNDCLASSEX wndClass;
@@ -148,6 +149,10 @@ LRESULT CALLBACK HackItDlg::ListThreadWindowProc(HWND hWnd, UINT uMsg, WPARAM wP
returnCode = theDlg->OnCheckTrayyedList(wParam, lParam);
break;
default:
+ if (uMsg == WM_ShellHook) {
+ theDlg->HandleShellHook(wParam, lParam);
+ }
+
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
}
@@ -159,24 +164,35 @@ LRESULT CALLBACK HackItDlg::ListThreadWindowProc(HWND hWnd, UINT uMsg, WPARAM wP
}
}
-BOOL CALLBACK HackItDlg::ConsolePollProc(HWND hwnd, LPARAM lParam) {
- char winClass[256];
-
- ::GetClassName(hwnd, winClass, 256);
-
- if (!strcmp(winClass, "ConsoleWindowClass")) {
- ::PostMessage((HWND)lParam, WM_CREATEDETECTED, NULL, (LPARAM)hwnd);
+void HackItDlg::HandleShellHook(WPARAM wParam, LPARAM lParam) {
+ switch (LOWORD(wParam) & 0x00FF)
+ {
+ case HSHELL_WINDOWCREATED:
+ {
+ char className[256];
+ GetClassName((HWND)lParam, className, 256);
+ if (lstrcmp(className, "ConsoleWindowClass") == 0) {
+ PostMessage(m_hWndManager, WM_CREATEDETECTED, 0, lParam);
+ }
+ }
+ break;
+ case HSHELL_WINDOWDESTROYED:
+ break;
+ case HSHELL_REDRAW:
+ {
+ char className[256];
+ GetClassName((HWND)wParam, className, 256);
+ if (lstrcmp(className, "ConsoleWindowClass") == 0) {
+ PostMessage(m_hWndManager, WM_SETTEXTDETECTED, 0, lParam);
+ }
+ }
+ break;
}
-
- return TRUE;
}
LRESULT HackItDlg::OnTimer(WPARAM wParam, LPARAM lParam)
{
switch (wParam) {
- case CONSOLE_WINDOW_POLL_TIMER:
- EnumWindows(ConsolePollProc, (LPARAM)m_hWndManager);
- break;
case WINDOW_LIST_CLEANER_TIMER:
this->CleanList();
break;

0 comments on commit 804a667

Please sign in to comment.