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.

95 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 2001-2002 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. 03/07/2002 mnikkel Added check for Null lpExecInfo
  34. --*/
  35. #include "precomp.h"
  36. IMPLEMENT_SHIM_BEGIN(RemoveDDEFlagFromShellExecuteEx)
  37. #include "ShimHookMacro.h"
  38. APIHOOK_ENUM_BEGIN
  39. APIHOOK_ENUM_ENTRY(ShellExecuteExW)
  40. APIHOOK_ENUM_END
  41. /*++
  42. Hook the call to ShellExecuteExW and remove the flag.
  43. --*/
  44. BOOL
  45. APIHOOK(ShellExecuteExW)(
  46. LPSHELLEXECUTEINFO lpExecInfo
  47. )
  48. {
  49. if (lpExecInfo)
  50. lpExecInfo->fMask = lpExecInfo->fMask & ~SEE_MASK_FLAG_DDEWAIT;
  51. LOGN( eDbgLevelInfo, "Removed SEE_MASK_FLAG_DDEWAIT from ShellExecuteExW");
  52. return ORIGINAL_API(ShellExecuteExW)(lpExecInfo);
  53. }
  54. /*++
  55. Register hooked functions
  56. --*/
  57. HOOK_BEGIN
  58. APIHOOK_ENTRY(SHELL32.DLL, ShellExecuteExW)
  59. HOOK_END
  60. IMPLEMENT_SHIM_END