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.

94 lines
1.9 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. MSWorks6.cpp
  5. Abstract:
  6. Due to a modification in the registry in Windows XP, this app gets the path
  7. for IE as "%programfiles%\ Internet Explorer\iexplore.exe" and since the
  8. env variable option flag is not set for ShellExecuteEx, it cannot expand it.
  9. Hooked ShellExecuteW also as the app calls this at a few places.
  10. Notes:
  11. This is an app specific shim.
  12. History:
  13. 01/25/2001 prashkud Created
  14. --*/
  15. #include "precomp.h"
  16. IMPLEMENT_SHIM_BEGIN(MSWorks6)
  17. #include "ShimHookMacro.h"
  18. APIHOOK_ENUM_BEGIN
  19. APIHOOK_ENUM_ENTRY(ShellExecuteExW)
  20. APIHOOK_ENUM_ENTRY(ShellExecuteW)
  21. APIHOOK_ENUM_END
  22. /*++
  23. Hooks ShellExecuteExW and sets the flag for expanding the environment variables
  24. --*/
  25. BOOL
  26. APIHOOK(ShellExecuteExW)(
  27. LPSHELLEXECUTEINFO lpExecInfo
  28. )
  29. {
  30. lpExecInfo->fMask |= SEE_MASK_DOENVSUBST;
  31. return ORIGINAL_API(ShellExecuteExW)(lpExecInfo);
  32. }
  33. /*++
  34. Hooks ShellExecuteW and expands the passed file path.
  35. --*/
  36. HINSTANCE
  37. APIHOOK(ShellExecuteW)(
  38. HWND hWnd,
  39. LPCWSTR lpVerb,
  40. LPCWSTR lpFile,
  41. LPCWSTR lpParameters,
  42. LPCWSTR lpDirectory,
  43. INT nShowCmd
  44. )
  45. {
  46. CSTRING_TRY
  47. {
  48. CString csPassedFile(lpFile);
  49. csPassedFile.ExpandEnvironmentStringsW();
  50. return ORIGINAL_API(ShellExecuteW)(hWnd, lpVerb, csPassedFile.Get(),
  51. lpParameters, lpDirectory, nShowCmd);
  52. }
  53. CSTRING_CATCH
  54. {
  55. return ORIGINAL_API(ShellExecuteW)(hWnd, lpVerb, lpFile,
  56. lpParameters, lpDirectory, nShowCmd);
  57. }
  58. }
  59. /*++
  60. Register hooked functions
  61. --*/
  62. HOOK_BEGIN
  63. APIHOOK_ENTRY(SHELL32.DLL, ShellExecuteExW)
  64. APIHOOK_ENTRY(SHELL32.DLL, ShellExecuteW)
  65. HOOK_END
  66. IMPLEMENT_SHIM_END