Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
3.6 KiB

  1. //---------------------------------------------------------------------------
  2. // SetHook.h - Window and DefWindowProc hooking decls.
  3. //---------------------------------------------------------------------------
  4. #pragma once
  5. //---------------------------------------------------------------------------
  6. // Hooked message disposition flags
  7. #define HMD_NIL 0x00000000
  8. #define HMD_THEMEDETACH 0x00000001 // detach: theme removed
  9. #define HMD_WINDOWDESTROY 0x00000002 // detach: window is dying
  10. #define HMD_CHANGETHEME 0x00000004 // theme is changing
  11. #define HMD_REATTACH 0x00000008 // attempt attaching window that was previously rejected.
  12. #define HMD_REVOKE 0x00000010 // theme revoked on non-compliant window.
  13. #define HMD_PROCESSDETACH 0x00000020 // process is dying
  14. #define HMD_BULKDETACH 0x00000040 // context is a DetachAll sequence.
  15. //---------------------------------------------------------------------------
  16. // Query class-specific hooking
  17. BOOL WINAPI FrameHookEnabled();
  18. BOOL WINAPI CtlHooksEnabled();
  19. //---------------------------------------------------------------------------
  20. // ThemeHookStartup/Shutdown() - invoked from DLL_PROCESS_ATTACH/DETACH, resp.
  21. BOOL WINAPI ThemeHookStartup();
  22. BOOL WINAPI ThemeHookShutdown();
  23. //---------------------------------------------------------------------------
  24. // More helper macros.
  25. #define STRINGIZE_ATOM(a) MAKEINTATOM(a)
  26. #define BOGUS_THEMEID 0
  27. #define IS_THEME_CHANGE_TARGET(lParam) \
  28. ((! g_pAppInfo->CustomAppTheme()) || (lParam & WTC_CUSTOMTHEME))
  29. //---------------------------------------------------------------------------
  30. // Nonclient theming target window classifications [scotthan]:
  31. // NIL: window has not been evaluated
  32. // REJECT: window has been rejected on the basis of current attributes or conditions,
  33. // but may be reconsidered a theming target
  34. // EXILE: window has been permanently rejected for attachment themewnd object because
  35. // it's wndproc has proven itself incompatible with theme protocol(s).
  36. // Helper macros:
  37. #define THEMEWND_NIL ((CThemeWnd*)NULL)
  38. #define THEMEWND_REJECT ((CThemeWnd*)-1)
  39. #define THEMEWND_EXILE ((CThemeWnd*)-2)
  40. #define THEMEWND_FAILURE ((CThemeWnd*)-3)
  41. #define EXILED_THEMEWND(pwnd) ((pwnd)==THEMEWND_EXILE)
  42. #define REJECTED_THEMEWND(pwnd) ((pwnd)==THEMEWND_REJECT)
  43. #define FAILED_THEMEWND(pwnd) ((pwnd)==THEMEWND_FAILURE)
  44. #define VALID_THEMEWND(pwnd) (((pwnd) != THEMEWND_NIL) && !FAILED_THEMEWND(pwnd) &&\
  45. !REJECTED_THEMEWND(pwnd) && !EXILED_THEMEWND(pwnd))
  46. #define ISWINDOW(hwnd) ((hwnd) && (hwnd != INVALID_HANDLE_VALUE) && (IsWindow(hwnd)))
  47. //---------------------------------------------------------------------------
  48. extern "C" BOOL WINAPI ThemeInitApiHook( DWORD dwCmd, void * pvData );
  49. //---- must manually call ProcessStartUp() if needed in ThemeInitApiHook() ----
  50. BOOL ProcessStartUp(HINSTANCE hModule);
  51. //---- avail for calling when tracking down leaks with BoundsChecker() ----
  52. BOOL ProcessShutDown();
  53. //---------------------------------------------------------------------------
  54. inline void ShutDownCheck(HWND hwnd)
  55. {
  56. #ifdef LOGGING
  57. //---- if we just released APP Window, call ProcessShutDown() for best leak detection ----
  58. if (hwnd == g_hwndFirstHooked)
  59. {
  60. if (LogOptionOn(LO_SHUTDOWN)) // "+shutdown" log option selected
  61. ProcessShutDown();
  62. }
  63. #endif
  64. }
  65. //---------------------------------------------------------------------------//