registry.c (958f1add) registry.c (0f67ae4b)
1/*
2 * Implementation of the Microsoft Installer (msi.dll)
3 *
4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Aric Stewart for CodeWeavers
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public

--- 24 unchanged lines hidden (view full) ---

33#include "msipriv.h"
34#include "wincrypt.h"
35#include "winver.h"
36#include "winuser.h"
37#include "sddl.h"
38
39WINE_DEFAULT_DEBUG_CHANNEL(msi);
40
1/*
2 * Implementation of the Microsoft Installer (msi.dll)
3 *
4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Aric Stewart for CodeWeavers
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public

--- 24 unchanged lines hidden (view full) ---

33#include "msipriv.h"
34#include "wincrypt.h"
35#include "winver.h"
36#include "winuser.h"
37#include "sddl.h"
38
39WINE_DEFAULT_DEBUG_CHANNEL(msi);
40
41/*
42 * This module will be all the helper functions for registry access by the
43 * installer bits.
44 */
45
46static const WCHAR szUserDataFeatures_fmt[] = {
47 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
48 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
49 'I','n','s','t','a','l','l','e','r','\\','U','s','e','r','D','a','t','a','\\',
50 '%','s','\\','P','r','o','d','u','c','t','s','\\','%','s','\\','F','e','a','t','u','r','e','s',0};
51
52static const WCHAR szUserDataComp_fmt[] = {
53 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
54 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
55 'I','n','s','t','a','l','l','e','r','\\','U','s','e','r','D','a','t','a','\\',
56 '%','s','\\','C','o','m','p','o','n','e','n','t','s','\\','%','s',0};
57
58static const WCHAR szUserDataComponents_fmt[] = {
59 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
60 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
61 'I','n','s','t','a','l','l','e','r','\\','U','s','e','r','D','a','t','a','\\',
62 '%','s','\\','C','o','m','p','o','n','e','n','t','s',0};
63
64static const WCHAR szUserDataProd_fmt[] = {
65 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
66 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
67 'I','n','s','t','a','l','l','e','r','\\','U','s','e','r','D','a','t','a','\\',
68 '%','s','\\','P','r','o','d','u','c','t','s','\\','%','s',0};
69
70static const WCHAR szUserDataProducts_fmt[] = {
71 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
72 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
73 'I','n','s','t','a','l','l','e','r','\\','U','s','e','r','D','a','t','a','\\',
74 '%','s','\\','P','r','o','d','u','c','t','s',0};
75
76static const WCHAR szUserDataPatch_fmt[] = {
77 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
78 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
79 'I','n','s','t','a','l','l','e','r','\\','U','s','e','r','D','a','t','a','\\',
80 '%','s','\\','P','a','t','c','h','e','s','\\','%','s',0};
81
82static const WCHAR szUserDataPatches_fmt[] = {
83 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
84 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
85 'I','n','s','t','a','l','l','e','r','\\','U','s','e','r','D','a','t','a','\\',
86 '%','s','\\','P','a','t','c','h','e','s',0};
87
88static const WCHAR szUserDataProductPatches_fmt[] = {
89 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
90 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
91 'I','n','s','t','a','l','l','e','r','\\','U','s','e','r','D','a','t','a','\\',
92 '%','s','\\','P','r','o','d','u','c','t','s','\\','%','s','\\','P','a','t','c','h','e','s',0};
93
94static const WCHAR szInstallProperties_fmt[] = {
95 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
96 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
97 'I','n','s','t','a','l','l','e','r','\\','U','s','e','r','D','a','t','a','\\',
98 '%','s','\\','P','r','o','d','u','c','t','s','\\','%','s','\\',
99 'I','n','s','t','a','l','l','P','r','o','p','e','r','t','i','e','s',0};
100
101static const WCHAR szInstaller_LocalManagedProd_fmt[] = {
102 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
103 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
104 'I','n','s','t','a','l','l','e','r','\\','M','a','n','a','g','e','d','\\','%','s','\\',
105 'I','n','s','t','a','l','l','e','r','\\','P','r','o','d','u','c','t','s','\\','%','s',0};
106
107static const WCHAR szInstaller_LocalManagedFeat_fmt[] = {
108 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
109 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
110 'I','n','s','t','a','l','l','e','r','\\','M','a','n','a','g','e','d','\\','%','s','\\',
111 'I','n','s','t','a','l','l','e','r','\\','F','e','a','t','u','r','e','s','\\','%','s',0};
112
113static const WCHAR szInstaller_Products[] = {
114 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
115 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
116 'I','n','s','t','a','l','l','e','r','\\','P','r','o','d','u','c','t','s',0};
117
118static const WCHAR szInstaller_Patches[] = {
119 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
120 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
121 'I','n','s','t','a','l','l','e','r','\\','P','a','t','c','h','e','s',0};
122
123static const WCHAR szInstaller_LocalClassesProducts[] = {
124 'S','o','f','t','w','a','r','e','\\','C','l','a','s','s','e','s','\\',
125 'I','n','s','t','a','l','l','e','r','\\','P','r','o','d','u','c','t','s',0};
126
127static const WCHAR szInstaller_LocalClassesFeatures[] = {
128 'S','o','f','t','w','a','r','e','\\','C','l','a','s','s','e','s','\\',
129 'I','n','s','t','a','l','l','e','r','\\','F','e','a','t','u','r','e','s',0};
130
131static const WCHAR szInstaller_LocalClassesProd[] = {
132 'S','o','f','t','w','a','r','e','\\','C','l','a','s','s','e','s','\\',
133 'I','n','s','t','a','l','l','e','r','\\','P','r','o','d','u','c','t','s','\\',0};
134
135static const WCHAR szInstaller_LocalClassesFeat[] = {
136 'S','o','f','t','w','a','r','e','\\','C','l','a','s','s','e','s','\\',
137 'I','n','s','t','a','l','l','e','r','\\','F','e','a','t','u','r','e','s','\\',0};
138
139static const WCHAR szInstaller_ClassesUpgradeCode[] = {
140 'S','o','f','t','w','a','r','e','\\','C','l','a','s','s','e','s','\\',
141 'I','n','s','t','a','l','l','e','r','\\','U','p','g','r','a','d','e','C','o','d','e','s','\\',0};
142
143static const WCHAR szInstaller_ClassesUpgradeCodes[] = {
144 'S','o','f','t','w','a','r','e','\\','C','l','a','s','s','e','s','\\',
145 'I','n','s','t','a','l','l','e','r','\\','U','p','g','r','a','d','e','C','o','d','e','s',0};
146
147static const WCHAR szInstaller_Features[] = {
148 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
149 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
150 'I','n','s','t','a','l','l','e','r','\\','F','e','a','t','u','r','e','s','\\',0};
151
152static const WCHAR szInstaller_UpgradeCodes[] = {
153 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
154 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
155 'I','n','s','t','a','l','l','e','r','\\','U','p','g','r','a','d','e','C','o','d','e','s','\\',0};
156
157static const WCHAR szInstaller_UserUpgradeCodes[] = {
158 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
159 'I','n','s','t','a','l','l','e','r','\\','U','p','g','r','a','d','e','C','o','d','e','s','\\',0};
160
161static const WCHAR szUninstall[] = {
162 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
163 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
164 'U','n','i','n','s','t','a','l','l','\\',0};
165
166static const WCHAR szUserComponents[] = {
167 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
168 'I','n','s','t','a','l','l','e','r','\\','C','o','m','p','o','n','e','n','t','s','\\',0};
169
170static const WCHAR szInstaller_Components[] = {
171 'S','o','f','t','w','a','r','e','\\','C','l','a','s','s','e','s','\\',
172 'I','n','s','t','a','l','l','e','r','\\','C','o','m','p','o','n','e','n','t','s','\\',0};
173
174static const WCHAR szUserFeatures[] = {
175 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
176 'I','n','s','t','a','l','l','e','r','\\','F','e','a','t','u','r','e','s','\\',0};
177
178static const WCHAR szUserProducts[] = {
179 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
180 'I','n','s','t','a','l','l','e','r','\\','P','r','o','d','u','c','t','s','\\',0};
181
182static const WCHAR szUserPatches[] = {
183 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
184 'I','n','s','t','a','l','l','e','r','\\','P','a','t','c','h','e','s','\\',0};
185
186BOOL unsquash_guid(LPCWSTR in, LPWSTR out)
187{
188 DWORD i,n=0;
189
190 if (lstrlenW(in) != 32)
191 return FALSE;
192
193 out[n++]='{';

--- 155 unchanged lines hidden (view full) ---

349 }
350
351 return MAKELONG(build, MAKEWORD(minor, major));
352}
353
354LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value )
355{
356 DWORD len;
41BOOL unsquash_guid(LPCWSTR in, LPWSTR out)
42{
43 DWORD i,n=0;
44
45 if (lstrlenW(in) != 32)
46 return FALSE;
47
48 out[n++]='{';

--- 155 unchanged lines hidden (view full) ---

204 }
205
206 return MAKELONG(build, MAKEWORD(minor, major));
207}
208
209LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value )
210{
211 DWORD len;
357 if (!value) value = szEmpty;
212 if (!value) value = L"";
358 len = (lstrlenW(value) + 1) * sizeof (WCHAR);
359 return RegSetValueExW( hkey, name, 0, REG_SZ, (const BYTE *)value, len );
360}
361
362LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value )
363{
364 LPCWSTR p = value;
365 while (*p) p += lstrlenW(p) + 1;

--- 84 unchanged lines hidden (view full) ---

450 WCHAR keypath[0x200];
451
452 TRACE("%s\n", debugstr_w(product));
453
454 if (platform == PLATFORM_INTEL)
455 access |= KEY_WOW64_32KEY;
456 else
457 access |= KEY_WOW64_64KEY;
213 len = (lstrlenW(value) + 1) * sizeof (WCHAR);
214 return RegSetValueExW( hkey, name, 0, REG_SZ, (const BYTE *)value, len );
215}
216
217LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value )
218{
219 LPCWSTR p = value;
220 while (*p) p += lstrlenW(p) + 1;

--- 84 unchanged lines hidden (view full) ---

305 WCHAR keypath[0x200];
306
307 TRACE("%s\n", debugstr_w(product));
308
309 if (platform == PLATFORM_INTEL)
310 access |= KEY_WOW64_32KEY;
311 else
312 access |= KEY_WOW64_64KEY;
458 lstrcpyW(keypath, szUninstall);
313 lstrcpyW(keypath, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
459 lstrcatW(keypath, product);
460 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
461 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
462}
463
464UINT MSIREG_DeleteUninstallKey(const WCHAR *product, enum platform platform)
465{
466 REGSAM access = KEY_ALL_ACCESS;
467 HKEY parent;
468 LONG r;
469
470 TRACE("%s\n", debugstr_w(product));
471
472 if (platform == PLATFORM_INTEL)
473 access |= KEY_WOW64_32KEY;
474 else
475 access |= KEY_WOW64_64KEY;
314 lstrcatW(keypath, product);
315 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
316 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
317}
318
319UINT MSIREG_DeleteUninstallKey(const WCHAR *product, enum platform platform)
320{
321 REGSAM access = KEY_ALL_ACCESS;
322 HKEY parent;
323 LONG r;
324
325 TRACE("%s\n", debugstr_w(product));
326
327 if (platform == PLATFORM_INTEL)
328 access |= KEY_WOW64_32KEY;
329 else
330 access |= KEY_WOW64_64KEY;
476 if ((r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szUninstall, 0, access, &parent)))
477 return r;
331 if ((r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\",
332 0, access, &parent))) return r;
478 r = RegDeleteTreeW(parent, product);
479 RegCloseKey(parent);
480 return r;
481}
482
483UINT MSIREG_OpenProductKey(LPCWSTR szProduct, LPCWSTR szUserSid, MSIINSTALLCONTEXT context, HKEY *key, BOOL create)
484{
485 HKEY root = HKEY_LOCAL_MACHINE;
486 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
487 WCHAR *usersid = NULL, squashed_pc[SQUASHED_GUID_SIZE], keypath[MAX_PATH];
488
489 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
490 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
491
492 if (context == MSIINSTALLCONTEXT_MACHINE)
493 {
333 r = RegDeleteTreeW(parent, product);
334 RegCloseKey(parent);
335 return r;
336}
337
338UINT MSIREG_OpenProductKey(LPCWSTR szProduct, LPCWSTR szUserSid, MSIINSTALLCONTEXT context, HKEY *key, BOOL create)
339{
340 HKEY root = HKEY_LOCAL_MACHINE;
341 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
342 WCHAR *usersid = NULL, squashed_pc[SQUASHED_GUID_SIZE], keypath[MAX_PATH];
343
344 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
345 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
346
347 if (context == MSIINSTALLCONTEXT_MACHINE)
348 {
494 lstrcpyW(keypath, szInstaller_LocalClassesProd);
349 lstrcpyW(keypath, L"Software\\Classes\\Installer\\Products\\");
495 lstrcatW( keypath, squashed_pc );
496 }
497 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
498 {
499 root = HKEY_CURRENT_USER;
350 lstrcatW( keypath, squashed_pc );
351 }
352 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
353 {
354 root = HKEY_CURRENT_USER;
500 lstrcpyW(keypath, szUserProducts);
355 lstrcpyW( keypath, L"Software\\Microsoft\\Installer\\Products\\" );
501 lstrcatW( keypath, squashed_pc );
502 }
503 else
504 {
505 if (!szUserSid)
506 {
507 if (!(usersid = get_user_sid()))
508 {
509 ERR("Failed to retrieve user SID\n");
510 return ERROR_FUNCTION_FAILED;
511 }
512 szUserSid = usersid;
513 }
356 lstrcatW( keypath, squashed_pc );
357 }
358 else
359 {
360 if (!szUserSid)
361 {
362 if (!(usersid = get_user_sid()))
363 {
364 ERR("Failed to retrieve user SID\n");
365 return ERROR_FUNCTION_FAILED;
366 }
367 szUserSid = usersid;
368 }
514 swprintf( keypath, ARRAY_SIZE(keypath), szInstaller_LocalManagedProd_fmt, szUserSid, squashed_pc );
369 swprintf( keypath, ARRAY_SIZE(keypath),
370 L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\%s\\Installer\\Products\\%s",
371 szUserSid, squashed_pc );
515 LocalFree(usersid);
516 }
517 if (create) return RegCreateKeyExW(root, keypath, 0, NULL, 0, access, NULL, key, NULL);
518 return RegOpenKeyExW(root, keypath, 0, access, key);
519}
520
521UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct)
522{
523 WCHAR squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
524
525 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
526 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
527
372 LocalFree(usersid);
373 }
374 if (create) return RegCreateKeyExW(root, keypath, 0, NULL, 0, access, NULL, key, NULL);
375 return RegOpenKeyExW(root, keypath, 0, access, key);
376}
377
378UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct)
379{
380 WCHAR squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
381
382 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
383 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
384
528 lstrcpyW(keypath, szUserProducts);
385 lstrcpyW( keypath, L"Software\\Microsoft\\Installer\\Products\\" );
529 lstrcatW( keypath, squashed_pc );
530 return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
531}
532
533UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY *key, BOOL create)
534{
535 WCHAR squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
536
537 if (!squash_guid( szPatch, squashed_pc )) return ERROR_FUNCTION_FAILED;
538 TRACE("%s squashed %s\n", debugstr_w(szPatch), debugstr_w(squashed_pc));
539
386 lstrcatW( keypath, squashed_pc );
387 return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
388}
389
390UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY *key, BOOL create)
391{
392 WCHAR squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
393
394 if (!squash_guid( szPatch, squashed_pc )) return ERROR_FUNCTION_FAILED;
395 TRACE("%s squashed %s\n", debugstr_w(szPatch), debugstr_w(squashed_pc));
396
540 lstrcpyW(keypath, szUserPatches);
397 lstrcpyW( keypath, L"Software\\Microsoft\\Installer\\Patches\\" );
541 lstrcatW( keypath, squashed_pc );
542
543 if (create) return RegCreateKeyW(HKEY_CURRENT_USER, keypath, key);
544 return RegOpenKeyW(HKEY_CURRENT_USER, keypath, key);
545}
546
547UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, LPCWSTR szUserSid, MSIINSTALLCONTEXT context,
548 HKEY *key, BOOL create)
549{
550 HKEY root = HKEY_LOCAL_MACHINE;
551 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
552 WCHAR squashed_pc[SQUASHED_GUID_SIZE], keypath[MAX_PATH], *usersid = NULL;
553
554 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
555 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
556
557 if (context == MSIINSTALLCONTEXT_MACHINE)
558 {
398 lstrcatW( keypath, squashed_pc );
399
400 if (create) return RegCreateKeyW(HKEY_CURRENT_USER, keypath, key);
401 return RegOpenKeyW(HKEY_CURRENT_USER, keypath, key);
402}
403
404UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, LPCWSTR szUserSid, MSIINSTALLCONTEXT context,
405 HKEY *key, BOOL create)
406{
407 HKEY root = HKEY_LOCAL_MACHINE;
408 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
409 WCHAR squashed_pc[SQUASHED_GUID_SIZE], keypath[MAX_PATH], *usersid = NULL;
410
411 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
412 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
413
414 if (context == MSIINSTALLCONTEXT_MACHINE)
415 {
559 lstrcpyW(keypath, szInstaller_LocalClassesFeat);
416 lstrcpyW(keypath, L"Software\\Classes\\Installer\\Features\\");
560 lstrcatW( keypath, squashed_pc );
561 }
562 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
563 {
564 root = HKEY_CURRENT_USER;
417 lstrcatW( keypath, squashed_pc );
418 }
419 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
420 {
421 root = HKEY_CURRENT_USER;
565 lstrcpyW(keypath, szUserFeatures);
422 lstrcpyW(keypath, L"Software\\Microsoft\\Installer\\Features\\");
566 lstrcatW( keypath, squashed_pc );
567 }
568 else
569 {
570 if (!szUserSid)
571 {
572 if (!(usersid = get_user_sid()))
573 {
574 ERR("Failed to retrieve user SID\n");
575 return ERROR_FUNCTION_FAILED;
576 }
577 szUserSid = usersid;
578 }
423 lstrcatW( keypath, squashed_pc );
424 }
425 else
426 {
427 if (!szUserSid)
428 {
429 if (!(usersid = get_user_sid()))
430 {
431 ERR("Failed to retrieve user SID\n");
432 return ERROR_FUNCTION_FAILED;
433 }
434 szUserSid = usersid;
435 }
579 swprintf( keypath, ARRAY_SIZE(keypath), szInstaller_LocalManagedFeat_fmt, szUserSid, squashed_pc );
436 swprintf( keypath, ARRAY_SIZE(keypath),
437 L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\%s\\Installer\\Features\\%s",
438 szUserSid, squashed_pc );
580 LocalFree(usersid);
581 }
582 if (create) return RegCreateKeyExW(root, keypath, 0, NULL, 0, access, NULL, key, NULL);
583 return RegOpenKeyExW(root, keypath, 0, access, key);
584}
585
586UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct)
587{
588 WCHAR squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
589
590 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
591 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
592
439 LocalFree(usersid);
440 }
441 if (create) return RegCreateKeyExW(root, keypath, 0, NULL, 0, access, NULL, key, NULL);
442 return RegOpenKeyExW(root, keypath, 0, access, key);
443}
444
445UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct)
446{
447 WCHAR squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
448
449 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
450 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
451
593 lstrcpyW(keypath, szUserFeatures);
452 lstrcpyW( keypath, L"Software\\Microsoft\\Installer\\Features\\" );
594 lstrcatW( keypath, squashed_pc );
595 return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
596}
597
598static UINT MSIREG_OpenInstallerFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create)
599{
600 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
601 WCHAR squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
602
603 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
604 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
605
453 lstrcatW( keypath, squashed_pc );
454 return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
455}
456
457static UINT MSIREG_OpenInstallerFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create)
458{
459 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
460 WCHAR squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
461
462 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
463 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
464
606 lstrcpyW(keypath, szInstaller_Features);
465 lstrcpyW(keypath, L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Features\\");
607 lstrcatW( keypath, squashed_pc );
608
609 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
610 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
611}
612
613UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, LPCWSTR szUserSid, MSIINSTALLCONTEXT context,
614 HKEY *key, BOOL create)
615{
466 lstrcatW( keypath, squashed_pc );
467
468 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
469 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
470}
471
472UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, LPCWSTR szUserSid, MSIINSTALLCONTEXT context,
473 HKEY *key, BOOL create)
474{
475 static const WCHAR fmtW[] =
476 L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\%s\\Products\\%s\\Features";
616 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
617 WCHAR squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200], *usersid = NULL;
618
619 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
620 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
621
622 if (context == MSIINSTALLCONTEXT_MACHINE)
623 {
477 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
478 WCHAR squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200], *usersid = NULL;
479
480 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
481 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
482
483 if (context == MSIINSTALLCONTEXT_MACHINE)
484 {
624 swprintf( keypath, ARRAY_SIZE(keypath), szUserDataFeatures_fmt, szLocalSid, squashed_pc );
485 swprintf( keypath, ARRAY_SIZE(keypath), fmtW, L"S-1-5-18", squashed_pc );
625 }
626 else
627 {
628 if (!szUserSid)
629 {
630 if (!(usersid = get_user_sid()))
631 {
632 ERR("Failed to retrieve user SID\n");
633 return ERROR_FUNCTION_FAILED;
634 }
635 szUserSid = usersid;
636 }
486 }
487 else
488 {
489 if (!szUserSid)
490 {
491 if (!(usersid = get_user_sid()))
492 {
493 ERR("Failed to retrieve user SID\n");
494 return ERROR_FUNCTION_FAILED;
495 }
496 szUserSid = usersid;
497 }
637 swprintf( keypath, ARRAY_SIZE(keypath), szUserDataFeatures_fmt, szUserSid, squashed_pc );
498 swprintf( keypath, ARRAY_SIZE(keypath), fmtW, szUserSid, squashed_pc );
638 LocalFree(usersid);
639 }
640 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
641 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
642}
643
644UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY *key, BOOL create)
645{
646 WCHAR squashed_cc[SQUASHED_GUID_SIZE], keypath[0x200];
647 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
648 UINT ret;
649
650 if (!squash_guid( szComponent, squashed_cc)) return ERROR_FUNCTION_FAILED;
651 TRACE("%s squashed %s\n", debugstr_w(szComponent), debugstr_w(squashed_cc));
652
499 LocalFree(usersid);
500 }
501 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
502 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
503}
504
505UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY *key, BOOL create)
506{
507 WCHAR squashed_cc[SQUASHED_GUID_SIZE], keypath[0x200];
508 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
509 UINT ret;
510
511 if (!squash_guid( szComponent, squashed_cc)) return ERROR_FUNCTION_FAILED;
512 TRACE("%s squashed %s\n", debugstr_w(szComponent), debugstr_w(squashed_cc));
513
653 lstrcpyW(keypath, szUserComponents);
514 lstrcpyW(keypath, L"Software\\Microsoft\\Installer\\Components\\");
654 lstrcatW( keypath, squashed_cc );
655
656 if (create) return RegCreateKeyW(HKEY_CURRENT_USER, keypath, key);
657 ret = RegOpenKeyW(HKEY_CURRENT_USER, keypath, key);
658 if (ret != ERROR_FILE_NOT_FOUND) return ret;
659
515 lstrcatW( keypath, squashed_cc );
516
517 if (create) return RegCreateKeyW(HKEY_CURRENT_USER, keypath, key);
518 ret = RegOpenKeyW(HKEY_CURRENT_USER, keypath, key);
519 if (ret != ERROR_FILE_NOT_FOUND) return ret;
520
660 lstrcpyW(keypath, szInstaller_Components);
521 lstrcpyW(keypath, L"Software\\Classes\\Installer\\Components\\");
661 lstrcatW( keypath, squashed_cc );
662 return RegOpenKeyExW( HKEY_LOCAL_MACHINE, keypath, 0, access, key );
663}
664
665UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid, HKEY *key, BOOL create)
666{
522 lstrcatW( keypath, squashed_cc );
523 return RegOpenKeyExW( HKEY_LOCAL_MACHINE, keypath, 0, access, key );
524}
525
526UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid, HKEY *key, BOOL create)
527{
528 static const WCHAR fmtW[] =
529 L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\%s\\Components\\%s";
667 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
668 WCHAR *usersid, squashed_comp[SQUASHED_GUID_SIZE], keypath[0x200];
669
670 if (!squash_guid( szComponent, squashed_comp )) return ERROR_FUNCTION_FAILED;
671 TRACE("%s squashed %s\n", debugstr_w(szComponent), debugstr_w(squashed_comp));
672
673 if (!szUserSid)
674 {
675 if (!(usersid = get_user_sid()))
676 {
677 ERR("Failed to retrieve user SID\n");
678 return ERROR_FUNCTION_FAILED;
679 }
530 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
531 WCHAR *usersid, squashed_comp[SQUASHED_GUID_SIZE], keypath[0x200];
532
533 if (!squash_guid( szComponent, squashed_comp )) return ERROR_FUNCTION_FAILED;
534 TRACE("%s squashed %s\n", debugstr_w(szComponent), debugstr_w(squashed_comp));
535
536 if (!szUserSid)
537 {
538 if (!(usersid = get_user_sid()))
539 {
540 ERR("Failed to retrieve user SID\n");
541 return ERROR_FUNCTION_FAILED;
542 }
680 swprintf( keypath, ARRAY_SIZE(keypath), szUserDataComp_fmt, usersid, squashed_comp );
543 swprintf( keypath, ARRAY_SIZE(keypath), fmtW, usersid, squashed_comp );
681 LocalFree(usersid);
682 }
544 LocalFree(usersid);
545 }
683 else
684 swprintf( keypath, ARRAY_SIZE(keypath), szUserDataComp_fmt, szUserSid, squashed_comp );
546 else swprintf( keypath, ARRAY_SIZE(keypath), fmtW, szUserSid, squashed_comp );
685
686 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
687 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
688}
689
690UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid)
691{
547
548 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
549 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
550}
551
552UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid)
553{
554 static const WCHAR fmtW[] =
555 L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\%s\\Components";
692 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
693 WCHAR *usersid, squashed_comp[SQUASHED_GUID_SIZE], keypath[0x200];
694 HKEY hkey;
695 LONG r;
696
697 if (!squash_guid( szComponent, squashed_comp )) return ERROR_FUNCTION_FAILED;
698 TRACE("%s squashed %s\n", debugstr_w(szComponent), debugstr_w(squashed_comp));
699
700 if (!szUserSid)
701 {
702 if (!(usersid = get_user_sid()))
703 {
704 ERR("Failed to retrieve user SID\n");
705 return ERROR_FUNCTION_FAILED;
706 }
556 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
557 WCHAR *usersid, squashed_comp[SQUASHED_GUID_SIZE], keypath[0x200];
558 HKEY hkey;
559 LONG r;
560
561 if (!squash_guid( szComponent, squashed_comp )) return ERROR_FUNCTION_FAILED;
562 TRACE("%s squashed %s\n", debugstr_w(szComponent), debugstr_w(squashed_comp));
563
564 if (!szUserSid)
565 {
566 if (!(usersid = get_user_sid()))
567 {
568 ERR("Failed to retrieve user SID\n");
569 return ERROR_FUNCTION_FAILED;
570 }
707 swprintf(keypath, ARRAY_SIZE(keypath), szUserDataComponents_fmt, usersid);
571 swprintf(keypath, ARRAY_SIZE(keypath), fmtW, usersid);
708 LocalFree(usersid);
709 }
572 LocalFree(usersid);
573 }
710 else
711 swprintf(keypath, ARRAY_SIZE(keypath), szUserDataComponents_fmt, szUserSid);
574 else swprintf(keypath, ARRAY_SIZE(keypath), fmtW, szUserSid);
712
713 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey)) return ERROR_SUCCESS;
714 r = RegDeleteTreeW( hkey, squashed_comp );
715 RegCloseKey(hkey);
716 return r;
717}
718
719UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext, LPCWSTR szUserSid, HKEY *key, BOOL create)
720{
575
576 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey)) return ERROR_SUCCESS;
577 r = RegDeleteTreeW( hkey, squashed_comp );
578 RegCloseKey(hkey);
579 return r;
580}
581
582UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext, LPCWSTR szUserSid, HKEY *key, BOOL create)
583{
584 static const WCHAR fmtW[] =
585 L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\%s\\Products\\%s";
721 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
722 WCHAR *usersid, squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
723
724 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
725 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
726
727 if (dwContext == MSIINSTALLCONTEXT_MACHINE)
586 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
587 WCHAR *usersid, squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
588
589 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
590 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
591
592 if (dwContext == MSIINSTALLCONTEXT_MACHINE)
728 swprintf( keypath, ARRAY_SIZE(keypath), szUserDataProd_fmt, szLocalSid, squashed_pc );
593 swprintf( keypath, ARRAY_SIZE(keypath), fmtW, L"S-1-5-18", squashed_pc );
729 else if (szUserSid)
594 else if (szUserSid)
730 swprintf( keypath, ARRAY_SIZE(keypath), szUserDataProd_fmt, szUserSid, squashed_pc );
595 swprintf( keypath, ARRAY_SIZE(keypath), fmtW, szUserSid, squashed_pc );
731 else
732 {
733 if (!(usersid = get_user_sid()))
734 {
735 ERR("Failed to retrieve user SID\n");
736 return ERROR_FUNCTION_FAILED;
737 }
596 else
597 {
598 if (!(usersid = get_user_sid()))
599 {
600 ERR("Failed to retrieve user SID\n");
601 return ERROR_FUNCTION_FAILED;
602 }
738 swprintf( keypath, ARRAY_SIZE(keypath), szUserDataProd_fmt, usersid, squashed_pc );
603 swprintf( keypath, ARRAY_SIZE(keypath), fmtW, usersid, squashed_pc );
739 LocalFree(usersid);
740 }
741 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
742 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
743}
744
745UINT MSIREG_OpenUserDataPatchKey(LPCWSTR szPatch, MSIINSTALLCONTEXT dwContext, HKEY *key, BOOL create)
746{
604 LocalFree(usersid);
605 }
606 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
607 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
608}
609
610UINT MSIREG_OpenUserDataPatchKey(LPCWSTR szPatch, MSIINSTALLCONTEXT dwContext, HKEY *key, BOOL create)
611{
612 static const WCHAR fmtW[] =
613 L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\%s\\Patches\\%s";
747 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
748 WCHAR *usersid, squashed_patch[SQUASHED_GUID_SIZE], keypath[0x200];
749
750 if (!squash_guid( szPatch, squashed_patch )) return ERROR_FUNCTION_FAILED;
751 TRACE("%s squashed %s\n", debugstr_w(szPatch), debugstr_w(squashed_patch));
752
753 if (dwContext == MSIINSTALLCONTEXT_MACHINE)
614 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
615 WCHAR *usersid, squashed_patch[SQUASHED_GUID_SIZE], keypath[0x200];
616
617 if (!squash_guid( szPatch, squashed_patch )) return ERROR_FUNCTION_FAILED;
618 TRACE("%s squashed %s\n", debugstr_w(szPatch), debugstr_w(squashed_patch));
619
620 if (dwContext == MSIINSTALLCONTEXT_MACHINE)
754 swprintf( keypath, ARRAY_SIZE(keypath), szUserDataPatch_fmt, szLocalSid, squashed_patch );
621 swprintf( keypath, ARRAY_SIZE(keypath), fmtW, L"S-1-5-18", squashed_patch );
755 else
756 {
757 if (!(usersid = get_user_sid()))
758 {
759 ERR("Failed to retrieve user SID\n");
760 return ERROR_FUNCTION_FAILED;
761 }
622 else
623 {
624 if (!(usersid = get_user_sid()))
625 {
626 ERR("Failed to retrieve user SID\n");
627 return ERROR_FUNCTION_FAILED;
628 }
762 swprintf( keypath, ARRAY_SIZE(keypath), szUserDataPatch_fmt, usersid, squashed_patch );
629 swprintf( keypath, ARRAY_SIZE(keypath), fmtW, usersid, squashed_patch );
763 LocalFree(usersid);
764 }
765 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
766 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
767}
768
769UINT MSIREG_DeleteUserDataPatchKey(LPCWSTR patch, MSIINSTALLCONTEXT context)
770{
630 LocalFree(usersid);
631 }
632 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
633 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
634}
635
636UINT MSIREG_DeleteUserDataPatchKey(LPCWSTR patch, MSIINSTALLCONTEXT context)
637{
638 static const WCHAR fmtW[] =
639 L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\%s\\Patches";
771 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
772 WCHAR *usersid, squashed_patch[SQUASHED_GUID_SIZE], keypath[0x200];
773 HKEY hkey;
774 LONG r;
775
776 if (!squash_guid( patch, squashed_patch )) return ERROR_FUNCTION_FAILED;
777 TRACE("%s squashed %s\n", debugstr_w(patch), debugstr_w(squashed_patch));
778
779 if (context == MSIINSTALLCONTEXT_MACHINE)
640 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
641 WCHAR *usersid, squashed_patch[SQUASHED_GUID_SIZE], keypath[0x200];
642 HKEY hkey;
643 LONG r;
644
645 if (!squash_guid( patch, squashed_patch )) return ERROR_FUNCTION_FAILED;
646 TRACE("%s squashed %s\n", debugstr_w(patch), debugstr_w(squashed_patch));
647
648 if (context == MSIINSTALLCONTEXT_MACHINE)
780 swprintf(keypath, ARRAY_SIZE(keypath), szUserDataPatches_fmt, szLocalSid);
649 swprintf(keypath, ARRAY_SIZE(keypath), fmtW, L"S-1-5-18");
781 else
782 {
783 if (!(usersid = get_user_sid()))
784 {
785 ERR("Failed to retrieve user SID\n");
786 return ERROR_FUNCTION_FAILED;
787 }
650 else
651 {
652 if (!(usersid = get_user_sid()))
653 {
654 ERR("Failed to retrieve user SID\n");
655 return ERROR_FUNCTION_FAILED;
656 }
788 swprintf(keypath, ARRAY_SIZE(keypath), szUserDataPatches_fmt, usersid);
657 swprintf(keypath, ARRAY_SIZE(keypath), fmtW, usersid);
789 LocalFree(usersid);
790 }
791 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey)) return ERROR_SUCCESS;
792 r = RegDeleteTreeW( hkey, squashed_patch );
793 RegCloseKey(hkey);
794 return r;
795}
796
797UINT MSIREG_OpenUserDataProductPatchesKey(LPCWSTR product, MSIINSTALLCONTEXT context, HKEY *key, BOOL create)
798{
658 LocalFree(usersid);
659 }
660 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey)) return ERROR_SUCCESS;
661 r = RegDeleteTreeW( hkey, squashed_patch );
662 RegCloseKey(hkey);
663 return r;
664}
665
666UINT MSIREG_OpenUserDataProductPatchesKey(LPCWSTR product, MSIINSTALLCONTEXT context, HKEY *key, BOOL create)
667{
668 static const WCHAR fmtW[] =
669 L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\%s\\Products\\%s\\Patches";
799 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
800 WCHAR *usersid, squashed_product[SQUASHED_GUID_SIZE], keypath[0x200];
801
802 if (!squash_guid( product, squashed_product )) return ERROR_FUNCTION_FAILED;
803 TRACE("%s squashed %s\n", debugstr_w(product), debugstr_w(squashed_product));
804
805 if (context == MSIINSTALLCONTEXT_MACHINE)
670 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
671 WCHAR *usersid, squashed_product[SQUASHED_GUID_SIZE], keypath[0x200];
672
673 if (!squash_guid( product, squashed_product )) return ERROR_FUNCTION_FAILED;
674 TRACE("%s squashed %s\n", debugstr_w(product), debugstr_w(squashed_product));
675
676 if (context == MSIINSTALLCONTEXT_MACHINE)
806 swprintf( keypath, ARRAY_SIZE(keypath), szUserDataProductPatches_fmt, szLocalSid, squashed_product );
677 swprintf( keypath, ARRAY_SIZE(keypath), fmtW, L"S-1-5-18", squashed_product );
807 else
808 {
809 if (!(usersid = get_user_sid()))
810 {
811 ERR("Failed to retrieve user SID\n");
812 return ERROR_FUNCTION_FAILED;
813 }
678 else
679 {
680 if (!(usersid = get_user_sid()))
681 {
682 ERR("Failed to retrieve user SID\n");
683 return ERROR_FUNCTION_FAILED;
684 }
814 swprintf( keypath, ARRAY_SIZE(keypath), szUserDataProductPatches_fmt, usersid, squashed_product );
685 swprintf( keypath, ARRAY_SIZE(keypath), fmtW, usersid, squashed_product );
815 LocalFree(usersid);
816 }
817 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
818 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
819}
820
821UINT MSIREG_OpenInstallProps(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext, LPCWSTR szUserSid, HKEY *key, BOOL create)
822{
686 LocalFree(usersid);
687 }
688 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
689 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
690}
691
692UINT MSIREG_OpenInstallProps(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext, LPCWSTR szUserSid, HKEY *key, BOOL create)
693{
694 static const WCHAR fmtW[] =
695 L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\%s\\Products\\%s\\InstallProperties";
823 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
824 WCHAR *usersid, squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
825
826 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
827 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
828
829 if (dwContext == MSIINSTALLCONTEXT_MACHINE)
696 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
697 WCHAR *usersid, squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
698
699 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
700 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
701
702 if (dwContext == MSIINSTALLCONTEXT_MACHINE)
830 swprintf( keypath, ARRAY_SIZE(keypath), szInstallProperties_fmt, szLocalSid, squashed_pc );
703 swprintf( keypath, ARRAY_SIZE(keypath), fmtW, L"S-1-5-18", squashed_pc );
831 else if (szUserSid)
704 else if (szUserSid)
832 swprintf( keypath, ARRAY_SIZE(keypath), szInstallProperties_fmt, szUserSid, squashed_pc );
705 swprintf( keypath, ARRAY_SIZE(keypath), fmtW, szUserSid, squashed_pc );
833 else
834 {
835 if (!(usersid = get_user_sid()))
836 {
837 ERR("Failed to retrieve user SID\n");
838 return ERROR_FUNCTION_FAILED;
839 }
706 else
707 {
708 if (!(usersid = get_user_sid()))
709 {
710 ERR("Failed to retrieve user SID\n");
711 return ERROR_FUNCTION_FAILED;
712 }
840 swprintf( keypath, ARRAY_SIZE(keypath), szInstallProperties_fmt, usersid, squashed_pc );
713 swprintf( keypath, ARRAY_SIZE(keypath), fmtW, usersid, squashed_pc );
841 LocalFree(usersid);
842 }
843 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
844 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
845}
846
847UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context)
848{
714 LocalFree(usersid);
715 }
716 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
717 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
718}
719
720UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context)
721{
722 static const WCHAR fmtW[] =
723 L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\%s\\Products";
849 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
850 WCHAR *usersid, squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
851 HKEY hkey;
852 LONG r;
853
854 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
855 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
856
857 if (context == MSIINSTALLCONTEXT_MACHINE)
724 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
725 WCHAR *usersid, squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
726 HKEY hkey;
727 LONG r;
728
729 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
730 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
731
732 if (context == MSIINSTALLCONTEXT_MACHINE)
858 swprintf(keypath, ARRAY_SIZE(keypath), szUserDataProducts_fmt, szLocalSid);
733 swprintf(keypath, ARRAY_SIZE(keypath), fmtW, L"S-1-5-18");
859 else
860 {
861 if (!(usersid = get_user_sid()))
862 {
863 ERR("Failed to retrieve user SID\n");
864 return ERROR_FUNCTION_FAILED;
865 }
734 else
735 {
736 if (!(usersid = get_user_sid()))
737 {
738 ERR("Failed to retrieve user SID\n");
739 return ERROR_FUNCTION_FAILED;
740 }
866 swprintf(keypath, ARRAY_SIZE(keypath), szUserDataProducts_fmt, usersid);
741 swprintf(keypath, ARRAY_SIZE(keypath), fmtW, usersid);
867 LocalFree(usersid);
868 }
869
870 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey)) return ERROR_SUCCESS;
871 r = RegDeleteTreeW( hkey, squashed_pc );
872 RegCloseKey(hkey);
873 return r;
874}
875
876UINT MSIREG_DeleteProductKey(LPCWSTR szProduct)
877{
878 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
879 WCHAR squashed_pc[SQUASHED_GUID_SIZE];
880 HKEY hkey;
881 LONG r;
882
883 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
884 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
885
742 LocalFree(usersid);
743 }
744
745 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, &hkey)) return ERROR_SUCCESS;
746 r = RegDeleteTreeW( hkey, squashed_pc );
747 RegCloseKey(hkey);
748 return r;
749}
750
751UINT MSIREG_DeleteProductKey(LPCWSTR szProduct)
752{
753 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
754 WCHAR squashed_pc[SQUASHED_GUID_SIZE];
755 HKEY hkey;
756 LONG r;
757
758 if (!squash_guid( szProduct, squashed_pc )) return ERROR_FUNCTION_FAILED;
759 TRACE("%s squashed %s\n", debugstr_w(szProduct), debugstr_w(squashed_pc));
760
886 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szInstaller_Products, 0, access, &hkey)) return ERROR_SUCCESS;
761 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Products",
762 0, access, &hkey)) return ERROR_SUCCESS;
887 r = RegDeleteTreeW( hkey, squashed_pc );
888 RegCloseKey(hkey);
889 return r;
890}
891
892UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY *key, BOOL create)
893{
894 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
895 WCHAR squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
896
897 if (!squash_guid( szPatch, squashed_pc )) return ERROR_FUNCTION_FAILED;
898 TRACE("%s squashed %s\n", debugstr_w(szPatch), debugstr_w(squashed_pc));
899
763 r = RegDeleteTreeW( hkey, squashed_pc );
764 RegCloseKey(hkey);
765 return r;
766}
767
768UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY *key, BOOL create)
769{
770 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
771 WCHAR squashed_pc[SQUASHED_GUID_SIZE], keypath[0x200];
772
773 if (!squash_guid( szPatch, squashed_pc )) return ERROR_FUNCTION_FAILED;
774 TRACE("%s squashed %s\n", debugstr_w(szPatch), debugstr_w(squashed_pc));
775
900 swprintf( keypath, ARRAY_SIZE(keypath), szInstaller_Patches, squashed_pc );
776 swprintf( keypath, ARRAY_SIZE(keypath), L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Patches",
777 squashed_pc );
901
902 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
903 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
904}
905
906UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY *key, BOOL create)
907{
908 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
909 WCHAR squashed_uc[SQUASHED_GUID_SIZE], keypath[0x200];
910
911 if (!squash_guid( szUpgradeCode, squashed_uc )) return ERROR_FUNCTION_FAILED;
912 TRACE("%s squashed %s\n", debugstr_w(szUpgradeCode), debugstr_w(squashed_uc));
913
778
779 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
780 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
781}
782
783UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY *key, BOOL create)
784{
785 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
786 WCHAR squashed_uc[SQUASHED_GUID_SIZE], keypath[0x200];
787
788 if (!squash_guid( szUpgradeCode, squashed_uc )) return ERROR_FUNCTION_FAILED;
789 TRACE("%s squashed %s\n", debugstr_w(szUpgradeCode), debugstr_w(squashed_uc));
790
914 lstrcpyW(keypath, szInstaller_UpgradeCodes);
791 lstrcpyW( keypath, L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UpgradeCodes\\" );
915 lstrcatW( keypath, squashed_uc );
916
917 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
918 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
919}
920
921UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL create)
922{
923 WCHAR squashed_uc[SQUASHED_GUID_SIZE], keypath[0x200];
924
925 if (!squash_guid( szUpgradeCode, squashed_uc )) return ERROR_FUNCTION_FAILED;
926 TRACE("%s squashed %s\n", debugstr_w(szUpgradeCode), debugstr_w(squashed_uc));
927
792 lstrcatW( keypath, squashed_uc );
793
794 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
795 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
796}
797
798UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL create)
799{
800 WCHAR squashed_uc[SQUASHED_GUID_SIZE], keypath[0x200];
801
802 if (!squash_guid( szUpgradeCode, squashed_uc )) return ERROR_FUNCTION_FAILED;
803 TRACE("%s squashed %s\n", debugstr_w(szUpgradeCode), debugstr_w(squashed_uc));
804
928 lstrcpyW(keypath, szInstaller_UserUpgradeCodes);
805 lstrcpyW(keypath, L"Software\\Microsoft\\Installer\\UpgradeCodes\\");
929 lstrcatW( keypath, squashed_uc );
930
931 if (create) return RegCreateKeyW(HKEY_CURRENT_USER, keypath, key);
932 return RegOpenKeyW(HKEY_CURRENT_USER, keypath, key);
933}
934
935UINT MSIREG_DeleteUpgradeCodesKey( const WCHAR *code )
936{
937 WCHAR squashed_code[SQUASHED_GUID_SIZE];
938 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
939 HKEY hkey;
940 LONG ret;
941
942 if (!squash_guid( code, squashed_code )) return ERROR_FUNCTION_FAILED;
943 TRACE( "%s squashed %s\n", debugstr_w(code), debugstr_w(squashed_code) );
944
806 lstrcatW( keypath, squashed_uc );
807
808 if (create) return RegCreateKeyW(HKEY_CURRENT_USER, keypath, key);
809 return RegOpenKeyW(HKEY_CURRENT_USER, keypath, key);
810}
811
812UINT MSIREG_DeleteUpgradeCodesKey( const WCHAR *code )
813{
814 WCHAR squashed_code[SQUASHED_GUID_SIZE];
815 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
816 HKEY hkey;
817 LONG ret;
818
819 if (!squash_guid( code, squashed_code )) return ERROR_FUNCTION_FAILED;
820 TRACE( "%s squashed %s\n", debugstr_w(code), debugstr_w(squashed_code) );
821
945 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, szInstaller_UpgradeCodes, 0, access, &hkey )) return ERROR_SUCCESS;
822 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UpgradeCodes\\",
823 0, access, &hkey )) return ERROR_SUCCESS;
946 ret = RegDeleteTreeW( hkey, squashed_code );
947 RegCloseKey( hkey );
948 return ret;
949}
950
951UINT MSIREG_DeleteUserUpgradeCodesKey(LPCWSTR szUpgradeCode)
952{
953 WCHAR squashed_uc[SQUASHED_GUID_SIZE], keypath[0x200];
954
955 if (!squash_guid( szUpgradeCode, squashed_uc )) return ERROR_FUNCTION_FAILED;
956 TRACE("%s squashed %s\n", debugstr_w(szUpgradeCode), debugstr_w(squashed_uc));
957
824 ret = RegDeleteTreeW( hkey, squashed_code );
825 RegCloseKey( hkey );
826 return ret;
827}
828
829UINT MSIREG_DeleteUserUpgradeCodesKey(LPCWSTR szUpgradeCode)
830{
831 WCHAR squashed_uc[SQUASHED_GUID_SIZE], keypath[0x200];
832
833 if (!squash_guid( szUpgradeCode, squashed_uc )) return ERROR_FUNCTION_FAILED;
834 TRACE("%s squashed %s\n", debugstr_w(szUpgradeCode), debugstr_w(squashed_uc));
835
958 lstrcpyW(keypath, szInstaller_UserUpgradeCodes);
836 lstrcpyW(keypath, L"Software\\Microsoft\\Installer\\UpgradeCodes\\");
959 lstrcatW( keypath, squashed_uc );
960 return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
961}
962
963UINT MSIREG_DeleteLocalClassesProductKey(LPCWSTR szProductCode)
964{
965 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
966 WCHAR squashed_pc[SQUASHED_GUID_SIZE];
967 HKEY hkey;
968 LONG r;
969
970 if (!squash_guid( szProductCode, squashed_pc )) return ERROR_FUNCTION_FAILED;
971 TRACE("%s squashed %s\n", debugstr_w(szProductCode), debugstr_w(squashed_pc));
972
837 lstrcatW( keypath, squashed_uc );
838 return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
839}
840
841UINT MSIREG_DeleteLocalClassesProductKey(LPCWSTR szProductCode)
842{
843 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
844 WCHAR squashed_pc[SQUASHED_GUID_SIZE];
845 HKEY hkey;
846 LONG r;
847
848 if (!squash_guid( szProductCode, squashed_pc )) return ERROR_FUNCTION_FAILED;
849 TRACE("%s squashed %s\n", debugstr_w(szProductCode), debugstr_w(squashed_pc));
850
973 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szInstaller_LocalClassesProducts, 0, access, &hkey)) return ERROR_SUCCESS;
851 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Classes\\Installer\\Products", 0, access, &hkey))
852 return ERROR_SUCCESS;
974 r = RegDeleteTreeW( hkey, squashed_pc );
975 RegCloseKey(hkey);
976 return r;
977}
978
979UINT MSIREG_DeleteLocalClassesFeaturesKey(LPCWSTR szProductCode)
980{
981 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
982 WCHAR squashed_pc[SQUASHED_GUID_SIZE];
983 HKEY hkey;
984 LONG r;
985
986 if (!squash_guid( szProductCode, squashed_pc )) return ERROR_FUNCTION_FAILED;
987 TRACE("%s squashed %s\n", debugstr_w(szProductCode), debugstr_w(squashed_pc));
988
853 r = RegDeleteTreeW( hkey, squashed_pc );
854 RegCloseKey(hkey);
855 return r;
856}
857
858UINT MSIREG_DeleteLocalClassesFeaturesKey(LPCWSTR szProductCode)
859{
860 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
861 WCHAR squashed_pc[SQUASHED_GUID_SIZE];
862 HKEY hkey;
863 LONG r;
864
865 if (!squash_guid( szProductCode, squashed_pc )) return ERROR_FUNCTION_FAILED;
866 TRACE("%s squashed %s\n", debugstr_w(szProductCode), debugstr_w(squashed_pc));
867
989 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szInstaller_LocalClassesFeatures, 0, access, &hkey)) return ERROR_SUCCESS;
868 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Classes\\Installer\\Features", 0, access, &hkey))
869 return ERROR_SUCCESS;
990 r = RegDeleteTreeW( hkey, squashed_pc );
991 RegCloseKey(hkey);
992 return r;
993}
994
995UINT MSIREG_OpenClassesUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY *key, BOOL create)
996{
997 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
998 WCHAR squashed_uc[SQUASHED_GUID_SIZE], keypath[0x200];
999
1000 if (!squash_guid( szUpgradeCode, squashed_uc )) return ERROR_FUNCTION_FAILED;
1001 TRACE("%s squashed %s\n", debugstr_w(szUpgradeCode), debugstr_w(squashed_uc));
1002
870 r = RegDeleteTreeW( hkey, squashed_pc );
871 RegCloseKey(hkey);
872 return r;
873}
874
875UINT MSIREG_OpenClassesUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY *key, BOOL create)
876{
877 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
878 WCHAR squashed_uc[SQUASHED_GUID_SIZE], keypath[0x200];
879
880 if (!squash_guid( szUpgradeCode, squashed_uc )) return ERROR_FUNCTION_FAILED;
881 TRACE("%s squashed %s\n", debugstr_w(szUpgradeCode), debugstr_w(squashed_uc));
882
1003 lstrcpyW(keypath, szInstaller_ClassesUpgradeCode);
883 lstrcpyW(keypath, L"Software\\Classes\\Installer\\UpgradeCodes\\");
1004 lstrcatW( keypath, squashed_uc );
1005
1006 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
1007 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
1008}
1009
1010UINT MSIREG_DeleteClassesUpgradeCodesKey(LPCWSTR szUpgradeCode)
1011{
1012 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
1013 WCHAR squashed_uc[SQUASHED_GUID_SIZE];
1014 HKEY hkey;
1015 LONG r;
1016
1017 if (!squash_guid( szUpgradeCode, squashed_uc )) return ERROR_FUNCTION_FAILED;
1018 TRACE("%s squashed %s\n", debugstr_w(szUpgradeCode), debugstr_w(squashed_uc));
1019
884 lstrcatW( keypath, squashed_uc );
885
886 if (create) return RegCreateKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, key, NULL);
887 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, keypath, 0, access, key);
888}
889
890UINT MSIREG_DeleteClassesUpgradeCodesKey(LPCWSTR szUpgradeCode)
891{
892 REGSAM access = KEY_WOW64_64KEY | KEY_ALL_ACCESS;
893 WCHAR squashed_uc[SQUASHED_GUID_SIZE];
894 HKEY hkey;
895 LONG r;
896
897 if (!squash_guid( szUpgradeCode, squashed_uc )) return ERROR_FUNCTION_FAILED;
898 TRACE("%s squashed %s\n", debugstr_w(szUpgradeCode), debugstr_w(squashed_uc));
899
1020 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szInstaller_ClassesUpgradeCodes, 0, access, &hkey)) return ERROR_SUCCESS;
900 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Classes\\Installer\\UpgradeCodes", 0, access, &hkey))
901 return ERROR_SUCCESS;
1021 r = RegDeleteTreeW( hkey, squashed_uc );
1022 RegCloseKey(hkey);
1023 return r;
1024}
1025
1026/*************************************************************************
1027 * MsiDecomposeDescriptorW [MSI.@]
1028 *

--- 129 unchanged lines hidden (view full) ---

1158
1159UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid)
1160{
1161 TRACE("%d %p\n", index, lpguid);
1162
1163 if (NULL == lpguid)
1164 return ERROR_INVALID_PARAMETER;
1165
902 r = RegDeleteTreeW( hkey, squashed_uc );
903 RegCloseKey(hkey);
904 return r;
905}
906
907/*************************************************************************
908 * MsiDecomposeDescriptorW [MSI.@]
909 *

--- 129 unchanged lines hidden (view full) ---

1039
1040UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid)
1041{
1042 TRACE("%d %p\n", index, lpguid);
1043
1044 if (NULL == lpguid)
1045 return ERROR_INVALID_PARAMETER;
1046
1166 return MsiEnumProductsExW( NULL, szAllSid, MSIINSTALLCONTEXT_ALL, index, lpguid,
1047 return MsiEnumProductsExW( NULL, L"S-1-1-0", MSIINSTALLCONTEXT_ALL, index, lpguid,
1167 NULL, NULL, NULL );
1168}
1169
1048 NULL, NULL, NULL );
1049}
1050
1170UINT WINAPI MsiEnumFeaturesA(LPCSTR szProduct, DWORD index,
1171 LPSTR szFeature, LPSTR szParent)
1051UINT WINAPI MsiEnumFeaturesA(LPCSTR szProduct, DWORD index, LPSTR szFeature, LPSTR szParent)
1172{
1173 DWORD r;
1174 WCHAR szwFeature[GUID_SIZE], szwParent[GUID_SIZE];
1175 LPWSTR szwProduct = NULL;
1176
1177 TRACE("%s %d %p %p\n", debugstr_a(szProduct), index, szFeature, szParent);
1178
1179 if( szProduct )

--- 12 unchanged lines hidden (view full) ---

1192 szParent, GUID_SIZE, NULL, NULL);
1193 }
1194
1195 msi_free( szwProduct);
1196
1197 return r;
1198}
1199
1052{
1053 DWORD r;
1054 WCHAR szwFeature[GUID_SIZE], szwParent[GUID_SIZE];
1055 LPWSTR szwProduct = NULL;
1056
1057 TRACE("%s %d %p %p\n", debugstr_a(szProduct), index, szFeature, szParent);
1058
1059 if( szProduct )

--- 12 unchanged lines hidden (view full) ---

1072 szParent, GUID_SIZE, NULL, NULL);
1073 }
1074
1075 msi_free( szwProduct);
1076
1077 return r;
1078}
1079
1200UINT WINAPI MsiEnumFeaturesW(LPCWSTR szProduct, DWORD index,
1201 LPWSTR szFeature, LPWSTR szParent)
1080UINT WINAPI MsiEnumFeaturesW(LPCWSTR szProduct, DWORD index, LPWSTR szFeature, LPWSTR szParent)
1202{
1203 HKEY hkeyProduct = 0;
1204 DWORD r, sz;
1205
1206 TRACE("%s %d %p %p\n", debugstr_w(szProduct), index, szFeature, szParent);
1207
1208 if( !szProduct )
1209 return ERROR_INVALID_PARAMETER;

--- 26 unchanged lines hidden (view full) ---

1236}
1237
1238UINT WINAPI MsiEnumComponentsW(DWORD index, LPWSTR lpguid)
1239{
1240 TRACE("%u, %p\n", index, lpguid);
1241
1242 if (!lpguid) return ERROR_INVALID_PARAMETER;
1243
1081{
1082 HKEY hkeyProduct = 0;
1083 DWORD r, sz;
1084
1085 TRACE("%s %d %p %p\n", debugstr_w(szProduct), index, szFeature, szParent);
1086
1087 if( !szProduct )
1088 return ERROR_INVALID_PARAMETER;

--- 26 unchanged lines hidden (view full) ---

1115}
1116
1117UINT WINAPI MsiEnumComponentsW(DWORD index, LPWSTR lpguid)
1118{
1119 TRACE("%u, %p\n", index, lpguid);
1120
1121 if (!lpguid) return ERROR_INVALID_PARAMETER;
1122
1244 return MsiEnumComponentsExW( szAllSid, MSIINSTALLCONTEXT_ALL, index, lpguid, NULL, NULL, NULL );
1123 return MsiEnumComponentsExW( L"S-1-1-0", MSIINSTALLCONTEXT_ALL, index, lpguid, NULL, NULL, NULL );
1245}
1246
1247UINT WINAPI MsiEnumComponentsExA( LPCSTR user_sid, DWORD ctx, DWORD index, CHAR guid[39],
1248 MSIINSTALLCONTEXT *installed_ctx, LPSTR sid, LPDWORD sid_len )
1249{
1250 UINT r;
1251 WCHAR *user_sidW = NULL, *sidW = NULL, guidW[GUID_SIZE];
1252

--- 16 unchanged lines hidden (view full) ---

1269 msi_free( user_sidW );
1270 msi_free( sidW );
1271 return r;
1272}
1273
1274static UINT fetch_machine_component( DWORD ctx, DWORD index, DWORD *idx, WCHAR guid[39],
1275 MSIINSTALLCONTEXT *installed_ctx, LPWSTR sid, LPDWORD sid_len )
1276{
1124}
1125
1126UINT WINAPI MsiEnumComponentsExA( LPCSTR user_sid, DWORD ctx, DWORD index, CHAR guid[39],
1127 MSIINSTALLCONTEXT *installed_ctx, LPSTR sid, LPDWORD sid_len )
1128{
1129 UINT r;
1130 WCHAR *user_sidW = NULL, *sidW = NULL, guidW[GUID_SIZE];
1131

--- 16 unchanged lines hidden (view full) ---

1148 msi_free( user_sidW );
1149 msi_free( sidW );
1150 return r;
1151}
1152
1153static UINT fetch_machine_component( DWORD ctx, DWORD index, DWORD *idx, WCHAR guid[39],
1154 MSIINSTALLCONTEXT *installed_ctx, LPWSTR sid, LPDWORD sid_len )
1155{
1277 static const WCHAR componentsW[] =
1278 {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
1279 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1280 'I','n','s','t','a','l','l','e','r','\\','U','s','e','r','D','a','t','a','\\',
1281 'S','-','1','-','5','-','1','8','\\','C','o','m','p','o','n','e','n','t','s',0};
1282 UINT r = ERROR_SUCCESS;
1283 WCHAR component[SQUASHED_GUID_SIZE];
1284 DWORD i = 0, len_component;
1285 REGSAM access = KEY_ENUMERATE_SUB_KEYS | KEY_WOW64_64KEY;
1286 HKEY key_components;
1287
1156 UINT r = ERROR_SUCCESS;
1157 WCHAR component[SQUASHED_GUID_SIZE];
1158 DWORD i = 0, len_component;
1159 REGSAM access = KEY_ENUMERATE_SUB_KEYS | KEY_WOW64_64KEY;
1160 HKEY key_components;
1161
1288 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, componentsW, 0, access, &key_components ))
1162 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE,
1163 L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Components",
1164 0, access, &key_components ))
1289 return ERROR_NO_MORE_ITEMS;
1290
1291 len_component = ARRAY_SIZE( component );
1292 while (!RegEnumKeyExW( key_components, i, component, &len_component, NULL, NULL, NULL, NULL ))
1293 {
1294 if (*idx == index) goto found;
1295 (*idx)++;
1296 len_component = ARRAY_SIZE( component );

--- 21 unchanged lines hidden (view full) ---

1318 RegCloseKey( key_components );
1319 return r;
1320}
1321
1322static UINT fetch_user_component( const WCHAR *usersid, DWORD ctx, DWORD index, DWORD *idx,
1323 WCHAR guid[39], MSIINSTALLCONTEXT *installed_ctx, LPWSTR sid,
1324 LPDWORD sid_len )
1325{
1165 return ERROR_NO_MORE_ITEMS;
1166
1167 len_component = ARRAY_SIZE( component );
1168 while (!RegEnumKeyExW( key_components, i, component, &len_component, NULL, NULL, NULL, NULL ))
1169 {
1170 if (*idx == index) goto found;
1171 (*idx)++;
1172 len_component = ARRAY_SIZE( component );

--- 21 unchanged lines hidden (view full) ---

1194 RegCloseKey( key_components );
1195 return r;
1196}
1197
1198static UINT fetch_user_component( const WCHAR *usersid, DWORD ctx, DWORD index, DWORD *idx,
1199 WCHAR guid[39], MSIINSTALLCONTEXT *installed_ctx, LPWSTR sid,
1200 LPDWORD sid_len )
1201{
1326 static const WCHAR userdataW[] =
1327 {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
1328 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1329 'I','n','s','t','a','l','l','e','r','\\','U','s','e','r','D','a','t','a',0};
1330 static const WCHAR componentsW[] = {'\\','C','o','m','p','o','n','e','n','t','s',0};
1331 UINT r = ERROR_SUCCESS;
1332 WCHAR path[MAX_PATH], component[SQUASHED_GUID_SIZE], user[128];
1333 DWORD i = 0, j = 0, len_component, len_user;
1334 REGSAM access = KEY_ENUMERATE_SUB_KEYS | KEY_WOW64_64KEY;
1335 HKEY key_users, key_components;
1336
1337 if (ctx == MSIINSTALLCONTEXT_USERMANAGED) /* FIXME: where to find these? */
1338 return ERROR_NO_MORE_ITEMS;
1339
1202 UINT r = ERROR_SUCCESS;
1203 WCHAR path[MAX_PATH], component[SQUASHED_GUID_SIZE], user[128];
1204 DWORD i = 0, j = 0, len_component, len_user;
1205 REGSAM access = KEY_ENUMERATE_SUB_KEYS | KEY_WOW64_64KEY;
1206 HKEY key_users, key_components;
1207
1208 if (ctx == MSIINSTALLCONTEXT_USERMANAGED) /* FIXME: where to find these? */
1209 return ERROR_NO_MORE_ITEMS;
1210
1340 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, userdataW, 0, access, &key_users ))
1341 return ERROR_NO_MORE_ITEMS;
1211 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData",
1212 0, access, &key_users )) return ERROR_NO_MORE_ITEMS;
1342
1343 len_user = ARRAY_SIZE( user );
1344 while (!RegEnumKeyExW( key_users, i, user, &len_user, NULL, NULL, NULL, NULL ))
1345 {
1213
1214 len_user = ARRAY_SIZE( user );
1215 while (!RegEnumKeyExW( key_users, i, user, &len_user, NULL, NULL, NULL, NULL ))
1216 {
1346 if ((wcscmp( usersid, szAllSid ) && wcscmp( usersid, user )) ||
1347 !wcscmp( szLocalSid, user ))
1217 if ((wcscmp( usersid, L"S-1-1-0" ) && wcscmp( usersid, user )) ||
1218 !wcscmp( L"S-1-5-18", user ))
1348 {
1349 i++;
1350 len_user = ARRAY_SIZE( user );
1351 continue;
1352 }
1353 lstrcpyW( path, user );
1219 {
1220 i++;
1221 len_user = ARRAY_SIZE( user );
1222 continue;
1223 }
1224 lstrcpyW( path, user );
1354 lstrcatW( path, componentsW );
1225 lstrcatW( path, L"\\Components" );
1355 if (RegOpenKeyExW( key_users, path, 0, access, &key_components ))
1356 {
1357 i++;
1358 len_user = ARRAY_SIZE( user );
1359 continue;
1360 }
1361 len_component = ARRAY_SIZE( component );
1362 while (!RegEnumKeyExW( key_components, j, component, &len_component, NULL, NULL, NULL, NULL ))

--- 130 unchanged lines hidden (view full) ---

1493 WCHAR szValName[SQUASHED_GUID_SIZE];
1494
1495 TRACE("%s %d %p\n", debugstr_w(szComponent), index, szProduct);
1496
1497 if (!szComponent || !*szComponent || !szProduct)
1498 return ERROR_INVALID_PARAMETER;
1499
1500 if (MSIREG_OpenUserDataComponentKey(szComponent, NULL, &hkeyComp, FALSE) != ERROR_SUCCESS &&
1226 if (RegOpenKeyExW( key_users, path, 0, access, &key_components ))
1227 {
1228 i++;
1229 len_user = ARRAY_SIZE( user );
1230 continue;
1231 }
1232 len_component = ARRAY_SIZE( component );
1233 while (!RegEnumKeyExW( key_components, j, component, &len_component, NULL, NULL, NULL, NULL ))

--- 130 unchanged lines hidden (view full) ---

1364 WCHAR szValName[SQUASHED_GUID_SIZE];
1365
1366 TRACE("%s %d %p\n", debugstr_w(szComponent), index, szProduct);
1367
1368 if (!szComponent || !*szComponent || !szProduct)
1369 return ERROR_INVALID_PARAMETER;
1370
1371 if (MSIREG_OpenUserDataComponentKey(szComponent, NULL, &hkeyComp, FALSE) != ERROR_SUCCESS &&
1501 MSIREG_OpenUserDataComponentKey(szComponent, szLocalSid, &hkeyComp, FALSE) != ERROR_SUCCESS)
1372 MSIREG_OpenUserDataComponentKey(szComponent, L"S-1-5-18", &hkeyComp, FALSE) != ERROR_SUCCESS)
1502 return ERROR_UNKNOWN_COMPONENT;
1503
1504 /* see if there are any products at all */
1505 sz = SQUASHED_GUID_SIZE;
1506 r = RegEnumValueW(hkeyComp, 0, szValName, &sz, NULL, NULL, NULL, NULL);
1507 if (r != ERROR_SUCCESS)
1508 {
1509 RegCloseKey(hkeyComp);

--- 71 unchanged lines hidden (view full) ---

1581 name_sz = name_max;
1582 val_sz = val_max;
1583 r = RegEnumValueW( key, iIndex, name, &name_sz,
1584 NULL, &type, (LPBYTE)val, &val_sz );
1585 if (r == ERROR_SUCCESS)
1586 break;
1587 if (r != ERROR_MORE_DATA)
1588 goto end;
1373 return ERROR_UNKNOWN_COMPONENT;
1374
1375 /* see if there are any products at all */
1376 sz = SQUASHED_GUID_SIZE;
1377 r = RegEnumValueW(hkeyComp, 0, szValName, &sz, NULL, NULL, NULL, NULL);
1378 if (r != ERROR_SUCCESS)
1379 {
1380 RegCloseKey(hkeyComp);

--- 71 unchanged lines hidden (view full) ---

1452 name_sz = name_max;
1453 val_sz = val_max;
1454 r = RegEnumValueW( key, iIndex, name, &name_sz,
1455 NULL, &type, (LPBYTE)val, &val_sz );
1456 if (r == ERROR_SUCCESS)
1457 break;
1458 if (r != ERROR_MORE_DATA)
1459 goto end;
1589
1460
1590 if (type != REG_MULTI_SZ)
1591 {
1592 ERR("component data has wrong type (%d)\n", type);
1593 goto end;
1594 }
1595
1596 r = ERROR_OUTOFMEMORY;
1597 if (name_sz + 1 >= name_max)

--- 247 unchanged lines hidden (view full) ---

1845
1846 *state = MSIPATCHSTATE_INVALID;
1847
1848 r = MSIREG_OpenUserDataProductKey(prodcode, context,
1849 usersid, &prod, FALSE);
1850 if (r != ERROR_SUCCESS)
1851 return ERROR_NO_MORE_ITEMS;
1852
1461 if (type != REG_MULTI_SZ)
1462 {
1463 ERR("component data has wrong type (%d)\n", type);
1464 goto end;
1465 }
1466
1467 r = ERROR_OUTOFMEMORY;
1468 if (name_sz + 1 >= name_max)

--- 247 unchanged lines hidden (view full) ---

1716
1717 *state = MSIPATCHSTATE_INVALID;
1718
1719 r = MSIREG_OpenUserDataProductKey(prodcode, context,
1720 usersid, &prod, FALSE);
1721 if (r != ERROR_SUCCESS)
1722 return ERROR_NO_MORE_ITEMS;
1723
1853 res = RegOpenKeyExW(prod, szPatches, 0, KEY_READ, &hkey);
1724 res = RegOpenKeyExW(prod, L"Patches", 0, KEY_READ, &hkey);
1854 if (res != ERROR_SUCCESS)
1855 goto done;
1856
1857 res = RegOpenKeyExW(hkey, patch, 0, KEY_READ, &udpatch);
1858 if (res != ERROR_SUCCESS)
1859 goto done;
1860
1861 size = sizeof(DWORD);
1725 if (res != ERROR_SUCCESS)
1726 goto done;
1727
1728 res = RegOpenKeyExW(hkey, patch, 0, KEY_READ, &udpatch);
1729 if (res != ERROR_SUCCESS)
1730 goto done;
1731
1732 size = sizeof(DWORD);
1862 res = RegGetValueW(udpatch, NULL, szState, RRF_RT_DWORD, &type, &val, &size);
1733 res = RegGetValueW(udpatch, NULL, L"State", RRF_RT_DWORD, &type, &val, &size);
1863 if (res != ERROR_SUCCESS ||
1864 val < MSIPATCHSTATE_APPLIED || val > MSIPATCHSTATE_REGISTERED)
1865 {
1866 r = ERROR_BAD_CONFIGURATION;
1867 goto done;
1868 }
1869
1870 *state = val;

--- 20 unchanged lines hidden (view full) ---

1891 LONG res;
1892 UINT temp, r = ERROR_NO_MORE_ITEMS;
1893
1894 if (MSIREG_OpenProductKey(prodcode, usersid, context,
1895 &prod, FALSE) != ERROR_SUCCESS)
1896 return ERROR_NO_MORE_ITEMS;
1897
1898 size = 0;
1734 if (res != ERROR_SUCCESS ||
1735 val < MSIPATCHSTATE_APPLIED || val > MSIPATCHSTATE_REGISTERED)
1736 {
1737 r = ERROR_BAD_CONFIGURATION;
1738 goto done;
1739 }
1740
1741 *state = val;

--- 20 unchanged lines hidden (view full) ---

1762 LONG res;
1763 UINT temp, r = ERROR_NO_MORE_ITEMS;
1764
1765 if (MSIREG_OpenProductKey(prodcode, usersid, context,
1766 &prod, FALSE) != ERROR_SUCCESS)
1767 return ERROR_NO_MORE_ITEMS;
1768
1769 size = 0;
1899 res = RegGetValueW(prod, szPatches, szPatches, RRF_RT_ANY, &type, NULL,
1770 res = RegGetValueW(prod, L"Patches", L"Patches", RRF_RT_ANY, &type, NULL,
1900 &size);
1901 if (res != ERROR_SUCCESS)
1902 goto done;
1903
1904 if (type != REG_MULTI_SZ)
1905 {
1906 r = ERROR_BAD_CONFIGURATION;
1907 goto done;
1908 }
1909
1910 patches = msi_alloc(size);
1911 if (!patches)
1912 {
1913 r = ERROR_OUTOFMEMORY;
1914 goto done;
1915 }
1916
1771 &size);
1772 if (res != ERROR_SUCCESS)
1773 goto done;
1774
1775 if (type != REG_MULTI_SZ)
1776 {
1777 r = ERROR_BAD_CONFIGURATION;
1778 goto done;
1779 }
1780
1781 patches = msi_alloc(size);
1782 if (!patches)
1783 {
1784 r = ERROR_OUTOFMEMORY;
1785 goto done;
1786 }
1787
1917 res = RegGetValueW(prod, szPatches, szPatches, RRF_RT_ANY, &type,
1788 res = RegGetValueW(prod, L"Patches", L"Patches", RRF_RT_ANY, &type,
1918 patches, &size);
1919 if (res != ERROR_SUCCESS)
1920 goto done;
1921
1922 for (ptr = patches; *ptr && r == ERROR_NO_MORE_ITEMS; ptr += lstrlenW(ptr) + 1)
1923 {
1924 if (!unsquash_guid(ptr, patch))
1925 {
1926 r = ERROR_BAD_CONFIGURATION;
1927 goto done;
1928 }
1929
1930 size = 0;
1789 patches, &size);
1790 if (res != ERROR_SUCCESS)
1791 goto done;
1792
1793 for (ptr = patches; *ptr && r == ERROR_NO_MORE_ITEMS; ptr += lstrlenW(ptr) + 1)
1794 {
1795 if (!unsquash_guid(ptr, patch))
1796 {
1797 r = ERROR_BAD_CONFIGURATION;
1798 goto done;
1799 }
1800
1801 size = 0;
1931 res = RegGetValueW(prod, szPatches, ptr, RRF_RT_REG_SZ,
1802 res = RegGetValueW(prod, L"Patches", ptr, RRF_RT_REG_SZ,
1932 &type, NULL, &size);
1933 if (res != ERROR_SUCCESS)
1934 continue;
1935
1936 if (transforms)
1937 {
1938 *transforms = msi_alloc(size);
1939 if (!*transforms)
1940 {
1941 r = ERROR_OUTOFMEMORY;
1942 goto done;
1943 }
1944
1803 &type, NULL, &size);
1804 if (res != ERROR_SUCCESS)
1805 continue;
1806
1807 if (transforms)
1808 {
1809 *transforms = msi_alloc(size);
1810 if (!*transforms)
1811 {
1812 r = ERROR_OUTOFMEMORY;
1813 goto done;
1814 }
1815
1945 res = RegGetValueW(prod, szPatches, ptr, RRF_RT_REG_SZ,
1816 res = RegGetValueW(prod, L"Patches", ptr, RRF_RT_REG_SZ,
1946 &type, *transforms, &size);
1947 if (res != ERROR_SUCCESS)
1948 continue;
1949 }
1950
1951 if (context == MSIINSTALLCONTEXT_USERMANAGED)
1952 {
1953 if (!(filter & MSIPATCHSTATE_APPLIED))

--- 31 unchanged lines hidden (view full) ---

1985 &patchkey, FALSE);
1986 RegCloseKey(patchkey);
1987 if (temp != ERROR_SUCCESS)
1988 continue;
1989 }
1990 }
1991 else if (context == MSIINSTALLCONTEXT_MACHINE)
1992 {
1817 &type, *transforms, &size);
1818 if (res != ERROR_SUCCESS)
1819 continue;
1820 }
1821
1822 if (context == MSIINSTALLCONTEXT_USERMANAGED)
1823 {
1824 if (!(filter & MSIPATCHSTATE_APPLIED))

--- 31 unchanged lines hidden (view full) ---

1856 &patchkey, FALSE);
1857 RegCloseKey(patchkey);
1858 if (temp != ERROR_SUCCESS)
1859 continue;
1860 }
1861 }
1862 else if (context == MSIINSTALLCONTEXT_MACHINE)
1863 {
1993 usersid = szEmpty;
1864 usersid = L"";
1994
1995 if (MSIREG_OpenUserDataProductKey(prodcode, context, NULL, &localprod, FALSE) == ERROR_SUCCESS &&
1865
1866 if (MSIREG_OpenUserDataProductKey(prodcode, context, NULL, &localprod, FALSE) == ERROR_SUCCESS &&
1996 RegOpenKeyExW(localprod, szPatches, 0, KEY_READ, &localpatch) == ERROR_SUCCESS &&
1867 RegOpenKeyExW(localprod, L"Patches", 0, KEY_READ, &localpatch) == ERROR_SUCCESS &&
1997 RegOpenKeyExW(localpatch, ptr, 0, KEY_READ, &patchkey) == ERROR_SUCCESS)
1998 {
1868 RegOpenKeyExW(localpatch, ptr, 0, KEY_READ, &patchkey) == ERROR_SUCCESS)
1869 {
1999 res = RegGetValueW(patchkey, NULL, szState, RRF_RT_REG_DWORD,
1870 res = RegGetValueW(patchkey, NULL, L"State", RRF_RT_REG_DWORD,
2000 &type, &state, &size);
2001
2002 if (!(filter & state))
2003 res = ERROR_NO_MORE_ITEMS;
2004
2005 RegCloseKey(patchkey);
2006 }
2007

--- 112 unchanged lines hidden (view full) ---

2120 TRACE("(%s, %s, %d, %d, %d, %p, %p, %p, %p, %p)\n",
2121 debugstr_w(szProductCode), debugstr_w(szUserSid), dwContext, dwFilter,
2122 dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext,
2123 szTargetUserSid, pcchTargetUserSid);
2124
2125 if (!szProductCode || !squash_guid( szProductCode, squashed_pc ))
2126 return ERROR_INVALID_PARAMETER;
2127
1871 &type, &state, &size);
1872
1873 if (!(filter & state))
1874 res = ERROR_NO_MORE_ITEMS;
1875
1876 RegCloseKey(patchkey);
1877 }
1878

--- 112 unchanged lines hidden (view full) ---

1991 TRACE("(%s, %s, %d, %d, %d, %p, %p, %p, %p, %p)\n",
1992 debugstr_w(szProductCode), debugstr_w(szUserSid), dwContext, dwFilter,
1993 dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext,
1994 szTargetUserSid, pcchTargetUserSid);
1995
1996 if (!szProductCode || !squash_guid( szProductCode, squashed_pc ))
1997 return ERROR_INVALID_PARAMETER;
1998
2128 if (szUserSid && !wcscmp( szUserSid, szLocalSid ))
1999 if (szUserSid && !wcscmp( szUserSid, L"S-1-5-18" ))
2129 return ERROR_INVALID_PARAMETER;
2130
2131 if (dwContext & MSIINSTALLCONTEXT_MACHINE && szUserSid)
2132 return ERROR_INVALID_PARAMETER;
2133
2134 if (dwContext <= MSIINSTALLCONTEXT_NONE ||
2135 dwContext > MSIINSTALLCONTEXT_ALL)
2136 return ERROR_INVALID_PARAMETER;

--- 161 unchanged lines hidden (view full) ---

2298 msi_free( sidW );
2299 return r;
2300}
2301
2302static UINT fetch_machine_product( const WCHAR *match, DWORD index, DWORD *idx,
2303 WCHAR installed_product[GUID_SIZE],
2304 MSIINSTALLCONTEXT *installed_ctx, WCHAR *sid, DWORD *sid_len )
2305{
2000 return ERROR_INVALID_PARAMETER;
2001
2002 if (dwContext & MSIINSTALLCONTEXT_MACHINE && szUserSid)
2003 return ERROR_INVALID_PARAMETER;
2004
2005 if (dwContext <= MSIINSTALLCONTEXT_NONE ||
2006 dwContext > MSIINSTALLCONTEXT_ALL)
2007 return ERROR_INVALID_PARAMETER;

--- 161 unchanged lines hidden (view full) ---

2169 msi_free( sidW );
2170 return r;
2171}
2172
2173static UINT fetch_machine_product( const WCHAR *match, DWORD index, DWORD *idx,
2174 WCHAR installed_product[GUID_SIZE],
2175 MSIINSTALLCONTEXT *installed_ctx, WCHAR *sid, DWORD *sid_len )
2176{
2306 static const WCHAR productsW[] =
2307 {'S','o','f','t','w','a','r','e','\\','C','l','a','s','s','e','s','\\',
2308 'I','n','s','t','a','l','l','e','r','\\','P','r','o','d','u','c','t','s',0};
2309 UINT r;
2310 WCHAR product[SQUASHED_GUID_SIZE];
2311 DWORD i = 0, len;
2312 REGSAM access = KEY_ENUMERATE_SUB_KEYS | KEY_WOW64_64KEY;
2313 HKEY key;
2314
2177 UINT r;
2178 WCHAR product[SQUASHED_GUID_SIZE];
2179 DWORD i = 0, len;
2180 REGSAM access = KEY_ENUMERATE_SUB_KEYS | KEY_WOW64_64KEY;
2181 HKEY key;
2182
2315 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, productsW, 0, access, &key ))
2183 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, L"Software\\Classes\\Installer\\Products", 0, access, &key ))
2316 return ERROR_NO_MORE_ITEMS;
2317
2318 len = ARRAY_SIZE( product );
2319 while (!RegEnumKeyExW( key, i, product, &len, NULL, NULL, NULL, NULL ))
2320 {
2321 if (match && wcscmp( match, product ))
2322 {
2323 i++;

--- 28 unchanged lines hidden (view full) ---

2352 RegCloseKey( key );
2353 return r;
2354}
2355
2356static UINT fetch_user_product( const WCHAR *match, const WCHAR *usersid, DWORD ctx, DWORD index,
2357 DWORD *idx, WCHAR installed_product[GUID_SIZE],
2358 MSIINSTALLCONTEXT *installed_ctx, WCHAR *sid, DWORD *sid_len )
2359{
2184 return ERROR_NO_MORE_ITEMS;
2185
2186 len = ARRAY_SIZE( product );
2187 while (!RegEnumKeyExW( key, i, product, &len, NULL, NULL, NULL, NULL ))
2188 {
2189 if (match && wcscmp( match, product ))
2190 {
2191 i++;

--- 28 unchanged lines hidden (view full) ---

2220 RegCloseKey( key );
2221 return r;
2222}
2223
2224static UINT fetch_user_product( const WCHAR *match, const WCHAR *usersid, DWORD ctx, DWORD index,
2225 DWORD *idx, WCHAR installed_product[GUID_SIZE],
2226 MSIINSTALLCONTEXT *installed_ctx, WCHAR *sid, DWORD *sid_len )
2227{
2360 static const WCHAR managedW[] =
2361 {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
2362 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s',
2363 'i','o','n','\\','I','n','s','t','a','l','l','e','r','\\','M','a','n','a','g','e','d',0};
2364 static const WCHAR managed_productsW[] =
2365 {'\\','I','n','s','t','a','l','l','e','r','\\','P','r','o','d','u','c','t','s',0};
2366 static const WCHAR unmanaged_productsW[] =
2367 {'\\','S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
2368 'I','n','s','t','a','l','l','e','r','\\','P','r','o','d','u','c','t','s',0};
2369 UINT r;
2370 const WCHAR *subkey;
2371 WCHAR path[MAX_PATH], product[SQUASHED_GUID_SIZE], user[128];
2372 DWORD i = 0, j = 0, len_product, len_user;
2373 REGSAM access = KEY_ENUMERATE_SUB_KEYS | KEY_WOW64_64KEY;
2374 HKEY key_users, key_products;
2375
2376 if (ctx == MSIINSTALLCONTEXT_USERMANAGED)
2377 {
2228 UINT r;
2229 const WCHAR *subkey;
2230 WCHAR path[MAX_PATH], product[SQUASHED_GUID_SIZE], user[128];
2231 DWORD i = 0, j = 0, len_product, len_user;
2232 REGSAM access = KEY_ENUMERATE_SUB_KEYS | KEY_WOW64_64KEY;
2233 HKEY key_users, key_products;
2234
2235 if (ctx == MSIINSTALLCONTEXT_USERMANAGED)
2236 {
2378 subkey = managed_productsW;
2379 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, managedW, 0, access, &key_users ))
2380 return ERROR_NO_MORE_ITEMS;
2237 subkey = L"\\Installer\\Products";
2238 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed",
2239 0, access, &key_users )) return ERROR_NO_MORE_ITEMS;
2381 }
2382 else if (ctx == MSIINSTALLCONTEXT_USERUNMANAGED)
2383 {
2240 }
2241 else if (ctx == MSIINSTALLCONTEXT_USERUNMANAGED)
2242 {
2384 subkey = unmanaged_productsW;
2243 subkey = L"\\Software\\Microsoft\\Installer\\Products";
2385 if (RegOpenKeyExW( HKEY_USERS, NULL, 0, access, &key_users ))
2386 return ERROR_NO_MORE_ITEMS;
2387 }
2388 else return ERROR_INVALID_PARAMETER;
2389
2390 len_user = ARRAY_SIZE( user );
2391 while (!RegEnumKeyExW( key_users, i, user, &len_user, NULL, NULL, NULL, NULL ))
2392 {
2244 if (RegOpenKeyExW( HKEY_USERS, NULL, 0, access, &key_users ))
2245 return ERROR_NO_MORE_ITEMS;
2246 }
2247 else return ERROR_INVALID_PARAMETER;
2248
2249 len_user = ARRAY_SIZE( user );
2250 while (!RegEnumKeyExW( key_users, i, user, &len_user, NULL, NULL, NULL, NULL ))
2251 {
2393 if (wcscmp( usersid, user ) && wcscmp( usersid, szAllSid ))
2252 if (wcscmp( usersid, user ) && wcscmp( usersid, L"S-1-1-0" ))
2394 {
2395 i++;
2396 len_user = ARRAY_SIZE( user );
2397 continue;
2398 }
2399 lstrcpyW( path, user );
2400 lstrcatW( path, subkey );
2401 if (RegOpenKeyExW( key_users, path, 0, access, &key_products ))

--- 112 unchanged lines hidden ---
2253 {
2254 i++;
2255 len_user = ARRAY_SIZE( user );
2256 continue;
2257 }
2258 lstrcpyW( path, user );
2259 lstrcatW( path, subkey );
2260 if (RegOpenKeyExW( key_users, path, 0, access, &key_products ))

--- 112 unchanged lines hidden ---