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.

99 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. QuickTime5.cpp
  5. Abstract:
  6. QuickTime 5 is calling Get/SetWindowLong(GWL_WNDPROC/DWL_DLGPROC) on hwnds outside its process
  7. and it is passing hardcoded strings within its address space (these calls will always fail on
  8. win9x). On 32-bit platforms this is pretty much benign, but on ia64 the call to SetWindowLong(hwnd, DWL_DLGPROC, crap)
  9. succeeds in trashing private window bits in explorer windows (since the window is not a dialog hwnd).
  10. Notes:
  11. This is an app specific shim.
  12. History:
  13. 7/31/2001 reinerf Created
  14. --*/
  15. #include "precomp.h"
  16. IMPLEMENT_SHIM_BEGIN(QuickTime5)
  17. #include "ShimHookMacro.h"
  18. APIHOOK_ENUM_BEGIN
  19. APIHOOK_ENUM_ENTRY(GetWindowLongA)
  20. APIHOOK_ENUM_ENTRY(SetWindowLongA)
  21. APIHOOK_ENUM_END
  22. LONG
  23. APIHOOK(GetWindowLongA)(HWND hwnd, int iIndex)
  24. {
  25. if (hwnd)
  26. {
  27. if ((iIndex == GWL_WNDPROC) ||
  28. (iIndex == DWL_DLGPROC))
  29. {
  30. DWORD dwPID = 0;
  31. GetWindowThreadProcessId(hwnd, &dwPID);
  32. if (GetCurrentProcessId() != dwPID)
  33. {
  34. // we are querying an hwnd that is not in our
  35. // process-- just fail the call
  36. return 0;
  37. }
  38. }
  39. }
  40. return ORIGINAL_API(GetWindowLongA)(hwnd, iIndex);
  41. }
  42. LONG
  43. APIHOOK(SetWindowLongA)(HWND hwnd, int iIndex, LONG lNew)
  44. {
  45. if (hwnd)
  46. {
  47. if ((iIndex == GWL_WNDPROC) ||
  48. (iIndex == DWL_DLGPROC))
  49. {
  50. DWORD dwPID = 0;
  51. GetWindowThreadProcessId(hwnd, &dwPID);
  52. if (GetCurrentProcessId() != dwPID)
  53. {
  54. // we are trying modify an hwnd that is not in our
  55. // process-- just fail the call
  56. return 0;
  57. }
  58. }
  59. }
  60. return ORIGINAL_API(SetWindowLongA)(hwnd, iIndex, lNew);
  61. }
  62. /*++
  63. Register hooked functions
  64. --*/
  65. HOOK_BEGIN
  66. APIHOOK_ENTRY(USER32.DLL, GetWindowLongA)
  67. APIHOOK_ENTRY(USER32.DLL, SetWindowLongA)
  68. HOOK_END
  69. IMPLEMENT_SHIM_END