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.

281 lines
5.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. F18Carrier.cpp
  5. Abstract:
  6. This fixes 2 problems:
  7. 1. In the Officers quarters, while reading the flight manual, pressing
  8. escape minimizes the app. This happens on win9x as well, but since
  9. the app does not recover well from task switching, we ignore the
  10. syskey messages that caused the switch.
  11. 2. The dialogs are cleared after drawing by a paint message that goes to
  12. the parent window after the dialog is drawn. Since they use a
  13. DirectDraw Blt to draw, they are not aware of that they're drawing
  14. over the dialog. On win9x, this extra paint message does not come
  15. through, but it's not clear why.
  16. We fix this by validating the drawing rect after after the paint
  17. message has come through.
  18. The window handling of the app is really weird, they have 2 main windows
  19. at any one time and switch focus between them. Then they have Screen*.dll
  20. files which each contain WndProcs which handle individual parts of the UI.
  21. Notes:
  22. This is an app specific shim.
  23. History:
  24. 07/12/2000 linstev Created
  25. --*/
  26. #include "precomp.h"
  27. IMPLEMENT_SHIM_BEGIN(F18Carrier)
  28. #include "ShimHookMacro.h"
  29. APIHOOK_ENUM_BEGIN
  30. APIHOOK_ENUM_ENTRY(RegisterClassA)
  31. APIHOOK_ENUM_ENTRY(RegisterClassW)
  32. APIHOOK_ENUM_ENTRY(RegisterClassExA)
  33. APIHOOK_ENUM_ENTRY(RegisterClassExW)
  34. APIHOOK_ENUM_ENTRY(SetWindowLongA)
  35. APIHOOK_ENUM_ENTRY(SetWindowLongW)
  36. APIHOOK_ENUM_END
  37. /*++
  38. Validate after paint and filter syskey messages.
  39. --*/
  40. LRESULT
  41. CALLBACK
  42. F18Carrier_WindowProcHook(
  43. WNDPROC pfnOld,
  44. HWND hwnd,
  45. UINT uMsg,
  46. WPARAM wParam,
  47. LPARAM lParam
  48. )
  49. {
  50. LRESULT lRet;
  51. RECT r;
  52. if ((uMsg == WM_PAINT) && (GetUpdateRect(hwnd, &r, FALSE)))
  53. {
  54. lRet = (*pfnOld)(hwnd, uMsg, wParam, lParam);
  55. //
  56. // Only do this for certain window classes, to prevent side-effects
  57. //
  58. WCHAR szName[MAX_PATH];
  59. if (GetClassNameW(hwnd, szName, MAX_PATH))
  60. {
  61. if (!wcsistr(szName, L"UI Class"))
  62. {
  63. return lRet;
  64. }
  65. }
  66. LOGN(
  67. eDbgLevelSpew,
  68. "Validating after paint");
  69. ValidateRect(hwnd, &r);
  70. }
  71. else if ((uMsg == WM_SYSKEYDOWN) || (uMsg == WM_SYSKEYUP))
  72. {
  73. LOGN(
  74. eDbgLevelSpew,
  75. "Removing syskey messages");
  76. return 0;
  77. }
  78. else
  79. {
  80. lRet = (*pfnOld)(hwnd, uMsg, wParam, lParam);
  81. }
  82. return lRet;
  83. }
  84. /*++
  85. The dialogproc hook
  86. --*/
  87. INT_PTR
  88. CALLBACK
  89. F18Carrier_DialogProcHook(
  90. DLGPROC pfnOld,
  91. HWND hwndDlg,
  92. UINT uMsg,
  93. WPARAM wParam,
  94. LPARAM lParam
  95. )
  96. {
  97. return (*pfnOld)(hwndDlg, uMsg, wParam, lParam);
  98. }
  99. /*++
  100. Hook the wndproc
  101. --*/
  102. ATOM
  103. APIHOOK(RegisterClassA)(
  104. CONST WNDCLASSA *lpWndClass
  105. )
  106. {
  107. WNDCLASSA wcNewWndClass = *lpWndClass;
  108. wcNewWndClass.lpfnWndProc =
  109. (WNDPROC) HookCallback(lpWndClass->lpfnWndProc, F18Carrier_WindowProcHook);
  110. return ORIGINAL_API(RegisterClassA)(&wcNewWndClass);
  111. }
  112. /*++
  113. Hook the wndproc
  114. --*/
  115. ATOM
  116. APIHOOK(RegisterClassW)(
  117. CONST WNDCLASSW *lpWndClass
  118. )
  119. {
  120. WNDCLASSW wcNewWndClass = *lpWndClass;
  121. wcNewWndClass.lpfnWndProc =
  122. (WNDPROC) HookCallback(lpWndClass->lpfnWndProc, F18Carrier_WindowProcHook);
  123. return ORIGINAL_API(RegisterClassW)(&wcNewWndClass);
  124. }
  125. /*++
  126. Hook the wndproc
  127. --*/
  128. ATOM
  129. APIHOOK(RegisterClassExA)(
  130. CONST WNDCLASSEXA *lpwcx
  131. )
  132. {
  133. WNDCLASSEXA wcNewWndClass = *lpwcx;
  134. wcNewWndClass.lpfnWndProc =
  135. (WNDPROC) HookCallback(lpwcx->lpfnWndProc, F18Carrier_WindowProcHook);
  136. return ORIGINAL_API(RegisterClassExA)(&wcNewWndClass);
  137. }
  138. /*++
  139. Hook the wndproc
  140. --*/
  141. ATOM
  142. APIHOOK(RegisterClassExW)(
  143. CONST WNDCLASSEXW *lpwcx
  144. )
  145. {
  146. WNDCLASSEXW wcNewWndClass = *lpwcx;
  147. wcNewWndClass.lpfnWndProc =
  148. (WNDPROC) HookCallback(lpwcx->lpfnWndProc, F18Carrier_WindowProcHook);
  149. return ORIGINAL_API(RegisterClassExW)(&wcNewWndClass);
  150. }
  151. /*++
  152. Hook the wndproc
  153. --*/
  154. LONG
  155. APIHOOK(SetWindowLongA)(
  156. HWND hWnd,
  157. int nIndex,
  158. LONG dwNewLong
  159. )
  160. {
  161. if (nIndex == GWL_WNDPROC)
  162. {
  163. dwNewLong = (LONG) HookCallback((PVOID)dwNewLong, F18Carrier_WindowProcHook);
  164. }
  165. else if (nIndex == DWL_DLGPROC)
  166. {
  167. dwNewLong = (LONG) HookCallback((PVOID)dwNewLong, F18Carrier_DialogProcHook);
  168. }
  169. return ORIGINAL_API(SetWindowLongA)(
  170. hWnd,
  171. nIndex,
  172. dwNewLong);
  173. }
  174. /*++
  175. Hook the wndproc
  176. --*/
  177. LONG
  178. APIHOOK(SetWindowLongW)(
  179. HWND hWnd,
  180. int nIndex,
  181. LONG dwNewLong
  182. )
  183. {
  184. if (nIndex == GWL_WNDPROC)
  185. {
  186. dwNewLong = (LONG) HookCallback((PVOID)dwNewLong, F18Carrier_WindowProcHook);
  187. }
  188. else if (nIndex == DWL_DLGPROC)
  189. {
  190. dwNewLong = (LONG) HookCallback((PVOID)dwNewLong, F18Carrier_DialogProcHook);
  191. }
  192. return ORIGINAL_API(SetWindowLongA)(
  193. hWnd,
  194. nIndex,
  195. dwNewLong);
  196. }
  197. /*++
  198. Register hooked functions
  199. --*/
  200. HOOK_BEGIN
  201. APIHOOK_ENTRY(USER32.DLL, RegisterClassA)
  202. APIHOOK_ENTRY(USER32.DLL, RegisterClassW)
  203. APIHOOK_ENTRY(USER32.DLL, RegisterClassExA)
  204. APIHOOK_ENTRY(USER32.DLL, RegisterClassExW)
  205. APIHOOK_ENTRY(USER32.DLL, SetWindowLongA)
  206. APIHOOK_ENTRY(USER32.DLL, SetWindowLongW)
  207. HOOK_END
  208. IMPLEMENT_SHIM_END