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.

97 lines
1.7 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. ZenWorks.cpp
  5. Abstract:
  6. ZenWorks console plugins setup program changes the
  7. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path
  8. registry key from REG_EXPAND_SZ to REG_SZ.
  9. Notes:
  10. This is an app specific shim.
  11. History:
  12. 06/06/2001 robkenny Created
  13. --*/
  14. #include "precomp.h"
  15. IMPLEMENT_SHIM_BEGIN(ZenWorks)
  16. #include "ShimHookMacro.h"
  17. APIHOOK_ENUM_BEGIN
  18. APIHOOK_ENUM_ENTRY(RegSetValueExA)
  19. APIHOOK_ENUM_END
  20. /*++
  21. Prevent HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path
  22. from being changed from a REG_EXPAND_SZ to REG_SZ
  23. --*/
  24. LONG
  25. APIHOOK(RegSetValueExA)(
  26. HKEY hKey,
  27. LPCSTR lpValueName,
  28. DWORD Reserved,
  29. DWORD dwType,
  30. CONST BYTE * lpData,
  31. DWORD cbData
  32. )
  33. {
  34. CSTRING_TRY
  35. {
  36. CString csValueName(lpValueName);
  37. DPFN( eDbgLevelSpew, "RegSetValueExA lpValueName(%S)", csValueName.Get());
  38. if (dwType == REG_SZ &&
  39. csValueName.CompareNoCase(L"Path") == 0)
  40. {
  41. dwType = REG_EXPAND_SZ;
  42. DPFN( eDbgLevelError, "RegSetValueExA lpValueName(%S) forced to REG_EXPAND_SZ type.",
  43. csValueName.Get());
  44. }
  45. }
  46. CSTRING_CATCH
  47. {
  48. // fall through
  49. }
  50. /*
  51. * Call the original API
  52. */
  53. return ORIGINAL_API(RegSetValueExA)(
  54. hKey,
  55. lpValueName,
  56. Reserved,
  57. dwType,
  58. lpData,
  59. cbData);
  60. }
  61. /*++
  62. Register hooked functions
  63. --*/
  64. HOOK_BEGIN
  65. APIHOOK_ENTRY(ADVAPI32.DLL, RegSetValueExA)
  66. HOOK_END
  67. IMPLEMENT_SHIM_END