Source code of Windows XP (NT5)
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.

131 lines
2.2 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. RemoveInvalidW2KWindowStyles.cpp
  5. Abstract:
  6. Windows 2000 deems certain previously supported Windows style bits as
  7. "invalid". This shim removes the newly invalidated style bits from the mask
  8. which will allow the CreateWindowEx call to succeed.
  9. Notes:
  10. This is a general purpose shim.
  11. History:
  12. 09/13/1999 markder Created
  13. --*/
  14. #include "precomp.h"
  15. IMPLEMENT_SHIM_BEGIN(RemoveInvalidW2KWindowStyles)
  16. #include "ShimHookMacro.h"
  17. APIHOOK_ENUM_BEGIN
  18. APIHOOK_ENUM_ENTRY(CreateWindowExA)
  19. APIHOOK_ENUM_ENTRY(CreateWindowExW)
  20. APIHOOK_ENUM_END
  21. /*++
  22. Remove invalid Windows 2000 style bits from dwExStyle mask before calling
  23. CreateWindowEx.
  24. --*/
  25. HWND
  26. APIHOOK(CreateWindowExA)(
  27. DWORD dwExStyle,
  28. LPCSTR lpClassName,
  29. LPCSTR lpWindowName,
  30. DWORD dwStyle,
  31. int x,
  32. int y,
  33. int nWidth,
  34. int nHeight,
  35. HWND hWndParent,
  36. HMENU hMenu,
  37. HINSTANCE hInstance,
  38. LPVOID lpParam
  39. )
  40. {
  41. // Defined in windows source as WS_INVALID50
  42. dwExStyle &= 0x85F77FF;
  43. return ORIGINAL_API(CreateWindowExA)(
  44. dwExStyle,
  45. lpClassName,
  46. lpWindowName,
  47. dwStyle,
  48. x,
  49. y,
  50. nWidth,
  51. nHeight,
  52. hWndParent,
  53. hMenu,
  54. hInstance,
  55. lpParam);
  56. }
  57. /*++
  58. Remove invalid Windows 2000 style bits from dwExStyle mask before calling
  59. CreateWindowEx.
  60. --*/
  61. HWND
  62. APIHOOK(CreateWindowExW)(
  63. DWORD dwExStyle,
  64. LPCWSTR lpClassName,
  65. LPCWSTR lpWindowName,
  66. DWORD dwStyle,
  67. int x,
  68. int y,
  69. int nWidth,
  70. int nHeight,
  71. HWND hWndParent,
  72. HMENU hMenu,
  73. HINSTANCE hInstance,
  74. LPVOID lpParam
  75. )
  76. {
  77. dwExStyle &= 0x85F77FF;
  78. // Call the original API
  79. return ORIGINAL_API(CreateWindowExW)(
  80. dwExStyle,
  81. lpClassName,
  82. lpWindowName,
  83. dwStyle,
  84. x,
  85. y,
  86. nWidth,
  87. nHeight,
  88. hWndParent,
  89. hMenu,
  90. hInstance,
  91. lpParam);
  92. }
  93. /*++
  94. Register hooked functions
  95. --*/
  96. HOOK_BEGIN
  97. APIHOOK_ENTRY(USER32.DLL, CreateWindowExA)
  98. APIHOOK_ENTRY(USER32.DLL, CreateWindowExW)
  99. HOOK_END
  100. IMPLEMENT_SHIM_END