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_fmt[] = {
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','\\',
113 static const WCHAR szUserPatch_fmt[] = {
114 'S','o','f','t','w','a','r','e','\\',
115 'M','i','c','r','o','s','o','f','t','\\',
116 'I','n','s','t','a','l','l','e','r','\\',
117 'P','a','t','c','h','e','s','\\',
120 static const WCHAR szInstaller_Products[] = {
121 'S','o','f','t','w','a','r','e','\\',
122 'M','i','c','r','o','s','o','f','t','\\',
123 'W','i','n','d','o','w','s','\\',
124 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
125 'I','n','s','t','a','l','l','e','r','\\',
126 'P','r','o','d','u','c','t','s',0};
128 static const WCHAR szInstaller_Products_fmt[] = {
129 'S','o','f','t','w','a','r','e','\\',
130 'M','i','c','r','o','s','o','f','t','\\',
131 'W','i','n','d','o','w','s','\\',
132 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
133 'I','n','s','t','a','l','l','e','r','\\',
134 'P','r','o','d','u','c','t','s','\\',
137 static const WCHAR szInstaller_Patches_fmt[] = {
138 'S','o','f','t','w','a','r','e','\\',
139 'M','i','c','r','o','s','o','f','t','\\',
140 'W','i','n','d','o','w','s','\\',
141 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
142 'I','n','s','t','a','l','l','e','r','\\',
143 'P','a','t','c','h','e','s','\\',
146 static const WCHAR szInstaller_UpgradeCodes_fmt[] = {
147 'S','o','f','t','w','a','r','e','\\',
148 'M','i','c','r','o','s','o','f','t','\\',
149 'W','i','n','d','o','w','s','\\',
150 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
151 'I','n','s','t','a','l','l','e','r','\\',
152 'U','p','g','r','a','d','e','C','o','d','e','s','\\',
155 static const WCHAR szInstaller_UserUpgradeCodes_fmt[] = {
156 'S','o','f','t','w','a','r','e','\\',
157 'M','i','c','r','o','s','o','f','t','\\',
158 'I','n','s','t','a','l','l','e','r','\\',
159 'U','p','g','r','a','d','e','C','o','d','e','s','\\',
162 static const WCHAR szUserDataProd_fmt[] = {
163 'S','o','f','t','w','a','r','e','\\',
164 'M','i','c','r','o','s','o','f','t','\\',
165 'W','i','n','d','o','w','s','\\',
166 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
167 'I','n','s','t','a','l','l','e','r','\\',
168 'U','s','e','r','D','a','t','a','\\',
169 '%','s','\\','P','r','o','d','u','c','t','s','\\','%','s',0};
171 static const WCHAR szInstallProperties_fmt[] = {
172 'S','o','f','t','w','a','r','e','\\',
173 'M','i','c','r','o','s','o','f','t','\\',
174 'W','i','n','d','o','w','s','\\',
175 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
176 'I','n','s','t','a','l','l','e','r','\\',
177 'U','s','e','r','D','a','t','a','\\',
178 '%','s','\\','P','r','o','d','u','c','t','s','\\','%','s','\\',
179 'I','n','s','t','a','l','l','P','r','o','p','e','r','t','i','e','s',0};
181 static const WCHAR szInstaller_LocalSystemProductCodes_fmt[] = {
182 'S','o','f','t','w','a','r','e','\\',
183 'M','i','c','r','o','s','o','f','t','\\',
184 'W','i','n','d','o','w','s','\\',
185 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
186 'I','n','s','t','a','l','l','e','r','\\',
187 'U','s','e','r','D','a','t','a','\\',
188 'S','-','1','-','5','-','1','8','\\','P','r','o','d','u','c','t','s','\\',
189 '%','s','\\','I','n','s','t','a','l','l','P','r','o','p','e','r','t','i','e','s',0};
191 static const WCHAR szInstaller_LocalSystemComponent_fmt[] = {
192 'S','o','f','t','w','a','r','e','\\',
193 'M','i','c','r','o','s','o','f','t','\\',
194 'W','i','n','d','o','w','s','\\',
195 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
196 'I','n','s','t','a','l','l','e','r','\\',
197 'U','s','e','r','D','a','t','a','\\',
198 'S','-','1','-','5','-','1','8','\\',
199 'C','o','m','p','o','n','e','n','t','s','\\','%','s',0};
201 static const WCHAR szInstaller_LocalClassesProd_fmt[] = {
202 'S','o','f','t','w','a','r','e','\\',
203 'C','l','a','s','s','e','s','\\',
204 'I','n','s','t','a','l','l','e','r','\\',
205 'P','r','o','d','u','c','t','s','\\','%','s',0};
207 static const WCHAR szInstaller_LocalClassesFeat_fmt[] = {
208 'S','o','f','t','w','a','r','e','\\',
209 'C','l','a','s','s','e','s','\\',
210 'I','n','s','t','a','l','l','e','r','\\',
211 'F','e','a','t','u','r','e','s','\\','%','s',0};
213 static const WCHAR szInstaller_LocalManagedProd_fmt[] = {
214 'S','o','f','t','w','a','r','e','\\',
215 'M','i','c','r','o','s','o','f','t','\\',
216 'W','i','n','d','o','w','s','\\',
217 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
218 'I','n','s','t','a','l','l','e','r','\\',
219 'M','a','n','a','g','e','d','\\','%','s','\\',
220 'I','n','s','t','a','l','l','e','r','\\',
221 'P','r','o','d','u','c','t','s','\\','%','s',0};
223 static const WCHAR localsid[] = {'S','-','1','-','5','-','1','8',0};
225 BOOL unsquash_guid(LPCWSTR in, LPWSTR out)
241 out[n++] = in[17+i*2];
242 out[n++] = in[16+i*2];
247 out[n++] = in[17+i*2];
248 out[n++] = in[16+i*2];
255 BOOL squash_guid(LPCWSTR in, LPWSTR out)
262 if (FAILED(CLSIDFromString((LPOLESTR)in, &guid)))
276 out[17+i*2] = in[n++];
277 out[16+i*2] = in[n++];
282 out[17+i*2] = in[n++];
283 out[16+i*2] = in[n++];
290 /* tables for encoding and decoding base85 */
291 static const unsigned char table_dec85[0x80] = {
292 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
293 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
294 0xff,0x00,0xff,0xff,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0xff,
295 0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0xff,0xff,0xff,0x16,0xff,0x17,
296 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,
297 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0xff,0x34,0x35,0x36,
298 0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43,0x44,0x45,0x46,
299 0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0xff,0x53,0x54,0xff,
302 static const char table_enc85[] =
303 "!$%&'()*+,-.0123456789=?@ABCDEFGHIJKLMNO"
304 "PQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx"
308 * Converts a base85 encoded guid into a GUID pointer
309 * Base85 encoded GUIDs should be 20 characters long.
311 * returns TRUE if successful, FALSE if not
313 BOOL decode_base85_guid( LPCWSTR str, GUID *guid )
315 DWORD i, val = 0, base = 1, *p;
321 for( i=0; i<20; i++ )
328 val += table_dec85[str[i]] * base;
331 if( table_dec85[str[i]] == 0xff )
341 * Encodes a base85 guid given a GUID pointer
342 * Caller should provide a 21 character buffer for the encoded string.
344 * returns TRUE if successful, FALSE if not
346 BOOL encode_base85_guid( GUID *guid, LPWSTR str )
348 unsigned int x, *p, i;
350 p = (unsigned int*) guid;
354 *str++ = table_enc85[x%85];
356 *str++ = table_enc85[x%85];
358 *str++ = table_enc85[x%85];
360 *str++ = table_enc85[x%85];
362 *str++ = table_enc85[x%85];
369 DWORD msi_version_str_to_dword(LPCWSTR p)
371 DWORD major, minor = 0, build = 0, version = 0;
382 p = strchrW(p+1, '.');
387 return MAKELONG(build, MAKEWORD(minor, major));
390 LPWSTR msi_version_dword_to_str(DWORD version)
392 static const WCHAR fmt[] = { '%','u','.','%','u','.','%','u',0 };
393 LPWSTR str = msi_alloc(20);
395 (version&0xff000000)>>24,
396 (version&0x00ff0000)>>16,
401 LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value )
403 static const WCHAR emptyW[] = {0};
405 if (!value) value = emptyW;
406 len = (lstrlenW(value) + 1) * sizeof (WCHAR);
407 return RegSetValueExW( hkey, name, 0, REG_SZ, (const BYTE *)value, len );
410 LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value )
413 while (*p) p += lstrlenW(p) + 1;
414 return RegSetValueExW( hkey, name, 0, REG_MULTI_SZ,
415 (const BYTE *)value, (p + 1 - value) * sizeof(WCHAR) );
418 LONG msi_reg_set_val_dword( HKEY hkey, LPCWSTR name, DWORD val )
420 return RegSetValueExW( hkey, name, 0, REG_DWORD, (LPBYTE)&val, sizeof (DWORD) );
423 LONG msi_reg_set_subkey_val( HKEY hkey, LPCWSTR path, LPCWSTR name, LPCWSTR val )
428 r = RegCreateKeyW( hkey, path, &hsubkey );
429 if (r != ERROR_SUCCESS)
431 r = msi_reg_set_val_str( hsubkey, name, val );
432 RegCloseKey( hsubkey );
436 LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name )
442 r = RegQueryValueExW(hkey, name, NULL, NULL, NULL, &len);
443 if (r != ERROR_SUCCESS)
446 len += sizeof (WCHAR);
447 val = msi_alloc( len );
451 RegQueryValueExW(hkey, name, NULL, NULL, (LPBYTE) val, &len);
455 BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val)
457 DWORD type, len = sizeof (DWORD);
458 LONG r = RegQueryValueExW(hkey, name, NULL, &type, (LPBYTE) val, &len);
459 return r == ERROR_SUCCESS && type == REG_DWORD;
462 static UINT get_user_sid(LPWSTR *usersid)
469 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
470 return ERROR_FUNCTION_FAILED;
473 if (!GetTokenInformation(token, TokenUser, (void *)buf, size, &size)) {
475 return ERROR_FUNCTION_FAILED;
478 user = (PTOKEN_USER)buf;
479 if (!ConvertSidToStringSidW(user->User.Sid, usersid)) {
481 return ERROR_FUNCTION_FAILED;
484 return ERROR_SUCCESS;
487 UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create)
490 WCHAR keypath[0x200];
491 TRACE("%s\n",debugstr_w(szProduct));
493 sprintfW(keypath,szUninstall_fmt,szProduct);
496 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
498 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
503 UINT MSIREG_DeleteUninstallKey(LPCWSTR szProduct)
505 WCHAR keypath[0x200];
506 TRACE("%s\n",debugstr_w(szProduct));
508 sprintfW(keypath,szUninstall_fmt,szProduct);
510 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
513 UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create)
516 WCHAR squished_pc[GUID_SIZE];
517 WCHAR keypath[0x200];
519 TRACE("%s\n",debugstr_w(szProduct));
520 if (!squash_guid(szProduct,squished_pc))
521 return ERROR_FUNCTION_FAILED;
522 TRACE("squished (%s)\n", debugstr_w(squished_pc));
524 sprintfW(keypath,szUserProduct_fmt,squished_pc);
527 rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
529 rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
534 UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct)
536 WCHAR squished_pc[GUID_SIZE];
537 WCHAR keypath[0x200];
539 TRACE("%s\n",debugstr_w(szProduct));
540 if (!squash_guid(szProduct,squished_pc))
541 return ERROR_FUNCTION_FAILED;
542 TRACE("squished (%s)\n", debugstr_w(squished_pc));
544 sprintfW(keypath,szUserProduct_fmt,squished_pc);
546 return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
549 UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create)
552 WCHAR squished_pc[GUID_SIZE];
553 WCHAR keypath[0x200];
555 TRACE("%s\n",debugstr_w(szPatch));
556 if (!squash_guid(szPatch,squished_pc))
557 return ERROR_FUNCTION_FAILED;
558 TRACE("squished (%s)\n", debugstr_w(squished_pc));
560 sprintfW(keypath,szUserPatch_fmt,squished_pc);
563 rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
565 rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
570 UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create)
573 WCHAR squished_pc[GUID_SIZE];
574 WCHAR keypath[0x200];
576 TRACE("%s\n",debugstr_w(szProduct));
577 if (!squash_guid(szProduct,squished_pc))
578 return ERROR_FUNCTION_FAILED;
579 TRACE("squished (%s)\n", debugstr_w(squished_pc));
581 sprintfW(keypath,szUserFeatures_fmt,squished_pc);
584 rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
586 rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
591 UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct)
593 WCHAR squished_pc[GUID_SIZE];
594 WCHAR keypath[0x200];
596 TRACE("%s\n",debugstr_w(szProduct));
597 if (!squash_guid(szProduct,squished_pc))
598 return ERROR_FUNCTION_FAILED;
599 TRACE("squished (%s)\n", debugstr_w(squished_pc));
601 sprintfW(keypath,szUserFeatures_fmt,squished_pc);
602 return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
605 UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create)
608 WCHAR squished_pc[GUID_SIZE];
609 WCHAR keypath[0x200];
611 TRACE("%s\n",debugstr_w(szProduct));
612 if (!squash_guid(szProduct,squished_pc))
613 return ERROR_FUNCTION_FAILED;
614 TRACE("squished (%s)\n", debugstr_w(squished_pc));
616 sprintfW(keypath,szInstaller_Features_fmt,squished_pc);
619 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,keypath,key);
621 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,keypath,key);
626 UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create)
629 WCHAR squished_pc[GUID_SIZE];
630 WCHAR keypath[0x200];
633 TRACE("%s\n", debugstr_w(szProduct));
634 if (!squash_guid(szProduct, squished_pc))
635 return ERROR_FUNCTION_FAILED;
636 TRACE("squished (%s)\n", debugstr_w(squished_pc));
638 rc = get_user_sid(&usersid);
639 if (rc != ERROR_SUCCESS || !usersid)
641 ERR("Failed to retrieve user SID: %d\n", rc);
645 sprintfW(keypath, szUserDataFeatures_fmt, usersid, squished_pc);
648 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
650 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
656 UINT MSIREG_OpenLocalUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create)
658 WCHAR squished_pc[GUID_SIZE];
659 WCHAR keypath[0x200];
661 TRACE("%s\n", debugstr_w(szProduct));
662 if (!squash_guid(szProduct, squished_pc))
663 return ERROR_FUNCTION_FAILED;
664 TRACE("squished (%s)\n", debugstr_w(squished_pc));
666 sprintfW(keypath, szUserDataFeatures_fmt, localsid, squished_pc);
669 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
671 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
674 UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create)
677 WCHAR squished_cc[GUID_SIZE];
678 WCHAR keypath[0x200];
680 TRACE("%s\n",debugstr_w(szComponent));
681 if (!squash_guid(szComponent,squished_cc))
682 return ERROR_FUNCTION_FAILED;
683 TRACE("squished (%s)\n", debugstr_w(squished_cc));
685 sprintfW(keypath,szUser_Components_fmt,squished_cc);
688 rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
690 rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
695 UINT MSIREG_OpenLocalUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create)
697 WCHAR comp[GUID_SIZE];
698 WCHAR keypath[0x200];
700 TRACE("%s\n", debugstr_w(szComponent));
701 if (!squash_guid(szComponent, comp))
702 return ERROR_FUNCTION_FAILED;
703 TRACE("squished (%s)\n", debugstr_w(comp));
705 sprintfW(keypath, szUserDataComp_fmt, localsid, comp);
708 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
710 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
713 UINT MSIREG_DeleteLocalUserDataComponentKey(LPCWSTR szComponent)
715 WCHAR comp[GUID_SIZE];
716 WCHAR keypath[0x200];
718 TRACE("%s\n", debugstr_w(szComponent));
719 if (!squash_guid(szComponent, comp))
720 return ERROR_FUNCTION_FAILED;
721 TRACE("squished (%s)\n", debugstr_w(comp));
723 sprintfW(keypath, szUserDataComp_fmt, localsid, comp);
724 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
727 UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create)
730 WCHAR comp[GUID_SIZE];
731 WCHAR keypath[0x200];
734 TRACE("%s\n", debugstr_w(szComponent));
735 if (!squash_guid(szComponent, comp))
736 return ERROR_FUNCTION_FAILED;
737 TRACE("squished (%s)\n", debugstr_w(comp));
739 rc = get_user_sid(&usersid);
740 if (rc != ERROR_SUCCESS || !usersid)
742 ERR("Failed to retrieve user SID: %d\n", rc);
746 sprintfW(keypath, szUserDataComp_fmt, usersid, comp);
749 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
751 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
757 UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent)
760 WCHAR comp[GUID_SIZE];
761 WCHAR keypath[0x200];
764 TRACE("%s\n", debugstr_w(szComponent));
765 if (!squash_guid(szComponent, comp))
766 return ERROR_FUNCTION_FAILED;
767 TRACE("squished (%s)\n", debugstr_w(comp));
769 rc = get_user_sid(&usersid);
770 if (rc != ERROR_SUCCESS || !usersid)
772 ERR("Failed to retrieve user SID: %d\n", rc);
776 sprintfW(keypath, szUserDataComp_fmt, usersid, comp);
779 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
782 UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, HKEY *key, BOOL create)
785 WCHAR squished_pc[GUID_SIZE];
786 WCHAR keypath[0x200];
789 TRACE("%s\n", debugstr_w(szProduct));
790 if (!squash_guid(szProduct, squished_pc))
791 return ERROR_FUNCTION_FAILED;
792 TRACE("squished (%s)\n", debugstr_w(squished_pc));
794 rc = get_user_sid(&usersid);
795 if (rc != ERROR_SUCCESS || !usersid)
797 ERR("Failed to retrieve user SID: %d\n", rc);
801 sprintfW(keypath, szUserDataProd_fmt, usersid, squished_pc);
804 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
806 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
812 static UINT MSIREG_OpenInstallProps(LPCWSTR szProduct, LPCWSTR szUserSID,
813 HKEY *key, BOOL create)
816 WCHAR squished_pc[GUID_SIZE];
817 WCHAR keypath[0x200];
819 TRACE("%s\n", debugstr_w(szProduct));
820 if (!squash_guid(szProduct, squished_pc))
821 return ERROR_FUNCTION_FAILED;
822 TRACE("squished (%s)\n", debugstr_w(squished_pc));
824 sprintfW(keypath, szInstallProperties_fmt, szUserSID, squished_pc);
827 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
829 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
834 UINT MSIREG_OpenCurrentUserInstallProps(LPCWSTR szProduct, HKEY *key,
840 rc = get_user_sid(&usersid);
841 if (rc != ERROR_SUCCESS || !usersid)
843 ERR("Failed to retrieve user SID: %d\n", rc);
847 rc = MSIREG_OpenInstallProps(szProduct, usersid, key, create);
853 UINT MSIREG_OpenLocalSystemInstallProps(LPCWSTR szProduct, HKEY *key,
856 return MSIREG_OpenInstallProps(szProduct, localsid, key, create);
859 UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct)
862 WCHAR squished_pc[GUID_SIZE];
863 WCHAR keypath[0x200];
866 TRACE("%s\n", debugstr_w(szProduct));
867 if (!squash_guid(szProduct, squished_pc))
868 return ERROR_FUNCTION_FAILED;
869 TRACE("squished (%s)\n", debugstr_w(squished_pc));
871 rc = get_user_sid(&usersid);
872 if (rc != ERROR_SUCCESS || !usersid)
874 ERR("Failed to retrieve user SID: %d\n", rc);
878 sprintfW(keypath, szUserDataProd_fmt, usersid, squished_pc);
881 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
884 UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create)
887 WCHAR squished_pc[GUID_SIZE];
888 WCHAR keypath[0x200];
890 TRACE("%s\n",debugstr_w(szProduct));
891 if (!squash_guid(szProduct,squished_pc))
892 return ERROR_FUNCTION_FAILED;
893 TRACE("squished (%s)\n", debugstr_w(squished_pc));
895 sprintfW(keypath,szInstaller_Products_fmt,squished_pc);
898 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,keypath,key);
900 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,keypath,key);
905 UINT MSIREG_DeleteProductKey(LPCWSTR szProduct)
907 WCHAR squished_pc[GUID_SIZE];
908 WCHAR keypath[0x200];
910 TRACE("%s\n", debugstr_w(szProduct));
911 if (!squash_guid(szProduct, squished_pc))
912 return ERROR_FUNCTION_FAILED;
913 TRACE("squished (%s)\n", debugstr_w(squished_pc));
915 sprintfW(keypath, szInstaller_Products_fmt, squished_pc);
917 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
920 UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create)
923 WCHAR squished_pc[GUID_SIZE];
924 WCHAR keypath[0x200];
926 TRACE("%s\n",debugstr_w(szPatch));
927 if (!squash_guid(szPatch,squished_pc))
928 return ERROR_FUNCTION_FAILED;
929 TRACE("squished (%s)\n", debugstr_w(squished_pc));
931 sprintfW(keypath,szInstaller_Patches_fmt,squished_pc);
934 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,keypath,key);
936 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,keypath,key);
941 UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL create)
944 WCHAR squished_pc[GUID_SIZE];
945 WCHAR keypath[0x200];
947 TRACE("%s\n",debugstr_w(szUpgradeCode));
948 if (!squash_guid(szUpgradeCode,squished_pc))
949 return ERROR_FUNCTION_FAILED;
950 TRACE("squished (%s)\n", debugstr_w(squished_pc));
952 sprintfW(keypath,szInstaller_UpgradeCodes_fmt,squished_pc);
955 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,keypath,key);
957 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,keypath,key);
962 UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL create)
965 WCHAR squished_pc[GUID_SIZE];
966 WCHAR keypath[0x200];
968 TRACE("%s\n",debugstr_w(szUpgradeCode));
969 if (!squash_guid(szUpgradeCode,squished_pc))
970 return ERROR_FUNCTION_FAILED;
971 TRACE("squished (%s)\n", debugstr_w(squished_pc));
973 sprintfW(keypath,szInstaller_UserUpgradeCodes_fmt,squished_pc);
976 rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
978 rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
983 UINT MSIREG_OpenLocalSystemProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
985 WCHAR squished_pc[GUID_SIZE];
986 WCHAR keypath[0x200];
988 TRACE("%s\n", debugstr_w(szProductCode));
990 if (!squash_guid(szProductCode, squished_pc))
991 return ERROR_FUNCTION_FAILED;
993 TRACE("squished (%s)\n", debugstr_w(squished_pc));
995 sprintfW(keypath, szInstaller_LocalSystemProductCodes_fmt, squished_pc);
998 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
1000 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
1003 UINT MSIREG_OpenLocalSystemComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create)
1005 WCHAR squished_pc[GUID_SIZE];
1006 WCHAR keypath[0x200];
1008 TRACE("%s\n", debugstr_w(szComponent));
1010 if (!squash_guid(szComponent, squished_pc))
1011 return ERROR_FUNCTION_FAILED;
1013 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1015 sprintfW(keypath, szInstaller_LocalSystemComponent_fmt, squished_pc);
1018 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
1020 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
1023 UINT MSIREG_OpenLocalClassesProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
1025 WCHAR squished_pc[GUID_SIZE];
1026 WCHAR keypath[0x200];
1028 TRACE("%s\n", debugstr_w(szProductCode));
1030 if (!squash_guid(szProductCode, squished_pc))
1031 return ERROR_FUNCTION_FAILED;
1033 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1035 sprintfW(keypath, szInstaller_LocalClassesProd_fmt, squished_pc);
1038 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
1040 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
1043 UINT MSIREG_OpenLocalClassesFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
1045 WCHAR squished_pc[GUID_SIZE];
1046 WCHAR keypath[0x200];
1048 TRACE("%s\n", debugstr_w(szProductCode));
1050 if (!squash_guid(szProductCode, squished_pc))
1051 return ERROR_FUNCTION_FAILED;
1053 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1055 sprintfW(keypath, szInstaller_LocalClassesFeat_fmt, squished_pc);
1058 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
1060 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
1063 UINT MSIREG_OpenLocalManagedProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
1065 WCHAR squished_pc[GUID_SIZE];
1066 WCHAR keypath[0x200];
1070 TRACE("%s\n", debugstr_w(szProductCode));
1072 if (!squash_guid(szProductCode, squished_pc))
1073 return ERROR_FUNCTION_FAILED;
1075 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1077 r = get_user_sid(&usersid);
1078 if (r != ERROR_SUCCESS || !usersid)
1080 ERR("Failed to retrieve user SID: %d\n", r);
1084 sprintfW(keypath, szInstaller_LocalManagedProd_fmt, usersid, squished_pc);
1088 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
1090 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
1093 /*************************************************************************
1094 * MsiDecomposeDescriptorW [MSI.@]
1096 * Decomposes an MSI descriptor into product, feature and component parts.
1097 * An MSI descriptor is a string of the form:
1098 * [base 85 guid] [feature code] '>' [base 85 guid]
1101 * szDescriptor [I] the descriptor to decompose
1102 * szProduct [O] buffer of MAX_FEATURE_CHARS+1 for the product guid
1103 * szFeature [O] buffer of MAX_FEATURE_CHARS+1 for the feature code
1104 * szComponent [O] buffer of MAX_FEATURE_CHARS+1 for the component guid
1105 * pUsed [O] the length of the descriptor
1108 * ERROR_SUCCESS if everything worked correctly
1109 * ERROR_INVALID_PARAMETER if the descriptor was invalid
1112 UINT WINAPI MsiDecomposeDescriptorW( LPCWSTR szDescriptor, LPWSTR szProduct,
1113 LPWSTR szFeature, LPWSTR szComponent, LPDWORD pUsed )
1117 GUID product, component;
1119 TRACE("%s %p %p %p %p\n", debugstr_w(szDescriptor), szProduct,
1120 szFeature, szComponent, pUsed);
1122 r = decode_base85_guid( szDescriptor, &product );
1124 return ERROR_INVALID_PARAMETER;
1126 TRACE("product %s\n", debugstr_guid( &product ));
1128 p = strchrW(&szDescriptor[20],'>');
1130 return ERROR_INVALID_PARAMETER;
1132 len = (p - &szDescriptor[20]);
1133 if( len > MAX_FEATURE_CHARS )
1134 return ERROR_INVALID_PARAMETER;
1136 TRACE("feature %s\n", debugstr_wn( &szDescriptor[20], len ));
1138 r = decode_base85_guid( p+1, &component );
1140 return ERROR_INVALID_PARAMETER;
1142 TRACE("component %s\n", debugstr_guid( &component ));
1145 StringFromGUID2( &product, szProduct, MAX_FEATURE_CHARS+1 );
1147 StringFromGUID2( &component, szComponent, MAX_FEATURE_CHARS+1 );
1150 memcpy( szFeature, &szDescriptor[20], len*sizeof(WCHAR) );
1153 len = ( &p[21] - szDescriptor );
1155 TRACE("length = %d\n", len);
1158 return ERROR_SUCCESS;
1161 UINT WINAPI MsiDecomposeDescriptorA( LPCSTR szDescriptor, LPSTR szProduct,
1162 LPSTR szFeature, LPSTR szComponent, LPDWORD pUsed )
1164 WCHAR product[MAX_FEATURE_CHARS+1];
1165 WCHAR feature[MAX_FEATURE_CHARS+1];
1166 WCHAR component[MAX_FEATURE_CHARS+1];
1167 LPWSTR str = NULL, p = NULL, f = NULL, c = NULL;
1170 TRACE("%s %p %p %p %p\n", debugstr_a(szDescriptor), szProduct,
1171 szFeature, szComponent, pUsed);
1173 str = strdupAtoW( szDescriptor );
1174 if( szDescriptor && !str )
1175 return ERROR_OUTOFMEMORY;
1184 r = MsiDecomposeDescriptorW( str, p, f, c, pUsed );
1186 if (r == ERROR_SUCCESS)
1188 WideCharToMultiByte( CP_ACP, 0, p, -1,
1189 szProduct, MAX_FEATURE_CHARS+1, NULL, NULL );
1190 WideCharToMultiByte( CP_ACP, 0, f, -1,
1191 szFeature, MAX_FEATURE_CHARS+1, NULL, NULL );
1192 WideCharToMultiByte( CP_ACP, 0, c, -1,
1193 szComponent, MAX_FEATURE_CHARS+1, NULL, NULL );
1201 UINT WINAPI MsiEnumProductsA(DWORD index, LPSTR lpguid)
1204 WCHAR szwGuid[GUID_SIZE];
1206 TRACE("%d %p\n", index, lpguid);
1209 return ERROR_INVALID_PARAMETER;
1210 r = MsiEnumProductsW(index, szwGuid);
1211 if( r == ERROR_SUCCESS )
1212 WideCharToMultiByte(CP_ACP, 0, szwGuid, -1, lpguid, GUID_SIZE, NULL, NULL);
1217 UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid)
1219 HKEY hkeyProducts = 0;
1221 WCHAR szKeyName[SQUISH_GUID_SIZE];
1223 TRACE("%d %p\n", index, lpguid);
1226 return ERROR_INVALID_PARAMETER;
1228 r = RegCreateKeyW(HKEY_LOCAL_MACHINE, szInstaller_Products, &hkeyProducts);
1229 if( r != ERROR_SUCCESS )
1230 return ERROR_NO_MORE_ITEMS;
1232 r = RegEnumKeyW(hkeyProducts, index, szKeyName, SQUISH_GUID_SIZE);
1233 if( r == ERROR_SUCCESS )
1234 unsquash_guid(szKeyName, lpguid);
1235 RegCloseKey(hkeyProducts);
1240 UINT WINAPI MsiEnumFeaturesA(LPCSTR szProduct, DWORD index,
1241 LPSTR szFeature, LPSTR szParent)
1244 WCHAR szwFeature[GUID_SIZE], szwParent[GUID_SIZE];
1245 LPWSTR szwProduct = NULL;
1247 TRACE("%s %d %p %p\n", debugstr_a(szProduct), index, szFeature, szParent);
1251 szwProduct = strdupAtoW( szProduct );
1253 return ERROR_OUTOFMEMORY;
1256 r = MsiEnumFeaturesW(szwProduct, index, szwFeature, szwParent);
1257 if( r == ERROR_SUCCESS )
1259 WideCharToMultiByte(CP_ACP, 0, szwFeature, -1,
1260 szFeature, GUID_SIZE, NULL, NULL);
1261 WideCharToMultiByte(CP_ACP, 0, szwParent, -1,
1262 szParent, GUID_SIZE, NULL, NULL);
1265 msi_free( szwProduct);
1270 UINT WINAPI MsiEnumFeaturesW(LPCWSTR szProduct, DWORD index,
1271 LPWSTR szFeature, LPWSTR szParent)
1273 HKEY hkeyProduct = 0;
1276 TRACE("%s %d %p %p\n", debugstr_w(szProduct), index, szFeature, szParent);
1279 return ERROR_INVALID_PARAMETER;
1281 r = MSIREG_OpenFeaturesKey(szProduct,&hkeyProduct,FALSE);
1282 if( r != ERROR_SUCCESS )
1283 return ERROR_NO_MORE_ITEMS;
1286 r = RegEnumValueW(hkeyProduct, index, szFeature, &sz, NULL, NULL, NULL, NULL);
1287 RegCloseKey(hkeyProduct);
1292 UINT WINAPI MsiEnumComponentsA(DWORD index, LPSTR lpguid)
1295 WCHAR szwGuid[GUID_SIZE];
1297 TRACE("%d %p\n", index, lpguid);
1299 r = MsiEnumComponentsW(index, szwGuid);
1300 if( r == ERROR_SUCCESS )
1301 WideCharToMultiByte(CP_ACP, 0, szwGuid, -1, lpguid, GUID_SIZE, NULL, NULL);
1306 UINT WINAPI MsiEnumComponentsW(DWORD index, LPWSTR lpguid)
1308 HKEY hkeyComponents = 0;
1310 WCHAR szKeyName[SQUISH_GUID_SIZE];
1312 TRACE("%d %p\n", index, lpguid);
1314 r = RegCreateKeyW(HKEY_LOCAL_MACHINE, szInstaller_Components, &hkeyComponents);
1315 if( r != ERROR_SUCCESS )
1316 return ERROR_NO_MORE_ITEMS;
1318 r = RegEnumKeyW(hkeyComponents, index, szKeyName, SQUISH_GUID_SIZE);
1319 if( r == ERROR_SUCCESS )
1320 unsquash_guid(szKeyName, lpguid);
1321 RegCloseKey(hkeyComponents);
1326 UINT WINAPI MsiEnumClientsA(LPCSTR szComponent, DWORD index, LPSTR szProduct)
1329 WCHAR szwProduct[GUID_SIZE];
1330 LPWSTR szwComponent = NULL;
1332 TRACE("%s %d %p\n", debugstr_a(szComponent), index, szProduct);
1335 return ERROR_INVALID_PARAMETER;
1339 szwComponent = strdupAtoW( szComponent );
1341 return ERROR_OUTOFMEMORY;
1344 r = MsiEnumClientsW(szComponent?szwComponent:NULL, index, szwProduct);
1345 if( r == ERROR_SUCCESS )
1347 WideCharToMultiByte(CP_ACP, 0, szwProduct, -1,
1348 szProduct, GUID_SIZE, NULL, NULL);
1351 msi_free( szwComponent);
1356 UINT WINAPI MsiEnumClientsW(LPCWSTR szComponent, DWORD index, LPWSTR szProduct)
1360 WCHAR szValName[SQUISH_GUID_SIZE];
1362 TRACE("%s %d %p\n", debugstr_w(szComponent), index, szProduct);
1364 if (!szComponent || !*szComponent || !szProduct)
1365 return ERROR_INVALID_PARAMETER;
1367 if (MSIREG_OpenUserDataComponentKey(szComponent, &hkeyComp, FALSE) != ERROR_SUCCESS &&
1368 MSIREG_OpenLocalSystemComponentKey(szComponent, &hkeyComp, FALSE) != ERROR_SUCCESS)
1369 return ERROR_UNKNOWN_COMPONENT;
1371 /* see if there are any products at all */
1372 sz = SQUISH_GUID_SIZE;
1373 r = RegEnumValueW(hkeyComp, 0, szValName, &sz, NULL, NULL, NULL, NULL);
1374 if (r != ERROR_SUCCESS)
1376 RegCloseKey(hkeyComp);
1379 return ERROR_INVALID_PARAMETER;
1381 return ERROR_UNKNOWN_COMPONENT;
1384 sz = SQUISH_GUID_SIZE;
1385 r = RegEnumValueW(hkeyComp, index, szValName, &sz, NULL, NULL, NULL, NULL);
1386 if( r == ERROR_SUCCESS )
1387 unsquash_guid(szValName, szProduct);
1389 RegCloseKey(hkeyComp);
1394 static UINT WINAPI MSI_EnumComponentQualifiers( LPCWSTR szComponent, DWORD iIndex,
1395 awstring *lpQualBuf, LPDWORD pcchQual,
1396 awstring *lpAppBuf, LPDWORD pcchAppBuf )
1398 DWORD name_sz, val_sz, name_max, val_max, type, ofs;
1399 LPWSTR name = NULL, val = NULL;
1403 TRACE("%s %08x %p %p %p %p\n", debugstr_w(szComponent), iIndex,
1404 lpQualBuf, pcchQual, lpAppBuf, pcchAppBuf);
1407 return ERROR_INVALID_PARAMETER;
1409 r = MSIREG_OpenUserComponentsKey( szComponent, &key, FALSE );
1410 if (r != ERROR_SUCCESS)
1411 return ERROR_UNKNOWN_COMPONENT;
1413 /* figure out how big the name is we want to return */
1415 r = ERROR_OUTOFMEMORY;
1416 name = msi_alloc( name_max * sizeof(WCHAR) );
1421 r = ERROR_OUTOFMEMORY;
1422 val = msi_alloc( val_max );
1426 /* loop until we allocate enough memory */
1431 r = RegEnumValueW( key, iIndex, name, &name_sz,
1432 NULL, &type, (LPBYTE)val, &val_sz );
1433 if (r == ERROR_SUCCESS)
1435 if (r != ERROR_MORE_DATA)
1438 if (type != REG_MULTI_SZ)
1440 ERR("component data has wrong type (%d)\n", type);
1444 r = ERROR_OUTOFMEMORY;
1445 if ((name_sz+1) >= name_max)
1449 name = msi_alloc( name_max * sizeof (WCHAR) );
1454 if (val_sz > val_max)
1456 val_max = val_sz + sizeof (WCHAR);
1458 val = msi_alloc( val_max * sizeof (WCHAR) );
1463 ERR("should be enough data, but isn't %d %d\n", name_sz, val_sz );
1468 r = MsiDecomposeDescriptorW( val, NULL, NULL, NULL, &ofs );
1469 if (r != ERROR_SUCCESS)
1472 TRACE("Providing %s and %s\n", debugstr_w(name), debugstr_w(val+ofs));
1474 r = msi_strcpy_to_awstring( name, lpQualBuf, pcchQual );
1475 r2 = msi_strcpy_to_awstring( val+ofs, lpAppBuf, pcchAppBuf );
1477 if (r2 != ERROR_SUCCESS)
1488 /*************************************************************************
1489 * MsiEnumComponentQualifiersA [MSI.@]
1491 UINT WINAPI MsiEnumComponentQualifiersA( LPCSTR szComponent, DWORD iIndex,
1492 LPSTR lpQualifierBuf, LPDWORD pcchQualifierBuf,
1493 LPSTR lpApplicationDataBuf, LPDWORD pcchApplicationDataBuf )
1495 awstring qual, appdata;
1499 TRACE("%s %08x %p %p %p %p\n", debugstr_a(szComponent), iIndex,
1500 lpQualifierBuf, pcchQualifierBuf, lpApplicationDataBuf,
1501 pcchApplicationDataBuf);
1503 comp = strdupAtoW( szComponent );
1504 if (szComponent && !comp)
1505 return ERROR_OUTOFMEMORY;
1507 qual.unicode = FALSE;
1508 qual.str.a = lpQualifierBuf;
1510 appdata.unicode = FALSE;
1511 appdata.str.a = lpApplicationDataBuf;
1513 r = MSI_EnumComponentQualifiers( comp, iIndex,
1514 &qual, pcchQualifierBuf, &appdata, pcchApplicationDataBuf );
1519 /*************************************************************************
1520 * MsiEnumComponentQualifiersW [MSI.@]
1522 UINT WINAPI MsiEnumComponentQualifiersW( LPCWSTR szComponent, DWORD iIndex,
1523 LPWSTR lpQualifierBuf, LPDWORD pcchQualifierBuf,
1524 LPWSTR lpApplicationDataBuf, LPDWORD pcchApplicationDataBuf )
1526 awstring qual, appdata;
1528 TRACE("%s %08x %p %p %p %p\n", debugstr_w(szComponent), iIndex,
1529 lpQualifierBuf, pcchQualifierBuf, lpApplicationDataBuf,
1530 pcchApplicationDataBuf);
1532 qual.unicode = TRUE;
1533 qual.str.w = lpQualifierBuf;
1535 appdata.unicode = TRUE;
1536 appdata.str.w = lpApplicationDataBuf;
1538 return MSI_EnumComponentQualifiers( szComponent, iIndex,
1539 &qual, pcchQualifierBuf, &appdata, pcchApplicationDataBuf );
1542 /*************************************************************************
1543 * MsiEnumRelatedProductsW [MSI.@]
1546 UINT WINAPI MsiEnumRelatedProductsW(LPCWSTR szUpgradeCode, DWORD dwReserved,
1547 DWORD iProductIndex, LPWSTR lpProductBuf)
1551 DWORD dwSize = SQUISH_GUID_SIZE;
1552 WCHAR szKeyName[SQUISH_GUID_SIZE];
1554 TRACE("%s %u %u %p\n", debugstr_w(szUpgradeCode), dwReserved,
1555 iProductIndex, lpProductBuf);
1557 if (NULL == szUpgradeCode)
1558 return ERROR_INVALID_PARAMETER;
1559 if (NULL == lpProductBuf)
1560 return ERROR_INVALID_PARAMETER;
1562 r = MSIREG_OpenUpgradeCodesKey(szUpgradeCode, &hkey, FALSE);
1563 if (r != ERROR_SUCCESS)
1564 return ERROR_NO_MORE_ITEMS;
1566 r = RegEnumValueW(hkey, iProductIndex, szKeyName, &dwSize, NULL, NULL, NULL, NULL);
1567 if( r == ERROR_SUCCESS )
1568 unsquash_guid(szKeyName, lpProductBuf);
1574 /*************************************************************************
1575 * MsiEnumRelatedProductsA [MSI.@]
1578 UINT WINAPI MsiEnumRelatedProductsA(LPCSTR szUpgradeCode, DWORD dwReserved,
1579 DWORD iProductIndex, LPSTR lpProductBuf)
1581 LPWSTR szwUpgradeCode = NULL;
1582 WCHAR productW[GUID_SIZE];
1585 TRACE("%s %u %u %p\n", debugstr_a(szUpgradeCode), dwReserved,
1586 iProductIndex, lpProductBuf);
1590 szwUpgradeCode = strdupAtoW( szUpgradeCode );
1591 if( !szwUpgradeCode )
1592 return ERROR_OUTOFMEMORY;
1595 r = MsiEnumRelatedProductsW( szwUpgradeCode, dwReserved,
1596 iProductIndex, productW );
1597 if (r == ERROR_SUCCESS)
1599 WideCharToMultiByte( CP_ACP, 0, productW, GUID_SIZE,
1600 lpProductBuf, GUID_SIZE, NULL, NULL );
1602 msi_free( szwUpgradeCode);
1606 /***********************************************************************
1607 * MsiEnumPatchesA [MSI.@]
1609 UINT WINAPI MsiEnumPatchesA( LPCSTR szProduct, DWORD iPatchIndex,
1610 LPSTR lpPatchBuf, LPSTR lpTransformsBuf, LPDWORD pcchTransformsBuf)
1612 FIXME("%s %d %p %p %p\n", debugstr_a(szProduct),
1613 iPatchIndex, lpPatchBuf, lpTransformsBuf, pcchTransformsBuf);
1614 return ERROR_NO_MORE_ITEMS;
1617 /***********************************************************************
1618 * MsiEnumPatchesW [MSI.@]
1620 UINT WINAPI MsiEnumPatchesW( LPCWSTR szProduct, DWORD iPatchIndex,
1621 LPWSTR lpPatchBuf, LPWSTR lpTransformsBuf, LPDWORD pcchTransformsBuf)
1623 FIXME("%s %d %p %p %p\n", debugstr_w(szProduct),
1624 iPatchIndex, lpPatchBuf, lpTransformsBuf, pcchTransformsBuf);
1625 return ERROR_NO_MORE_ITEMS;
1628 UINT WINAPI MsiEnumProductsExA( LPCSTR szProductCode, LPCSTR szUserSid,
1629 DWORD dwContext, DWORD dwIndex, CHAR szInstalledProductCode[39],
1630 MSIINSTALLCONTEXT* pdwInstalledContext, LPSTR szSid, LPDWORD pcchSid)
1632 FIXME("%s %s %d %d %p %p %p %p\n", debugstr_a(szProductCode), debugstr_a(szUserSid),
1633 dwContext, dwIndex, szInstalledProductCode, pdwInstalledContext,
1635 return ERROR_NO_MORE_ITEMS;
1638 UINT WINAPI MsiEnumProductsExW( LPCWSTR szProductCode, LPCWSTR szUserSid,
1639 DWORD dwContext, DWORD dwIndex, WCHAR szInstalledProductCode[39],
1640 MSIINSTALLCONTEXT* pdwInstalledContext, LPWSTR szSid, LPDWORD pcchSid)
1642 FIXME("%s %s %d %d %p %p %p %p\n", debugstr_w(szProductCode), debugstr_w(szUserSid),
1643 dwContext, dwIndex, szInstalledProductCode, pdwInstalledContext,
1645 return ERROR_NO_MORE_ITEMS;