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.

116 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. JavaVM2.cpp
  5. Abstract:
  6. For versions of msjavx86.exe >= 06.00.3229.0000 we need to
  7. append /nowin2kcheck to the execution of javatrig.exe.
  8. Notes:
  9. This is an app specific shim.
  10. History:
  11. 05/31/2001 mnikkel Created
  12. --*/
  13. #include "precomp.h"
  14. IMPLEMENT_SHIM_BEGIN(JavaVM2)
  15. #include "ShimHookMacro.h"
  16. APIHOOK_ENUM_BEGIN
  17. APIHOOK_ENUM_ENTRY(CreateProcessA)
  18. APIHOOK_ENUM_END
  19. /*++
  20. Check CreateProcessA for execution of javatrig, if found
  21. append /nowin2kcheck to the command line.
  22. --*/
  23. BOOL
  24. APIHOOK(CreateProcessA)(
  25. LPCSTR lpApplicationName,
  26. LPSTR lpCommandLine,
  27. LPSECURITY_ATTRIBUTES lpProcessAttributes,
  28. LPSECURITY_ATTRIBUTES lpThreadAttributes,
  29. BOOL bInheritHandles,
  30. DWORD dwCreationFlags,
  31. LPVOID lpEnvironment,
  32. LPCSTR lpCurrentDirectory,
  33. LPSTARTUPINFOA lpStartupInfo,
  34. LPPROCESS_INFORMATION lpProcessInformation
  35. )
  36. {
  37. DPFN( eDbgLevelSpew, "[CreateProcessA] appname:(%s)\ncommandline:(%s)", lpApplicationName, lpCommandLine );
  38. if (lpCommandLine)
  39. {
  40. CSTRING_TRY
  41. {
  42. CString csCL(lpCommandLine);
  43. int nLoc = csCL.Find(L"javatrig.exe ");
  44. if ( nLoc > -1 )
  45. {
  46. csCL += L" /nowin2kcheck";
  47. DPFN( eDbgLevelSpew, "[CreateProcessA] appname:(%s)\nNEW commandline:(%S)", lpApplicationName, csCL.Get() );
  48. return ORIGINAL_API(CreateProcessA)(lpApplicationName,
  49. csCL.GetAnsi(),
  50. lpProcessAttributes,
  51. lpThreadAttributes,
  52. bInheritHandles,
  53. dwCreationFlags,
  54. lpEnvironment,
  55. lpCurrentDirectory,
  56. lpStartupInfo,
  57. lpProcessInformation);
  58. }
  59. }
  60. CSTRING_CATCH
  61. {
  62. // Do Nothing
  63. }
  64. }
  65. //
  66. // Call the original API
  67. //
  68. return ORIGINAL_API(CreateProcessA)(lpApplicationName,
  69. lpCommandLine,
  70. lpProcessAttributes,
  71. lpThreadAttributes,
  72. bInheritHandles,
  73. dwCreationFlags,
  74. lpEnvironment,
  75. lpCurrentDirectory,
  76. lpStartupInfo,
  77. lpProcessInformation);
  78. }
  79. /*++
  80. Register hooked functions
  81. --*/
  82. HOOK_BEGIN
  83. APIHOOK_ENTRY(KERNEL32.DLL, CreateProcessA)
  84. HOOK_END
  85. IMPLEMENT_SHIM_END