1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
//****************************************************************************
//
// SxSHelpers.h
//
// Some helping classes and methods for SxS in mscoree and mscorwks/mscorsvr
//
//****************************************************************************
#ifndef SXSHELPERS_H_
#define SXSHELPERS_H_
#define V1_VERSION_NUM W("v1.0.3705")
// This string is the magic string located in the registry which determines that a key is actually
// a version.
//
// For example:
//
// HCR/clsid/xxxx-xx-xx-xx/InprocServer32/1.0.3705.0
// /1.0.3705.125
//
// If this SBSVERSIONVALUE is set as a ValueName in these
// version keys, then we're saying that there is an implementation of the object
// for that version of the runtime.
//
// i.e., if 1.0.3705.0 has the value name of SBSVERSIONVALUE, then 1.0.3705.0 implements
// this class id.
#define SBSVERSIONVALUE W("ImplementedInThisVersion")
// Find the runtime version from registry for rclsid
// If succeeded, *ppwzRuntimeVersion will have the runtime version
// corresponding to the highest version
// If failed, *ppwzRuntimeVersion will be NULL
//
// Note: If succeeded, this function will allocate memory for
// *ppwzRuntimeVersion. It if the caller's repsonsibility to
// release that memory
HRESULT FindRuntimeVersionFromRegistry(
REFCLSID rclsid,
__deref_out_z LPWSTR *ppwzRuntimeVersion,
__deref_out_opt LPWSTR *ppwzSupportedVersions);
// Find assembly info from registry for rclsid
// If succeeded, *ppwzClassName, *ppwzAssemblyString, *ppwzCodeBase
// will have their value corresponding to the highest version
// If failed, they will be set to NULL
// Note: If succeeded, this function will allocate memory for
// *ppwzClassName, *ppwzAssemblyString and *ppwzCodeBase.
// Caller is responsible to release them.
//
HRESULT FindShimInfoFromRegistry(
REFCLSID rclsid,
BOOL bLoadRecord,
WORD wHighestRuntimeMajorVersion,
WORD wHighestRuntimeMinorVersion,
__deref_out_z LPWSTR *ppwzClassName,
__deref_out_z LPWSTR *ppwzAssemblyString,
__deref_out_z LPWSTR *ppwzCodeBase);
// Find assembly info from Win32 activattion context for rclsid
// If succeeded, *ppwzRuntimeVersion, *ppwzClassName, *ppwzAssemblyString,
// will have their value corresponding to the highest version
// If failed, they will be set to NULL
// Note: If succeeded, this function will allocate memory for
// *ppwzClassName, *ppwzAssemblyString and *ppwzCodeBase.
// Caller is responsible to release them.
// Also notice codebase is not supported in Win32 case.
//
HRESULT FindShimInfoFromWin32(
REFCLSID rclsid,
BOOL bLoadRecord,
__deref_opt_out_opt LPWSTR *ppwzRuntimeVersion,
__deref_opt_out_opt LPWSTR *ppwszSupportedRuntimeVersions,
__deref_opt_out_opt LPWSTR *ppwzClassName,
__deref_opt_out_opt LPWSTR *ppwzAssemblyString,
BOOL *pfRegFreePIA);
// Get information from the Win32 fusion about the config file and the application base.
HRESULT GetConfigFileFromWin32Manifest(__out_ecount_part(dwBuffer, *pSize) WCHAR* buffer, SIZE_T dwBuffer, SIZE_T* pSize);
HRESULT GetApplicationPathFromWin32Manifest(__out_ecount_part(dwBuffer, *pSize) WCHAR* buffer, SIZE_T dwBuffer, SIZE_T* pSize);
//****************************************************************************
// AssemblyVersion
//
// class to handle assembly version
// Since only functions in this file will use it,
// we declare it in the cpp file so other people won't use it.
//
//****************************************************************************
class AssemblyVersion
{
public:
// constructors
inline AssemblyVersion();
inline AssemblyVersion(AssemblyVersion& version);
// Init
HRESULT Init(LPCWSTR pwzVersion, BOOL bStartsWithV);
inline HRESULT Init(WORD major, WORD minor, WORD build, WORD revision);
// Mofifiers.
inline void SetBuild(WORD build);
inline void SetRevision(WORD revision);
// assign operator
inline AssemblyVersion& operator=(const AssemblyVersion& version);
// Comparison operator
friend BOOL operator==(const AssemblyVersion& version1,
const AssemblyVersion& version2);
friend BOOL operator>=(const AssemblyVersion& version1,
const AssemblyVersion& version2);
private:
// pwzVersion must have format of "a.b.c.d",
// where a,b,c,d are all numbers
HRESULT ValidateVersion(LPCWSTR pwzVersion);
private:
WORD _major;
WORD _minor;
WORD _build;
WORD _revision;
};
extern BOOL operator==(const AssemblyVersion& version1,
const AssemblyVersion& version2);
extern BOOL operator>=(const AssemblyVersion& version1,
const AssemblyVersion& version2);
inline BOOL operator<(const AssemblyVersion& version1,
const AssemblyVersion& version2);
#include <sxshelpers.inl>
#endif // SXSHELPERS_H_
|