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.

121 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. ExchangeServerSetup.cpp
  5. Abstract:
  6. This is a non-reusable patch for Exchange Server Setup 5.5 for SP2 and SP3
  7. to change the parameters passed to xcopy. The reason for that is that
  8. Win2k's xcopy doesn't have the /y parameter a default parameter.
  9. Notes:
  10. This is an app specific shim.
  11. History:
  12. 02/16/2000 clupu Created
  13. --*/
  14. #include "precomp.h"
  15. IMPLEMENT_SHIM_BEGIN(ExchangeServerSetup)
  16. #include "ShimHookMacro.h"
  17. APIHOOK_ENUM_BEGIN
  18. APIHOOK_ENUM_ENTRY(CreateProcessW)
  19. APIHOOK_ENUM_END
  20. /*++
  21. Change the parameters passed to xcopy.
  22. --*/
  23. BOOL
  24. APIHOOK(CreateProcessW)(
  25. LPWSTR lpApplicationName,
  26. LPWSTR lpCommandLine,
  27. LPSECURITY_ATTRIBUTES lpProcessAttributes,
  28. LPSECURITY_ATTRIBUTES lpThreadAttributes,
  29. BOOL bInheritHandles,
  30. DWORD dwCreationFlags,
  31. LPVOID lpEnvironment,
  32. LPWSTR lpCurrentDirectory,
  33. LPSTARTUPINFOW lpStartupInfo,
  34. LPPROCESS_INFORMATION lpProcessInformation
  35. )
  36. {
  37. BOOL bRet;
  38. if (lpCommandLine != NULL) {
  39. int cchSize = lstrlenW(lpCommandLine);
  40. WCHAR ch;
  41. if (cchSize > 12) {
  42. DPFN(
  43. eDbgLevelInfo,
  44. "[CreateProcessW] for \"%ws\".\n",
  45. lpCommandLine);
  46. ch = lpCommandLine[11];
  47. lpCommandLine[11] = 0;
  48. if (CompareStringW(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT),
  49. NORM_IGNORECASE,
  50. lpCommandLine,
  51. -1,
  52. L"xcopy /s /e",
  53. -1
  54. ) == CSTR_EQUAL) {
  55. StringCchCopyW(lpCommandLine, cchSize + 1, L"xcopy /sye ");
  56. lpCommandLine[11] = ch;
  57. DPFN(
  58. eDbgLevelInfo,
  59. "[CreateProcessW] changed to \"%ws\".\n",
  60. lpCommandLine);
  61. } else {
  62. lpCommandLine[11] = ch;
  63. }
  64. }
  65. }
  66. bRet = ORIGINAL_API(CreateProcessW)(
  67. lpApplicationName,
  68. lpCommandLine,
  69. lpProcessAttributes,
  70. lpThreadAttributes,
  71. bInheritHandles,
  72. dwCreationFlags,
  73. lpEnvironment,
  74. lpCurrentDirectory,
  75. lpStartupInfo,
  76. lpProcessInformation);
  77. return bRet;
  78. }
  79. /*++
  80. Register hooked functions
  81. --*/
  82. HOOK_BEGIN
  83. APIHOOK_ENTRY(KERNEL32.DLL, CreateProcessW)
  84. HOOK_END
  85. IMPLEMENT_SHIM_END