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_DeleteUserUpgradeCodesKey(LPCWSTR szUpgradeCode
)
985 WCHAR squished_pc
[GUID_SIZE
];
986 WCHAR keypath
[0x200];
988 TRACE("%s\n",debugstr_w(szUpgradeCode
));
989 if (!squash_guid(szUpgradeCode
,squished_pc
))
990 return ERROR_FUNCTION_FAILED
;
991 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
993 sprintfW(keypath
,szInstaller_UserUpgradeCodes_fmt
,squished_pc
);
995 return RegDeleteTreeW(HKEY_CURRENT_USER
, keypath
);
998 UINT
MSIREG_OpenLocalSystemProductKey(LPCWSTR szProductCode
, HKEY
*key
, BOOL create
)
1000 WCHAR squished_pc
[GUID_SIZE
];
1001 WCHAR keypath
[0x200];
1003 TRACE("%s\n", debugstr_w(szProductCode
));
1005 if (!squash_guid(szProductCode
, squished_pc
))
1006 return ERROR_FUNCTION_FAILED
;
1008 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
1010 sprintfW(keypath
, szInstaller_LocalSystemProductCodes_fmt
, squished_pc
);
1013 return RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
1015 return RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
1018 UINT
MSIREG_OpenLocalSystemComponentKey(LPCWSTR szComponent
, HKEY
*key
, BOOL create
)
1020 WCHAR squished_pc
[GUID_SIZE
];
1021 WCHAR keypath
[0x200];
1023 TRACE("%s\n", debugstr_w(szComponent
));
1025 if (!squash_guid(szComponent
, squished_pc
))
1026 return ERROR_FUNCTION_FAILED
;
1028 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
1030 sprintfW(keypath
, szInstaller_LocalSystemComponent_fmt
, squished_pc
);
1033 return RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
1035 return RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
1038 UINT
MSIREG_OpenLocalClassesProductKey(LPCWSTR szProductCode
, HKEY
*key
, BOOL create
)
1040 WCHAR squished_pc
[GUID_SIZE
];
1041 WCHAR keypath
[0x200];
1043 TRACE("%s\n", debugstr_w(szProductCode
));
1045 if (!squash_guid(szProductCode
, squished_pc
))
1046 return ERROR_FUNCTION_FAILED
;
1048 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
1050 sprintfW(keypath
, szInstaller_LocalClassesProd_fmt
, squished_pc
);
1053 return RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
1055 return RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
1058 UINT
MSIREG_OpenLocalClassesFeaturesKey(LPCWSTR szProductCode
, HKEY
*key
, BOOL create
)
1060 WCHAR squished_pc
[GUID_SIZE
];
1061 WCHAR keypath
[0x200];
1063 TRACE("%s\n", debugstr_w(szProductCode
));
1065 if (!squash_guid(szProductCode
, squished_pc
))
1066 return ERROR_FUNCTION_FAILED
;
1068 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
1070 sprintfW(keypath
, szInstaller_LocalClassesFeat_fmt
, squished_pc
);
1073 return RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
1075 return RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
1078 UINT
MSIREG_OpenLocalManagedProductKey(LPCWSTR szProductCode
, HKEY
*key
, BOOL create
)
1080 WCHAR squished_pc
[GUID_SIZE
];
1081 WCHAR keypath
[0x200];
1085 TRACE("%s\n", debugstr_w(szProductCode
));
1087 if (!squash_guid(szProductCode
, squished_pc
))
1088 return ERROR_FUNCTION_FAILED
;
1090 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
1092 r
= get_user_sid(&usersid
);
1093 if (r
!= ERROR_SUCCESS
|| !usersid
)
1095 ERR("Failed to retrieve user SID: %d\n", r
);
1099 sprintfW(keypath
, szInstaller_LocalManagedProd_fmt
, usersid
, squished_pc
);
1103 return RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
1105 return RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
1108 /*************************************************************************
1109 * MsiDecomposeDescriptorW [MSI.@]
1111 * Decomposes an MSI descriptor into product, feature and component parts.
1112 * An MSI descriptor is a string of the form:
1113 * [base 85 guid] [feature code] '>' [base 85 guid]
1116 * szDescriptor [I] the descriptor to decompose
1117 * szProduct [O] buffer of MAX_FEATURE_CHARS+1 for the product guid
1118 * szFeature [O] buffer of MAX_FEATURE_CHARS+1 for the feature code
1119 * szComponent [O] buffer of MAX_FEATURE_CHARS+1 for the component guid
1120 * pUsed [O] the length of the descriptor
1123 * ERROR_SUCCESS if everything worked correctly
1124 * ERROR_INVALID_PARAMETER if the descriptor was invalid
1127 UINT WINAPI
MsiDecomposeDescriptorW( LPCWSTR szDescriptor
, LPWSTR szProduct
,
1128 LPWSTR szFeature
, LPWSTR szComponent
, LPDWORD pUsed
)
1132 GUID product
, component
;
1134 TRACE("%s %p %p %p %p\n", debugstr_w(szDescriptor
), szProduct
,
1135 szFeature
, szComponent
, pUsed
);
1137 r
= decode_base85_guid( szDescriptor
, &product
);
1139 return ERROR_INVALID_PARAMETER
;
1141 TRACE("product %s\n", debugstr_guid( &product
));
1143 p
= strchrW(&szDescriptor
[20],'>');
1145 return ERROR_INVALID_PARAMETER
;
1147 len
= (p
- &szDescriptor
[20]);
1148 if( len
> MAX_FEATURE_CHARS
)
1149 return ERROR_INVALID_PARAMETER
;
1151 TRACE("feature %s\n", debugstr_wn( &szDescriptor
[20], len
));
1153 r
= decode_base85_guid( p
+1, &component
);
1155 return ERROR_INVALID_PARAMETER
;
1157 TRACE("component %s\n", debugstr_guid( &component
));
1160 StringFromGUID2( &product
, szProduct
, MAX_FEATURE_CHARS
+1 );
1162 StringFromGUID2( &component
, szComponent
, MAX_FEATURE_CHARS
+1 );
1165 memcpy( szFeature
, &szDescriptor
[20], len
*sizeof(WCHAR
) );
1168 len
= ( &p
[21] - szDescriptor
);
1170 TRACE("length = %d\n", len
);
1173 return ERROR_SUCCESS
;
1176 UINT WINAPI
MsiDecomposeDescriptorA( LPCSTR szDescriptor
, LPSTR szProduct
,
1177 LPSTR szFeature
, LPSTR szComponent
, LPDWORD pUsed
)
1179 WCHAR product
[MAX_FEATURE_CHARS
+1];
1180 WCHAR feature
[MAX_FEATURE_CHARS
+1];
1181 WCHAR component
[MAX_FEATURE_CHARS
+1];
1182 LPWSTR str
= NULL
, p
= NULL
, f
= NULL
, c
= NULL
;
1185 TRACE("%s %p %p %p %p\n", debugstr_a(szDescriptor
), szProduct
,
1186 szFeature
, szComponent
, pUsed
);
1188 str
= strdupAtoW( szDescriptor
);
1189 if( szDescriptor
&& !str
)
1190 return ERROR_OUTOFMEMORY
;
1199 r
= MsiDecomposeDescriptorW( str
, p
, f
, c
, pUsed
);
1201 if (r
== ERROR_SUCCESS
)
1203 WideCharToMultiByte( CP_ACP
, 0, p
, -1,
1204 szProduct
, MAX_FEATURE_CHARS
+1, NULL
, NULL
);
1205 WideCharToMultiByte( CP_ACP
, 0, f
, -1,
1206 szFeature
, MAX_FEATURE_CHARS
+1, NULL
, NULL
);
1207 WideCharToMultiByte( CP_ACP
, 0, c
, -1,
1208 szComponent
, MAX_FEATURE_CHARS
+1, NULL
, NULL
);
1216 UINT WINAPI
MsiEnumProductsA(DWORD index
, LPSTR lpguid
)
1219 WCHAR szwGuid
[GUID_SIZE
];
1221 TRACE("%d %p\n", index
, lpguid
);
1224 return ERROR_INVALID_PARAMETER
;
1225 r
= MsiEnumProductsW(index
, szwGuid
);
1226 if( r
== ERROR_SUCCESS
)
1227 WideCharToMultiByte(CP_ACP
, 0, szwGuid
, -1, lpguid
, GUID_SIZE
, NULL
, NULL
);
1232 UINT WINAPI
MsiEnumProductsW(DWORD index
, LPWSTR lpguid
)
1234 HKEY hkeyProducts
= 0;
1236 WCHAR szKeyName
[SQUISH_GUID_SIZE
];
1238 TRACE("%d %p\n", index
, lpguid
);
1241 return ERROR_INVALID_PARAMETER
;
1243 r
= RegCreateKeyW(HKEY_LOCAL_MACHINE
, szInstaller_Products
, &hkeyProducts
);
1244 if( r
!= ERROR_SUCCESS
)
1245 return ERROR_NO_MORE_ITEMS
;
1247 r
= RegEnumKeyW(hkeyProducts
, index
, szKeyName
, SQUISH_GUID_SIZE
);
1248 if( r
== ERROR_SUCCESS
)
1249 unsquash_guid(szKeyName
, lpguid
);
1250 RegCloseKey(hkeyProducts
);
1255 UINT WINAPI
MsiEnumFeaturesA(LPCSTR szProduct
, DWORD index
,
1256 LPSTR szFeature
, LPSTR szParent
)
1259 WCHAR szwFeature
[GUID_SIZE
], szwParent
[GUID_SIZE
];
1260 LPWSTR szwProduct
= NULL
;
1262 TRACE("%s %d %p %p\n", debugstr_a(szProduct
), index
, szFeature
, szParent
);
1266 szwProduct
= strdupAtoW( szProduct
);
1268 return ERROR_OUTOFMEMORY
;
1271 r
= MsiEnumFeaturesW(szwProduct
, index
, szwFeature
, szwParent
);
1272 if( r
== ERROR_SUCCESS
)
1274 WideCharToMultiByte(CP_ACP
, 0, szwFeature
, -1,
1275 szFeature
, GUID_SIZE
, NULL
, NULL
);
1276 WideCharToMultiByte(CP_ACP
, 0, szwParent
, -1,
1277 szParent
, GUID_SIZE
, NULL
, NULL
);
1280 msi_free( szwProduct
);
1285 UINT WINAPI
MsiEnumFeaturesW(LPCWSTR szProduct
, DWORD index
,
1286 LPWSTR szFeature
, LPWSTR szParent
)
1288 HKEY hkeyProduct
= 0;
1291 TRACE("%s %d %p %p\n", debugstr_w(szProduct
), index
, szFeature
, szParent
);
1294 return ERROR_INVALID_PARAMETER
;
1296 r
= MSIREG_OpenFeaturesKey(szProduct
,&hkeyProduct
,FALSE
);
1297 if( r
!= ERROR_SUCCESS
)
1298 return ERROR_NO_MORE_ITEMS
;
1301 r
= RegEnumValueW(hkeyProduct
, index
, szFeature
, &sz
, NULL
, NULL
, NULL
, NULL
);
1302 RegCloseKey(hkeyProduct
);
1307 UINT WINAPI
MsiEnumComponentsA(DWORD index
, LPSTR lpguid
)
1310 WCHAR szwGuid
[GUID_SIZE
];
1312 TRACE("%d %p\n", index
, lpguid
);
1314 r
= MsiEnumComponentsW(index
, szwGuid
);
1315 if( r
== ERROR_SUCCESS
)
1316 WideCharToMultiByte(CP_ACP
, 0, szwGuid
, -1, lpguid
, GUID_SIZE
, NULL
, NULL
);
1321 UINT WINAPI
MsiEnumComponentsW(DWORD index
, LPWSTR lpguid
)
1323 HKEY hkeyComponents
= 0;
1325 WCHAR szKeyName
[SQUISH_GUID_SIZE
];
1327 TRACE("%d %p\n", index
, lpguid
);
1329 r
= RegCreateKeyW(HKEY_LOCAL_MACHINE
, szInstaller_Components
, &hkeyComponents
);
1330 if( r
!= ERROR_SUCCESS
)
1331 return ERROR_NO_MORE_ITEMS
;
1333 r
= RegEnumKeyW(hkeyComponents
, index
, szKeyName
, SQUISH_GUID_SIZE
);
1334 if( r
== ERROR_SUCCESS
)
1335 unsquash_guid(szKeyName
, lpguid
);
1336 RegCloseKey(hkeyComponents
);
1341 UINT WINAPI
MsiEnumClientsA(LPCSTR szComponent
, DWORD index
, LPSTR szProduct
)
1344 WCHAR szwProduct
[GUID_SIZE
];
1345 LPWSTR szwComponent
= NULL
;
1347 TRACE("%s %d %p\n", debugstr_a(szComponent
), index
, szProduct
);
1350 return ERROR_INVALID_PARAMETER
;
1354 szwComponent
= strdupAtoW( szComponent
);
1356 return ERROR_OUTOFMEMORY
;
1359 r
= MsiEnumClientsW(szComponent
?szwComponent
:NULL
, index
, szwProduct
);
1360 if( r
== ERROR_SUCCESS
)
1362 WideCharToMultiByte(CP_ACP
, 0, szwProduct
, -1,
1363 szProduct
, GUID_SIZE
, NULL
, NULL
);
1366 msi_free( szwComponent
);
1371 UINT WINAPI
MsiEnumClientsW(LPCWSTR szComponent
, DWORD index
, LPWSTR szProduct
)
1375 WCHAR szValName
[SQUISH_GUID_SIZE
];
1377 TRACE("%s %d %p\n", debugstr_w(szComponent
), index
, szProduct
);
1379 if (!szComponent
|| !*szComponent
|| !szProduct
)
1380 return ERROR_INVALID_PARAMETER
;
1382 if (MSIREG_OpenUserDataComponentKey(szComponent
, &hkeyComp
, FALSE
) != ERROR_SUCCESS
&&
1383 MSIREG_OpenLocalSystemComponentKey(szComponent
, &hkeyComp
, FALSE
) != ERROR_SUCCESS
)
1384 return ERROR_UNKNOWN_COMPONENT
;
1386 /* see if there are any products at all */
1387 sz
= SQUISH_GUID_SIZE
;
1388 r
= RegEnumValueW(hkeyComp
, 0, szValName
, &sz
, NULL
, NULL
, NULL
, NULL
);
1389 if (r
!= ERROR_SUCCESS
)
1391 RegCloseKey(hkeyComp
);
1394 return ERROR_INVALID_PARAMETER
;
1396 return ERROR_UNKNOWN_COMPONENT
;
1399 sz
= SQUISH_GUID_SIZE
;
1400 r
= RegEnumValueW(hkeyComp
, index
, szValName
, &sz
, NULL
, NULL
, NULL
, NULL
);
1401 if( r
== ERROR_SUCCESS
)
1402 unsquash_guid(szValName
, szProduct
);
1404 RegCloseKey(hkeyComp
);
1409 static UINT WINAPI
MSI_EnumComponentQualifiers( LPCWSTR szComponent
, DWORD iIndex
,
1410 awstring
*lpQualBuf
, LPDWORD pcchQual
,
1411 awstring
*lpAppBuf
, LPDWORD pcchAppBuf
)
1413 DWORD name_sz
, val_sz
, name_max
, val_max
, type
, ofs
;
1414 LPWSTR name
= NULL
, val
= NULL
;
1418 TRACE("%s %08x %p %p %p %p\n", debugstr_w(szComponent
), iIndex
,
1419 lpQualBuf
, pcchQual
, lpAppBuf
, pcchAppBuf
);
1422 return ERROR_INVALID_PARAMETER
;
1424 r
= MSIREG_OpenUserComponentsKey( szComponent
, &key
, FALSE
);
1425 if (r
!= ERROR_SUCCESS
)
1426 return ERROR_UNKNOWN_COMPONENT
;
1428 /* figure out how big the name is we want to return */
1430 r
= ERROR_OUTOFMEMORY
;
1431 name
= msi_alloc( name_max
* sizeof(WCHAR
) );
1436 r
= ERROR_OUTOFMEMORY
;
1437 val
= msi_alloc( val_max
);
1441 /* loop until we allocate enough memory */
1446 r
= RegEnumValueW( key
, iIndex
, name
, &name_sz
,
1447 NULL
, &type
, (LPBYTE
)val
, &val_sz
);
1448 if (r
== ERROR_SUCCESS
)
1450 if (r
!= ERROR_MORE_DATA
)
1453 if (type
!= REG_MULTI_SZ
)
1455 ERR("component data has wrong type (%d)\n", type
);
1459 r
= ERROR_OUTOFMEMORY
;
1460 if ((name_sz
+1) >= name_max
)
1464 name
= msi_alloc( name_max
* sizeof (WCHAR
) );
1469 if (val_sz
> val_max
)
1471 val_max
= val_sz
+ sizeof (WCHAR
);
1473 val
= msi_alloc( val_max
* sizeof (WCHAR
) );
1478 ERR("should be enough data, but isn't %d %d\n", name_sz
, val_sz
);
1483 r
= MsiDecomposeDescriptorW( val
, NULL
, NULL
, NULL
, &ofs
);
1484 if (r
!= ERROR_SUCCESS
)
1487 TRACE("Providing %s and %s\n", debugstr_w(name
), debugstr_w(val
+ofs
));
1489 r
= msi_strcpy_to_awstring( name
, lpQualBuf
, pcchQual
);
1490 r2
= msi_strcpy_to_awstring( val
+ofs
, lpAppBuf
, pcchAppBuf
);
1492 if (r2
!= ERROR_SUCCESS
)
1503 /*************************************************************************
1504 * MsiEnumComponentQualifiersA [MSI.@]
1506 UINT WINAPI
MsiEnumComponentQualifiersA( LPCSTR szComponent
, DWORD iIndex
,
1507 LPSTR lpQualifierBuf
, LPDWORD pcchQualifierBuf
,
1508 LPSTR lpApplicationDataBuf
, LPDWORD pcchApplicationDataBuf
)
1510 awstring qual
, appdata
;
1514 TRACE("%s %08x %p %p %p %p\n", debugstr_a(szComponent
), iIndex
,
1515 lpQualifierBuf
, pcchQualifierBuf
, lpApplicationDataBuf
,
1516 pcchApplicationDataBuf
);
1518 comp
= strdupAtoW( szComponent
);
1519 if (szComponent
&& !comp
)
1520 return ERROR_OUTOFMEMORY
;
1522 qual
.unicode
= FALSE
;
1523 qual
.str
.a
= lpQualifierBuf
;
1525 appdata
.unicode
= FALSE
;
1526 appdata
.str
.a
= lpApplicationDataBuf
;
1528 r
= MSI_EnumComponentQualifiers( comp
, iIndex
,
1529 &qual
, pcchQualifierBuf
, &appdata
, pcchApplicationDataBuf
);
1534 /*************************************************************************
1535 * MsiEnumComponentQualifiersW [MSI.@]
1537 UINT WINAPI
MsiEnumComponentQualifiersW( LPCWSTR szComponent
, DWORD iIndex
,
1538 LPWSTR lpQualifierBuf
, LPDWORD pcchQualifierBuf
,
1539 LPWSTR lpApplicationDataBuf
, LPDWORD pcchApplicationDataBuf
)
1541 awstring qual
, appdata
;
1543 TRACE("%s %08x %p %p %p %p\n", debugstr_w(szComponent
), iIndex
,
1544 lpQualifierBuf
, pcchQualifierBuf
, lpApplicationDataBuf
,
1545 pcchApplicationDataBuf
);
1547 qual
.unicode
= TRUE
;
1548 qual
.str
.w
= lpQualifierBuf
;
1550 appdata
.unicode
= TRUE
;
1551 appdata
.str
.w
= lpApplicationDataBuf
;
1553 return MSI_EnumComponentQualifiers( szComponent
, iIndex
,
1554 &qual
, pcchQualifierBuf
, &appdata
, pcchApplicationDataBuf
);
1557 /*************************************************************************
1558 * MsiEnumRelatedProductsW [MSI.@]
1561 UINT WINAPI
MsiEnumRelatedProductsW(LPCWSTR szUpgradeCode
, DWORD dwReserved
,
1562 DWORD iProductIndex
, LPWSTR lpProductBuf
)
1566 DWORD dwSize
= SQUISH_GUID_SIZE
;
1567 WCHAR szKeyName
[SQUISH_GUID_SIZE
];
1569 TRACE("%s %u %u %p\n", debugstr_w(szUpgradeCode
), dwReserved
,
1570 iProductIndex
, lpProductBuf
);
1572 if (NULL
== szUpgradeCode
)
1573 return ERROR_INVALID_PARAMETER
;
1574 if (NULL
== lpProductBuf
)
1575 return ERROR_INVALID_PARAMETER
;
1577 r
= MSIREG_OpenUpgradeCodesKey(szUpgradeCode
, &hkey
, FALSE
);
1578 if (r
!= ERROR_SUCCESS
)
1579 return ERROR_NO_MORE_ITEMS
;
1581 r
= RegEnumValueW(hkey
, iProductIndex
, szKeyName
, &dwSize
, NULL
, NULL
, NULL
, NULL
);
1582 if( r
== ERROR_SUCCESS
)
1583 unsquash_guid(szKeyName
, lpProductBuf
);
1589 /*************************************************************************
1590 * MsiEnumRelatedProductsA [MSI.@]
1593 UINT WINAPI
MsiEnumRelatedProductsA(LPCSTR szUpgradeCode
, DWORD dwReserved
,
1594 DWORD iProductIndex
, LPSTR lpProductBuf
)
1596 LPWSTR szwUpgradeCode
= NULL
;
1597 WCHAR productW
[GUID_SIZE
];
1600 TRACE("%s %u %u %p\n", debugstr_a(szUpgradeCode
), dwReserved
,
1601 iProductIndex
, lpProductBuf
);
1605 szwUpgradeCode
= strdupAtoW( szUpgradeCode
);
1606 if( !szwUpgradeCode
)
1607 return ERROR_OUTOFMEMORY
;
1610 r
= MsiEnumRelatedProductsW( szwUpgradeCode
, dwReserved
,
1611 iProductIndex
, productW
);
1612 if (r
== ERROR_SUCCESS
)
1614 WideCharToMultiByte( CP_ACP
, 0, productW
, GUID_SIZE
,
1615 lpProductBuf
, GUID_SIZE
, NULL
, NULL
);
1617 msi_free( szwUpgradeCode
);
1621 /***********************************************************************
1622 * MsiEnumPatchesA [MSI.@]
1624 UINT WINAPI
MsiEnumPatchesA( LPCSTR szProduct
, DWORD iPatchIndex
,
1625 LPSTR lpPatchBuf
, LPSTR lpTransformsBuf
, LPDWORD pcchTransformsBuf
)
1627 FIXME("%s %d %p %p %p\n", debugstr_a(szProduct
),
1628 iPatchIndex
, lpPatchBuf
, lpTransformsBuf
, pcchTransformsBuf
);
1629 return ERROR_NO_MORE_ITEMS
;
1632 /***********************************************************************
1633 * MsiEnumPatchesW [MSI.@]
1635 UINT WINAPI
MsiEnumPatchesW( LPCWSTR szProduct
, DWORD iPatchIndex
,
1636 LPWSTR lpPatchBuf
, LPWSTR lpTransformsBuf
, LPDWORD pcchTransformsBuf
)
1638 FIXME("%s %d %p %p %p\n", debugstr_w(szProduct
),
1639 iPatchIndex
, lpPatchBuf
, lpTransformsBuf
, pcchTransformsBuf
);
1640 return ERROR_NO_MORE_ITEMS
;
1643 UINT WINAPI
MsiEnumProductsExA( LPCSTR szProductCode
, LPCSTR szUserSid
,
1644 DWORD dwContext
, DWORD dwIndex
, CHAR szInstalledProductCode
[39],
1645 MSIINSTALLCONTEXT
* pdwInstalledContext
, LPSTR szSid
, LPDWORD pcchSid
)
1647 FIXME("%s %s %d %d %p %p %p %p\n", debugstr_a(szProductCode
), debugstr_a(szUserSid
),
1648 dwContext
, dwIndex
, szInstalledProductCode
, pdwInstalledContext
,
1650 return ERROR_NO_MORE_ITEMS
;
1653 UINT WINAPI
MsiEnumProductsExW( LPCWSTR szProductCode
, LPCWSTR szUserSid
,
1654 DWORD dwContext
, DWORD dwIndex
, WCHAR szInstalledProductCode
[39],
1655 MSIINSTALLCONTEXT
* pdwInstalledContext
, LPWSTR szSid
, LPDWORD pcchSid
)
1657 FIXME("%s %s %d %d %p %p %p %p\n", debugstr_w(szProductCode
), debugstr_w(szUserSid
),
1658 dwContext
, dwIndex
, szInstalledProductCode
, pdwInstalledContext
,
1660 return ERROR_NO_MORE_ITEMS
;