Revision | 190 (tree) |
---|---|
Time | 2018-07-19 13:11:51 |
Author | sebastiandotnet |
- fix unsafe string cpy/cat methods
@@ -66,8 +66,7 @@ | ||
66 | 66 | ICLRRuntimeInfo* runtimeInfo = nullptr; |
67 | 67 | ICorRuntimeHost* runtimeHost = nullptr; |
68 | 68 | |
69 | - WCHAR directoryPath[MAX_PATH + 1]; | |
70 | - IfFailGo(GetDllDirectory(directoryPath, ARRAYSIZE(directoryPath))); | |
69 | + auto directoryPath = UpdateManagedAggregator_Folder; | |
71 | 70 | |
72 | 71 | WCHAR fullInnerAddinFilePath[MAX_PATH + 1]; |
73 | 72 | IfFailGo(AppendPath(fullInnerAddinFilePath, directoryPath)); |
@@ -59,8 +59,7 @@ | ||
59 | 59 | ICLRRuntimeInfo* runtimeInfo = nullptr; |
60 | 60 | ICorRuntimeHost* runtimeHost = nullptr; |
61 | 61 | |
62 | - WCHAR directoryPath[MAX_PATH + 1]; | |
63 | - IfFailGo(GetDllDirectory(directoryPath, ARRAYSIZE(directoryPath))); | |
62 | + auto directoryPath = TargetManagedAggregator_Folder; | |
64 | 63 | |
65 | 64 | WCHAR fullInnerAddinFilePath[MAX_PATH + 1]; |
66 | 65 | IfFailGo(AppendPath(fullInnerAddinFilePath, directoryPath)); |
@@ -85,7 +84,7 @@ | ||
85 | 84 | |
86 | 85 | IfFailGo(runtimeHost->CreateDomainSetup(&unkAppDomainSetup)); |
87 | 86 | IfFailGo(unkAppDomainSetup->QueryInterface(__uuidof(pDomainSetup), (LPVOID*)&pDomainSetup)); |
88 | - pDomainSetup->put_ApplicationBase(CComBSTR(directoryPath)); | |
87 | + pDomainSetup->put_ApplicationBase(CComBSTR(TargetManagedAggregator_AppDomain_BaseFolder)); | |
89 | 88 | |
90 | 89 | if (PathFileExists(fullInnerAddinConfigFilePath)) |
91 | 90 | { |
@@ -92,7 +91,8 @@ | ||
92 | 91 | IfFailGo(pDomainSetup->put_ConfigurationFile(fullInnerAddinConfigFilePath)); |
93 | 92 | } |
94 | 93 | |
95 | - IfFailGo(runtimeHost->CreateDomainEx(T2W(directoryPath), pDomainSetup, 0, &unkAppDomain)); | |
94 | + auto appDomainFriendlyName = wcslen(TargetManagedAggregator_AppDomain_FriendlyName) > 0 ? T2W(TargetManagedAggregator_AppDomain_FriendlyName) : T2W(directoryPath); | |
95 | + IfFailGo(runtimeHost->CreateDomainEx(appDomainFriendlyName, pDomainSetup, 0, &unkAppDomain)); | |
96 | 96 | IfFailGo(unkAppDomain->QueryInterface(__uuidof(_appDomain), (LPVOID*)&_appDomain)); |
97 | 97 | IfFailGo(_appDomain->CreateInstance( |
98 | 98 | CComBSTR(TargetManagedAggregator_AssemblyName), |
@@ -13,8 +13,8 @@ | ||
13 | 13 | HRESULT UnRegisterCOMAddin(LPCWSTR pszOfficeApp, LPCWSTR pszProgID, bool registerPerMachine); |
14 | 14 | |
15 | 15 | HKEY TargetRootKey(RegisterMode mode); |
16 | - void ProgIdSubKey(LPCWSTR progId, RegisterMode mode, WCHAR* progIdKey); | |
17 | - void ClassIdSubKey(LPCWSTR classId, RegisterMode mode, WCHAR* classIdKey); | |
16 | + void ProgIdSubKey(LPCWSTR progId, RegisterMode mode, WCHAR* progIdKey, int maxLen); | |
17 | + void ClassIdSubKey(LPCWSTR classId, RegisterMode mode, WCHAR* classIdKey, int maxLen); | |
18 | 18 | BOOL SetKeyAndValue(HKEY hKeyRoot, LPCWSTR pszPath, LPCWSTR pszSubkey1, LPCWSTR pszSubkey2, LPCWSTR pszSubkey3, LPCWSTR pszvalueName, LPCWSTR pszValue); |
19 | 19 | LONG RecursiveDeleteKey(HKEY hKeyParent, LPCWSTR pszKeyChild); |
20 | 20 | LONG RecursiveDeleteKey(HKEY hKeyParent, LPCWSTR pszKeyChild, LPCWSTR pszKeyChild2); |
@@ -95,10 +95,10 @@ | ||
95 | 95 | HKEY targetRootKey = TargetRootKey(mode); |
96 | 96 | |
97 | 97 | WCHAR classIdKey[512]; |
98 | - ClassIdSubKey(classId, mode, classIdKey); | |
98 | + ClassIdSubKey(classId, mode, classIdKey, 512); | |
99 | 99 | |
100 | 100 | WCHAR progIdKey[512]; |
101 | - ProgIdSubKey(progId, mode, progIdKey); | |
101 | + ProgIdSubKey(progId, mode, progIdKey, 512); | |
102 | 102 | |
103 | 103 | // Target Key ProgId |
104 | 104 | if (!SetKeyAndValue(targetRootKey, progIdKey, NULL, NULL, NULL, NULL, progId)) |
@@ -152,9 +152,9 @@ | ||
152 | 152 | |
153 | 153 | HKEY hKeyRoot = TargetRootKey(mode); |
154 | 154 | WCHAR classIdKey[512]; |
155 | - ClassIdSubKey(classId, mode, classIdKey); | |
155 | + ClassIdSubKey(classId, mode, classIdKey, 512); | |
156 | 156 | WCHAR progIdKey[512]; |
157 | - ProgIdSubKey(progId, mode, progIdKey); | |
157 | + ProgIdSubKey(progId, mode, progIdKey, 512); | |
158 | 158 | |
159 | 159 | if (mode != User) |
160 | 160 | { |
@@ -181,10 +181,10 @@ | ||
181 | 181 | bool keyCreated = false; |
182 | 182 | HKEY hKey; |
183 | 183 | |
184 | - lstrcpy(szKeyBuf, L"Software\\Microsoft\\Office\\"); | |
185 | - lstrcat(szKeyBuf, pszOfficeApp); | |
186 | - lstrcat(szKeyBuf, L"\\Addins\\"); | |
187 | - lstrcat(szKeyBuf, pszProgID); | |
184 | + StringCchCopy(szKeyBuf, 1024, L"Software\\Microsoft\\Office\\"); | |
185 | + StringCchCat(szKeyBuf, 1024, pszOfficeApp); | |
186 | + StringCchCat(szKeyBuf, 1024, L"\\Addins\\"); | |
187 | + StringCchCat(szKeyBuf, 1024, pszProgID); | |
188 | 188 | |
189 | 189 | HKEY root = registerPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
190 | 190 | IfFailGo(RegCreateKeyEx(root, szKeyBuf, 0, NULL, REG_OPTION_NON_VOLATILE, _regKeyOptions, NULL, &hKey, NULL)); |
@@ -227,10 +227,10 @@ | ||
227 | 227 | |
228 | 228 | HKEY root = registerPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
229 | 229 | WCHAR szKeyBuf[1024]; |
230 | - lstrcpy(szKeyBuf, L"Software\\Microsoft\\Office\\"); | |
231 | - lstrcat(szKeyBuf, pszOfficeApp); | |
232 | - lstrcat(szKeyBuf, L"\\Addins\\"); | |
233 | - lstrcat(szKeyBuf, pszProgID); | |
230 | + StringCchCopy(szKeyBuf, 1024, L"Software\\Microsoft\\Office\\"); | |
231 | + StringCchCat(szKeyBuf, 1024, pszOfficeApp); | |
232 | + StringCchCat(szKeyBuf, 1024, L"\\Addins\\"); | |
233 | + StringCchCat(szKeyBuf, 1024, pszProgID); | |
234 | 234 | |
235 | 235 | HRESULT hr = RecursiveDeleteKey(root, szKeyBuf); |
236 | 236 | if (E_ACCESSDENIED != hr) // if key is missing - we dont care |
@@ -254,16 +254,16 @@ | ||
254 | 254 | return hKeyRoot; |
255 | 255 | } |
256 | 256 | |
257 | - void ClassIdSubKey(LPCWSTR classId, RegisterMode mode, WCHAR* classIdKey) | |
257 | + void ClassIdSubKey(LPCWSTR classId, RegisterMode mode, WCHAR* classIdKey, int maxLen) | |
258 | 258 | { |
259 | - lstrcpy(classIdKey, L"Software\\Classes\\CLSID\\"); | |
260 | - lstrcat(classIdKey, classId); | |
259 | + StringCchCopy(classIdKey, maxLen, L"Software\\Classes\\CLSID\\"); | |
260 | + StringCchCat(classIdKey, maxLen, classId); | |
261 | 261 | } |
262 | 262 | |
263 | - void ProgIdSubKey(LPCWSTR progId, RegisterMode mode, WCHAR* progIdKey) | |
263 | + void ProgIdSubKey(LPCWSTR progId, RegisterMode mode, WCHAR* progIdKey, int maxLen) | |
264 | 264 | { |
265 | - lstrcpy(progIdKey, L"Software\\Classes\\"); | |
266 | - lstrcat(progIdKey, progId); | |
265 | + StringCchCopy(progIdKey, maxLen, L"Software\\Classes\\"); | |
266 | + StringCchCat(progIdKey, maxLen, progId); | |
267 | 267 | } |
268 | 268 | |
269 | 269 | BOOL SetKeyAndValue(HKEY hKeyRoot, LPCWSTR pszPath, LPCWSTR pszSubkey1, LPCWSTR pszSubkey2, LPCWSTR pszSubkey3, LPCWSTR pszvalueName, LPCWSTR pszValue) |
@@ -271,22 +271,22 @@ | ||
271 | 271 | HKEY hKey; |
272 | 272 | WCHAR szKeyBuf[1024]; |
273 | 273 | |
274 | - lstrcpy(szKeyBuf, pszPath); | |
274 | + StringCchCopy(szKeyBuf, 1024, pszPath); | |
275 | 275 | |
276 | 276 | if (pszSubkey1 != NULL) |
277 | 277 | { |
278 | - lstrcat(szKeyBuf, L"\\"); | |
279 | - lstrcat(szKeyBuf, pszSubkey1); | |
278 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
279 | + StringCchCat(szKeyBuf, 1024, pszSubkey1); | |
280 | 280 | } |
281 | 281 | if (pszSubkey2 != NULL) |
282 | 282 | { |
283 | - lstrcat(szKeyBuf, L"\\"); | |
284 | - lstrcat(szKeyBuf, pszSubkey2); | |
283 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
284 | + StringCchCat(szKeyBuf, 1024, pszSubkey2); | |
285 | 285 | } |
286 | 286 | if (pszSubkey3 != NULL) |
287 | 287 | { |
288 | - lstrcat(szKeyBuf, L"\\"); | |
289 | - lstrcat(szKeyBuf, pszSubkey3); | |
288 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
289 | + StringCchCat(szKeyBuf, 1024, pszSubkey3); | |
290 | 290 | } |
291 | 291 | |
292 | 292 | // if its return 5 - E_ACCESS_DENIED |
@@ -310,9 +310,9 @@ | ||
310 | 310 | LONG RecursiveDeleteKey(HKEY hKeyParent, LPCWSTR pszKeyChild, LPCWSTR pszKeyChild2) |
311 | 311 | { |
312 | 312 | WCHAR szKeyBuf[1024]; |
313 | - lstrcpy(szKeyBuf, pszKeyChild); | |
314 | - lstrcat(szKeyBuf, L"\\"); | |
315 | - lstrcat(szKeyBuf, pszKeyChild2); | |
313 | + StringCchCopy(szKeyBuf, 1024, pszKeyChild); | |
314 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
315 | + StringCchCat(szKeyBuf, 1024, pszKeyChild2); | |
316 | 316 | return RecursiveDeleteKey(hKeyParent, szKeyBuf); |
317 | 317 | } |
318 | 318 |
@@ -319,11 +319,11 @@ | ||
319 | 319 | LONG RecursiveDeleteKey(HKEY hKeyParent, LPCWSTR pszKeyChild, LPCWSTR pszKeyChild2, LPCWSTR pszKeyChild3) |
320 | 320 | { |
321 | 321 | WCHAR szKeyBuf[1024]; |
322 | - lstrcpy(szKeyBuf, pszKeyChild); | |
323 | - lstrcat(szKeyBuf, L"\\"); | |
324 | - lstrcat(szKeyBuf, pszKeyChild2); | |
325 | - lstrcat(szKeyBuf, L"\\"); | |
326 | - lstrcat(szKeyBuf, pszKeyChild3); | |
322 | + StringCchCopy(szKeyBuf, 1024, pszKeyChild); | |
323 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
324 | + StringCchCat(szKeyBuf, 1024, pszKeyChild2); | |
325 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
326 | + StringCchCat(szKeyBuf, 1024, pszKeyChild3); | |
327 | 327 | return RecursiveDeleteKey(hKeyParent, szKeyBuf); |
328 | 328 | } |
329 | 329 |
@@ -13,8 +13,8 @@ | ||
13 | 13 | HRESULT UnRegisterCOMAddin(LPCWSTR pszOfficeApp, LPCWSTR pszProgID, bool registerPerMachine); |
14 | 14 | |
15 | 15 | HKEY TargetRootKey(RegisterMode mode); |
16 | - void ProgIdSubKey(LPCWSTR progId, RegisterMode mode, WCHAR* progIdKey); | |
17 | - void ClassIdSubKey(LPCWSTR classId, RegisterMode mode, WCHAR* classIdKey); | |
16 | + void ProgIdSubKey(LPCWSTR progId, RegisterMode mode, WCHAR* progIdKey, int maxLen); | |
17 | + void ClassIdSubKey(LPCWSTR classId, RegisterMode mode, WCHAR* classIdKey, int maxLen); | |
18 | 18 | BOOL SetKeyAndValue(HKEY hKeyRoot, LPCWSTR pszPath, LPCWSTR pszSubkey1, LPCWSTR pszSubkey2, LPCWSTR pszSubkey3, LPCWSTR pszvalueName, LPCWSTR pszValue); |
19 | 19 | LONG RecursiveDeleteKey(HKEY hKeyParent, LPCWSTR pszKeyChild); |
20 | 20 | LONG RecursiveDeleteKey(HKEY hKeyParent, LPCWSTR pszKeyChild, LPCWSTR pszKeyChild2); |
@@ -95,10 +95,10 @@ | ||
95 | 95 | HKEY targetRootKey = TargetRootKey(mode); |
96 | 96 | |
97 | 97 | WCHAR classIdKey[512]; |
98 | - ClassIdSubKey(classId, mode, classIdKey); | |
98 | + ClassIdSubKey(classId, mode, classIdKey, 512); | |
99 | 99 | |
100 | 100 | WCHAR progIdKey[512]; |
101 | - ProgIdSubKey(progId, mode, progIdKey); | |
101 | + ProgIdSubKey(progId, mode, progIdKey, 512); | |
102 | 102 | |
103 | 103 | // Target Key ProgId |
104 | 104 | if (!SetKeyAndValue(targetRootKey, progIdKey, NULL, NULL, NULL, NULL, progId)) |
@@ -152,9 +152,9 @@ | ||
152 | 152 | |
153 | 153 | HKEY hKeyRoot = TargetRootKey(mode); |
154 | 154 | WCHAR classIdKey[512]; |
155 | - ClassIdSubKey(classId, mode, classIdKey); | |
155 | + ClassIdSubKey(classId, mode, classIdKey, 512); | |
156 | 156 | WCHAR progIdKey[512]; |
157 | - ProgIdSubKey(progId, mode, progIdKey); | |
157 | + ProgIdSubKey(progId, mode, progIdKey, 512); | |
158 | 158 | |
159 | 159 | if (mode != User) |
160 | 160 | { |
@@ -181,10 +181,10 @@ | ||
181 | 181 | bool keyCreated = false; |
182 | 182 | HKEY hKey; |
183 | 183 | |
184 | - lstrcpy(szKeyBuf, L"Software\\Microsoft\\Office\\"); | |
185 | - lstrcat(szKeyBuf, pszOfficeApp); | |
186 | - lstrcat(szKeyBuf, L"\\Addins\\"); | |
187 | - lstrcat(szKeyBuf, pszProgID); | |
184 | + StringCchCopy(szKeyBuf, 1024, L"Software\\Microsoft\\Office\\"); | |
185 | + StringCchCat(szKeyBuf, 1024, pszOfficeApp); | |
186 | + StringCchCat(szKeyBuf, 1024, L"\\Addins\\"); | |
187 | + StringCchCat(szKeyBuf, 1024, pszProgID); | |
188 | 188 | |
189 | 189 | HKEY root = registerPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
190 | 190 | IfFailGo(RegCreateKeyEx(root, szKeyBuf, 0, NULL, REG_OPTION_NON_VOLATILE, _regKeyOptions, NULL, &hKey, NULL)); |
@@ -227,10 +227,10 @@ | ||
227 | 227 | |
228 | 228 | HKEY root = registerPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
229 | 229 | WCHAR szKeyBuf[1024]; |
230 | - lstrcpy(szKeyBuf, L"Software\\Microsoft\\Office\\"); | |
231 | - lstrcat(szKeyBuf, pszOfficeApp); | |
232 | - lstrcat(szKeyBuf, L"\\Addins\\"); | |
233 | - lstrcat(szKeyBuf, pszProgID); | |
230 | + StringCchCopy(szKeyBuf, 1024, L"Software\\Microsoft\\Office\\"); | |
231 | + StringCchCat(szKeyBuf, 1024, pszOfficeApp); | |
232 | + StringCchCat(szKeyBuf, 1024, L"\\Addins\\"); | |
233 | + StringCchCat(szKeyBuf, 1024, pszProgID); | |
234 | 234 | |
235 | 235 | HRESULT hr = RecursiveDeleteKey(root, szKeyBuf); |
236 | 236 | if (E_ACCESSDENIED != hr) // if key is missing - we dont care |
@@ -254,16 +254,16 @@ | ||
254 | 254 | return hKeyRoot; |
255 | 255 | } |
256 | 256 | |
257 | - void ClassIdSubKey(LPCWSTR classId, RegisterMode mode, WCHAR* classIdKey) | |
257 | + void ClassIdSubKey(LPCWSTR classId, RegisterMode mode, WCHAR* classIdKey, int maxLen) | |
258 | 258 | { |
259 | - lstrcpy(classIdKey, L"Software\\Classes\\CLSID\\"); | |
260 | - lstrcat(classIdKey, classId); | |
259 | + StringCchCopy(classIdKey, maxLen, L"Software\\Classes\\CLSID\\"); | |
260 | + StringCchCat(classIdKey, maxLen, classId); | |
261 | 261 | } |
262 | 262 | |
263 | - void ProgIdSubKey(LPCWSTR progId, RegisterMode mode, WCHAR* progIdKey) | |
263 | + void ProgIdSubKey(LPCWSTR progId, RegisterMode mode, WCHAR* progIdKey, int maxLen) | |
264 | 264 | { |
265 | - lstrcpy(progIdKey, L"Software\\Classes\\"); | |
266 | - lstrcat(progIdKey, progId); | |
265 | + StringCchCopy(progIdKey, maxLen, L"Software\\Classes\\"); | |
266 | + StringCchCat(progIdKey, maxLen, progId); | |
267 | 267 | } |
268 | 268 | |
269 | 269 | BOOL SetKeyAndValue(HKEY hKeyRoot, LPCWSTR pszPath, LPCWSTR pszSubkey1, LPCWSTR pszSubkey2, LPCWSTR pszSubkey3, LPCWSTR pszvalueName, LPCWSTR pszValue) |
@@ -271,22 +271,22 @@ | ||
271 | 271 | HKEY hKey; |
272 | 272 | WCHAR szKeyBuf[1024]; |
273 | 273 | |
274 | - lstrcpy(szKeyBuf, pszPath); | |
274 | + StringCchCopy(szKeyBuf, 1024, pszPath); | |
275 | 275 | |
276 | 276 | if (pszSubkey1 != NULL) |
277 | 277 | { |
278 | - lstrcat(szKeyBuf, L"\\"); | |
279 | - lstrcat(szKeyBuf, pszSubkey1); | |
278 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
279 | + StringCchCat(szKeyBuf, 1024, pszSubkey1); | |
280 | 280 | } |
281 | 281 | if (pszSubkey2 != NULL) |
282 | 282 | { |
283 | - lstrcat(szKeyBuf, L"\\"); | |
284 | - lstrcat(szKeyBuf, pszSubkey2); | |
283 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
284 | + StringCchCat(szKeyBuf, 1024, pszSubkey2); | |
285 | 285 | } |
286 | 286 | if (pszSubkey3 != NULL) |
287 | 287 | { |
288 | - lstrcat(szKeyBuf, L"\\"); | |
289 | - lstrcat(szKeyBuf, pszSubkey3); | |
288 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
289 | + StringCchCat(szKeyBuf, 1024, pszSubkey3); | |
290 | 290 | } |
291 | 291 | |
292 | 292 | // if its return 5 - E_ACCESS_DENIED |
@@ -310,9 +310,9 @@ | ||
310 | 310 | LONG RecursiveDeleteKey(HKEY hKeyParent, LPCWSTR pszKeyChild, LPCWSTR pszKeyChild2) |
311 | 311 | { |
312 | 312 | WCHAR szKeyBuf[1024]; |
313 | - lstrcpy(szKeyBuf, pszKeyChild); | |
314 | - lstrcat(szKeyBuf, L"\\"); | |
315 | - lstrcat(szKeyBuf, pszKeyChild2); | |
313 | + StringCchCopy(szKeyBuf, 1024, pszKeyChild); | |
314 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
315 | + StringCchCat(szKeyBuf, 1024, pszKeyChild2); | |
316 | 316 | return RecursiveDeleteKey(hKeyParent, szKeyBuf); |
317 | 317 | } |
318 | 318 |
@@ -319,11 +319,11 @@ | ||
319 | 319 | LONG RecursiveDeleteKey(HKEY hKeyParent, LPCWSTR pszKeyChild, LPCWSTR pszKeyChild2, LPCWSTR pszKeyChild3) |
320 | 320 | { |
321 | 321 | WCHAR szKeyBuf[1024]; |
322 | - lstrcpy(szKeyBuf, pszKeyChild); | |
323 | - lstrcat(szKeyBuf, L"\\"); | |
324 | - lstrcat(szKeyBuf, pszKeyChild2); | |
325 | - lstrcat(szKeyBuf, L"\\"); | |
326 | - lstrcat(szKeyBuf, pszKeyChild3); | |
322 | + StringCchCopy(szKeyBuf, 1024, pszKeyChild); | |
323 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
324 | + StringCchCat(szKeyBuf, 1024, pszKeyChild2); | |
325 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
326 | + StringCchCat(szKeyBuf, 1024, pszKeyChild3); | |
327 | 327 | return RecursiveDeleteKey(hKeyParent, szKeyBuf); |
328 | 328 | } |
329 | 329 |
@@ -13,8 +13,8 @@ | ||
13 | 13 | HRESULT UnRegisterCOMAddin(LPCWSTR pszOfficeApp, LPCWSTR pszProgID, bool registerPerMachine); |
14 | 14 | |
15 | 15 | HKEY TargetRootKey(RegisterMode mode); |
16 | - void ProgIdSubKey(LPCWSTR progId, RegisterMode mode, WCHAR* progIdKey); | |
17 | - void ClassIdSubKey(LPCWSTR classId, RegisterMode mode, WCHAR* classIdKey); | |
16 | + void ProgIdSubKey(LPCWSTR progId, RegisterMode mode, WCHAR* progIdKey, int maxLen); | |
17 | + void ClassIdSubKey(LPCWSTR classId, RegisterMode mode, WCHAR* classIdKey, int maxLen); | |
18 | 18 | BOOL SetKeyAndValue(HKEY hKeyRoot, LPCWSTR pszPath, LPCWSTR pszSubkey1, LPCWSTR pszSubkey2, LPCWSTR pszSubkey3, LPCWSTR pszvalueName, LPCWSTR pszValue); |
19 | 19 | LONG RecursiveDeleteKey(HKEY hKeyParent, LPCWSTR pszKeyChild); |
20 | 20 | LONG RecursiveDeleteKey(HKEY hKeyParent, LPCWSTR pszKeyChild, LPCWSTR pszKeyChild2); |
@@ -95,10 +95,10 @@ | ||
95 | 95 | HKEY targetRootKey = TargetRootKey(mode); |
96 | 96 | |
97 | 97 | WCHAR classIdKey[512]; |
98 | - ClassIdSubKey(classId, mode, classIdKey); | |
98 | + ClassIdSubKey(classId, mode, classIdKey, 512); | |
99 | 99 | |
100 | 100 | WCHAR progIdKey[512]; |
101 | - ProgIdSubKey(progId, mode, progIdKey); | |
101 | + ProgIdSubKey(progId, mode, progIdKey, 512); | |
102 | 102 | |
103 | 103 | // Target Key ProgId |
104 | 104 | if (!SetKeyAndValue(targetRootKey, progIdKey, NULL, NULL, NULL, NULL, progId)) |
@@ -152,9 +152,9 @@ | ||
152 | 152 | |
153 | 153 | HKEY hKeyRoot = TargetRootKey(mode); |
154 | 154 | WCHAR classIdKey[512]; |
155 | - ClassIdSubKey(classId, mode, classIdKey); | |
155 | + ClassIdSubKey(classId, mode, classIdKey, 512); | |
156 | 156 | WCHAR progIdKey[512]; |
157 | - ProgIdSubKey(progId, mode, progIdKey); | |
157 | + ProgIdSubKey(progId, mode, progIdKey, 512); | |
158 | 158 | |
159 | 159 | if (mode != User) |
160 | 160 | { |
@@ -181,10 +181,10 @@ | ||
181 | 181 | bool keyCreated = false; |
182 | 182 | HKEY hKey; |
183 | 183 | |
184 | - lstrcpy(szKeyBuf, L"Software\\Microsoft\\Office\\"); | |
185 | - lstrcat(szKeyBuf, pszOfficeApp); | |
186 | - lstrcat(szKeyBuf, L"\\Addins\\"); | |
187 | - lstrcat(szKeyBuf, pszProgID); | |
184 | + StringCchCopy(szKeyBuf, 1024, L"Software\\Microsoft\\Office\\"); | |
185 | + StringCchCat(szKeyBuf, 1024, pszOfficeApp); | |
186 | + StringCchCat(szKeyBuf, 1024, L"\\Addins\\"); | |
187 | + StringCchCat(szKeyBuf, 1024, pszProgID); | |
188 | 188 | |
189 | 189 | HKEY root = registerPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
190 | 190 | IfFailGo(RegCreateKeyEx(root, szKeyBuf, 0, NULL, REG_OPTION_NON_VOLATILE, _regKeyOptions, NULL, &hKey, NULL)); |
@@ -227,10 +227,10 @@ | ||
227 | 227 | |
228 | 228 | HKEY root = registerPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
229 | 229 | WCHAR szKeyBuf[1024]; |
230 | - lstrcpy(szKeyBuf, L"Software\\Microsoft\\Office\\"); | |
231 | - lstrcat(szKeyBuf, pszOfficeApp); | |
232 | - lstrcat(szKeyBuf, L"\\Addins\\"); | |
233 | - lstrcat(szKeyBuf, pszProgID); | |
230 | + StringCchCopy(szKeyBuf, 1024, L"Software\\Microsoft\\Office\\"); | |
231 | + StringCchCat(szKeyBuf, 1024, pszOfficeApp); | |
232 | + StringCchCat(szKeyBuf, 1024, L"\\Addins\\"); | |
233 | + StringCchCat(szKeyBuf, 1024, pszProgID); | |
234 | 234 | |
235 | 235 | HRESULT hr = RecursiveDeleteKey(root, szKeyBuf); |
236 | 236 | if (E_ACCESSDENIED != hr) // if key is missing - we dont care |
@@ -254,16 +254,16 @@ | ||
254 | 254 | return hKeyRoot; |
255 | 255 | } |
256 | 256 | |
257 | - void ClassIdSubKey(LPCWSTR classId, RegisterMode mode, WCHAR* classIdKey) | |
257 | + void ClassIdSubKey(LPCWSTR classId, RegisterMode mode, WCHAR* classIdKey, int maxLen) | |
258 | 258 | { |
259 | - lstrcpy(classIdKey, L"Software\\Classes\\CLSID\\"); | |
260 | - lstrcat(classIdKey, classId); | |
259 | + StringCchCopy(classIdKey, maxLen, L"Software\\Classes\\CLSID\\"); | |
260 | + StringCchCat(classIdKey, maxLen, classId); | |
261 | 261 | } |
262 | 262 | |
263 | - void ProgIdSubKey(LPCWSTR progId, RegisterMode mode, WCHAR* progIdKey) | |
263 | + void ProgIdSubKey(LPCWSTR progId, RegisterMode mode, WCHAR* progIdKey, int maxLen) | |
264 | 264 | { |
265 | - lstrcpy(progIdKey, L"Software\\Classes\\"); | |
266 | - lstrcat(progIdKey, progId); | |
265 | + StringCchCopy(progIdKey, maxLen, L"Software\\Classes\\"); | |
266 | + StringCchCat(progIdKey, maxLen, progId); | |
267 | 267 | } |
268 | 268 | |
269 | 269 | BOOL SetKeyAndValue(HKEY hKeyRoot, LPCWSTR pszPath, LPCWSTR pszSubkey1, LPCWSTR pszSubkey2, LPCWSTR pszSubkey3, LPCWSTR pszvalueName, LPCWSTR pszValue) |
@@ -271,22 +271,22 @@ | ||
271 | 271 | HKEY hKey; |
272 | 272 | WCHAR szKeyBuf[1024]; |
273 | 273 | |
274 | - lstrcpy(szKeyBuf, pszPath); | |
274 | + StringCchCopy(szKeyBuf, 1024, pszPath); | |
275 | 275 | |
276 | 276 | if (pszSubkey1 != NULL) |
277 | 277 | { |
278 | - lstrcat(szKeyBuf, L"\\"); | |
279 | - lstrcat(szKeyBuf, pszSubkey1); | |
278 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
279 | + StringCchCat(szKeyBuf, 1024, pszSubkey1); | |
280 | 280 | } |
281 | 281 | if (pszSubkey2 != NULL) |
282 | 282 | { |
283 | - lstrcat(szKeyBuf, L"\\"); | |
284 | - lstrcat(szKeyBuf, pszSubkey2); | |
283 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
284 | + StringCchCat(szKeyBuf, 1024, pszSubkey2); | |
285 | 285 | } |
286 | 286 | if (pszSubkey3 != NULL) |
287 | 287 | { |
288 | - lstrcat(szKeyBuf, L"\\"); | |
289 | - lstrcat(szKeyBuf, pszSubkey3); | |
288 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
289 | + StringCchCat(szKeyBuf, 1024, pszSubkey3); | |
290 | 290 | } |
291 | 291 | |
292 | 292 | // if its return 5 - E_ACCESS_DENIED |
@@ -310,9 +310,9 @@ | ||
310 | 310 | LONG RecursiveDeleteKey(HKEY hKeyParent, LPCWSTR pszKeyChild, LPCWSTR pszKeyChild2) |
311 | 311 | { |
312 | 312 | WCHAR szKeyBuf[1024]; |
313 | - lstrcpy(szKeyBuf, pszKeyChild); | |
314 | - lstrcat(szKeyBuf, L"\\"); | |
315 | - lstrcat(szKeyBuf, pszKeyChild2); | |
313 | + StringCchCopy(szKeyBuf, 1024, pszKeyChild); | |
314 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
315 | + StringCchCat(szKeyBuf, 1024, pszKeyChild2); | |
316 | 316 | return RecursiveDeleteKey(hKeyParent, szKeyBuf); |
317 | 317 | } |
318 | 318 |
@@ -319,11 +319,11 @@ | ||
319 | 319 | LONG RecursiveDeleteKey(HKEY hKeyParent, LPCWSTR pszKeyChild, LPCWSTR pszKeyChild2, LPCWSTR pszKeyChild3) |
320 | 320 | { |
321 | 321 | WCHAR szKeyBuf[1024]; |
322 | - lstrcpy(szKeyBuf, pszKeyChild); | |
323 | - lstrcat(szKeyBuf, L"\\"); | |
324 | - lstrcat(szKeyBuf, pszKeyChild2); | |
325 | - lstrcat(szKeyBuf, L"\\"); | |
326 | - lstrcat(szKeyBuf, pszKeyChild3); | |
322 | + StringCchCopy(szKeyBuf, 1024, pszKeyChild); | |
323 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
324 | + StringCchCat(szKeyBuf, 1024, pszKeyChild2); | |
325 | + StringCchCat(szKeyBuf, 1024, L"\\"); | |
326 | + StringCchCat(szKeyBuf, 1024, pszKeyChild3); | |
327 | 327 | return RecursiveDeleteKey(hKeyParent, szKeyBuf); |
328 | 328 | } |
329 | 329 |
@@ -40,8 +40,8 @@ | ||
40 | 40 | </Shim> |
41 | 41 | <ManagedAddinAggregator> |
42 | 42 | <Folder> |
43 | - <Path>LocalAppData</Path> | |
44 | - <SubFolder>NetOffice\InnerAddin\1.0.0.0</SubFolder> | |
43 | + <Path></Path> | |
44 | + <SubFolder></SubFolder> | |
45 | 45 | </Folder> |
46 | 46 | <AssemblyName>NetOffice, PublicKeyToken=82590859a0ddadaf</AssemblyName> |
47 | 47 | <ClassName>NetOffice.Tools.Isolation.ManagedInnerComAggregator</ClassName> |
@@ -48,8 +48,8 @@ | ||
48 | 48 | <AppDomain> |
49 | 49 | <FriendlyName></FriendlyName> |
50 | 50 | <Folder> |
51 | - <Path>LocalAppData</Path> | |
52 | - <SubFolder>NetOffice\InnerAddin\1.0.0.0</SubFolder> | |
51 | + <Path></Path> | |
52 | + <SubFolder></SubFolder> | |
53 | 53 | </Folder> |
54 | 54 | </AppDomain> |
55 | 55 | <Target> |
@@ -61,8 +61,8 @@ | ||
61 | 61 | </ManagedAddinAggregator> |
62 | 62 | <ManagedUpdateAggregator> |
63 | 63 | <Folder> |
64 | - <Path>LocalAppData</Path> | |
65 | - <SubFolder>NetOffice\InnerAddin\1.0.0.0</SubFolder> | |
64 | + <Path></Path> | |
65 | + <SubFolder></SubFolder> | |
66 | 66 | </Folder> |
67 | 67 | <AssemblyName>InnerUpdate, PublicKeyToken=e58b77e9e2189611</AssemblyName> |
68 | 68 | <ClassName>NetOffice.Tools.Isolation.ManagedInnerUpdateAggregator</ClassName> |