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.

93 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. RemoveDDEFlagFromShellExecuteEx.cpp
  5. Abstract:
  6. Some applications call ShellExecute which in turn calls ShellExecuteEx.
  7. One of the flags in the SHELLEXECUTEINFO structure is 'SEE_MASK_FLAG_DDEWAIT'.
  8. This flag gets set by ShellExecuteEx as a default whenever ShellExecute is
  9. called.
  10. Here is the description for the flag:
  11. 'Wait for the DDE conversation to terminate before returning
  12. (if the ShellExecuteEx function causes a DDE conversation to start).
  13. The SEE_MASK_FLAG_DDEWAIT flag must be specified if the thread calling
  14. ShellExecuteEx does not have a message loop or if the thread or process
  15. will terminate soon after ShellExecuteEx returns. Under such conditions,
  16. the calling thread will not be available to complete the DDE conversation,
  17. so it is important that ShellExecuteEx complete the conversation before
  18. returning control to the caller. Failure to complete the conversation can
  19. result in an unsuccessful launch of the document.
  20. If the calling thread has a message loop and will exist for some time
  21. after the call to ShellExecuteEx returns, the SEE_MASK_FLAG_DDEWAIT
  22. flag is optional. If the flag is omitted, the calling thread's message
  23. pump will be used to complete the DDE conversation. The calling application
  24. regains control sooner, since the DDE conversation can be completed in the background.'
  25. When the flag gets passed, it can sometimes cause synchronzation problems.
  26. An example is Photo Express Platinum 2000. It attempts to launch Internet Explorer,
  27. but IE wreaks havoc on the app that made the call.
  28. This shim simply removes this flag from the ShellExecuteEx call.
  29. Notes:
  30. This is a general purpose shim.
  31. History:
  32. 04/16/2001 rparsons Created
  33. --*/
  34. #include "precomp.h"
  35. IMPLEMENT_SHIM_BEGIN(RemoveDDEFlagFromShellExecuteEx)
  36. #include "ShimHookMacro.h"
  37. APIHOOK_ENUM_BEGIN
  38. APIHOOK_ENUM_ENTRY(ShellExecuteExW)
  39. APIHOOK_ENUM_END
  40. /*++
  41. Hook the call to ShellExecuteExW and remove the flag.
  42. --*/
  43. BOOL
  44. APIHOOK(ShellExecuteExW)(
  45. LPSHELLEXECUTEINFO lpExecInfo
  46. )
  47. {
  48. lpExecInfo->fMask = lpExecInfo->fMask & ~SEE_MASK_FLAG_DDEWAIT;
  49. LOGN( eDbgLevelInfo, "Removed SEE_MASK_FLAG_DDEWAIT from ShellExecuteExW");
  50. return ORIGINAL_API(ShellExecuteExW)(lpExecInfo);
  51. }
  52. /*++
  53. Register hooked functions
  54. --*/
  55. HOOK_BEGIN
  56. APIHOOK_ENTRY(SHELL32.DLL, ShellExecuteExW)
  57. HOOK_END
  58. IMPLEMENT_SHIM_END