147 lines
3.6 KiB
C
147 lines
3.6 KiB
C
|
/*++
|
||
|
|
||
|
Copyright (c) 2000 Microsoft Corporation
|
||
|
|
||
|
Module Name:
|
||
|
|
||
|
CorrectPathChangesBase.cpp
|
||
|
|
||
|
Abstract:
|
||
|
Several paths were changed between Win9x and WinNT. This routine defines
|
||
|
the CorrectPathChangesBase routines that is called with a Win9x path and returns
|
||
|
the corresponding WinNT path.
|
||
|
|
||
|
History:
|
||
|
|
||
|
03-Mar-00 robkenny Converted CorrectPathChanges.cpp to this class.
|
||
|
08/14/2001 robkenny Inserted inside the ShimLib namespace.
|
||
|
|
||
|
--*/
|
||
|
#pragma once
|
||
|
|
||
|
#include "ShimHook.h"
|
||
|
#include "ShimLib.h"
|
||
|
#include "CharVector.h"
|
||
|
#include "StrSafe.h"
|
||
|
|
||
|
|
||
|
namespace ShimLib
|
||
|
{
|
||
|
|
||
|
class StringPairW
|
||
|
{
|
||
|
public:
|
||
|
CString lpOld;
|
||
|
CString lpNew;
|
||
|
|
||
|
StringPairW()
|
||
|
{
|
||
|
}
|
||
|
StringPairW(const WCHAR * lpszOld, const WCHAR * lpszNew)
|
||
|
{
|
||
|
lpOld = lpszOld;
|
||
|
lpNew = lpszNew;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
class EnvironmentValues : public VectorT<StringPairW>
|
||
|
{
|
||
|
protected:
|
||
|
BOOL bInitialized;
|
||
|
|
||
|
public:
|
||
|
EnvironmentValues();
|
||
|
~EnvironmentValues();
|
||
|
|
||
|
void Initialize();
|
||
|
|
||
|
WCHAR * ExpandEnvironmentValueW(const WCHAR * lpOld);
|
||
|
char * ExpandEnvironmentValueA(const char * lpOld);
|
||
|
|
||
|
void AddEnvironmentValue(const WCHAR * lpOld, const WCHAR * lpNew);
|
||
|
|
||
|
enum eAddNameEnum
|
||
|
{
|
||
|
eIgnoreName = 0,
|
||
|
eAddName = 1,
|
||
|
};
|
||
|
enum eAddNoDLEnum
|
||
|
{
|
||
|
eIgnoreNoDL = 0,
|
||
|
eAddNoDL = 1,
|
||
|
};
|
||
|
|
||
|
void AddAll_CSIDL();
|
||
|
void Add_Variants(const WCHAR * lpEnvName, const WCHAR * lpEnvValue, eAddNameEnum eName, eAddNoDLEnum eNoDL);
|
||
|
void Add_CSIDL(const WCHAR * lpEnvName, int nFolder, eAddNameEnum eName, eAddNoDLEnum eNoDL);
|
||
|
};
|
||
|
|
||
|
class CorrectPathChangesBase
|
||
|
{
|
||
|
protected:
|
||
|
|
||
|
EnvironmentValues * lpEnvironmentValues;
|
||
|
VectorT<StringPairW> vKnownPathFixes;
|
||
|
|
||
|
BOOL bInitialized;
|
||
|
BOOL bEnabled;
|
||
|
|
||
|
protected:
|
||
|
virtual void InitializePathFixes();
|
||
|
virtual void InitializeEnvironmentValuesW();
|
||
|
|
||
|
void AddEnvironmentValue(const WCHAR * lpOld, const WCHAR * lpNew);
|
||
|
void InsertPathChangeW( const WCHAR * lpOld, const WCHAR * lpNew);
|
||
|
|
||
|
public:
|
||
|
CorrectPathChangesBase();
|
||
|
virtual ~CorrectPathChangesBase();
|
||
|
|
||
|
// Init the class
|
||
|
virtual BOOL ClassInit();
|
||
|
|
||
|
// Init all path changes, must be called after SHIM_STATIC_DLLS_INITIALIZED
|
||
|
virtual void InitializeCorrectPathChanges();
|
||
|
|
||
|
virtual WCHAR * ExpandEnvironmentValueW(const WCHAR * lpOld);
|
||
|
virtual char * ExpandEnvironmentValueA(const char * lpOld);
|
||
|
|
||
|
virtual void AddPathChangeW(const WCHAR * lpOld, const WCHAR * lpNew);
|
||
|
|
||
|
virtual void AddCommandLineA(const char * lpCommandLine );
|
||
|
virtual void AddCommandLineW(const WCHAR * lpCommandLine );
|
||
|
|
||
|
virtual void AddFromToPairW(const WCHAR * lpFromToPair );
|
||
|
|
||
|
virtual char * CorrectPathAllocA(const char * str);
|
||
|
virtual WCHAR * CorrectPathAllocW(const WCHAR * str);
|
||
|
|
||
|
inline void Enable(BOOL enable);
|
||
|
};
|
||
|
|
||
|
|
||
|
/*++
|
||
|
Enable (or disable if value is FALSE) changing of paths.
|
||
|
--*/
|
||
|
inline void CorrectPathChangesBase::Enable(BOOL isEnabled)
|
||
|
{
|
||
|
bEnabled = isEnabled;
|
||
|
}
|
||
|
|
||
|
// Typical path fixes
|
||
|
class CorrectPathChangesUser : public CorrectPathChangesBase
|
||
|
{
|
||
|
protected:
|
||
|
virtual void InitializePathFixes();
|
||
|
};
|
||
|
|
||
|
// Typical path fixes, moving user directories to All Users
|
||
|
class CorrectPathChangesAllUser : public CorrectPathChangesUser
|
||
|
{
|
||
|
protected:
|
||
|
|
||
|
virtual void InitializePathFixes();
|
||
|
};
|
||
|
|
||
|
}; // end of namespace ShimLib
|