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.

77 lines
1.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. EmulateGetStdHandle.cpp
  5. Abstract:
  6. Normally, when a process is created, members hStdInput, hStdOutput, and
  7. hStdError of STARTUPINFO struct are set to NULL. Some apps like
  8. Baby-Sitters Club Activity Center and Baby-Sitters Club 3-rd Grade Disk 2
  9. may check these handles and send Error messages.
  10. This shim can be used in this case to send appropriate handles and prevent
  11. program terminate.
  12. History:
  13. 06/14/2000 a-vales created
  14. 11/29/2000 andyseti Converted into AppSpecific shim.
  15. --*/
  16. #include "precomp.h"
  17. IMPLEMENT_SHIM_BEGIN(EmulateGetStdHandle)
  18. #include "ShimHookMacro.h"
  19. APIHOOK_ENUM_BEGIN
  20. APIHOOK_ENUM_ENTRY(GetStdHandle)
  21. APIHOOK_ENUM_END
  22. HANDLE
  23. APIHOOK(GetStdHandle)(
  24. DWORD nStdHandle)
  25. {
  26. HANDLE hStd = ORIGINAL_API(GetStdHandle)(nStdHandle);
  27. if (hStd == 0)
  28. {
  29. switch (nStdHandle)
  30. {
  31. case STD_INPUT_HANDLE:
  32. LOGN( eDbgLevelError, "Correcting GetStdHandle(STD_INPUT_HANDLE). Returning handle = 1.");
  33. hStd = (HANDLE) 1;
  34. break;
  35. case STD_OUTPUT_HANDLE:
  36. LOGN( eDbgLevelError, "Correcting GetStdHandle(STD_OUTPUT_HANDLE). Returning handle = 2.");
  37. hStd = (HANDLE) 2;
  38. break;
  39. case STD_ERROR_HANDLE:
  40. LOGN( eDbgLevelError, "Correcting GetStdHandle(STD_ERROR_HANDLE). Returning handle = 3.");
  41. hStd = (HANDLE) 3;
  42. break;
  43. }
  44. }
  45. return hStd;
  46. }
  47. /*++
  48. Register hooked functions
  49. --*/
  50. HOOK_BEGIN
  51. APIHOOK_ENTRY(KERNEL32.DLL, GetStdHandle)
  52. HOOK_END
  53. IMPLEMENT_SHIM_END