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.

146 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. CorrectPathChangesBase.cpp
  5. Abstract:
  6. Several paths were changed between Win9x and WinNT. This routine defines
  7. the CorrectPathChangesBase routines that is called with a Win9x path and returns
  8. the corresponding WinNT path.
  9. History:
  10. 03-Mar-00 robkenny Converted CorrectPathChanges.cpp to this class.
  11. 08/14/2001 robkenny Inserted inside the ShimLib namespace.
  12. --*/
  13. #pragma once
  14. #include "ShimHook.h"
  15. #include "ShimLib.h"
  16. #include "CharVector.h"
  17. #include "StrSafe.h"
  18. namespace ShimLib
  19. {
  20. class StringPairW
  21. {
  22. public:
  23. CString lpOld;
  24. CString lpNew;
  25. StringPairW()
  26. {
  27. }
  28. StringPairW(const WCHAR * lpszOld, const WCHAR * lpszNew)
  29. {
  30. lpOld = lpszOld;
  31. lpNew = lpszNew;
  32. }
  33. };
  34. class EnvironmentValues : public VectorT<StringPairW>
  35. {
  36. protected:
  37. BOOL bInitialized;
  38. public:
  39. EnvironmentValues();
  40. ~EnvironmentValues();
  41. void Initialize();
  42. WCHAR * ExpandEnvironmentValueW(const WCHAR * lpOld);
  43. char * ExpandEnvironmentValueA(const char * lpOld);
  44. void AddEnvironmentValue(const WCHAR * lpOld, const WCHAR * lpNew);
  45. enum eAddNameEnum
  46. {
  47. eIgnoreName = 0,
  48. eAddName = 1,
  49. };
  50. enum eAddNoDLEnum
  51. {
  52. eIgnoreNoDL = 0,
  53. eAddNoDL = 1,
  54. };
  55. void AddAll_CSIDL();
  56. void Add_Variants(const WCHAR * lpEnvName, const WCHAR * lpEnvValue, eAddNameEnum eName, eAddNoDLEnum eNoDL);
  57. void Add_CSIDL(const WCHAR * lpEnvName, int nFolder, eAddNameEnum eName, eAddNoDLEnum eNoDL);
  58. };
  59. class CorrectPathChangesBase
  60. {
  61. protected:
  62. EnvironmentValues * lpEnvironmentValues;
  63. VectorT<StringPairW> vKnownPathFixes;
  64. BOOL bInitialized;
  65. BOOL bEnabled;
  66. protected:
  67. virtual void InitializePathFixes();
  68. virtual void InitializeEnvironmentValuesW();
  69. void AddEnvironmentValue(const WCHAR * lpOld, const WCHAR * lpNew);
  70. void InsertPathChangeW( const WCHAR * lpOld, const WCHAR * lpNew);
  71. public:
  72. CorrectPathChangesBase();
  73. virtual ~CorrectPathChangesBase();
  74. // Init the class
  75. virtual BOOL ClassInit();
  76. // Init all path changes, must be called after SHIM_STATIC_DLLS_INITIALIZED
  77. virtual void InitializeCorrectPathChanges();
  78. virtual WCHAR * ExpandEnvironmentValueW(const WCHAR * lpOld);
  79. virtual char * ExpandEnvironmentValueA(const char * lpOld);
  80. virtual void AddPathChangeW(const WCHAR * lpOld, const WCHAR * lpNew);
  81. virtual void AddCommandLineA(const char * lpCommandLine );
  82. virtual void AddCommandLineW(const WCHAR * lpCommandLine );
  83. virtual void AddFromToPairW(const WCHAR * lpFromToPair );
  84. virtual char * CorrectPathAllocA(const char * str);
  85. virtual WCHAR * CorrectPathAllocW(const WCHAR * str);
  86. inline void Enable(BOOL enable);
  87. };
  88. /*++
  89. Enable (or disable if value is FALSE) changing of paths.
  90. --*/
  91. inline void CorrectPathChangesBase::Enable(BOOL isEnabled)
  92. {
  93. bEnabled = isEnabled;
  94. }
  95. // Typical path fixes
  96. class CorrectPathChangesUser : public CorrectPathChangesBase
  97. {
  98. protected:
  99. virtual void InitializePathFixes();
  100. };
  101. // Typical path fixes, moving user directories to All Users
  102. class CorrectPathChangesAllUser : public CorrectPathChangesUser
  103. {
  104. protected:
  105. virtual void InitializePathFixes();
  106. };
  107. }; // end of namespace ShimLib