• R/O
  • SSH
  • HTTPS

netoffice: Commit


Commit MetaInfo

Revision192 (tree)
Time2018-07-20 02:19:59
Authorsebastiandotnet

Log Message

- bring shim custom reg keys to work

Change Summary

Incremental Difference

--- NetOfficeShimLoader/ShimLoader/CustomRegisterValue.cpp (revision 191)
+++ NetOfficeShimLoader/ShimLoader/CustomRegisterValue.cpp (revision 192)
@@ -1,5 +1,6 @@
11 #include "stdafx.h"
22 #include "CustomRegisterValue.h"
3+#include <ctime>
34
45 namespace NetOffice_ShimLoader_Register
56 {
@@ -12,13 +13,15 @@
1213 /*_name = nullptr;
1314 _kind = 0;
1415 _value = nullptr;*/
16+ _parseValue = FALSE;
1517 }
1618
17- CustomRegisterValue::CustomRegisterValue(_bstr_t name, _bstr_t kind, _bstr_t value)
19+ CustomRegisterValue::CustomRegisterValue(_bstr_t name, _bstr_t kind, _bstr_t value, BOOL parseValue)
1820 {
1921 _name = name;
2022 _kind = kind;
2123 _value = value;
24+ _parseValue = parseValue;
2225 }
2326
2427 CustomRegisterValue::~CustomRegisterValue()
@@ -52,6 +55,38 @@
5255 return _value;
5356 }
5457
58+ void CustomRegisterValue::ProcessedValue(WCHAR* buffer, int maxLen)
59+ {
60+ time_t t = time(NULL);
61+ struct tm buf;
62+
63+ if (_parseValue && 0 == wcscmp(_value, L"$LocalTime"))
64+ {
65+ if(NULL == localtime_s(&buf, &t))
66+ wcsftime(buffer, maxLen, L"%d-%m-%Y %I:%M:%S", &buf);
67+ else
68+ StringCchCopy(buffer, maxLen, _value);
69+ }
70+ else if (_parseValue && 0 == wcscmp(_value, L"$LocalTimeUSFormat"))
71+ {
72+ if (NULL == localtime_s(&buf, &t))
73+ wcsftime(buffer, maxLen, L"%m/%d/%Y %I:%M:%S", &buf);
74+ else
75+ StringCchCopy(buffer, maxLen, _value);
76+ }
77+ else if (_parseValue && 0 == wcscmp(_value, L"$LocalTimeDEFormat"))
78+ {
79+ if (NULL == localtime_s(&buf, &t))
80+ wcsftime(buffer, maxLen, L"%d.%m.%Y %I:%M:%S", &buf);
81+ else
82+ StringCchCopy(buffer, maxLen, _value);
83+ }
84+ else
85+ {
86+ StringCchCopy(buffer, maxLen, _value);
87+ }
88+ }
89+
5590 DWORD CustomRegisterValue::RegKind()
5691 {
5792 if (0 == wcscmp(_kind, L"REG_DWORD"))
--- NetOfficeShimLoader/ShimLoader/CustomRegisterValue.h (revision 191)
+++ NetOfficeShimLoader/ShimLoader/CustomRegisterValue.h (revision 192)
@@ -8,7 +8,7 @@
88
99 // Ctor, Dtor
1010 CustomRegisterValue();
11- CustomRegisterValue(_bstr_t name, _bstr_t kind, _bstr_t value);
11+ CustomRegisterValue(_bstr_t name, _bstr_t kind, _bstr_t value, BOOL parseValue);
1212 virtual ~CustomRegisterValue();
1313
1414 // CustomRegisterValue Methods
@@ -16,6 +16,8 @@
1616 _bstr_t Name();
1717 _bstr_t Kind();
1818 _bstr_t Value();
19+ void ProcessedValue(WCHAR* buffer, int maxLen);
20+
1921 DWORD RegKind();
2022
2123 private:
@@ -23,8 +25,9 @@
2325 _bstr_t _name;
2426 _bstr_t _kind;
2527 _bstr_t _value;
28+ BOOL _parseValue;
2629 };
2730
28- // Pointer to PCustomRegisterValue
31+ // Pointer to CustomRegisterValue
2932 typedef CustomRegisterValue* PCustomRegisterValue;
3033 }
--- NetOfficeShimLoader/ShimLoader/DllRegister32.cpp (revision 191)
+++ NetOfficeShimLoader/ShimLoader/DllRegister32.cpp (revision 192)
@@ -44,7 +44,7 @@
4444 hr = RegisterCOMComponent(module, progId, classId, version, description, mode);
4545 if (SUCCEEDED(hr) && addinRegistration)
4646 {
47- size_t arraySize = (sizeof(officeApplications) / sizeof(*officeApplications));
47+ size_t arraySize = ShimProxy_Host_Application_Length;
4848 for (size_t i = 0; i < arraySize; i++)
4949 {
5050 hr = RegisterCOMAddin(officeApplications[i], progId, friendlyName, description, addinLoadBehavior, addinCommandLineSafe, System == mode);
@@ -72,7 +72,7 @@
7272
7373 if (addinRegistration)
7474 {
75- size_t arraySize = (sizeof(officeApplications) / sizeof(*officeApplications));
75+ size_t arraySize = ShimProxy_Host_Application_Length;
7676 for (size_t i = 0; i < arraySize; i++)
7777 {
7878 if (!SUCCEEDED(UnRegisterCOMAddin(officeApplications[i], progId, 0 == mode)))
@@ -213,7 +213,7 @@
213213
214214 if (NULL != Custom_Register_Values)
215215 {
216- size_t arraySize = (sizeof(Custom_Register_Values) / sizeof(*Custom_Register_Values));
216+ size_t arraySize = Custom_Register_Values_Length;
217217 for (size_t i = 0; i < arraySize; i++)
218218 {
219219 auto value = Custom_Register_Values[i];
--- NetOfficeShimLoader/ShimLoader/DllRegister32On64.cpp (revision 191)
+++ NetOfficeShimLoader/ShimLoader/DllRegister32On64.cpp (revision 192)
@@ -44,7 +44,7 @@
4444 hr = RegisterCOMComponent(module, progId, classId, version, description, mode);
4545 if (SUCCEEDED(hr) && addinRegistration)
4646 {
47- size_t arraySize = (sizeof(officeApplications) / sizeof(*officeApplications));
47+ size_t arraySize = ShimProxy_Host_Application_Length;
4848 for (size_t i = 0; i < arraySize; i++)
4949 {
5050 hr = RegisterCOMAddin(officeApplications[i], progId, friendlyName, description, addinLoadBehavior, addinCommandLineSafe, System == mode);
@@ -72,7 +72,7 @@
7272
7373 if (addinRegistration)
7474 {
75- size_t arraySize = (sizeof(officeApplications) / sizeof(*officeApplications));
75+ size_t arraySize = ShimProxy_Host_Application_Length;
7676 for (size_t i = 0; i < arraySize; i++)
7777 {
7878 if (!SUCCEEDED(UnRegisterCOMAddin(officeApplications[i], progId, 0 == mode)))
@@ -213,11 +213,11 @@
213213
214214 if (NULL != Custom_Register_Values)
215215 {
216- size_t arraySize = (sizeof(Custom_Register_Values) / sizeof(*Custom_Register_Values));
216+ size_t arraySize = Custom_Register_Values_Length;
217217 for (size_t i = 0; i < arraySize; i++)
218218 {
219219 auto value = Custom_Register_Values[i];
220- if(value->SeemsToBeValid())
220+ if (value->SeemsToBeValid())
221221 SetCustomValue(hKey, value);
222222 }
223223 }
@@ -256,14 +256,17 @@
256256
257257 HRESULT SetCustomValue(HKEY hKey, PCustomRegisterValue value)
258258 {
259+ WCHAR valueBuffer[256];
260+ value->ProcessedValue(valueBuffer, 256);
261+
259262 DWORD dwTemp = 0;
260263 #if UNICODE
261- dwTemp = lstrlen(value->Value()) * 2 + 2;
264+ dwTemp = lstrlen(valueBuffer) * 2 + 2;
262265 #else
263- dwTemp = lstrlen(value->Value()) + 1;
266+ dwTemp = lstrlen(valueBuffer) + 1;
264267 #endif
265268
266- return RegSetValueEx(hKey, value->Name(), 0, value->RegKind(), (BYTE*)value->Value().copy(), dwTemp);
269+ return RegSetValueEx(hKey, value->Name(), 0, value->RegKind(), (BYTE*)valueBuffer, dwTemp);
267270 }
268271
269272 HKEY TargetRootKey(RegisterMode mode)
--- NetOfficeShimLoader/ShimLoader/DllRegister64.cpp (revision 191)
+++ NetOfficeShimLoader/ShimLoader/DllRegister64.cpp (revision 192)
@@ -44,7 +44,7 @@
4444 hr = RegisterCOMComponent(module, progId, classId, version, description, mode);
4545 if (SUCCEEDED(hr) && addinRegistration)
4646 {
47- size_t arraySize = (sizeof(officeApplications) / sizeof(*officeApplications));
47+ size_t arraySize = ShimProxy_Host_Application_Length;
4848 for (size_t i = 0; i < arraySize; i++)
4949 {
5050 hr = RegisterCOMAddin(officeApplications[i], progId, friendlyName, description, addinLoadBehavior, addinCommandLineSafe, System == mode);
@@ -72,7 +72,7 @@
7272
7373 if (addinRegistration)
7474 {
75- size_t arraySize = (sizeof(officeApplications) / sizeof(*officeApplications));
75+ size_t arraySize = ShimProxy_Host_Application_Length;
7676 for (size_t i = 0; i < arraySize; i++)
7777 {
7878 if (!SUCCEEDED(UnRegisterCOMAddin(officeApplications[i], progId, 0 == mode)))
@@ -213,7 +213,7 @@
213213
214214 if (NULL != Custom_Register_Values)
215215 {
216- size_t arraySize = (sizeof(Custom_Register_Values) / sizeof(*Custom_Register_Values));
216+ size_t arraySize = Custom_Register_Values_Length;
217217 for (size_t i = 0; i < arraySize; i++)
218218 {
219219 auto value = Custom_Register_Values[i];
--- NetOfficeShimLoader/ShimLoader/Manifest.xml (revision 191)
+++ NetOfficeShimLoader/ShimLoader/Manifest.xml (revision 192)
@@ -13,6 +13,7 @@
1313 <Addin>
1414 <Applications>
1515 <PowerPoint></PowerPoint>
16+ <Word></Word>
1617 </Applications>
1718 <FriendlyName>NetOffice Generic COM Shim</FriendlyName>
1819 <Description>Shim Loader supplied by NetOffice</Description>
@@ -23,7 +24,14 @@
2324 <Name>Greetings</Name>
2425 <Type>REG_SZ</Type>
2526 <Value>Greetings from Shim Register</Value>
27+ <ParseValue>false</ParseValue>
2628 </CustomReg>
29+ <CustomReg>
30+ <Name>CreatedAt</Name>
31+ <Type>REG_SZ</Type>
32+ <Value>$LocalTime</Value>
33+ <ParseValue>true</ParseValue>
34+ </CustomReg>
2735 </CustomRegs>
2836 </Addin>
2937 </Register>
--- NetOfficeShimLoader/ShimLoader/ShimArguments.cpp (revision 191)
+++ NetOfficeShimLoader/ShimLoader/ShimArguments.cpp (revision 192)
@@ -171,6 +171,7 @@
171171 addins = document->selectNodes("/ShimLoader/Shim/Register/Addin/Applications/*");
172172 IfNullGo(addins);
173173
174+ ShimProxy_Host_Application_Length = addins->length;
174175 ShimProxy_Host_Application = new LPCWSTR[addins->length];
175176 for (int i = 0; i < addins->length; i++)
176177 {
@@ -197,6 +198,7 @@
197198 customRegs = document->selectNodes("/ShimLoader/Shim/Register/Addin/CustomRegs/CustomReg");
198199 if (customRegs)
199200 {
201+ Custom_Register_Values_Length = customRegs->length;
200202 Custom_Register_Values = new PCustomRegisterValue[customRegs->length];
201203 for (int i = 0; i < customRegs->length; i++)
202204 {
@@ -206,12 +208,15 @@
206208 auto nameNode = domNode->selectSingleNode("Name");
207209 auto typeNode = domNode->selectSingleNode("Type");
208210 auto valueNode = domNode->selectSingleNode("Value");
211+ auto parseValueNode = domNode->selectSingleNode("ParseValue");
212+
209213 if (nameNode && typeNode && valueNode)
210214 {
211215 auto theName = nameNode->text.copy(true);
212216 auto theType = typeNode->text.copy(true);
213217 auto theValue = valueNode->text.copy(true);
214- Custom_Register_Values[i] = new CustomRegisterValue(theName, theType, theValue);
218+ auto parseTheValue = NULL != parseValueNode ? ToBool(parseValueNode->text) : FALSE;
219+ Custom_Register_Values[i] = new CustomRegisterValue(theName, theType, theValue, parseTheValue);
215220 }
216221 domNode->Release();
217222 }
--- NetOfficeShimLoader/ShimLoader/Vars.h (revision 191)
+++ NetOfficeShimLoader/ShimLoader/Vars.h (revision 192)
@@ -33,9 +33,10 @@
3333 extern DWORD ShimProxy_LoadBehavior;
3434 extern DWORD ShimProxy_CommandLineSafe;
3535 extern LPCWSTR* ShimProxy_Host_Application;
36+extern size_t ShimProxy_Host_Application_Length;
3637 extern PCustomRegisterValue* Custom_Register_Values;
38+extern size_t Custom_Register_Values_Length;
3739
38-
3940 //
4041 // Managed Update Aggregator
4142 //
--- NetOfficeShimLoader/ShimLoader/Vars.hpp (revision 191)
+++ NetOfficeShimLoader/ShimLoader/Vars.hpp (revision 192)
@@ -33,9 +33,10 @@
3333 DWORD ShimProxy_LoadBehavior = 3;
3434 DWORD ShimProxy_CommandLineSafe = 0;
3535 LPCWSTR* ShimProxy_Host_Application = nullptr;
36+size_t ShimProxy_Host_Application_Length = 0;
3637 PCustomRegisterValue* Custom_Register_Values = nullptr;
38+size_t Custom_Register_Values_Length = 0;
3739
38-
3940 //
4041 // Managed Update Aggregator
4142 //
Show on old repository browser