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.

138 lines
3.4 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. DirtTrackRacing.cpp
  5. Abstract:
  6. App shows a white (or whatever your default window background color is) screen when starting up which is
  7. inconsistent behavior from on 9x because on 9x it doesn't draw anything if the app's window class doesn't
  8. have a background brush. Use a black brush for the background.
  9. Notes:
  10. This is an app specific shim.
  11. History:
  12. 10/01/2000 maonis Created
  13. 11/07/2000 maonis Added checking for Dirt Track Racing Sprint Cars window class.
  14. 11/29/2000 andyseti Converted into AppSpecific shim.
  15. --*/
  16. #include "precomp.h"
  17. IMPLEMENT_SHIM_BEGIN(DirtTrackRacing)
  18. #include "ShimHookMacro.h"
  19. APIHOOK_ENUM_BEGIN
  20. APIHOOK_ENUM_ENTRY(RegisterClassA)
  21. APIHOOK_ENUM_ENTRY(CreateWindowExA)
  22. APIHOOK_ENUM_END
  23. /*++
  24. Register a black brush for the window class.
  25. --*/
  26. ATOM
  27. APIHOOK(RegisterClassA)(
  28. CONST WNDCLASSA *lpwcx
  29. )
  30. {
  31. CSTRING_TRY
  32. {
  33. CString csClassName(lpwcx->lpszClassName);
  34. if ( !csClassName.CompareNoCase(L"DTR Class") || !csClassName.CompareNoCase(L"DTRSC Class"))
  35. {
  36. WNDCLASSA wcNewWndClass = *lpwcx;
  37. wcNewWndClass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
  38. LOGN(
  39. eDbgLevelError,
  40. "RegisterClassA called. Register a black brush for the window class=%s.",
  41. lpwcx->lpszClassName);
  42. return ORIGINAL_API(RegisterClassA)(&wcNewWndClass);
  43. }
  44. }
  45. CSTRING_CATCH
  46. {
  47. // Do nothing
  48. }
  49. return ORIGINAL_API(RegisterClassA)(lpwcx);
  50. }
  51. /*++
  52. We need to hide the window at first so after you choose the mode and start the app it won't flicker.
  53. DDraw will automatically unhide the window.
  54. --*/
  55. HWND
  56. APIHOOK(CreateWindowExA)(
  57. DWORD dwExStyle,
  58. LPCSTR lpClassName, // registered class name
  59. LPCSTR lpWindowName, // window name
  60. DWORD dwStyle, // window style
  61. int x, // horizontal position of window
  62. int y, // vertical position of window
  63. int nWidth, // window width
  64. int nHeight, // window height
  65. HWND hWndParent, // handle to parent or owner window
  66. HMENU hMenu, // menu handle or child identifier
  67. HINSTANCE hInstance, // handle to application instance
  68. LPVOID lpParam // window-creation data
  69. )
  70. {
  71. CSTRING_TRY
  72. {
  73. CString csClassName(lpClassName);
  74. if ( !csClassName.CompareNoCase(L"DTR Class") || !csClassName.CompareNoCase(L"DTRSC Class"))
  75. {
  76. dwStyle &= ~WS_VISIBLE;
  77. LOGN( eDbgLevelError,
  78. "CreateWindowExA called. Hide the window at first for the window class=%s.",
  79. lpClassName);
  80. }
  81. }
  82. CSTRING_CATCH
  83. {
  84. // Do nothing
  85. }
  86. return ORIGINAL_API(CreateWindowExA)(
  87. dwExStyle,
  88. lpClassName,
  89. lpWindowName,
  90. dwStyle,
  91. x, y,
  92. nWidth, nHeight,
  93. hWndParent,
  94. hMenu,
  95. hInstance,
  96. lpParam);
  97. }
  98. /*++
  99. Register hooked functions
  100. --*/
  101. HOOK_BEGIN
  102. APIHOOK_ENTRY(USER32.DLL, RegisterClassA)
  103. APIHOOK_ENTRY(USER32.DLL, CreateWindowExA)
  104. HOOK_END
  105. IMPLEMENT_SHIM_END