2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Aric Stewart for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #define NONAMELESSUNION
32 #include "wine/debug.h"
36 #include "wine/unicode.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msi);
45 * This module will be all the helper functions for registry access by the
48 static const WCHAR szUserFeatures_fmt[] = {
49 'S','o','f','t','w','a','r','e','\\',
50 'M','i','c','r','o','s','o','f','t','\\',
51 'I','n','s','t','a','l','l','e','r','\\',
52 'F','e','a','t','u','r','e','s','\\',
55 static const WCHAR szUserDataFeatures_fmt[] = {
56 'S','o','f','t','w','a','r','e','\\',
57 'M','i','c','r','o','s','o','f','t','\\',
58 'W','i','n','d','o','w','s','\\',
59 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
60 'I','n','s','t','a','l','l','e','r','\\',
61 'U','s','e','r','D','a','t','a','\\',
62 '%','s','\\','P','r','o','d','u','c','t','s','\\',
63 '%','s','\\','F','e','a','t','u','r','e','s',0};
65 static const WCHAR szInstaller_Features_fmt[] = {
66 'S','o','f','t','w','a','r','e','\\',
67 'M','i','c','r','o','s','o','f','t','\\',
68 'W','i','n','d','o','w','s','\\',
69 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
70 'I','n','s','t','a','l','l','e','r','\\',
71 'F','e','a','t','u','r','e','s','\\',
74 static const WCHAR szInstaller_Components[] = {
75 'S','o','f','t','w','a','r','e','\\',
76 'M','i','c','r','o','s','o','f','t','\\',
77 'W','i','n','d','o','w','s','\\',
78 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
79 'I','n','s','t','a','l','l','e','r','\\',
80 'C','o','m','p','o','n','e','n','t','s',0 };
82 static const WCHAR szUser_Components_fmt[] = {
83 'S','o','f','t','w','a','r','e','\\',
84 'M','i','c','r','o','s','o','f','t','\\',
85 'I','n','s','t','a','l','l','e','r','\\',
86 'C','o','m','p','o','n','e','n','t','s','\\',
89 static const WCHAR szUserDataComp_fmt[] = {
90 'S','o','f','t','w','a','r','e','\\',
91 'M','i','c','r','o','s','o','f','t','\\',
92 'W','i','n','d','o','w','s','\\',
93 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
94 'I','n','s','t','a','l','l','e','r','\\',
95 'U','s','e','r','D','a','t','a','\\',
96 '%','s','\\','C','o','m','p','o','n','e','n','t','s','\\','%','s',0};
98 static const WCHAR szUninstall_fmt[] = {
99 'S','o','f','t','w','a','r','e','\\',
100 'M','i','c','r','o','s','o','f','t','\\',
101 'W','i','n','d','o','w','s','\\',
102 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
103 'U','n','i','n','s','t','a','l','l','\\',
106 static const WCHAR szUserProduct[] = {
107 'S','o','f','t','w','a','r','e','\\',
108 'M','i','c','r','o','s','o','f','t','\\',
109 'I','n','s','t','a','l','l','e','r','\\',
110 'P','r','o','d','u','c','t','s',0};
112 static const WCHAR szUserProduct_fmt[] = {
113 'S','o','f','t','w','a','r','e','\\',
114 'M','i','c','r','o','s','o','f','t','\\',
115 'I','n','s','t','a','l','l','e','r','\\',
116 'P','r','o','d','u','c','t','s','\\',
119 static const WCHAR szUserPatch_fmt[] = {
120 'S','o','f','t','w','a','r','e','\\',
121 'M','i','c','r','o','s','o','f','t','\\',
122 'I','n','s','t','a','l','l','e','r','\\',
123 'P','a','t','c','h','e','s','\\',
126 static const WCHAR szInstaller_Products[] = {
127 'S','o','f','t','w','a','r','e','\\',
128 'M','i','c','r','o','s','o','f','t','\\',
129 'W','i','n','d','o','w','s','\\',
130 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
131 'I','n','s','t','a','l','l','e','r','\\',
132 'P','r','o','d','u','c','t','s',0};
134 static const WCHAR szInstaller_Products_fmt[] = {
135 'S','o','f','t','w','a','r','e','\\',
136 'M','i','c','r','o','s','o','f','t','\\',
137 'W','i','n','d','o','w','s','\\',
138 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
139 'I','n','s','t','a','l','l','e','r','\\',
140 'P','r','o','d','u','c','t','s','\\',
143 static const WCHAR szInstaller_Patches_fmt[] = {
144 'S','o','f','t','w','a','r','e','\\',
145 'M','i','c','r','o','s','o','f','t','\\',
146 'W','i','n','d','o','w','s','\\',
147 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
148 'I','n','s','t','a','l','l','e','r','\\',
149 'P','a','t','c','h','e','s','\\',
152 static const WCHAR szInstaller_UpgradeCodes_fmt[] = {
153 'S','o','f','t','w','a','r','e','\\',
154 'M','i','c','r','o','s','o','f','t','\\',
155 'W','i','n','d','o','w','s','\\',
156 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
157 'I','n','s','t','a','l','l','e','r','\\',
158 'U','p','g','r','a','d','e','C','o','d','e','s','\\',
161 static const WCHAR szInstaller_UserUpgradeCodes_fmt[] = {
162 'S','o','f','t','w','a','r','e','\\',
163 'M','i','c','r','o','s','o','f','t','\\',
164 'I','n','s','t','a','l','l','e','r','\\',
165 'U','p','g','r','a','d','e','C','o','d','e','s','\\',
168 static const WCHAR szUserDataProd_fmt[] = {
169 'S','o','f','t','w','a','r','e','\\',
170 'M','i','c','r','o','s','o','f','t','\\',
171 'W','i','n','d','o','w','s','\\',
172 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
173 'I','n','s','t','a','l','l','e','r','\\',
174 'U','s','e','r','D','a','t','a','\\',
175 '%','s','\\','P','r','o','d','u','c','t','s','\\','%','s',0};
177 static const WCHAR szUserDataPatch_fmt[] = {
178 'S','o','f','t','w','a','r','e','\\',
179 'M','i','c','r','o','s','o','f','t','\\',
180 'W','i','n','d','o','w','s','\\',
181 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
182 'I','n','s','t','a','l','l','e','r','\\',
183 'U','s','e','r','D','a','t','a','\\',
184 '%','s','\\','P','a','t','c','h','e','s','\\','%','s',0};
186 static const WCHAR szUserDataProductPatches_fmt[] = {
187 'S','o','f','t','w','a','r','e','\\',
188 'M','i','c','r','o','s','o','f','t','\\',
189 'W','i','n','d','o','w','s','\\',
190 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
191 'I','n','s','t','a','l','l','e','r','\\',
192 'U','s','e','r','D','a','t','a','\\',
193 '%','s','\\','P','r','o','d','u','c','t','s','\\','%','s','\\',
194 'P','a','t','c','h','e','s',0};
196 static const WCHAR szInstallProperties_fmt[] = {
197 'S','o','f','t','w','a','r','e','\\',
198 'M','i','c','r','o','s','o','f','t','\\',
199 'W','i','n','d','o','w','s','\\',
200 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
201 'I','n','s','t','a','l','l','e','r','\\',
202 'U','s','e','r','D','a','t','a','\\',
203 '%','s','\\','P','r','o','d','u','c','t','s','\\','%','s','\\',
204 'I','n','s','t','a','l','l','P','r','o','p','e','r','t','i','e','s',0};
206 static const WCHAR szInstaller_LocalClassesProd[] = {
207 'S','o','f','t','w','a','r','e','\\',
208 'C','l','a','s','s','e','s','\\',
209 'I','n','s','t','a','l','l','e','r','\\',
210 'P','r','o','d','u','c','t','s',0};
212 static const WCHAR szInstaller_LocalClassesProd_fmt[] = {
213 'S','o','f','t','w','a','r','e','\\',
214 'C','l','a','s','s','e','s','\\',
215 'I','n','s','t','a','l','l','e','r','\\',
216 'P','r','o','d','u','c','t','s','\\','%','s',0};
218 static const WCHAR szInstaller_LocalClassesFeat_fmt[] = {
219 'S','o','f','t','w','a','r','e','\\',
220 'C','l','a','s','s','e','s','\\',
221 'I','n','s','t','a','l','l','e','r','\\',
222 'F','e','a','t','u','r','e','s','\\','%','s',0};
224 static const WCHAR szInstaller_LocalManaged_fmt[] = {
225 'S','o','f','t','w','a','r','e','\\',
226 'M','i','c','r','o','s','o','f','t','\\',
227 'W','i','n','d','o','w','s','\\',
228 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
229 'I','n','s','t','a','l','l','e','r','\\',
230 'M','a','n','a','g','e','d','\\','%','s','\\',
231 'I','n','s','t','a','l','l','e','r','\\',
232 'P','r','o','d','u','c','t','s',0};
234 static const WCHAR szInstaller_LocalManagedProd_fmt[] = {
235 'S','o','f','t','w','a','r','e','\\',
236 'M','i','c','r','o','s','o','f','t','\\',
237 'W','i','n','d','o','w','s','\\',
238 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
239 'I','n','s','t','a','l','l','e','r','\\',
240 'M','a','n','a','g','e','d','\\','%','s','\\',
241 'I','n','s','t','a','l','l','e','r','\\',
242 'P','r','o','d','u','c','t','s','\\','%','s',0};
244 static const WCHAR szInstaller_LocalManagedFeat_fmt[] = {
245 'S','o','f','t','w','a','r','e','\\',
246 'M','i','c','r','o','s','o','f','t','\\',
247 'W','i','n','d','o','w','s','\\',
248 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
249 'I','n','s','t','a','l','l','e','r','\\',
250 'M','a','n','a','g','e','d','\\','%','s','\\',
251 'I','n','s','t','a','l','l','e','r','\\',
252 'F','e','a','t','u','r','e','s','\\','%','s',0};
254 static const WCHAR szInstaller_ClassesUpgrade_fmt[] = {
255 'I','n','s','t','a','l','l','e','r','\\',
256 'U','p','g','r','a','d','e','C','o','d','e','s','\\',
259 BOOL unsquash_guid(LPCWSTR in, LPWSTR out)
263 if (lstrlenW(in) != 32)
278 out[n++] = in[17+i*2];
279 out[n++] = in[16+i*2];
284 out[n++] = in[17+i*2];
285 out[n++] = in[16+i*2];
292 BOOL squash_guid(LPCWSTR in, LPWSTR out)
299 if (FAILED(CLSIDFromString((LPCOLESTR)in, &guid)))
313 out[17+i*2] = in[n++];
314 out[16+i*2] = in[n++];
319 out[17+i*2] = in[n++];
320 out[16+i*2] = in[n++];
327 /* tables for encoding and decoding base85 */
328 static const unsigned char table_dec85[0x80] = {
329 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
330 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
331 0xff,0x00,0xff,0xff,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0xff,
332 0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0xff,0xff,0xff,0x16,0xff,0x17,
333 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,
334 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0xff,0x34,0x35,0x36,
335 0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43,0x44,0x45,0x46,
336 0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0xff,0x53,0x54,0xff,
339 static const char table_enc85[] =
340 "!$%&'()*+,-.0123456789=?@ABCDEFGHIJKLMNO"
341 "PQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx"
345 * Converts a base85 encoded guid into a GUID pointer
346 * Base85 encoded GUIDs should be 20 characters long.
348 * returns TRUE if successful, FALSE if not
350 BOOL decode_base85_guid( LPCWSTR str, GUID *guid )
352 DWORD i, val = 0, base = 1, *p;
358 for( i=0; i<20; i++ )
365 val += table_dec85[str[i]] * base;
368 if( table_dec85[str[i]] == 0xff )
378 * Encodes a base85 guid given a GUID pointer
379 * Caller should provide a 21 character buffer for the encoded string.
381 * returns TRUE if successful, FALSE if not
383 BOOL encode_base85_guid( GUID *guid, LPWSTR str )
385 unsigned int x, *p, i;
387 p = (unsigned int*) guid;
391 *str++ = table_enc85[x%85];
393 *str++ = table_enc85[x%85];
395 *str++ = table_enc85[x%85];
397 *str++ = table_enc85[x%85];
399 *str++ = table_enc85[x%85];
406 DWORD msi_version_str_to_dword(LPCWSTR p)
408 DWORD major, minor = 0, build = 0, version = 0;
419 p = strchrW(p+1, '.');
424 return MAKELONG(build, MAKEWORD(minor, major));
427 LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value )
430 if (!value) value = szEmpty;
431 len = (lstrlenW(value) + 1) * sizeof (WCHAR);
432 return RegSetValueExW( hkey, name, 0, REG_SZ, (const BYTE *)value, len );
435 LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value )
438 while (*p) p += lstrlenW(p) + 1;
439 return RegSetValueExW( hkey, name, 0, REG_MULTI_SZ,
440 (const BYTE *)value, (p + 1 - value) * sizeof(WCHAR) );
443 LONG msi_reg_set_val_dword( HKEY hkey, LPCWSTR name, DWORD val )
445 return RegSetValueExW( hkey, name, 0, REG_DWORD, (LPBYTE)&val, sizeof (DWORD) );
448 LONG msi_reg_set_subkey_val( HKEY hkey, LPCWSTR path, LPCWSTR name, LPCWSTR val )
453 r = RegCreateKeyW( hkey, path, &hsubkey );
454 if (r != ERROR_SUCCESS)
456 r = msi_reg_set_val_str( hsubkey, name, val );
457 RegCloseKey( hsubkey );
461 LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name )
467 r = RegQueryValueExW(hkey, name, NULL, NULL, NULL, &len);
468 if (r != ERROR_SUCCESS)
471 len += sizeof (WCHAR);
472 val = msi_alloc( len );
476 RegQueryValueExW(hkey, name, NULL, NULL, (LPBYTE) val, &len);
480 BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val)
482 DWORD type, len = sizeof (DWORD);
483 LONG r = RegQueryValueExW(hkey, name, NULL, &type, (LPBYTE) val, &len);
484 return r == ERROR_SUCCESS && type == REG_DWORD;
487 static UINT get_user_sid(LPWSTR *usersid)
494 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
495 return ERROR_FUNCTION_FAILED;
498 if (!GetTokenInformation(token, TokenUser, buf, size, &size)) {
500 return ERROR_FUNCTION_FAILED;
503 user = (PTOKEN_USER)buf;
504 if (!ConvertSidToStringSidW(user->User.Sid, usersid)) {
506 return ERROR_FUNCTION_FAILED;
509 return ERROR_SUCCESS;
512 UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create)
515 WCHAR keypath[0x200];
516 TRACE("%s\n",debugstr_w(szProduct));
518 sprintfW(keypath,szUninstall_fmt,szProduct);
521 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
523 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
528 UINT MSIREG_DeleteUninstallKey(LPCWSTR szProduct)
530 WCHAR keypath[0x200];
531 TRACE("%s\n",debugstr_w(szProduct));
533 sprintfW(keypath,szUninstall_fmt,szProduct);
535 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
538 UINT MSIREG_OpenProductKey(LPCWSTR szProduct, LPCWSTR szUserSid,
539 MSIINSTALLCONTEXT context, HKEY *key, BOOL create)
542 LPWSTR usersid = NULL;
543 HKEY root = HKEY_LOCAL_MACHINE;
544 WCHAR squished_pc[GUID_SIZE];
545 WCHAR keypath[MAX_PATH];
547 TRACE("(%s, %d, %d)\n", debugstr_w(szProduct), context, create);
549 if (!squash_guid(szProduct, squished_pc))
550 return ERROR_FUNCTION_FAILED;
552 TRACE("squished (%s)\n", debugstr_w(squished_pc));
554 if (context == MSIINSTALLCONTEXT_MACHINE)
556 sprintfW(keypath, szInstaller_LocalClassesProd_fmt, squished_pc);
558 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
560 root = HKEY_CURRENT_USER;
561 sprintfW(keypath, szUserProduct_fmt, squished_pc);
567 r = get_user_sid(&usersid);
568 if (r != ERROR_SUCCESS || !usersid)
570 ERR("Failed to retrieve user SID: %d\n", r);
577 sprintfW(keypath, szInstaller_LocalManagedProd_fmt,
578 szUserSid, squished_pc);
583 return RegCreateKeyW(root, keypath, key);
585 return RegOpenKeyW(root, keypath, key);
588 UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct)
590 WCHAR squished_pc[GUID_SIZE];
591 WCHAR keypath[0x200];
593 TRACE("%s\n",debugstr_w(szProduct));
594 if (!squash_guid(szProduct,squished_pc))
595 return ERROR_FUNCTION_FAILED;
596 TRACE("squished (%s)\n", debugstr_w(squished_pc));
598 sprintfW(keypath,szUserProduct_fmt,squished_pc);
600 return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
603 UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create)
606 WCHAR squished_pc[GUID_SIZE];
607 WCHAR keypath[0x200];
609 TRACE("%s\n",debugstr_w(szPatch));
610 if (!squash_guid(szPatch,squished_pc))
611 return ERROR_FUNCTION_FAILED;
612 TRACE("squished (%s)\n", debugstr_w(squished_pc));
614 sprintfW(keypath,szUserPatch_fmt,squished_pc);
617 rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
619 rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
624 UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
625 HKEY *key, BOOL create)
629 HKEY root = HKEY_LOCAL_MACHINE;
630 WCHAR squished_pc[GUID_SIZE];
631 WCHAR keypath[MAX_PATH];
633 TRACE("(%s, %d, %d)\n", debugstr_w(szProduct), context, create);
635 if (!squash_guid(szProduct, squished_pc))
636 return ERROR_FUNCTION_FAILED;
638 TRACE("squished (%s)\n", debugstr_w(squished_pc));
640 if (context == MSIINSTALLCONTEXT_MACHINE)
642 sprintfW(keypath, szInstaller_LocalClassesFeat_fmt, squished_pc);
644 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
646 root = HKEY_CURRENT_USER;
647 sprintfW(keypath, szUserFeatures_fmt, squished_pc);
651 r = get_user_sid(&usersid);
652 if (r != ERROR_SUCCESS || !usersid)
654 ERR("Failed to retrieve user SID: %d\n", r);
658 sprintfW(keypath, szInstaller_LocalManagedFeat_fmt, usersid, squished_pc);
663 return RegCreateKeyW(root, keypath, key);
665 return RegOpenKeyW(root, keypath, key);
668 UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct)
670 WCHAR squished_pc[GUID_SIZE];
671 WCHAR keypath[0x200];
673 TRACE("%s\n",debugstr_w(szProduct));
674 if (!squash_guid(szProduct,squished_pc))
675 return ERROR_FUNCTION_FAILED;
676 TRACE("squished (%s)\n", debugstr_w(squished_pc));
678 sprintfW(keypath,szUserFeatures_fmt,squished_pc);
679 return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
682 static UINT MSIREG_OpenInstallerFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create)
685 WCHAR squished_pc[GUID_SIZE];
686 WCHAR keypath[0x200];
688 TRACE("%s\n",debugstr_w(szProduct));
689 if (!squash_guid(szProduct,squished_pc))
690 return ERROR_FUNCTION_FAILED;
691 TRACE("squished (%s)\n", debugstr_w(squished_pc));
693 sprintfW(keypath,szInstaller_Features_fmt,squished_pc);
696 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,keypath,key);
698 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,keypath,key);
703 UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
704 HKEY *key, BOOL create)
708 WCHAR squished_pc[GUID_SIZE];
709 WCHAR keypath[0x200];
711 TRACE("(%s, %d, %d)\n", debugstr_w(szProduct), context, create);
713 if (!squash_guid(szProduct, squished_pc))
714 return ERROR_FUNCTION_FAILED;
716 TRACE("squished (%s)\n", debugstr_w(squished_pc));
718 if (context == MSIINSTALLCONTEXT_MACHINE)
720 sprintfW(keypath, szUserDataFeatures_fmt, szLocalSid, squished_pc);
724 r = get_user_sid(&usersid);
725 if (r != ERROR_SUCCESS || !usersid)
727 ERR("Failed to retrieve user SID: %d\n", r);
731 sprintfW(keypath, szUserDataFeatures_fmt, usersid, squished_pc);
736 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
738 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
741 UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create)
744 WCHAR squished_cc[GUID_SIZE];
745 WCHAR keypath[0x200];
747 TRACE("%s\n",debugstr_w(szComponent));
748 if (!squash_guid(szComponent,squished_cc))
749 return ERROR_FUNCTION_FAILED;
750 TRACE("squished (%s)\n", debugstr_w(squished_cc));
752 sprintfW(keypath,szUser_Components_fmt,squished_cc);
755 rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
757 rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
762 UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid,
763 HKEY *key, BOOL create)
766 WCHAR comp[GUID_SIZE];
767 WCHAR keypath[0x200];
770 TRACE("%s\n", debugstr_w(szComponent));
771 if (!squash_guid(szComponent, comp))
772 return ERROR_FUNCTION_FAILED;
773 TRACE("squished (%s)\n", debugstr_w(comp));
777 rc = get_user_sid(&usersid);
778 if (rc != ERROR_SUCCESS || !usersid)
780 ERR("Failed to retrieve user SID: %d\n", rc);
784 sprintfW(keypath, szUserDataComp_fmt, usersid, comp);
788 sprintfW(keypath, szUserDataComp_fmt, szUserSid, comp);
791 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
793 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
798 UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid)
801 WCHAR comp[GUID_SIZE];
802 WCHAR keypath[0x200];
805 TRACE("%s\n", debugstr_w(szComponent));
806 if (!squash_guid(szComponent, comp))
807 return ERROR_FUNCTION_FAILED;
808 TRACE("squished (%s)\n", debugstr_w(comp));
812 rc = get_user_sid(&usersid);
813 if (rc != ERROR_SUCCESS || !usersid)
815 ERR("Failed to retrieve user SID: %d\n", rc);
819 sprintfW(keypath, szUserDataComp_fmt, usersid, comp);
823 sprintfW(keypath, szUserDataComp_fmt, szUserSid, comp);
825 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
828 UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext,
829 LPCWSTR szUserSid, HKEY *key, BOOL create)
832 WCHAR squished_pc[GUID_SIZE];
833 WCHAR keypath[0x200];
836 TRACE("%s\n", debugstr_w(szProduct));
837 if (!squash_guid(szProduct, squished_pc))
838 return ERROR_FUNCTION_FAILED;
839 TRACE("squished (%s)\n", debugstr_w(squished_pc));
841 if (dwContext == MSIINSTALLCONTEXT_MACHINE)
842 sprintfW(keypath, szUserDataProd_fmt, szLocalSid, squished_pc);
844 sprintfW(keypath, szUserDataProd_fmt, szUserSid, squished_pc);
847 rc = get_user_sid(&usersid);
848 if (rc != ERROR_SUCCESS || !usersid)
850 ERR("Failed to retrieve user SID: %d\n", rc);
854 sprintfW(keypath, szUserDataProd_fmt, usersid, squished_pc);
859 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
861 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
866 UINT MSIREG_OpenUserDataPatchKey(LPCWSTR szPatch, MSIINSTALLCONTEXT dwContext,
867 HKEY *key, BOOL create)
870 WCHAR squished_patch[GUID_SIZE];
871 WCHAR keypath[0x200];
874 TRACE("%s\n", debugstr_w(szPatch));
875 if (!squash_guid(szPatch, squished_patch))
876 return ERROR_FUNCTION_FAILED;
877 TRACE("squished (%s)\n", debugstr_w(squished_patch));
879 if (dwContext == MSIINSTALLCONTEXT_MACHINE)
880 sprintfW(keypath, szUserDataPatch_fmt, szLocalSid, squished_patch);
883 rc = get_user_sid(&usersid);
884 if (rc != ERROR_SUCCESS || !usersid)
886 ERR("Failed to retrieve user SID: %d\n", rc);
890 sprintfW(keypath, szUserDataPatch_fmt, usersid, squished_patch);
895 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
897 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
900 UINT MSIREG_DeleteUserDataPatchKey(LPCWSTR patch, MSIINSTALLCONTEXT context)
903 WCHAR squished_patch[GUID_SIZE];
904 WCHAR keypath[0x200];
907 TRACE("%s\n", debugstr_w(patch));
908 if (!squash_guid(patch, squished_patch))
909 return ERROR_FUNCTION_FAILED;
910 TRACE("squished (%s)\n", debugstr_w(squished_patch));
912 if (context == MSIINSTALLCONTEXT_MACHINE)
913 sprintfW(keypath, szUserDataPatch_fmt, szLocalSid, squished_patch);
916 r = get_user_sid(&usersid);
917 if (r != ERROR_SUCCESS || !usersid)
919 ERR("Failed to retrieve user SID: %d\n", r);
923 sprintfW(keypath, szUserDataPatch_fmt, usersid, squished_patch);
927 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
930 UINT MSIREG_OpenUserDataProductPatchesKey(LPCWSTR product, MSIINSTALLCONTEXT context,
931 HKEY *key, BOOL create)
934 WCHAR squished_product[GUID_SIZE];
935 WCHAR keypath[0x200];
938 TRACE("%s\n", debugstr_w(product));
939 if (!squash_guid(product, squished_product))
940 return ERROR_FUNCTION_FAILED;
942 if (context == MSIINSTALLCONTEXT_MACHINE)
943 sprintfW(keypath, szUserDataProductPatches_fmt, szLocalSid, squished_product);
946 rc = get_user_sid(&usersid);
947 if (rc != ERROR_SUCCESS || !usersid)
949 ERR("Failed to retrieve user SID: %d\n", rc);
953 sprintfW(keypath, szUserDataProductPatches_fmt, usersid, squished_product);
958 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
960 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
963 UINT MSIREG_OpenInstallProps(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext,
964 LPCWSTR szUserSid, HKEY *key, BOOL create)
968 WCHAR squished_pc[GUID_SIZE];
969 WCHAR keypath[0x200];
971 TRACE("%s\n", debugstr_w(szProduct));
972 if (!squash_guid(szProduct, squished_pc))
973 return ERROR_FUNCTION_FAILED;
974 TRACE("squished (%s)\n", debugstr_w(squished_pc));
976 if (dwContext == MSIINSTALLCONTEXT_MACHINE)
977 sprintfW(keypath, szInstallProperties_fmt, szLocalSid, squished_pc);
979 sprintfW(keypath, szInstallProperties_fmt, szUserSid, squished_pc);
982 rc = get_user_sid(&usersid);
983 if (rc != ERROR_SUCCESS || !usersid)
985 ERR("Failed to retrieve user SID: %d\n", rc);
989 sprintfW(keypath, szInstallProperties_fmt, usersid, squished_pc);
994 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
996 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
999 UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct)
1002 WCHAR squished_pc[GUID_SIZE];
1003 WCHAR keypath[0x200];
1006 TRACE("%s\n", debugstr_w(szProduct));
1007 if (!squash_guid(szProduct, squished_pc))
1008 return ERROR_FUNCTION_FAILED;
1009 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1011 rc = get_user_sid(&usersid);
1012 if (rc != ERROR_SUCCESS || !usersid)
1014 ERR("Failed to retrieve user SID: %d\n", rc);
1018 sprintfW(keypath, szUserDataProd_fmt, usersid, squished_pc);
1021 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
1024 UINT MSIREG_DeleteProductKey(LPCWSTR szProduct)
1026 WCHAR squished_pc[GUID_SIZE];
1027 WCHAR keypath[0x200];
1029 TRACE("%s\n", debugstr_w(szProduct));
1030 if (!squash_guid(szProduct, squished_pc))
1031 return ERROR_FUNCTION_FAILED;
1032 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1034 sprintfW(keypath, szInstaller_Products_fmt, squished_pc);
1036 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
1039 UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create)
1042 WCHAR squished_pc[GUID_SIZE];
1043 WCHAR keypath[0x200];
1045 TRACE("%s\n",debugstr_w(szPatch));
1046 if (!squash_guid(szPatch,squished_pc))
1047 return ERROR_FUNCTION_FAILED;
1048 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1050 sprintfW(keypath,szInstaller_Patches_fmt,squished_pc);
1053 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,keypath,key);
1055 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,keypath,key);
1060 UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL create)
1063 WCHAR squished_pc[GUID_SIZE];
1064 WCHAR keypath[0x200];
1066 TRACE("%s\n",debugstr_w(szUpgradeCode));
1067 if (!squash_guid(szUpgradeCode,squished_pc))
1068 return ERROR_FUNCTION_FAILED;
1069 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1071 sprintfW(keypath,szInstaller_UpgradeCodes_fmt,squished_pc);
1074 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,keypath,key);
1076 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,keypath,key);
1081 UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL create)
1084 WCHAR squished_pc[GUID_SIZE];
1085 WCHAR keypath[0x200];
1087 TRACE("%s\n",debugstr_w(szUpgradeCode));
1088 if (!squash_guid(szUpgradeCode,squished_pc))
1089 return ERROR_FUNCTION_FAILED;
1090 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1092 sprintfW(keypath,szInstaller_UserUpgradeCodes_fmt,squished_pc);
1095 rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
1097 rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
1102 UINT MSIREG_DeleteUserUpgradeCodesKey(LPCWSTR szUpgradeCode)
1104 WCHAR squished_pc[GUID_SIZE];
1105 WCHAR keypath[0x200];
1107 TRACE("%s\n",debugstr_w(szUpgradeCode));
1108 if (!squash_guid(szUpgradeCode,squished_pc))
1109 return ERROR_FUNCTION_FAILED;
1110 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1112 sprintfW(keypath,szInstaller_UserUpgradeCodes_fmt,squished_pc);
1114 return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
1117 UINT MSIREG_DeleteLocalClassesProductKey(LPCWSTR szProductCode)
1119 WCHAR squished_pc[GUID_SIZE];
1120 WCHAR keypath[0x200];
1122 TRACE("%s\n", debugstr_w(szProductCode));
1124 if (!squash_guid(szProductCode, squished_pc))
1125 return ERROR_FUNCTION_FAILED;
1127 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1129 sprintfW(keypath, szInstaller_LocalClassesProd_fmt, squished_pc);
1131 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
1134 UINT MSIREG_DeleteLocalClassesFeaturesKey(LPCWSTR szProductCode)
1136 WCHAR squished_pc[GUID_SIZE];
1137 WCHAR keypath[0x200];
1139 TRACE("%s\n", debugstr_w(szProductCode));
1141 if (!squash_guid(szProductCode, squished_pc))
1142 return ERROR_FUNCTION_FAILED;
1144 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1146 sprintfW(keypath, szInstaller_LocalClassesFeat_fmt, squished_pc);
1148 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
1151 UINT MSIREG_OpenClassesUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL create)
1153 WCHAR squished_pc[GUID_SIZE];
1154 WCHAR keypath[0x200];
1156 TRACE("%s\n", debugstr_w(szUpgradeCode));
1157 if (!squash_guid(szUpgradeCode, squished_pc))
1158 return ERROR_FUNCTION_FAILED;
1159 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1161 sprintfW(keypath, szInstaller_ClassesUpgrade_fmt, squished_pc);
1164 return RegCreateKeyW(HKEY_CLASSES_ROOT, keypath, key);
1166 return RegOpenKeyW(HKEY_CLASSES_ROOT, keypath, key);
1169 /*************************************************************************
1170 * MsiDecomposeDescriptorW [MSI.@]
1172 * Decomposes an MSI descriptor into product, feature and component parts.
1173 * An MSI descriptor is a string of the form:
1174 * [base 85 guid] [feature code] '>' [base 85 guid]
1177 * szDescriptor [I] the descriptor to decompose
1178 * szProduct [O] buffer of MAX_FEATURE_CHARS+1 for the product guid
1179 * szFeature [O] buffer of MAX_FEATURE_CHARS+1 for the feature code
1180 * szComponent [O] buffer of MAX_FEATURE_CHARS+1 for the component guid
1181 * pUsed [O] the length of the descriptor
1184 * ERROR_SUCCESS if everything worked correctly
1185 * ERROR_INVALID_PARAMETER if the descriptor was invalid
1188 UINT WINAPI MsiDecomposeDescriptorW( LPCWSTR szDescriptor, LPWSTR szProduct,
1189 LPWSTR szFeature, LPWSTR szComponent, LPDWORD pUsed )
1193 GUID product, component;
1195 TRACE("%s %p %p %p %p\n", debugstr_w(szDescriptor), szProduct,
1196 szFeature, szComponent, pUsed);
1198 r = decode_base85_guid( szDescriptor, &product );
1200 return ERROR_INVALID_PARAMETER;
1202 TRACE("product %s\n", debugstr_guid( &product ));
1204 p = strchrW(&szDescriptor[20],'>');
1206 return ERROR_INVALID_PARAMETER;
1208 len = (p - &szDescriptor[20]);
1209 if( len > MAX_FEATURE_CHARS )
1210 return ERROR_INVALID_PARAMETER;
1212 TRACE("feature %s\n", debugstr_wn( &szDescriptor[20], len ));
1214 r = decode_base85_guid( p+1, &component );
1216 return ERROR_INVALID_PARAMETER;
1218 TRACE("component %s\n", debugstr_guid( &component ));
1221 StringFromGUID2( &product, szProduct, MAX_FEATURE_CHARS+1 );
1223 StringFromGUID2( &component, szComponent, MAX_FEATURE_CHARS+1 );
1226 memcpy( szFeature, &szDescriptor[20], len*sizeof(WCHAR) );
1229 len = ( &p[21] - szDescriptor );
1231 TRACE("length = %d\n", len);
1232 if (pUsed) *pUsed = len;
1234 return ERROR_SUCCESS;
1237 UINT WINAPI MsiDecomposeDescriptorA( LPCSTR szDescriptor, LPSTR szProduct,
1238 LPSTR szFeature, LPSTR szComponent, LPDWORD pUsed )
1240 WCHAR product[MAX_FEATURE_CHARS+1];
1241 WCHAR feature[MAX_FEATURE_CHARS+1];
1242 WCHAR component[MAX_FEATURE_CHARS+1];
1243 LPWSTR str = NULL, p = NULL, f = NULL, c = NULL;
1246 TRACE("%s %p %p %p %p\n", debugstr_a(szDescriptor), szProduct,
1247 szFeature, szComponent, pUsed);
1249 str = strdupAtoW( szDescriptor );
1250 if( szDescriptor && !str )
1251 return ERROR_OUTOFMEMORY;
1260 r = MsiDecomposeDescriptorW( str, p, f, c, pUsed );
1262 if (r == ERROR_SUCCESS)
1264 WideCharToMultiByte( CP_ACP, 0, p, -1,
1265 szProduct, MAX_FEATURE_CHARS+1, NULL, NULL );
1266 WideCharToMultiByte( CP_ACP, 0, f, -1,
1267 szFeature, MAX_FEATURE_CHARS+1, NULL, NULL );
1268 WideCharToMultiByte( CP_ACP, 0, c, -1,
1269 szComponent, MAX_FEATURE_CHARS+1, NULL, NULL );
1277 UINT WINAPI MsiEnumProductsA(DWORD index, LPSTR lpguid)
1280 WCHAR szwGuid[GUID_SIZE];
1282 TRACE("%d %p\n", index, lpguid);
1285 return ERROR_INVALID_PARAMETER;
1286 r = MsiEnumProductsW(index, szwGuid);
1287 if( r == ERROR_SUCCESS )
1288 WideCharToMultiByte(CP_ACP, 0, szwGuid, -1, lpguid, GUID_SIZE, NULL, NULL);
1293 UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid)
1296 WCHAR szKeyName[SQUISH_GUID_SIZE];
1298 DWORD machine_count, managed_count, unmanaged_count;
1299 WCHAR keypath[MAX_PATH];
1300 LPWSTR usersid = NULL;
1302 static DWORD last_index;
1304 TRACE("%d %p\n", index, lpguid);
1307 return ERROR_INVALID_PARAMETER;
1309 if (index && index - last_index != 1)
1310 return ERROR_INVALID_PARAMETER;
1313 r = RegCreateKeyW(HKEY_LOCAL_MACHINE, szInstaller_LocalClassesProd, &key);
1314 if( r != ERROR_SUCCESS ) goto failed;
1316 r = RegQueryInfoKeyW(key, NULL, NULL, NULL, &machine_count, NULL, NULL,
1317 NULL, NULL, NULL, NULL, NULL);
1318 if( r != ERROR_SUCCESS ) goto failed;
1320 if (machine_count && index <= machine_count)
1322 r = RegEnumKeyW(key, index, szKeyName, SQUISH_GUID_SIZE);
1323 if( r == ERROR_SUCCESS )
1325 unsquash_guid(szKeyName, lpguid);
1328 return ERROR_SUCCESS;
1334 r = get_user_sid(&usersid);
1335 if (r != ERROR_SUCCESS || !usersid)
1337 ERR("Failed to retrieve user SID: %d\n", r);
1341 sprintfW(keypath, szInstaller_LocalManaged_fmt, usersid);
1344 r = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, &key);
1345 if( r != ERROR_SUCCESS ) goto failed;
1347 r = RegQueryInfoKeyW(key, NULL, NULL, NULL, &managed_count, NULL, NULL,
1348 NULL, NULL, NULL, NULL, NULL);
1349 if( r != ERROR_SUCCESS ) goto failed;
1351 if (managed_count && index <= machine_count + managed_count)
1353 r = RegEnumKeyW(key, index - machine_count, szKeyName, SQUISH_GUID_SIZE);
1354 if( r == ERROR_SUCCESS )
1356 unsquash_guid(szKeyName, lpguid);
1359 return ERROR_SUCCESS;
1365 r = RegCreateKeyW(HKEY_CURRENT_USER, szUserProduct, &key);
1366 if( r != ERROR_SUCCESS ) goto failed;
1368 r = RegQueryInfoKeyW(key, NULL, NULL, NULL, &unmanaged_count, NULL, NULL,
1369 NULL, NULL, NULL, NULL, NULL);
1370 if( r != ERROR_SUCCESS ) goto failed;
1372 if (unmanaged_count && index <= machine_count + managed_count + unmanaged_count)
1374 r = RegEnumKeyW(key, index - machine_count - managed_count, szKeyName, SQUISH_GUID_SIZE);
1375 if( r == ERROR_SUCCESS )
1377 unsquash_guid(szKeyName, lpguid);
1380 return ERROR_SUCCESS;
1386 return ERROR_NO_MORE_ITEMS;
1389 UINT WINAPI MsiEnumFeaturesA(LPCSTR szProduct, DWORD index,
1390 LPSTR szFeature, LPSTR szParent)
1393 WCHAR szwFeature[GUID_SIZE], szwParent[GUID_SIZE];
1394 LPWSTR szwProduct = NULL;
1396 TRACE("%s %d %p %p\n", debugstr_a(szProduct), index, szFeature, szParent);
1400 szwProduct = strdupAtoW( szProduct );
1402 return ERROR_OUTOFMEMORY;
1405 r = MsiEnumFeaturesW(szwProduct, index, szwFeature, szwParent);
1406 if( r == ERROR_SUCCESS )
1408 WideCharToMultiByte(CP_ACP, 0, szwFeature, -1,
1409 szFeature, GUID_SIZE, NULL, NULL);
1410 WideCharToMultiByte(CP_ACP, 0, szwParent, -1,
1411 szParent, GUID_SIZE, NULL, NULL);
1414 msi_free( szwProduct);
1419 UINT WINAPI MsiEnumFeaturesW(LPCWSTR szProduct, DWORD index,
1420 LPWSTR szFeature, LPWSTR szParent)
1422 HKEY hkeyProduct = 0;
1425 TRACE("%s %d %p %p\n", debugstr_w(szProduct), index, szFeature, szParent);
1428 return ERROR_INVALID_PARAMETER;
1430 r = MSIREG_OpenInstallerFeaturesKey(szProduct,&hkeyProduct,FALSE);
1431 if( r != ERROR_SUCCESS )
1432 return ERROR_NO_MORE_ITEMS;
1435 r = RegEnumValueW(hkeyProduct, index, szFeature, &sz, NULL, NULL, NULL, NULL);
1436 RegCloseKey(hkeyProduct);
1441 UINT WINAPI MsiEnumComponentsA(DWORD index, LPSTR lpguid)
1444 WCHAR szwGuid[GUID_SIZE];
1446 TRACE("%d %p\n", index, lpguid);
1448 r = MsiEnumComponentsW(index, szwGuid);
1449 if( r == ERROR_SUCCESS )
1450 WideCharToMultiByte(CP_ACP, 0, szwGuid, -1, lpguid, GUID_SIZE, NULL, NULL);
1455 UINT WINAPI MsiEnumComponentsW(DWORD index, LPWSTR lpguid)
1457 HKEY hkeyComponents = 0;
1459 WCHAR szKeyName[SQUISH_GUID_SIZE];
1461 TRACE("%d %p\n", index, lpguid);
1463 r = RegCreateKeyW(HKEY_LOCAL_MACHINE, szInstaller_Components, &hkeyComponents);
1464 if( r != ERROR_SUCCESS )
1465 return ERROR_NO_MORE_ITEMS;
1467 r = RegEnumKeyW(hkeyComponents, index, szKeyName, SQUISH_GUID_SIZE);
1468 if( r == ERROR_SUCCESS )
1469 unsquash_guid(szKeyName, lpguid);
1470 RegCloseKey(hkeyComponents);
1475 UINT WINAPI MsiEnumClientsA(LPCSTR szComponent, DWORD index, LPSTR szProduct)
1478 WCHAR szwProduct[GUID_SIZE];
1479 LPWSTR szwComponent = NULL;
1481 TRACE("%s %d %p\n", debugstr_a(szComponent), index, szProduct);
1484 return ERROR_INVALID_PARAMETER;
1488 szwComponent = strdupAtoW( szComponent );
1490 return ERROR_OUTOFMEMORY;
1493 r = MsiEnumClientsW(szComponent?szwComponent:NULL, index, szwProduct);
1494 if( r == ERROR_SUCCESS )
1496 WideCharToMultiByte(CP_ACP, 0, szwProduct, -1,
1497 szProduct, GUID_SIZE, NULL, NULL);
1500 msi_free( szwComponent);
1505 UINT WINAPI MsiEnumClientsW(LPCWSTR szComponent, DWORD index, LPWSTR szProduct)
1509 WCHAR szValName[SQUISH_GUID_SIZE];
1511 TRACE("%s %d %p\n", debugstr_w(szComponent), index, szProduct);
1513 if (!szComponent || !*szComponent || !szProduct)
1514 return ERROR_INVALID_PARAMETER;
1516 if (MSIREG_OpenUserDataComponentKey(szComponent, NULL, &hkeyComp, FALSE) != ERROR_SUCCESS &&
1517 MSIREG_OpenUserDataComponentKey(szComponent, szLocalSid, &hkeyComp, FALSE) != ERROR_SUCCESS)
1518 return ERROR_UNKNOWN_COMPONENT;
1520 /* see if there are any products at all */
1521 sz = SQUISH_GUID_SIZE;
1522 r = RegEnumValueW(hkeyComp, 0, szValName, &sz, NULL, NULL, NULL, NULL);
1523 if (r != ERROR_SUCCESS)
1525 RegCloseKey(hkeyComp);
1528 return ERROR_INVALID_PARAMETER;
1530 return ERROR_UNKNOWN_COMPONENT;
1533 sz = SQUISH_GUID_SIZE;
1534 r = RegEnumValueW(hkeyComp, index, szValName, &sz, NULL, NULL, NULL, NULL);
1535 if( r == ERROR_SUCCESS )
1536 unsquash_guid(szValName, szProduct);
1538 RegCloseKey(hkeyComp);
1543 static UINT MSI_EnumComponentQualifiers( LPCWSTR szComponent, DWORD iIndex,
1544 awstring *lpQualBuf, LPDWORD pcchQual,
1545 awstring *lpAppBuf, LPDWORD pcchAppBuf )
1547 DWORD name_sz, val_sz, name_max, val_max, type, ofs;
1548 LPWSTR name = NULL, val = NULL;
1552 TRACE("%s %08x %p %p %p %p\n", debugstr_w(szComponent), iIndex,
1553 lpQualBuf, pcchQual, lpAppBuf, pcchAppBuf);
1556 return ERROR_INVALID_PARAMETER;
1558 r = MSIREG_OpenUserComponentsKey( szComponent, &key, FALSE );
1559 if (r != ERROR_SUCCESS)
1560 return ERROR_UNKNOWN_COMPONENT;
1562 /* figure out how big the name is we want to return */
1564 r = ERROR_OUTOFMEMORY;
1565 name = msi_alloc( name_max * sizeof(WCHAR) );
1570 r = ERROR_OUTOFMEMORY;
1571 val = msi_alloc( val_max );
1575 /* loop until we allocate enough memory */
1580 r = RegEnumValueW( key, iIndex, name, &name_sz,
1581 NULL, &type, (LPBYTE)val, &val_sz );
1582 if (r == ERROR_SUCCESS)
1584 if (r != ERROR_MORE_DATA)
1587 if (type != REG_MULTI_SZ)
1589 ERR("component data has wrong type (%d)\n", type);
1593 r = ERROR_OUTOFMEMORY;
1594 if ((name_sz+1) >= name_max)
1598 name = msi_alloc( name_max * sizeof (WCHAR) );
1603 if (val_sz > val_max)
1605 val_max = val_sz + sizeof (WCHAR);
1607 val = msi_alloc( val_max * sizeof (WCHAR) );
1612 ERR("should be enough data, but isn't %d %d\n", name_sz, val_sz );
1617 r = MsiDecomposeDescriptorW( val, NULL, NULL, NULL, &ofs );
1618 if (r != ERROR_SUCCESS)
1621 TRACE("Providing %s and %s\n", debugstr_w(name), debugstr_w(val+ofs));
1623 r = msi_strcpy_to_awstring( name, lpQualBuf, pcchQual );
1624 r2 = msi_strcpy_to_awstring( val+ofs, lpAppBuf, pcchAppBuf );
1626 if (r2 != ERROR_SUCCESS)
1637 /*************************************************************************
1638 * MsiEnumComponentQualifiersA [MSI.@]
1640 UINT WINAPI MsiEnumComponentQualifiersA( LPCSTR szComponent, DWORD iIndex,
1641 LPSTR lpQualifierBuf, LPDWORD pcchQualifierBuf,
1642 LPSTR lpApplicationDataBuf, LPDWORD pcchApplicationDataBuf )
1644 awstring qual, appdata;
1648 TRACE("%s %08x %p %p %p %p\n", debugstr_a(szComponent), iIndex,
1649 lpQualifierBuf, pcchQualifierBuf, lpApplicationDataBuf,
1650 pcchApplicationDataBuf);
1652 comp = strdupAtoW( szComponent );
1653 if (szComponent && !comp)
1654 return ERROR_OUTOFMEMORY;
1656 qual.unicode = FALSE;
1657 qual.str.a = lpQualifierBuf;
1659 appdata.unicode = FALSE;
1660 appdata.str.a = lpApplicationDataBuf;
1662 r = MSI_EnumComponentQualifiers( comp, iIndex,
1663 &qual, pcchQualifierBuf, &appdata, pcchApplicationDataBuf );
1668 /*************************************************************************
1669 * MsiEnumComponentQualifiersW [MSI.@]
1671 UINT WINAPI MsiEnumComponentQualifiersW( LPCWSTR szComponent, DWORD iIndex,
1672 LPWSTR lpQualifierBuf, LPDWORD pcchQualifierBuf,
1673 LPWSTR lpApplicationDataBuf, LPDWORD pcchApplicationDataBuf )
1675 awstring qual, appdata;
1677 TRACE("%s %08x %p %p %p %p\n", debugstr_w(szComponent), iIndex,
1678 lpQualifierBuf, pcchQualifierBuf, lpApplicationDataBuf,
1679 pcchApplicationDataBuf);
1681 qual.unicode = TRUE;
1682 qual.str.w = lpQualifierBuf;
1684 appdata.unicode = TRUE;
1685 appdata.str.w = lpApplicationDataBuf;
1687 return MSI_EnumComponentQualifiers( szComponent, iIndex,
1688 &qual, pcchQualifierBuf, &appdata, pcchApplicationDataBuf );
1691 /*************************************************************************
1692 * MsiEnumRelatedProductsW [MSI.@]
1695 UINT WINAPI MsiEnumRelatedProductsW(LPCWSTR szUpgradeCode, DWORD dwReserved,
1696 DWORD iProductIndex, LPWSTR lpProductBuf)
1700 DWORD dwSize = SQUISH_GUID_SIZE;
1701 WCHAR szKeyName[SQUISH_GUID_SIZE];
1703 TRACE("%s %u %u %p\n", debugstr_w(szUpgradeCode), dwReserved,
1704 iProductIndex, lpProductBuf);
1706 if (NULL == szUpgradeCode)
1707 return ERROR_INVALID_PARAMETER;
1708 if (NULL == lpProductBuf)
1709 return ERROR_INVALID_PARAMETER;
1711 r = MSIREG_OpenUpgradeCodesKey(szUpgradeCode, &hkey, FALSE);
1712 if (r != ERROR_SUCCESS)
1713 return ERROR_NO_MORE_ITEMS;
1715 r = RegEnumValueW(hkey, iProductIndex, szKeyName, &dwSize, NULL, NULL, NULL, NULL);
1716 if( r == ERROR_SUCCESS )
1717 unsquash_guid(szKeyName, lpProductBuf);
1723 /*************************************************************************
1724 * MsiEnumRelatedProductsA [MSI.@]
1727 UINT WINAPI MsiEnumRelatedProductsA(LPCSTR szUpgradeCode, DWORD dwReserved,
1728 DWORD iProductIndex, LPSTR lpProductBuf)
1730 LPWSTR szwUpgradeCode = NULL;
1731 WCHAR productW[GUID_SIZE];
1734 TRACE("%s %u %u %p\n", debugstr_a(szUpgradeCode), dwReserved,
1735 iProductIndex, lpProductBuf);
1739 szwUpgradeCode = strdupAtoW( szUpgradeCode );
1740 if( !szwUpgradeCode )
1741 return ERROR_OUTOFMEMORY;
1744 r = MsiEnumRelatedProductsW( szwUpgradeCode, dwReserved,
1745 iProductIndex, productW );
1746 if (r == ERROR_SUCCESS)
1748 WideCharToMultiByte( CP_ACP, 0, productW, GUID_SIZE,
1749 lpProductBuf, GUID_SIZE, NULL, NULL );
1751 msi_free( szwUpgradeCode);
1755 /***********************************************************************
1756 * MsiEnumPatchesExA [MSI.@]
1758 UINT WINAPI MsiEnumPatchesExA(LPCSTR szProductCode, LPCSTR szUserSid,
1759 DWORD dwContext, DWORD dwFilter, DWORD dwIndex, LPSTR szPatchCode,
1760 LPSTR szTargetProductCode, MSIINSTALLCONTEXT *pdwTargetProductContext,
1761 LPSTR szTargetUserSid, LPDWORD pcchTargetUserSid)
1763 LPWSTR prodcode = NULL;
1764 LPWSTR usersid = NULL;
1765 LPWSTR targsid = NULL;
1766 WCHAR patch[GUID_SIZE];
1767 WCHAR targprod[GUID_SIZE];
1771 TRACE("(%s, %s, %d, %d, %d, %p, %p, %p, %p, %p)\n",
1772 debugstr_a(szProductCode), debugstr_a(szUserSid), dwContext, dwFilter,
1773 dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext,
1774 szTargetUserSid, pcchTargetUserSid);
1776 if (szTargetUserSid && !pcchTargetUserSid)
1777 return ERROR_INVALID_PARAMETER;
1779 if (szProductCode) prodcode = strdupAtoW(szProductCode);
1780 if (szUserSid) usersid = strdupAtoW(szUserSid);
1782 r = MsiEnumPatchesExW(prodcode, usersid, dwContext, dwFilter, dwIndex,
1783 patch, targprod, pdwTargetProductContext,
1785 if (r != ERROR_SUCCESS)
1788 WideCharToMultiByte(CP_ACP, 0, patch, -1, szPatchCode,
1789 GUID_SIZE, NULL, NULL);
1790 WideCharToMultiByte(CP_ACP, 0, targprod, -1, szTargetProductCode,
1791 GUID_SIZE, NULL, NULL);
1793 if (!szTargetUserSid)
1795 if (pcchTargetUserSid)
1796 *pcchTargetUserSid = len;
1801 targsid = msi_alloc(++len * sizeof(WCHAR));
1804 r = ERROR_OUTOFMEMORY;
1808 r = MsiEnumPatchesExW(prodcode, usersid, dwContext, dwFilter, dwIndex,
1809 patch, targprod, pdwTargetProductContext,
1811 if (r != ERROR_SUCCESS || !szTargetUserSid)
1814 WideCharToMultiByte(CP_ACP, 0, targsid, -1, szTargetUserSid,
1815 *pcchTargetUserSid, NULL, NULL);
1817 len = lstrlenW(targsid);
1818 if (*pcchTargetUserSid < len + 1)
1820 r = ERROR_MORE_DATA;
1821 *pcchTargetUserSid = len * sizeof(WCHAR);
1824 *pcchTargetUserSid = len;
1834 static UINT msi_get_patch_state(LPCWSTR prodcode, LPCWSTR usersid,
1835 MSIINSTALLCONTEXT context,
1836 LPWSTR patch, MSIPATCHSTATE *state)
1838 DWORD type, val, size;
1839 HKEY prod, hkey = 0;
1842 UINT r = ERROR_NO_MORE_ITEMS;
1844 *state = MSIPATCHSTATE_INVALID;
1846 r = MSIREG_OpenUserDataProductKey(prodcode, context,
1847 usersid, &prod, FALSE);
1848 if (r != ERROR_SUCCESS)
1849 return ERROR_NO_MORE_ITEMS;
1851 res = RegOpenKeyExW(prod, szPatches, 0, KEY_READ, &hkey);
1852 if (res != ERROR_SUCCESS)
1855 res = RegOpenKeyExW(hkey, patch, 0, KEY_READ, &udpatch);
1856 if (res != ERROR_SUCCESS)
1859 size = sizeof(DWORD);
1860 res = RegGetValueW(udpatch, NULL, szState, RRF_RT_DWORD, &type, &val, &size);
1861 if (res != ERROR_SUCCESS ||
1862 val < MSIPATCHSTATE_APPLIED || val > MSIPATCHSTATE_REGISTERED)
1864 r = ERROR_BAD_CONFIGURATION;
1872 RegCloseKey(udpatch);
1879 static UINT msi_check_product_patches(LPCWSTR prodcode, LPCWSTR usersid,
1880 MSIINSTALLCONTEXT context, DWORD filter, DWORD index, DWORD *idx,
1881 LPWSTR patch, LPWSTR targetprod, MSIINSTALLCONTEXT *targetctx,
1882 LPWSTR targetsid, DWORD *sidsize, LPWSTR *transforms)
1884 MSIPATCHSTATE state = MSIPATCHSTATE_INVALID;
1885 LPWSTR ptr, patches = NULL;
1886 HKEY prod, patchkey = 0;
1887 HKEY localprod = 0, localpatch = 0;
1890 UINT temp, r = ERROR_NO_MORE_ITEMS;
1892 if (MSIREG_OpenProductKey(prodcode, usersid, context,
1893 &prod, FALSE) != ERROR_SUCCESS)
1894 return ERROR_NO_MORE_ITEMS;
1897 res = RegGetValueW(prod, szPatches, szPatches, RRF_RT_ANY, &type, NULL,
1899 if (res != ERROR_SUCCESS)
1902 if (type != REG_MULTI_SZ)
1904 r = ERROR_BAD_CONFIGURATION;
1908 patches = msi_alloc(size);
1911 r = ERROR_OUTOFMEMORY;
1915 res = RegGetValueW(prod, szPatches, szPatches, RRF_RT_ANY, &type,
1917 if (res != ERROR_SUCCESS)
1921 for (ptr = patches; *ptr && r == ERROR_NO_MORE_ITEMS; ptr += lstrlenW(ptr))
1923 if (!unsquash_guid(ptr, patch))
1925 r = ERROR_BAD_CONFIGURATION;
1930 res = RegGetValueW(prod, szPatches, ptr, RRF_RT_REG_SZ,
1931 &type, NULL, &size);
1932 if (res != ERROR_SUCCESS)
1937 *transforms = msi_alloc(size);
1940 r = ERROR_OUTOFMEMORY;
1944 res = RegGetValueW(prod, szPatches, ptr, RRF_RT_REG_SZ,
1945 &type, *transforms, &size);
1946 if (res != ERROR_SUCCESS)
1950 if (context == MSIINSTALLCONTEXT_USERMANAGED)
1952 if (!(filter & MSIPATCHSTATE_APPLIED))
1954 temp = msi_get_patch_state(prodcode, usersid, context,
1956 if (temp == ERROR_BAD_CONFIGURATION)
1958 r = ERROR_BAD_CONFIGURATION;
1962 if (temp != ERROR_SUCCESS || !(filter & state))
1966 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
1968 if (!(filter & MSIPATCHSTATE_APPLIED))
1970 temp = msi_get_patch_state(prodcode, usersid, context,
1972 if (temp == ERROR_BAD_CONFIGURATION)
1974 r = ERROR_BAD_CONFIGURATION;
1978 if (temp != ERROR_SUCCESS || !(filter & state))
1983 temp = MSIREG_OpenUserDataPatchKey(patch, context,
1985 RegCloseKey(patchkey);
1986 if (temp != ERROR_SUCCESS)
1990 else if (context == MSIINSTALLCONTEXT_MACHINE)
1994 if (MSIREG_OpenUserDataProductKey(prodcode, context, NULL, &localprod, FALSE) == ERROR_SUCCESS &&
1995 RegOpenKeyExW(localprod, szPatches, 0, KEY_READ, &localpatch) == ERROR_SUCCESS &&
1996 RegOpenKeyExW(localpatch, ptr, 0, KEY_READ, &patchkey) == ERROR_SUCCESS)
1998 res = RegGetValueW(patchkey, NULL, szState, RRF_RT_REG_DWORD,
1999 &type, &state, &size);
2001 if (!(filter & state))
2002 res = ERROR_NO_MORE_ITEMS;
2004 RegCloseKey(patchkey);
2007 RegCloseKey(localpatch);
2008 RegCloseKey(localprod);
2010 if (res != ERROR_SUCCESS)
2022 lstrcpyW(targetprod, prodcode);
2025 *targetctx = context;
2029 lstrcpynW(targetsid, usersid, *sidsize);
2030 if (lstrlenW(usersid) >= *sidsize)
2031 r = ERROR_MORE_DATA;
2036 *sidsize = lstrlenW(usersid);
2038 *sidsize *= sizeof(WCHAR);
2049 static UINT msi_enum_patches(LPCWSTR szProductCode, LPCWSTR szUserSid,
2050 DWORD dwContext, DWORD dwFilter, DWORD dwIndex, DWORD *idx,
2051 LPWSTR szPatchCode, LPWSTR szTargetProductCode,
2052 MSIINSTALLCONTEXT *pdwTargetProductContext, LPWSTR szTargetUserSid,
2053 LPDWORD pcchTargetUserSid, LPWSTR *szTransforms)
2055 LPWSTR usersid = NULL;
2056 UINT r = ERROR_INVALID_PARAMETER;
2060 get_user_sid(&usersid);
2061 szUserSid = usersid;
2064 if (dwContext & MSIINSTALLCONTEXT_USERMANAGED)
2066 r = msi_check_product_patches(szProductCode, szUserSid,
2067 MSIINSTALLCONTEXT_USERMANAGED, dwFilter,
2068 dwIndex, idx, szPatchCode,
2069 szTargetProductCode,
2070 pdwTargetProductContext, szTargetUserSid,
2071 pcchTargetUserSid, szTransforms);
2072 if (r != ERROR_NO_MORE_ITEMS)
2076 if (dwContext & MSIINSTALLCONTEXT_USERUNMANAGED)
2078 r = msi_check_product_patches(szProductCode, szUserSid,
2079 MSIINSTALLCONTEXT_USERUNMANAGED, dwFilter,
2080 dwIndex, idx, szPatchCode,
2081 szTargetProductCode,
2082 pdwTargetProductContext, szTargetUserSid,
2083 pcchTargetUserSid, szTransforms);
2084 if (r != ERROR_NO_MORE_ITEMS)
2088 if (dwContext & MSIINSTALLCONTEXT_MACHINE)
2090 r = msi_check_product_patches(szProductCode, szUserSid,
2091 MSIINSTALLCONTEXT_MACHINE, dwFilter,
2092 dwIndex, idx, szPatchCode,
2093 szTargetProductCode,
2094 pdwTargetProductContext, szTargetUserSid,
2095 pcchTargetUserSid, szTransforms);
2096 if (r != ERROR_NO_MORE_ITEMS)
2105 /***********************************************************************
2106 * MsiEnumPatchesExW [MSI.@]
2108 UINT WINAPI MsiEnumPatchesExW(LPCWSTR szProductCode, LPCWSTR szUserSid,
2109 DWORD dwContext, DWORD dwFilter, DWORD dwIndex, LPWSTR szPatchCode,
2110 LPWSTR szTargetProductCode, MSIINSTALLCONTEXT *pdwTargetProductContext,
2111 LPWSTR szTargetUserSid, LPDWORD pcchTargetUserSid)
2113 WCHAR squished_pc[GUID_SIZE];
2117 static DWORD last_index;
2119 TRACE("(%s, %s, %d, %d, %d, %p, %p, %p, %p, %p)\n",
2120 debugstr_w(szProductCode), debugstr_w(szUserSid), dwContext, dwFilter,
2121 dwIndex, szPatchCode, szTargetProductCode, pdwTargetProductContext,
2122 szTargetUserSid, pcchTargetUserSid);
2124 if (!szProductCode || !squash_guid(szProductCode, squished_pc))
2125 return ERROR_INVALID_PARAMETER;
2127 if (!lstrcmpW(szUserSid, szLocalSid))
2128 return ERROR_INVALID_PARAMETER;
2130 if (dwContext & MSIINSTALLCONTEXT_MACHINE && szUserSid)
2131 return ERROR_INVALID_PARAMETER;
2133 if (dwContext <= MSIINSTALLCONTEXT_NONE ||
2134 dwContext > MSIINSTALLCONTEXT_ALL)
2135 return ERROR_INVALID_PARAMETER;
2137 if (dwFilter <= MSIPATCHSTATE_INVALID || dwFilter > MSIPATCHSTATE_ALL)
2138 return ERROR_INVALID_PARAMETER;
2140 if (dwIndex && dwIndex - last_index != 1)
2141 return ERROR_INVALID_PARAMETER;
2146 r = msi_enum_patches(szProductCode, szUserSid, dwContext, dwFilter,
2147 dwIndex, &idx, szPatchCode, szTargetProductCode,
2148 pdwTargetProductContext, szTargetUserSid,
2149 pcchTargetUserSid, NULL);
2151 if (r == ERROR_SUCCESS)
2152 last_index = dwIndex;
2159 /***********************************************************************
2160 * MsiEnumPatchesA [MSI.@]
2162 UINT WINAPI MsiEnumPatchesA(LPCSTR szProduct, DWORD iPatchIndex,
2163 LPSTR lpPatchBuf, LPSTR lpTransformsBuf, LPDWORD pcchTransformsBuf)
2165 LPWSTR product, transforms;
2166 WCHAR patch[GUID_SIZE];
2170 TRACE("(%s %d %p %p %p)\n", debugstr_a(szProduct), iPatchIndex,
2171 lpPatchBuf, lpTransformsBuf, pcchTransformsBuf);
2173 if (!szProduct || !lpPatchBuf || !lpTransformsBuf || !pcchTransformsBuf)
2174 return ERROR_INVALID_PARAMETER;
2176 product = strdupAtoW(szProduct);
2178 return ERROR_OUTOFMEMORY;
2180 len = *pcchTransformsBuf;
2181 transforms = msi_alloc( len * sizeof(WCHAR) );
2184 r = ERROR_OUTOFMEMORY;
2188 r = MsiEnumPatchesW(product, iPatchIndex, patch, transforms, &len);
2189 if (r != ERROR_SUCCESS && r != ERROR_MORE_DATA)
2192 WideCharToMultiByte(CP_ACP, 0, patch, -1, lpPatchBuf,
2193 GUID_SIZE, NULL, NULL);
2195 if (!WideCharToMultiByte(CP_ACP, 0, transforms, -1, lpTransformsBuf,
2196 *pcchTransformsBuf, NULL, NULL))
2197 r = ERROR_MORE_DATA;
2199 if (r == ERROR_MORE_DATA)
2201 lpTransformsBuf[*pcchTransformsBuf - 1] = '\0';
2202 *pcchTransformsBuf = len * 2;
2205 *pcchTransformsBuf = strlen( lpTransformsBuf );
2208 msi_free(transforms);
2214 /***********************************************************************
2215 * MsiEnumPatchesW [MSI.@]
2217 UINT WINAPI MsiEnumPatchesW(LPCWSTR szProduct, DWORD iPatchIndex,
2218 LPWSTR lpPatchBuf, LPWSTR lpTransformsBuf, LPDWORD pcchTransformsBuf)
2220 WCHAR squished_pc[GUID_SIZE];
2221 LPWSTR transforms = NULL;
2226 TRACE("(%s %d %p %p %p)\n", debugstr_w(szProduct), iPatchIndex,
2227 lpPatchBuf, lpTransformsBuf, pcchTransformsBuf);
2229 if (!szProduct || !squash_guid(szProduct, squished_pc))
2230 return ERROR_INVALID_PARAMETER;
2232 if (!lpPatchBuf || !lpTransformsBuf || !pcchTransformsBuf)
2233 return ERROR_INVALID_PARAMETER;
2235 if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
2236 &prod, FALSE) != ERROR_SUCCESS &&
2237 MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2238 &prod, FALSE) != ERROR_SUCCESS &&
2239 MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
2240 &prod, FALSE) != ERROR_SUCCESS)
2241 return ERROR_UNKNOWN_PRODUCT;
2245 r = msi_enum_patches(szProduct, NULL, MSIINSTALLCONTEXT_ALL,
2246 MSIPATCHSTATE_ALL, iPatchIndex, &idx, lpPatchBuf,
2247 NULL, NULL, NULL, NULL, &transforms);
2248 if (r != ERROR_SUCCESS)
2251 lstrcpynW(lpTransformsBuf, transforms, *pcchTransformsBuf);
2252 if (*pcchTransformsBuf <= lstrlenW(transforms))
2254 r = ERROR_MORE_DATA;
2255 *pcchTransformsBuf = lstrlenW(transforms);
2258 *pcchTransformsBuf = lstrlenW(transforms);
2261 msi_free(transforms);
2265 UINT WINAPI MsiEnumProductsExA( LPCSTR szProductCode, LPCSTR szUserSid,
2266 DWORD dwContext, DWORD dwIndex, CHAR szInstalledProductCode[39],
2267 MSIINSTALLCONTEXT* pdwInstalledContext, LPSTR szSid, LPDWORD pcchSid)
2269 FIXME("%s %s %d %d %p %p %p %p\n", debugstr_a(szProductCode), debugstr_a(szUserSid),
2270 dwContext, dwIndex, szInstalledProductCode, pdwInstalledContext,
2272 return ERROR_NO_MORE_ITEMS;
2275 UINT WINAPI MsiEnumProductsExW( LPCWSTR szProductCode, LPCWSTR szUserSid,
2276 DWORD dwContext, DWORD dwIndex, WCHAR szInstalledProductCode[39],
2277 MSIINSTALLCONTEXT* pdwInstalledContext, LPWSTR szSid, LPDWORD pcchSid)
2279 FIXME("%s %s %d %d %p %p %p %p\n", debugstr_w(szProductCode), debugstr_w(szUserSid),
2280 dwContext, dwIndex, szInstalledProductCode, pdwInstalledContext,
2282 return ERROR_NO_MORE_ITEMS;