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.

90 lines
1.4 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. NullHwndInMessageBox.cpp
  5. Abstract:
  6. This shim replaces "non window" handles in msgbox with NULL to tell it
  7. that desktop is owner.
  8. Notes:
  9. This is a general purpose shim.
  10. History:
  11. 12/08/1999 a-jamd Created
  12. --*/
  13. #include "precomp.h"
  14. IMPLEMENT_SHIM_BEGIN(NullHwndInMessageBox)
  15. #include "ShimHookMacro.h"
  16. APIHOOK_ENUM_BEGIN
  17. APIHOOK_ENUM_ENTRY(MessageBoxA)
  18. APIHOOK_ENUM_ENTRY(MessageBoxW)
  19. APIHOOK_ENUM_END
  20. /*++
  21. This stub function sets hWnd to NULL if it is not a valid window.
  22. --*/
  23. int
  24. APIHOOK(MessageBoxA)(
  25. HWND hWnd,
  26. LPCSTR lpText,
  27. LPCSTR lpCaption,
  28. UINT uType
  29. )
  30. {
  31. if (IsWindow(hWnd) == 0) {
  32. hWnd = NULL;
  33. }
  34. return ORIGINAL_API(MessageBoxA)(hWnd, lpText, lpCaption, uType);
  35. }
  36. /*++
  37. This stub function sets hWnd to NULL if it is not a valid window.
  38. --*/
  39. int
  40. APIHOOK(MessageBoxW)(
  41. HWND hWnd,
  42. LPCWSTR lpText,
  43. LPCWSTR lpCaption,
  44. UINT uType
  45. )
  46. {
  47. if (IsWindow(hWnd) == 0) {
  48. hWnd = NULL;
  49. }
  50. return ORIGINAL_API(MessageBoxW)(hWnd, lpText, lpCaption, uType);
  51. }
  52. /*++
  53. Register hooked functions
  54. --*/
  55. HOOK_BEGIN
  56. APIHOOK_ENTRY(USER32.DLL, MessageBoxA)
  57. APIHOOK_ENTRY(USER32.DLL, MessageBoxW)
  58. HOOK_END
  59. IMPLEMENT_SHIM_END