• R/O
  • SSH
  • HTTPS

netoffice: Commit


Commit MetaInfo

Revision193 (tree)
Time2018-07-22 03:20:43
Authorsebastiandotnet

Log Message

- fix com shim manifest redirection

Change Summary

Incremental Difference

Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
--- NetOfficeShimLoader/ShimLoader/DllRegister32On64.cpp (revision 192)
+++ NetOfficeShimLoader/ShimLoader/DllRegister32On64.cpp (revision 193)
@@ -24,22 +24,19 @@
2424
2525 HRESULT DllRegister(HINSTANCE module, LPCWSTR officeApplications[], DWORD addinLoadBehavior, DWORD addinCommandLineSafe, WCHAR* progId, WCHAR* classId, WCHAR* friendlyName, WCHAR* description, WCHAR* version, RegisterMode mode, BOOL addinRegistration)
2626 {
27+ NetOffice_ShimLoader_Analytics::WriteLog(L"Register32On64::DllRegister::Enter");
28+
2729 HRESULT hr = S_OK;
2830
29- if (NULL == module)
30- return E_INVALIDARG;
31- if (NULL == officeApplications)
32- return E_INVALIDARG;
33- if (!progId || !progId[0])
34- return E_INVALIDARG;
35- if (!classId || !classId[0])
36- return E_INVALIDARG;
37- if (!friendlyName || !friendlyName[0])
38- return E_INVALIDARG;
39- if (!description || !description[0])
40- return E_INVALIDARG;
41- if (!version || !version[0])
42- return E_INVALIDARG;
31+ if (NULL == module || NULL == officeApplications ||
32+ !progId || !progId[0] || !classId || !classId[0] ||
33+ !friendlyName || !friendlyName[0] || !description || !description[0] ||
34+ !version || !version[0])
35+ {
36+ hr = E_INVALIDARG;
37+ NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllRegister::FailExit", hr);
38+ return hr;
39+ }
4340
4441 hr = RegisterCOMComponent(module, progId, classId, version, description, mode);
4542 if (SUCCEEDED(hr) && addinRegistration)
@@ -49,26 +46,38 @@
4946 {
5047 hr = RegisterCOMAddin(officeApplications[i], progId, friendlyName, description, addinLoadBehavior, addinCommandLineSafe, System == mode);
5148 if (!SUCCEEDED(hr))
49+ {
50+ NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllRegister::Error#RegisterCOMAddin");
5251 break;
52+ }
5353 }
5454 }
55+ else
56+ {
57+ NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllRegister::Error#RegisterCOMComponent");
58+ }
5559
60+ if (SUCCEEDED(hr))
61+ NetOffice_ShimLoader_Analytics::WriteLog(L"Register32On64::DllRegister::Exit");
62+ else
63+ NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllRegister::FailExit");
64+
5665 return hr;
5766 }
5867
5968 HRESULT DllUnregister(LPCWSTR officeApplications[], WCHAR* progId, WCHAR* classId, WCHAR* version, RegisterMode mode, BOOL addinRegistration)
6069 {
70+ NetOffice_ShimLoader_Analytics::WriteLog(L"Register32On64::DllUnregister::Enter");
71+
6172 HRESULT hr = S_OK;
6273 HRESULT addin = S_OK;
6374
64- if (NULL == officeApplications)
65- return E_INVALIDARG;
66- if (!progId || !progId[0])
67- return E_INVALIDARG;
68- if (!classId || !classId[0])
69- return E_INVALIDARG;
70- if (!version || !version[0])
71- return E_INVALIDARG;
75+ if (NULL == officeApplications || !progId || !progId[0] || !classId || !classId[0] || !version || !version[0])
76+ {
77+ hr = E_INVALIDARG;
78+ NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllUnregister::FailExit", hr);
79+ return hr;
80+ }
7281
7382 if (addinRegistration)
7483 {
@@ -76,81 +85,102 @@
7685 for (size_t i = 0; i < arraySize; i++)
7786 {
7887 if (!SUCCEEDED(UnRegisterCOMAddin(officeApplications[i], progId, 0 == mode)))
88+ {
89+ NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllUnregister::Error#UnRegisterCOMAddin");
7990 addin = E_FAIL;
91+ }
8092 }
8193 }
8294
8395 hr = UnregisterCOMComponent(progId, classId, version, mode);
96+ if(FAILED(hr))
97+ NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllUnregister::Error#UnregisterCOMComponent");
8498
99+ if(SUCCEEDED(addin != S_OK ? addin : hr))
100+ NetOffice_ShimLoader_Analytics::WriteLog(L"Register32On64::DllUnregister::Exit");
101+ else
102+ NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllUnregister::FailExit");
103+
85104 return addin != S_OK ? addin : hr;
86105 }
87106
88107 HRESULT RegisterCOMComponent(HINSTANCE module, LPCWSTR progId, LPCWSTR classId, LPCWSTR version, LPCWSTR description, RegisterMode mode)
89108 {
90- HRESULT result = S_OK;
109+ HRESULT hr = S_OK;
110+ BOOL setKeyResult = FALSE;
91111
92112 WCHAR moduleFullFileName[512];
93113 DWORD dwResult = ::GetModuleFileName(module, moduleFullFileName, 512);
94- if (0 == dwResult)
95- return E_FAIL;
114+ if (0 != dwResult)
115+ {
116+ HKEY targetRootKey = TargetRootKey(mode);
96117
97- HKEY targetRootKey = TargetRootKey(mode);
118+ WCHAR classIdKey[512];
119+ ClassIdSubKey(classId, mode, classIdKey, 512);
98120
99- WCHAR classIdKey[512];
100- ClassIdSubKey(classId, mode, classIdKey, 512);
121+ WCHAR progIdKey[512];
122+ ProgIdSubKey(progId, mode, progIdKey, 512);
101123
102- WCHAR progIdKey[512];
103- ProgIdSubKey(progId, mode, progIdKey, 512);
124+ // Target Key ProgId
125+ setKeyResult = SetKeyAndValue(targetRootKey, progIdKey, NULL, NULL, NULL, NULL, progId);
126+ IfFalseGo(setKeyResult);
127+ setKeyResult = SetKeyAndValue(targetRootKey, progIdKey, L"CLSID", NULL, NULL, NULL, classId);
128+ IfFalseGo(setKeyResult);
104129
105- // Target Key ProgId
106- if (!SetKeyAndValue(targetRootKey, progIdKey, NULL, NULL, NULL, NULL, progId))
107- return S_FALSE;
108- if (!SetKeyAndValue(targetRootKey, progIdKey, L"CLSID", NULL, NULL, NULL, classId))
109- return S_FALSE;
130+ // Target Key IID
131+ setKeyResult = SetKeyAndValue(targetRootKey, classIdKey, NULL, NULL, NULL, NULL, progId);
132+ IfFalseGo(setKeyResult);
133+ setKeyResult = SetKeyAndValue(targetRootKey, classIdKey, L"InprocServer32", NULL, NULL, L"ThreadingModel", L"Apartment");
134+ IfFalseGo(setKeyResult);
135+ setKeyResult = SetKeyAndValue(targetRootKey, classIdKey, L"InprocServer32", NULL, NULL, NULL, moduleFullFileName);
136+ IfFalseGo(setKeyResult);
137+ setKeyResult = SetKeyAndValue(targetRootKey, classIdKey, L"InprocServer32", version, NULL, L"ThreadingModel", L"Apartment");
138+ IfFalseGo(setKeyResult);
139+ setKeyResult = SetKeyAndValue(targetRootKey, classIdKey, L"InprocServer32", version, NULL, NULL, moduleFullFileName);
140+ IfFalseGo(setKeyResult);
141+ setKeyResult = SetKeyAndValue(targetRootKey, classIdKey, L"ProgId", NULL, NULL, NULL, progId);
142+ IfFalseGo(setKeyResult);
110143
111- // Target Key IID
112- if (!SetKeyAndValue(targetRootKey, classIdKey, NULL, NULL, NULL, NULL, progId))
113- return S_FALSE;
114- if (!SetKeyAndValue(targetRootKey, classIdKey, L"InprocServer32", NULL, NULL, L"ThreadingModel", L"Apartment"))
115- return S_FALSE;
116- if (!SetKeyAndValue(targetRootKey, classIdKey, L"InprocServer32", NULL, NULL, NULL, moduleFullFileName))
117- return S_FALSE;
118- if (!SetKeyAndValue(targetRootKey, classIdKey, L"InprocServer32", version, NULL, L"ThreadingModel", L"Apartment"))
119- return S_FALSE;
120- if (!SetKeyAndValue(targetRootKey, classIdKey, L"InprocServer32", version, NULL, NULL, moduleFullFileName))
121- return S_FALSE;
122- if (!SetKeyAndValue(targetRootKey, classIdKey, L"ProgId", NULL, NULL, NULL, progId))
123- return S_FALSE;
144+ //if (mode != User)
145+ //{
146+ // // HKEY_CLASSES_ROOT ProgId
147+ // setKeyResult = SetKeyAndValue(HKEY_CLASSES_ROOT, progId, NULL, NULL, NULL, NULL, progId);
148+ // IfFalseGo(setKeyResult);
149+ // setKeyResult = SetKeyAndValue(HKEY_CLASSES_ROOT, progId, L"CLSID", NULL, NULL, NULL, classId);
150+ // IfFalseGo(setKeyResult);
124151
125- if(mode != User)
152+ // // HKEY_CLASSES_ROOT IID
153+ // setKeyResult = SetKeyAndValue(HKEY_CLASSES_ROOT, L"CLSID", classId, NULL, NULL, NULL, progId);
154+ // IfFalseGo(setKeyResult);
155+ // setKeyResult = SetKeyAndValue(HKEY_CLASSES_ROOT, L"CLSID", classId, L"InprocServer32", NULL, L"ThreadingModel", L"Apartment");
156+ // IfFalseGo(setKeyResult);
157+ // setKeyResult = SetKeyAndValue(HKEY_CLASSES_ROOT, L"CLSID", classId, L"InprocServer32", NULL, NULL, moduleFullFileName);
158+ // IfFalseGo(setKeyResult);
159+ // setKeyResult = SetKeyAndValue(HKEY_CLASSES_ROOT, L"CLSID", classId, L"InprocServer32", version, L"ThreadingModel", L"Apartment");
160+ // IfFalseGo(setKeyResult);
161+ // setKeyResult = SetKeyAndValue(HKEY_CLASSES_ROOT, L"CLSID", classId, L"InprocServer32", version, NULL, moduleFullFileName);
162+ // IfFalseGo(setKeyResult);
163+ // setKeyResult = SetKeyAndValue(HKEY_CLASSES_ROOT, L"CLSID", classId, L"ProgId", NULL, NULL, progId);
164+ // IfFalseGo(setKeyResult);
165+ //}
166+ }
167+ else
126168 {
127- // HKEY_CLASSES_ROOT ProgId
128- if (!SetKeyAndValue(HKEY_CLASSES_ROOT, progId, NULL, NULL, NULL, NULL, progId))
129- return S_FALSE;
130- if (!SetKeyAndValue(HKEY_CLASSES_ROOT, progId, L"CLSID", NULL, NULL, NULL, classId))
131- return S_FALSE;
132-
133- // HKEY_CLASSES_ROOT IID
134- if (!SetKeyAndValue(HKEY_CLASSES_ROOT, L"CLSID", classId, NULL, NULL, NULL, progId))
135- return S_FALSE;
136- if (!SetKeyAndValue(HKEY_CLASSES_ROOT, L"CLSID", classId, L"InprocServer32", NULL, L"ThreadingModel", L"Apartment"))
137- return S_FALSE;
138- if (!SetKeyAndValue(HKEY_CLASSES_ROOT, L"CLSID", classId, L"InprocServer32", NULL, NULL, moduleFullFileName))
139- return S_FALSE;
140- if (!SetKeyAndValue(HKEY_CLASSES_ROOT, L"CLSID", classId, L"InprocServer32", version, L"ThreadingModel", L"Apartment"))
141- return S_FALSE;
142- if (!SetKeyAndValue(HKEY_CLASSES_ROOT, L"CLSID", classId, L"InprocServer32", version, NULL, moduleFullFileName))
143- return S_FALSE;
144- if (!SetKeyAndValue(HKEY_CLASSES_ROOT, L"CLSID", classId, L"ProgId", NULL, NULL, progId))
145- return S_FALSE;
169+ hr = E_FAIL;
170+ goto Error;
146171 }
147172
148- return result;
173+ return hr;
174+
175+ Error:
176+
177+ return hr;
149178 }
150179
151180 HRESULT UnregisterCOMComponent(LPCWSTR progId, LPCWSTR classId, LPCWSTR version, RegisterMode mode)
152181 {
153- HRESULT result = S_OK;
182+ HRESULT hr = S_OK;
183+ LONG deleteKeyResult = 0;
154184
155185 HKEY hKeyRoot = TargetRootKey(mode);
156186 WCHAR classIdKey[512];
@@ -158,21 +188,26 @@
158188 WCHAR progIdKey[512];
159189 ProgIdSubKey(progId, mode, progIdKey, 512);
160190
161- if (mode != User)
162- {
163- if (ERROR_SUCCESS != RecursiveDeleteKey(HKEY_CLASSES_ROOT, progId))
164- result = E_FAIL;
165- if (ERROR_SUCCESS != RecursiveDeleteKey(HKEY_CLASSES_ROOT, L"CLSID", classId))
166- result = E_FAIL;
167- }
191+ //if (mode != User)
192+ //{
193+ // deleteKeyResult = RecursiveDeleteKey(HKEY_CLASSES_ROOT, progId);
194+ // IfZeroGo(deleteKeyResult);
168195
169- if (ERROR_SUCCESS != RecursiveDeleteKey(hKeyRoot, classIdKey))
170- result = E_FAIL;
196+ // deleteKeyResult = RecursiveDeleteKey(HKEY_CLASSES_ROOT, L"CLSID", classId);
197+ // IfZeroGo(deleteKeyResult);
198+ //}
171199
172- if (ERROR_SUCCESS != RecursiveDeleteKey(hKeyRoot, progIdKey))
173- result = E_FAIL;
200+ deleteKeyResult = RecursiveDeleteKey(hKeyRoot, progIdKey);
201+ IfNotZeroGo(deleteKeyResult);
174202
175- return result;
203+ deleteKeyResult = RecursiveDeleteKey(hKeyRoot, classIdKey);
204+ IfNotZeroGo(deleteKeyResult);
205+
206+ return hr;
207+
208+ Error:
209+
210+ return hr;
176211 }
177212
178213 HRESULT RegisterCOMAddin(LPCWSTR pszOfficeApp, LPCWSTR pszProgID, LPCWSTR pszFriendlyName, LPCWSTR pszDescription, DWORD dwStartupContext, DWORD dwCommandLineSafe, bool registerPerMachine)
@@ -223,9 +258,10 @@
223258 }
224259
225260 RegCloseKey(hKey);
261+ return hr;
226262
227- return hr;
228263 Error:
264+
229265 if (keyCreated)
230266 {
231267 RegCloseKey(hKey);
@@ -236,6 +272,7 @@
236272
237273 HRESULT UnRegisterCOMAddin(LPCWSTR pszOfficeApp, LPCWSTR pszProgID, bool registerPerMachine)
238274 {
275+ HRESULT hr = S_OK;
239276 HRESULT result = S_OK;
240277
241278 HKEY root = registerPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
@@ -245,12 +282,7 @@
245282 StringCchCat(szKeyBuf, 1024, L"\\Addins\\");
246283 StringCchCat(szKeyBuf, 1024, pszProgID);
247284
248- HRESULT hr = RecursiveDeleteKey(root, szKeyBuf);
249- if (E_ACCESSDENIED != hr) // if key is missing - we dont care
250- {
251- result = hr;
252- }
253-
285+ hr = RecursiveDeleteKey(root, szKeyBuf);
254286 return result;
255287 }
256288
@@ -359,6 +391,8 @@
359391 {
360392 HKEY hKeyChild;
361393 LONG lRes = RegOpenKeyEx(hKeyParent, pszKeyChild, 0, _regKeyOptions, &hKeyChild);
394+ if (lRes == ERROR_PATH_NOT_FOUND)
395+ return 0;
362396 if (lRes != ERROR_SUCCESS)
363397 return lRes;
364398
--- NetOfficeShimLoader/ShimLoader/PathParser.cpp (revision 192)
+++ NetOfficeShimLoader/ShimLoader/PathParser.cpp (revision 193)
@@ -23,40 +23,42 @@
2323 _parseLegacyMap.clear();
2424 }
2525
26- HRESULT PathParser::Parse(BSTR path, WCHAR* result, int maxLen)
26+ HRESULT PathParser::Parse(BSTR path, WCHAR* result, int maxLen, BSTR documentPath)
2727 {
2828 HRESULT hr = E_FAIL;
2929
3030 if (OperatingSystemIsVistaOrAbove())
3131 {
32- hr = ParseLegacyInternal(path, result, maxLen);
32+ hr = ParseLegacyInternal(path, result, maxLen, documentPath);
3333 }
3434 else
3535 {
36- hr = ParseInternal(path, result, maxLen);
36+ hr = ParseInternal(path, result, maxLen, documentPath);
3737 }
3838
3939 return hr;
4040 }
4141
42- HRESULT PathParser::ParseEx(BSTR path, BSTR subFolderPath, WCHAR* result, int maxLen)
42+ HRESULT PathParser::ParseEx(BSTR path, BSTR subFolderPath, WCHAR* result, int maxLen, BSTR documentPath)
4343 {
4444 HRESULT hr = E_FAIL;
4545
4646 if (OperatingSystemIsVistaOrAbove())
4747 {
48- hr = ParseInternal(path, result, maxLen);
48+ hr = ParseInternal(path, result, maxLen, documentPath);
4949 if (SUCCEEDED(hr) && 0 != wcscmp(subFolderPath, L""))
5050 {
51- StringCchCat(result, maxLen, subFolderPath);
51+ hr = PathAppend(result, subFolderPath);
52+ //StringCchCat(result, maxLen, subFolderPath);
5253 }
5354 }
5455 else
5556 {
56- hr = ParseLegacyInternal(path, result, maxLen);
57+ hr = ParseLegacyInternal(path, result, maxLen, documentPath);
5758 if (SUCCEEDED(hr) && 0 != wcscmp(subFolderPath, L""))
5859 {
59- StringCchCat(result, maxLen, subFolderPath);
60+ hr = PathAppend(result, subFolderPath);
61+ //StringCchCat(result, maxLen, subFolderPath);
6062 }
6163 }
6264
@@ -63,6 +65,47 @@
6365 return hr;
6466 }
6567
68+ HRESULT PathParser::ParseEx(BSTR path, BSTR subFolderPath, BSTR filePath, WCHAR* result, int maxLen)
69+ {
70+ return ParseEx(path, subFolderPath, filePath, result, maxLen, NULL);
71+ }
72+
73+ HRESULT PathParser::ParseEx(BSTR path, BSTR subFolderPath, BSTR filePath, WCHAR* result, int maxLen, BSTR documentPath)
74+ {
75+ HRESULT hr = E_FAIL;
76+
77+ if (OperatingSystemIsVistaOrAbove())
78+ {
79+ hr = ParseInternal(path, result, maxLen, documentPath);
80+ if (SUCCEEDED(hr) && 0 != wcscmp(subFolderPath, L""))
81+ {
82+ hr = PathAppend(result, subFolderPath);
83+ //StringCchCat(result, maxLen, subFolderPath);
84+ }
85+ if (SUCCEEDED(hr) && 0 != wcscmp(filePath, L""))
86+ {
87+ hr = PathAppend(result, filePath);
88+ //StringCchCat(result, maxLen, filePath);
89+ }
90+ }
91+ else
92+ {
93+ hr = ParseLegacyInternal(path, result, maxLen, documentPath);
94+ if (SUCCEEDED(hr) && 0 != wcscmp(subFolderPath, L""))
95+ {
96+ hr = PathAppend(result, subFolderPath);
97+ //StringCchCat(result, maxLen, subFolderPath);
98+ }
99+ if (SUCCEEDED(hr) && 0 != wcscmp(filePath, L""))
100+ {
101+ hr = PathAppend(result, filePath);
102+ //StringCchCat(result, maxLen, filePath);
103+ }
104+ }
105+
106+ return hr;
107+ }
108+
66109 GUID PathParser::FindGuid(BSTR path)
67110 {
68111 for (auto it = _parseMap.begin(); it != _parseMap.end(); it++)
@@ -89,14 +132,18 @@
89132 return 0;
90133 }
91134
92- HRESULT PathParser::ParseInternal(BSTR path, WCHAR* result, int maxLen)
135+ HRESULT PathParser::ParseInternal(BSTR path, WCHAR* result, int maxLen, BSTR documentPath)
93136 {
94137 HRESULT hr = E_FAIL;
95138 PWSTR buffer = nullptr;
96139 auto folderId = FindGuid(path);
97140
98- if (folderId != GUID_NULL)
141+ if (NULL != documentPath && 0 == wcscmp(L"DocumentPath", path))
99142 {
143+ lstrcpyn(result, documentPath, maxLen);
144+ }
145+ else if (folderId != GUID_NULL)
146+ {
100147 hr = SHGetKnownFolderPath(folderId, KF_FLAG_DEFAULT, NULL, &buffer);
101148 if (SUCCEEDED(hr))
102149 {
@@ -117,14 +164,18 @@
117164 return hr;
118165 }
119166
120- HRESULT PathParser::ParseLegacyInternal(BSTR path, WCHAR* result, int maxLen)
167+ HRESULT PathParser::ParseLegacyInternal(BSTR path, WCHAR* result, int maxLen, BSTR documentPath)
121168 {
122169 HRESULT hr = E_FAIL;
123170 TCHAR* szPath = new TCHAR[MAX_PATH + 1];
124171 auto folderId = FindDWord(path);
125172
126- if (folderId != 0)
173+ if (NULL != documentPath && 0 == wcscmp(L"DocumentPath", path))
127174 {
175+ lstrcpyn(result, documentPath, maxLen);
176+ }
177+ else if (folderId != 0)
178+ {
128179 hr = SHGetFolderPath(NULL, folderId, NULL, 0, szPath);
129180 if (SUCCEEDED(hr))
130181 {
--- NetOfficeShimLoader/ShimLoader/PathParser.h (revision 192)
+++ NetOfficeShimLoader/ShimLoader/PathParser.h (revision 193)
@@ -11,17 +11,21 @@
1111 PathParser();
1212 virtual ~PathParser();
1313
14- HRESULT Parse(BSTR path, WCHAR* result, int maxLen);
14+ HRESULT Parse(BSTR path, WCHAR* result, int maxLen, BSTR documentPath);
1515
16- HRESULT ParseEx(BSTR path, BSTR subFolderPath, WCHAR* result, int maxLen);
16+ HRESULT ParseEx(BSTR path, BSTR subFolderPath, WCHAR* result, int maxLen, BSTR documentPath);
1717
18+ HRESULT ParseEx(BSTR path, BSTR subFolderPath, BSTR filePath, WCHAR* result, int maxLen);
19+
20+ HRESULT ParseEx(BSTR path, BSTR subFolderPath, BSTR filePath, WCHAR* result, int maxLen, BSTR documentPath);
21+
1822 protected:
1923
2024 BOOL OperatingSystemIsVistaOrAbove();
2125
22- HRESULT ParseInternal(BSTR path, WCHAR* result, int maxLen);
26+ HRESULT ParseInternal(BSTR path, WCHAR* result, int maxLen, BSTR documentPath);
2327
24- HRESULT ParseLegacyInternal(BSTR path, WCHAR* result, int maxLen);
28+ HRESULT ParseLegacyInternal(BSTR path, WCHAR* result, int maxLen, BSTR documentPath);
2529
2630 GUID FindGuid(BSTR path);
2731
--- NetOfficeShimLoader/ShimLoader/Redirection.xml (revision 192)
+++ NetOfficeShimLoader/ShimLoader/Redirection.xml (revision 193)
@@ -1,6 +1,8 @@
11 <?xml version="1.0" encoding="utf-8"?>
2-<ShimLoaderRedirection>
3- <Folder isSpecialFolder="false"></Folder>
4- <SubFolder></SubFolder>
5- <File></File>
6-</ShimLoaderRedirection>
\ No newline at end of file
2+<ShimLoader Version="1.0.0.0">
3+ <Manifest>
4+ <Folder>LocalAppData</Folder>
5+ <SubFolder>NetOffice\InnerAddin</SubFolder>
6+ <File>InnerAddin.dll.ShimSettings</File>
7+ </Manifest>
8+</ShimLoader>
--- NetOfficeShimLoader/ShimLoader/ShimArguments.cpp (revision 192)
+++ NetOfficeShimLoader/ShimLoader/ShimArguments.cpp (revision 193)
@@ -18,6 +18,7 @@
1818 ShimArguments::ShimArguments()
1919 {
2020 _document = nullptr;
21+ lstrcpyn(_documentPath, L"", MAX_PATH);
2122 _coInitialized = false;
2223 _readState = E_NOT_SET;
2324 IncComponents(L"ShimArguments");
@@ -35,6 +36,42 @@
3536 * ShimArguments Methods
3637 ***************************************************************************/
3738
39+ MSXML::IXMLDOMDocument2Ptr ShimArguments::LoadFile(WCHAR* fileName)
40+ {
41+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::LoadFile::Enter");
42+
43+ HRESULT hr = E_FAIL;
44+ bool b = FALSE;
45+ MSXML::IXMLDOMDocument2Ptr document;
46+
47+ b = PathFileExists(fileName);
48+ if (!b)
49+ {
50+ NetOffice_ShimLoader_Analytics::WriteError(L"ShimArguments::LoadFile::MissingFile", fileName);
51+ }
52+ IfFalseGo(b);
53+
54+ IfFailGo(ComInitialize());
55+ IfFailGo(document.CreateInstance(__uuidof(MSXML::DOMDocument60), NULL, CLSCTX_INPROC_SERVER));
56+ IfFailGo(VARIANT_TRUE == document->load(fileName) ? S_OK : E_FAIL);
57+
58+ IfFailGo(document->setProperty("SelectionLanguage", "XPath"));
59+
60+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::LoadFile::Exit");
61+ return document;
62+
63+ Error:
64+
65+ NetOffice_ShimLoader_Analytics::WriteError(L"ShimArguments::LoadFile::Error", hr);
66+ if (document)
67+ {
68+ document.Release();
69+ document = nullptr;
70+ }
71+
72+ return NULL;
73+ }
74+
3875 BOOL ShimArguments::IsLoaded()
3976 {
4077 return NULL != _document;
@@ -42,12 +79,18 @@
4279
4380 HRESULT ShimArguments::Load()
4481 {
82+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::Load::Enter");
83+
4584 HRESULT hr = E_FAIL;
46- bool b = FALSE;
85+ MSXML::IXMLDOMNodePtr redirectFolderNode = nullptr;
86+ MSXML::IXMLDOMNodePtr redirectSubFolderNode = nullptr;
87+ MSXML::IXMLDOMNodePtr redirectFileNode = nullptr;
4788
89+ PathParser parser;
90+
4891 WCHAR directoryPath[MAX_PATH + 1];
4992 IfFailGo(GetDllDirectory(directoryPath, ARRAYSIZE(directoryPath)));
50-
93+ lstrcpyn(_documentPath, directoryPath, MAX_PATH);
5194 WCHAR moduleFileName[MAX_PATH + 1];
5295 IfFailGo(GetModuleFileName(_module, moduleFileName, ARRAYSIZE(moduleFileName)));
5396
@@ -55,18 +98,55 @@
5598 IfFailGo(AppendPath(fullSettingsFilePath, directoryPath));
5699 IfFailGo(AppendPath(fullSettingsFilePath, moduleFileName));
57100 PWSTR target = StrCatBuff(fullSettingsFilePath, L".ShimSettings", ARRAYSIZE(fullSettingsFilePath));
101+ // TODO: delete target then?
58102
59- IfFalseGo(PathFileExists(target));
103+ _document = LoadFile(target);
60104
61- IfFailGo(ComInitialize());
62- IfFailGo(_document.CreateInstance(__uuidof(MSXML::DOMDocument60), NULL, CLSCTX_INPROC_SERVER));
63- IfFailGo(VARIANT_TRUE == _document->load(target) ? S_OK : E_FAIL);
64- IfFailGo(_document->setProperty("SelectionLanguage", "XPath"));
105+ if (_document)
106+ {
107+ for (size_t i = 0; i < 3; i++)
108+ {
109+ MSXML::IXMLDOMNodePtr document = nullptr;
110+ hr = _document.QueryInterface(__uuidof(IXMLDOMNode), &document);
111+ if (SUCCEEDED(hr))
112+ {
113+ redirectFolderNode = document->selectSingleNode("/ShimLoader/Manifest/Folder");
114+ if (!redirectFolderNode)
115+ break;
116+ redirectSubFolderNode = document->selectSingleNode("/ShimLoader/Manifest/SubFolder");
117+ if (!redirectSubFolderNode)
118+ break;
119+ redirectFileNode = document->selectSingleNode("/ShimLoader/Manifest/File");
120+ if (!redirectFileNode)
121+ break;
65122
123+ auto foo1 = redirectFolderNode->text.copy();
124+ auto foo2 = redirectSubFolderNode->text.copy();
125+ auto foo3 = redirectFileNode->text.copy();
126+ parser.ParseEx(foo1, foo2, foo3, _documentPath, MAX_PATH);
127+
128+ _document = LoadFile(_documentPath);
129+
130+ document.Release();
131+ document = nullptr;
132+
133+ break;
134+ }
135+ }
136+ }
137+ else
138+ {
139+ hr = E_FAIL;
140+ goto Error;
141+ }
142+
143+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::Load::Exit");
66144 return hr;
67145
68146 Error:
69147
148+ NetOffice_ShimLoader_Analytics::WriteError(L"ShimArguments::Load::FailExit", hr);
149+
70150 if (_document)
71151 {
72152 _document.Release();
@@ -78,6 +158,8 @@
78158
79159 HRESULT ShimArguments::Unload()
80160 {
161+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::Unload::Enter");
162+
81163 HRESULT hr = S_OK;
82164 if (_document)
83165 {
@@ -89,6 +171,8 @@
89171 {
90172 hr = E_FAIL;
91173 }
174+
175+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::Unload::Exit", hr);
92176 return hr;
93177 }
94178
@@ -99,8 +183,11 @@
99183
100184 HRESULT ShimArguments::Read()
101185 {
186+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::Read::Enter");
187+
102188 HRESULT hr = E_FAIL;
103189 MSXML::IXMLDOMNodePtr document = nullptr;
190+
104191 if (IsLoaded())
105192 {
106193 hr = _document.QueryInterface(__uuidof(IXMLDOMNode), &document);
@@ -128,11 +215,19 @@
128215 document.Release();
129216 document = nullptr;
130217 }
218+
219+ if(SUCCEEDED(hr))
220+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::Read::Exit");
221+ else
222+ NetOffice_ShimLoader_Analytics::WriteError(L"ShimArguments::Read::FailExit", hr);
223+
131224 return hr;
132225 }
133226
134227 HRESULT ShimArguments::ReadShimRegister(MSXML::IXMLDOMNodePtr document)
135228 {
229+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadShimRegister::Enter");
230+
136231 HRESULT hr = S_OK;
137232 DllRegisterModeParser parser;
138233 MSXML::IXMLDOMNodePtr registerShim = nullptr;
@@ -223,16 +318,20 @@
223318 }
224319 }
225320
321+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadShimRegister::Exit");
226322 return hr;
227323
228324 Error:
229325
230326 hr = E_FAIL;
327+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadShimRegister::FailExit", hr);
231328 return hr;
232329 }
233330
234331 HRESULT ShimArguments::ReadShimSettings(MSXML::IXMLDOMNodePtr document)
235332 {
333+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadShimSettings::Enter");
334+
236335 HRESULT hr = S_OK;
237336 MSXML::IXMLDOMNodePtr enabledNode = nullptr;
238337 MSXML::IXMLDOMNodePtr blindAggEnabledNode = nullptr;
@@ -253,16 +352,20 @@
253352 if (debugMessageBoxNode)
254353 ENABLE_DEBUG_MESSAGE_BOX = ToBool(debugMessageBoxNode->text);
255354
355+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadShimSettings::Exit");
256356 return hr;
257357
258358 Error:
259359
260360 hr = E_FAIL;
361+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadShimSettings::FailExit");
261362 return hr;
262363 }
263364
264365 HRESULT ShimArguments::ReadShimDefaults(MSXML::IXMLDOMNodePtr document)
265366 {
367+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadShimDefaults::Enter");
368+
266369 HRESULT hr = S_OK;
267370 MSXML::IXMLDOMNodePtr extensibilityDefaultNode = nullptr;
268371 MSXML::IXMLDOMNodePtr extensibilityFailNode = nullptr;
@@ -275,16 +378,20 @@
275378 EXTENSIBILITY_DEFAULT_RESULT = stol(extensibilityDefaultNode->text.copy());
276379 EXTENSIBILITY_FAIL_RESULT = stol(extensibilityFailNode->text.copy());
277380
381+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadShimDefaults::Exit");
278382 return hr;
279383
280384 Error:
281385
282386 hr = E_FAIL;
387+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadShimDefaults::FailExit");
283388 return hr;
284389 }
285390
286391 HRESULT ShimArguments::ReadManagedAddinAggregator(MSXML::IXMLDOMNodePtr document)
287392 {
393+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadManagedAddinAggregator::Enter");
394+
288395 HRESULT hr = S_OK;
289396 PathParser parser;
290397 MSXML::IXMLDOMNodePtr folderPathNode = nullptr;
@@ -324,8 +431,8 @@
324431 targetClassName = document->selectSingleNode("/ShimLoader/ManagedAddinAggregator/Target/ClassName");
325432 IfNullGo(targetClassName);
326433
327- IfFailGo(parser.ParseEx(folderPathNode->text, folderPathSubFolderNode->text, TargetManagedAggregator_Folder, MAX_PATH + 1));
328- IfFailGo(parser.ParseEx(appDomainFolderPathNode->text, appDomainSubFolderNode->text, TargetManagedAggregator_AppDomain_BaseFolder, MAX_PATH + 1));
434+ IfFailGo(parser.ParseEx(folderPathNode->text, folderPathSubFolderNode->text, TargetManagedAggregator_Folder, MAX_PATH + 1, _documentPath));
435+ IfFailGo(parser.ParseEx(appDomainFolderPathNode->text, appDomainSubFolderNode->text, TargetManagedAggregator_AppDomain_BaseFolder, MAX_PATH + 1, _documentPath));
329436
330437 lstrcpyn(TargetManagedAggregator_AssemblyName, assemblyNameNode->text, MAX_PATH + 1);
331438 lstrcpyn(TargetManagedAggregator_ClassName, classNameNode->text, MAX_PATH + 1);
@@ -335,16 +442,20 @@
335442 lstrcpyn(Target_ConfigFileName, targetConfigFileName->text, MAX_PATH + 1);
336443 lstrcpyn(Target_ConnectClassName, targetClassName->text, MAX_PATH + 1);
337444
445+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadManagedAddinAggregator::Exit");
338446 return hr;
339447
340448 Error:
341449
342450 hr = E_FAIL;
451+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadManagedAddinAggregator::FailExit");
343452 return hr;
344453 }
345454
346455 HRESULT ShimArguments::ReadManagedUpdateAggregator(MSXML::IXMLDOMNodePtr document)
347456 {
457+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadManagedUpdateAggregator::Enter");
458+
348459 HRESULT hr = S_OK;
349460 PathParser parser;
350461
@@ -387,8 +498,8 @@
387498 targetClassName = document->selectSingleNode("/ShimLoader/ManagedUpdateAggregator/Target/ClassName");
388499 IfNullGo(targetClassName);
389500
390- IfFailGo(parser.ParseEx(folderPathNode->text, folderPathSubFolderNode->text, UpdateManagedAggregator_Folder, MAX_PATH + 1));
391- IfFailGo(parser.ParseEx(appDomainFolderPathNode->text, appDomainSubFolderNode->text, UpdateManagedAggregator_AppDomain_BaseFolder, MAX_PATH + 1));
501+ IfFailGo(parser.ParseEx(folderPathNode->text, folderPathSubFolderNode->text, UpdateManagedAggregator_Folder, MAX_PATH + 1, _documentPath));
502+ IfFailGo(parser.ParseEx(appDomainFolderPathNode->text, appDomainSubFolderNode->text, UpdateManagedAggregator_AppDomain_BaseFolder, MAX_PATH + 1, _documentPath));
392503
393504 lstrcpyn(UpdateManagedAggregator_AssemblyName, assemblyNameNode->text, MAX_PATH + 1);
394505 lstrcpyn(UpdateManagedAggregator_ClassName, classNameNode->text, MAX_PATH + 1);
@@ -398,17 +509,19 @@
398509 lstrcpyn(Update_ConfigFileName, targetConfigFileName->text, MAX_PATH + 1);
399510 lstrcpyn(Update_ConnectClassName, targetClassName->text, MAX_PATH + 1);
400511
512+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadManagedUpdateAggregator::Exit");
401513 return hr;
402514
403515 Error:
404516
405517 hr = E_FAIL;
518+ NetOffice_ShimLoader_Analytics::WriteLog(L"ShimArguments::ReadManagedUpdateAggregator::FailExit");
406519 return hr;
407520 }
408521
409522 HRESULT ShimArguments::ComInitialize()
410523 {
411- HRESULT hr = E_FAIL;
524+ HRESULT hr = S_OK;
412525
413526 if (!_coInitialized)
414527 {
--- NetOfficeShimLoader/ShimLoader/ShimArguments.h (revision 192)
+++ NetOfficeShimLoader/ShimLoader/ShimArguments.h (revision 193)
@@ -46,10 +46,13 @@
4646 HRESULT ReadManagedAddinAggregator(MSXML::IXMLDOMNodePtr document);
4747 HRESULT ReadManagedUpdateAggregator(MSXML::IXMLDOMNodePtr document);
4848
49+ MSXML::IXMLDOMDocument2Ptr LoadFile(WCHAR* fileName);
50+
4951 HRESULT ComInitialize();
5052 HRESULT ComUninitialize();
5153 BOOL ToBool(_bstr_t value);
5254
55+ WCHAR _documentPath[MAX_PATH +1];
5356 MSXML::IXMLDOMDocument2Ptr _document;
5457 bool _coInitialized;
5558 HRESULT _readState;
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
--- Source/PowerPoint/Behind/DispatchInterfaces/Point.cs (revision 192)
+++ Source/PowerPoint/Behind/DispatchInterfaces/Point.cs (revision 193)
@@ -7,7 +7,7 @@
77 namespace NetOffice.PowerPointApi.Behind
88 {
99 /// <summary>
10- /// DispatchInterface Point
10+ /// DispatchInterface Point
1111 /// SupportByVersion PowerPoint, 14,15,16
1212 /// </summary>
1313 /// <remarks> MSDN Online: http://msdn.microsoft.com/en-us/en-us/library/office/ff746485.aspx </remarks>
@@ -57,9 +57,9 @@
5757 _type = typeof(Point); return _type;
5858 }
5959 }
60-
60+
6161 #endregion
62-
62+
6363 #region Ctor
6464
6565 /// <summary>
@@ -71,9 +71,9 @@
7171 }
7272
7373 #endregion
74-
75- #region Properties
7674
75+ #region Properties
76+
7777 /// <summary>
7878 /// SupportByVersion PowerPoint 14, 15, 16
7979 /// Get
Show on old repository browser