2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2002,2003,2004 Mike McCormack for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #define NONAMELESSUNION
30 #include "wine/debug.h"
36 #include "wine/unicode.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(msi);
45 * The MSVC headers define the MSIDBOPEN_* macros cast to LPCTSTR,
46 * which is a problem because LPCTSTR isn't defined when compiling wine.
47 * To work around this problem, we need to define LPCTSTR as LPCWSTR here,
48 * and make sure to only use it in W functions.
50 #define LPCTSTR LPCWSTR
52 DEFINE_GUID( CLSID_MsiDatabase, 0x000c1084, 0x0000, 0x0000, 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
54 static const WCHAR szInstaller[] = {
55 'S','o','f','t','w','a','r','e','\\',
56 'M','i','c','r','o','s','o','f','t','\\',
57 'W','i','n','d','o','w','s','\\',
58 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
59 'I','n','s','t','a','l','l','e','r',0 };
61 static const WCHAR szFeatures[] = {
62 'F','e','a','t','u','r','e','s',0 };
63 static const WCHAR szComponents[] = {
64 'C','o','m','p','o','n','e','n','t','s',0 };
67 INSTALLUILEVEL gUILevel;
69 INSTALLUI_HANDLERA gUIHandler;
72 WCHAR gszLogFile[MAX_PATH];
77 * A .msi file is a structured storage file.
78 * It should contain a number of streams.
81 BOOL unsquash_guid(LPCWSTR in, LPWSTR out)
97 out[n++] = in[17+i*2];
98 out[n++] = in[16+i*2];
103 out[n++] = in[17+i*2];
104 out[n++] = in[16+i*2];
111 BOOL squash_guid(LPCWSTR in, LPWSTR out)
131 out[17+i*2] = in[n++];
132 out[16+i*2] = in[n++];
138 out[17+i*2] = in[n++];
139 out[16+i*2] = in[n++];
149 /* tables for encoding and decoding base85 */
150 static const unsigned char table_dec85[0x80] = {
151 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
152 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
153 0xff,0x00,0xff,0xff,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0xff,
154 0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0xff,0xff,0xff,0x16,0xff,0x17,
155 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,
156 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0xff,0x34,0x35,0x36,
157 0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43,0x44,0x45,0x46,
158 0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0xff,0x53,0x54,0xff,
161 static const char table_enc85[] =
162 "!$%&'()*+,-.0123456789=?@ABCDEFGHIJKLMNO"
163 "PQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx"
167 * Converts a base85 encoded guid into a GUID pointer
168 * Base85 encoded GUIDs should be 20 characters long.
170 * returns TRUE if successful, FALSE if not
172 BOOL decode_base85_guid( LPCWSTR str, GUID *guid )
174 DWORD i, val = 0, base = 1, *p;
177 for( i=0; i<20; i++ )
184 val += table_dec85[str[i]] * base;
187 if( table_dec85[str[i]] == 0xff )
197 * Encodes a base85 guid given a GUID pointer
198 * Caller should provide a 21 character buffer for the encoded string.
200 * returns TRUE if successful, FALSE if not
202 BOOL encode_base85_guid( GUID *guid, LPWSTR str )
204 unsigned int x, *p, i;
206 p = (unsigned int*) guid;
210 *str++ = table_enc85[x%85];
212 *str++ = table_enc85[x%85];
214 *str++ = table_enc85[x%85];
216 *str++ = table_enc85[x%85];
218 *str++ = table_enc85[x%85];
226 VOID MSI_CloseDatabase( MSIOBJECTHDR *arg )
228 MSIDATABASE *db = (MSIDATABASE *) arg;
230 free_cached_tables( db );
231 IStorage_Release( db->storage );
234 UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
236 IStorage *stg = NULL;
238 MSIDATABASE *db = NULL;
239 UINT ret = ERROR_FUNCTION_FAILED;
243 TRACE("%s %s\n",debugstr_w(szDBPath),debugstr_w(szPersist) );
246 return ERROR_INVALID_PARAMETER;
248 szMode = (LPWSTR) szPersist;
249 if( HIWORD( szPersist ) )
251 /* UINT len = lstrlenW( szPerist ) + 1; */
252 FIXME("don't support persist files yet\b");
253 return ERROR_INVALID_PARAMETER;
254 /* szMode = HeapAlloc( GetProcessHeap(), 0, len * sizeof (DWORD) ); */
256 else if( szPersist == MSIDBOPEN_READONLY )
258 r = StgOpenStorage( szDBPath, NULL,
259 STGM_DIRECT|STGM_READ|STGM_SHARE_DENY_WRITE, NULL, 0, &stg);
261 else if( szPersist == MSIDBOPEN_CREATE )
263 r = StgCreateDocfile( szDBPath,
264 STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, &stg);
265 if( r == ERROR_SUCCESS )
267 IStorage_SetClass( stg, &CLSID_MsiDatabase );
268 r = init_string_table( stg );
271 else if( szPersist == MSIDBOPEN_TRANSACT )
273 r = StgOpenStorage( szDBPath, NULL,
274 STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, 0, &stg);
278 ERR("unknown flag %p\n",szPersist);
279 return ERROR_INVALID_PARAMETER;
284 FIXME("open failed r = %08lx!\n",r);
285 return ERROR_FUNCTION_FAILED;
288 r = IStorage_Stat( stg, &stat, STATFLAG_NONAME );
291 FIXME("Failed to stat storage\n");
295 if( memcmp( &stat.clsid, &CLSID_MsiDatabase, sizeof (GUID) ) )
297 ERR("storage GUID is not a MSI database GUID %s\n",
298 debugstr_guid(&stat.clsid) );
303 db = alloc_msiobject( MSIHANDLETYPE_DATABASE, sizeof (MSIDATABASE),
307 FIXME("Failed to allocate a handle\n");
311 if( TRACE_ON( msi ) )
312 enum_stream_names( stg );
317 ret = load_string_table( db );
318 if( ret != ERROR_SUCCESS )
321 msiobj_addref( &db->hdr );
322 IStorage_AddRef( stg );
327 msiobj_release( &db->hdr );
329 IStorage_Release( stg );
334 UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
339 TRACE("%s %s %p\n",debugstr_w(szDBPath),debugstr_w(szPersist), phDB);
341 ret = MSI_OpenDatabaseW( szDBPath, szPersist, &db );
342 if( ret == ERROR_SUCCESS )
344 *phDB = alloc_msihandle( &db->hdr );
345 msiobj_release( &db->hdr );
351 UINT WINAPI MsiOpenDatabaseA(LPCSTR szDBPath, LPCSTR szPersist, MSIHANDLE *phDB)
353 HRESULT r = ERROR_FUNCTION_FAILED;
354 LPWSTR szwDBPath = NULL, szwPersist = NULL;
357 TRACE("%s %s %p\n", debugstr_a(szDBPath), debugstr_a(szPersist), phDB);
361 len = MultiByteToWideChar( CP_ACP, 0, szDBPath, -1, NULL, 0 );
362 szwDBPath = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
365 MultiByteToWideChar( CP_ACP, 0, szDBPath, -1, szwDBPath, len );
368 if( HIWORD(szPersist) )
370 len = MultiByteToWideChar( CP_ACP, 0, szPersist, -1, NULL, 0 );
371 szwPersist = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
374 MultiByteToWideChar( CP_ACP, 0, szPersist, -1, szwPersist, len );
377 szwPersist = (LPWSTR) szPersist;
379 r = MsiOpenDatabaseW( szwDBPath, szwPersist, phDB );
383 HeapFree( GetProcessHeap(), 0, szwPersist );
385 HeapFree( GetProcessHeap(), 0, szwDBPath );
390 UINT WINAPI MsiOpenProductA(LPCSTR szProduct, MSIHANDLE *phProduct)
393 LPWSTR szwProd = NULL;
395 TRACE("%s %p\n",debugstr_a(szProduct), phProduct);
399 len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
400 szwProd = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
402 MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProd, len );
405 ret = MsiOpenProductW( szwProd, phProduct );
408 HeapFree( GetProcessHeap(), 0, szwProd );
413 UINT WINAPI MsiOpenProductW(LPCWSTR szProduct, MSIHANDLE *phProduct)
415 static const WCHAR szKey[] = {
416 'S','o','f','t','w','a','r','e','\\',
417 'M','i','c','r','o','s','o','f','t','\\',
418 'W','i','n','d','o','w','s','\\',
419 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
420 'U','n','i','n','s','t','a','l','l',0 };
421 static const WCHAR szLocalPackage[] = {
422 'L','o','c','a','l','P','a','c','k','a','g','e', 0
426 HKEY hKeyProduct = NULL, hKeyUninstall = NULL;
429 TRACE("%s %p\n",debugstr_w(szProduct), phProduct);
431 r = RegOpenKeyW( HKEY_LOCAL_MACHINE, szKey, &hKeyUninstall );
432 if( r != ERROR_SUCCESS )
433 return ERROR_UNKNOWN_PRODUCT;
435 r = RegOpenKeyW( hKeyUninstall, szProduct, &hKeyProduct );
436 if( r != ERROR_SUCCESS )
438 r = ERROR_UNKNOWN_PRODUCT;
442 /* find the size of the path */
444 r = RegQueryValueExW( hKeyProduct, szLocalPackage,
445 NULL, &type, NULL, &count );
446 if( r != ERROR_SUCCESS )
448 r = ERROR_UNKNOWN_PRODUCT;
452 /* now alloc and fetch the path of the database to open */
453 path = HeapAlloc( GetProcessHeap(), 0, count );
457 r = RegQueryValueExW( hKeyProduct, szLocalPackage,
458 NULL, &type, (LPBYTE) path, &count );
459 if( r != ERROR_SUCCESS )
461 r = ERROR_UNKNOWN_PRODUCT;
465 r = MsiOpenPackageW( path, phProduct );
469 HeapFree( GetProcessHeap(), 0, path );
471 RegCloseKey( hKeyProduct );
472 RegCloseKey( hKeyUninstall );
477 UINT WINAPI MsiAdvertiseProductA(LPCSTR szPackagePath, LPCSTR szScriptfilePath, LPCSTR szTransforms, LANGID lgidLanguage)
479 FIXME("%s %s %s 0x%08x\n",debugstr_a(szPackagePath), debugstr_a(szScriptfilePath), debugstr_a(szTransforms), lgidLanguage);
480 return ERROR_CALL_NOT_IMPLEMENTED;
483 UINT WINAPI MsiAdvertiseProductW(LPCWSTR szPackagePath, LPCWSTR szScriptfilePath, LPCWSTR szTransforms, LANGID lgidLanguage)
485 FIXME("%s %s %s 0x%08x\n",debugstr_w(szPackagePath), debugstr_w(szScriptfilePath), debugstr_w(szTransforms), lgidLanguage);
486 return ERROR_CALL_NOT_IMPLEMENTED;
489 UINT WINAPI MsiAdvertiseProductExA(LPCSTR szPackagePath, LPCSTR szScriptfilePath, LPCSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
491 FIXME("%s %s %s 0x%08x 0x%08lx 0x%08lx\n",
492 debugstr_a(szPackagePath), debugstr_a(szScriptfilePath), debugstr_a(szTransforms), lgidLanguage, dwPlatform, dwOptions);
493 return ERROR_CALL_NOT_IMPLEMENTED;
496 UINT WINAPI MsiAdvertiseProductExW( LPCWSTR szPackagePath, LPCWSTR szScriptfilePath, LPCWSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
498 FIXME("%s %s %s 0x%08x 0x%08lx 0x%08lx\n",
499 debugstr_w(szPackagePath), debugstr_w(szScriptfilePath), debugstr_w(szTransforms), lgidLanguage, dwPlatform, dwOptions);
500 return ERROR_CALL_NOT_IMPLEMENTED;
503 UINT WINAPI MsiInstallProductA(LPCSTR szPackagePath, LPCSTR szCommandLine)
505 LPWSTR szwPath = NULL, szwCommand = NULL;
506 UINT r = ERROR_FUNCTION_FAILED; /* FIXME: check return code */
508 TRACE("%s %s\n",debugstr_a(szPackagePath), debugstr_a(szCommandLine));
512 UINT len = MultiByteToWideChar( CP_ACP, 0, szPackagePath, -1, NULL, 0 );
513 szwPath = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
516 MultiByteToWideChar( CP_ACP, 0, szPackagePath, -1, szwPath, len );
521 UINT len = MultiByteToWideChar( CP_ACP, 0, szCommandLine, -1, NULL, 0 );
522 szwCommand = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
525 MultiByteToWideChar( CP_ACP, 0, szCommandLine, -1, szwCommand, len );
528 r = MsiInstallProductW( szwPath, szwCommand );
532 HeapFree( GetProcessHeap(), 0, szwPath );
535 HeapFree( GetProcessHeap(), 0, szwCommand );
540 UINT WINAPI MsiInstallProductW(LPCWSTR szPackagePath, LPCWSTR szCommandLine)
542 MSIPACKAGE *package = NULL;
543 UINT rc = ERROR_SUCCESS;
546 FIXME("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
548 rc = MsiVerifyPackageW(szPackagePath);
549 if (rc != ERROR_SUCCESS)
552 rc = MSI_OpenPackageW(szPackagePath,&package);
553 if (rc != ERROR_SUCCESS)
556 handle = alloc_msihandle( &package->hdr );
558 rc = ACTION_DoTopLevelINSTALL(package, szPackagePath, szCommandLine);
560 MsiCloseHandle(handle);
561 msiobj_release( &package->hdr );
565 UINT WINAPI MsiReinstallProductA(LPCSTR szProduct, DWORD dwReinstallMode)
567 FIXME("%s 0x%08lx\n", debugstr_a(szProduct), dwReinstallMode);
568 return ERROR_CALL_NOT_IMPLEMENTED;
571 UINT WINAPI MsiReinstallProductW(LPCWSTR szProduct, DWORD dwReinstallMode)
573 FIXME("%s 0x%08lx\n", debugstr_w(szProduct), dwReinstallMode);
574 return ERROR_CALL_NOT_IMPLEMENTED;
577 UINT WINAPI MsiApplyPatchA(LPCSTR szPatchPackage, LPCSTR szInstallPackage, INSTALLTYPE eInstallType, LPCSTR szCommandLine)
579 FIXME("%s %s %d %s\n", debugstr_a(szPatchPackage), debugstr_a(szInstallPackage), eInstallType, debugstr_a(szCommandLine));
580 return ERROR_CALL_NOT_IMPLEMENTED;
583 UINT WINAPI MsiApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szInstallPackage, INSTALLTYPE eInstallType, LPCWSTR szCommandLine)
585 FIXME("%s %s %d %s\n", debugstr_w(szPatchPackage), debugstr_w(szInstallPackage), eInstallType, debugstr_w(szCommandLine));
586 return ERROR_CALL_NOT_IMPLEMENTED;
589 UINT WINAPI MsiConfigureProductA(LPCSTR szProduct, int iInstallLevel, INSTALLSTATE eInstallState)
591 LPWSTR szwProduct = NULL;
592 UINT hr = ERROR_SUCCESS;
594 FIXME("%s %d %d\n",debugstr_a(szProduct), iInstallLevel, eInstallState);
598 UINT len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
599 szwProduct = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
602 MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProduct, len );
605 hr = MsiConfigureProductW( szwProduct, iInstallLevel, eInstallState );
609 HeapFree( GetProcessHeap(), 0, szwProduct );
614 UINT WINAPI MsiConfigureProductW(LPCWSTR szProduct, int iInstallLevel, INSTALLSTATE eInstallState)
616 FIXME("%s %d %d\n",debugstr_w(szProduct), iInstallLevel, eInstallState);
617 return ERROR_CALL_NOT_IMPLEMENTED;
620 UINT WINAPI MsiGetProductCodeA(LPCSTR szComponent, LPSTR szBuffer)
622 LPWSTR szwComponent = NULL, szwBuffer = NULL;
623 UINT hr = ERROR_INSTALL_FAILURE;
625 FIXME("%s %s\n",debugstr_a(szComponent), debugstr_a(szBuffer));
629 UINT len = MultiByteToWideChar( CP_ACP, 0, szComponent, -1, NULL, 0 );
630 szwComponent = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
633 MultiByteToWideChar( CP_ACP, 0, szComponent, -1, szwComponent, len );
635 return ERROR_INVALID_PARAMETER;
639 szwBuffer = HeapAlloc( GetProcessHeap(), 0, GUID_SIZE * sizeof(WCHAR) );
644 hr = MsiGetProductCodeW( szwComponent, szwBuffer );
646 if( ERROR_SUCCESS == hr )
648 WideCharToMultiByte(CP_ACP, 0, szwBuffer, -1, szBuffer, GUID_SIZE, NULL, NULL);
653 HeapFree( GetProcessHeap(), 0, szwComponent );
655 HeapFree( GetProcessHeap(), 0, szwBuffer );
660 UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer)
662 FIXME("%s %s\n",debugstr_w(szComponent), debugstr_w(szBuffer));
663 if (NULL == szComponent) {
664 return ERROR_INVALID_PARAMETER;
666 return ERROR_CALL_NOT_IMPLEMENTED;
672 UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute, LPSTR szBuffer, DWORD *pcchValueBuf)
674 LPWSTR szwProduct = NULL, szwAttribute = NULL, szwBuffer = NULL;
675 UINT hr = ERROR_INSTALL_FAILURE;
677 FIXME("%s %s %p %p\n",debugstr_a(szProduct), debugstr_a(szAttribute), szBuffer, pcchValueBuf);
679 if (NULL != szBuffer && NULL == pcchValueBuf) {
680 return ERROR_INVALID_PARAMETER;
684 UINT len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
685 szwProduct = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
688 MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProduct, len );
690 return ERROR_INVALID_PARAMETER;
695 UINT len = MultiByteToWideChar( CP_ACP, 0, szAttribute, -1, NULL, 0 );
696 szwAttribute = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
699 MultiByteToWideChar( CP_ACP, 0, szAttribute, -1, szwAttribute, len );
701 return ERROR_INVALID_PARAMETER;
706 szwBuffer = HeapAlloc( GetProcessHeap(), 0, (*pcchValueBuf) * sizeof(WCHAR) );
711 hr = MsiGetProductInfoW( szwProduct, szwAttribute, szwBuffer, pcchValueBuf );
713 if( ERROR_SUCCESS == hr )
715 WideCharToMultiByte(CP_ACP, 0, szwBuffer, -1, szBuffer, *pcchValueBuf, NULL, NULL);
720 HeapFree( GetProcessHeap(), 0, szwProduct );
722 HeapFree( GetProcessHeap(), 0, szwAttribute );
724 HeapFree( GetProcessHeap(), 0, szwBuffer );
729 UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute, LPWSTR szBuffer, DWORD *pcchValueBuf)
734 FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szAttribute), szBuffer, pcchValueBuf);
736 if (NULL != szBuffer && NULL == pcchValueBuf) {
737 return ERROR_INVALID_PARAMETER;
739 if (NULL == szProduct || NULL == szAttribute) {
740 return ERROR_INVALID_PARAMETER;
743 hr = MsiOpenProductW(szProduct, &hProduct);
744 if (ERROR_SUCCESS != hr) return hr;
746 hr = MsiGetPropertyW(hProduct, szAttribute, szBuffer, pcchValueBuf);
747 MsiCloseHandle(hProduct);
751 UINT WINAPI MsiDatabaseImportA(LPCSTR szFolderPath, LPCSTR szFilename)
753 FIXME("%s %s\n",debugstr_a(szFolderPath), debugstr_a(szFilename));
754 return ERROR_CALL_NOT_IMPLEMENTED;
757 UINT WINAPI MsiDatabaseImportW(LPCWSTR szFolderPath, LPCWSTR szFilename)
759 FIXME("%s %s\n",debugstr_w(szFolderPath), debugstr_w(szFilename));
760 return ERROR_CALL_NOT_IMPLEMENTED;
763 UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
765 LPWSTR szwLogFile = NULL;
766 UINT hr = ERROR_INSTALL_FAILURE;
768 FIXME("%08lx %s %08lx\n", dwLogMode, debugstr_a(szLogFile), attributes);
772 UINT len = MultiByteToWideChar( CP_ACP, 0, szLogFile, -1, NULL, 0 );
773 szwLogFile = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
776 MultiByteToWideChar( CP_ACP, 0, szLogFile, -1, szwLogFile, len );
778 return ERROR_INVALID_PARAMETER;
781 hr = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
785 HeapFree( GetProcessHeap(), 0, szwLogFile );
790 UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
792 HANDLE the_file = INVALID_HANDLE_VALUE;
793 TRACE("%08lx %s %08lx\n", dwLogMode, debugstr_w(szLogFile), attributes);
794 strcpyW(gszLogFile,szLogFile);
795 if (!(attributes & INSTALLLOGATTRIBUTES_APPEND))
796 DeleteFileW(szLogFile);
797 the_file = CreateFileW(szLogFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
798 FILE_ATTRIBUTE_NORMAL, NULL);
799 if (the_file != INVALID_HANDLE_VALUE)
800 CloseHandle(the_file);
802 ERR("Unable to enable log %s\n",debugstr_w(szLogFile));
804 return ERROR_SUCCESS;
807 INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct)
809 FIXME("%s\n", debugstr_a(szProduct));
810 return INSTALLSTATE_UNKNOWN;
813 INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
815 FIXME("%s\n", debugstr_w(szProduct));
816 return INSTALLSTATE_UNKNOWN;
819 INSTALLUILEVEL WINAPI MsiSetInternalUI(INSTALLUILEVEL dwUILevel, HWND *phWnd)
821 INSTALLUILEVEL old = gUILevel;
822 HWND oldwnd = gUIhwnd;
823 TRACE("%08x %p\n", dwUILevel, phWnd);
825 gUILevel = dwUILevel;
834 INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler,
835 DWORD dwMessageFilter, LPVOID pvContext)
837 INSTALLUI_HANDLERA prev = gUIHandler;
839 TRACE("(%p %lx %p)\n",puiHandler,dwMessageFilter,pvContext);
840 gUIHandler = puiHandler;
841 gUIFilter = dwMessageFilter;
842 gUIContext = pvContext;
847 UINT WINAPI MsiLoadStringA(HINSTANCE hInstance, UINT uID, LPSTR lpBuffer, int nBufferMax, DWORD e)
849 /*FIXME("%08lx %08lx %08lx %08lx %08lx\n",a,b,c,d,e);*/
850 FIXME("%p %u %p %d %08lx\n",hInstance,uID,lpBuffer,nBufferMax,e);
851 return ERROR_CALL_NOT_IMPLEMENTED;
854 UINT WINAPI MsiLoadStringW(HINSTANCE hInstance, UINT uID, LPWSTR lpBuffer, int nBufferMax, DWORD e)
856 FIXME("%p %u %p %d %08lx\n",hInstance,uID,lpBuffer,nBufferMax,e);
858 int ret = LoadStringW(hInstance,uID,lpBuffer,nBufferMax);
859 FIXME("%s\n",debugstr_w(lpBuffer));
862 return ERROR_CALL_NOT_IMPLEMENTED;
865 INSTALLSTATE WINAPI MsiLocateComponentA(LPCSTR szComponent, LPSTR lpPathBuf, DWORD *pcchBuf)
867 FIXME("%s %p %08lx\n", debugstr_a(szComponent), lpPathBuf, *pcchBuf);
868 return INSTALLSTATE_UNKNOWN;
871 INSTALLSTATE WINAPI MsiLocateComponentW(LPCWSTR szComponent, LPSTR lpPathBuf, DWORD *pcchBuf)
873 FIXME("%s %p %08lx\n", debugstr_w(szComponent), lpPathBuf, *pcchBuf);
874 return INSTALLSTATE_UNKNOWN;
879 UINT WINAPI MsiMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType, WORD wLanguageId, DWORD f)
881 FIXME("%p %s %s %u %08x %08lx\n",hWnd,debugstr_a(lpText),debugstr_a(lpCaption),uType,wLanguageId,f);
883 MessageBoxExA(hWnd,lpText,lpCaption,uType|MB_OK,wLanguageId);
885 return ERROR_CALL_NOT_IMPLEMENTED;
888 UINT WINAPI MsiMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType, WORD wLanguageId, DWORD f)
890 /*FIXME("%08lx %08lx %08lx %08lx %08lx %08lx\n",a,b,c,d,e,f);*/
891 FIXME("%p %s %s %u %08x %08lx\n",hWnd,debugstr_w(lpText),debugstr_w(lpCaption),uType,wLanguageId,f);
893 MessageBoxExW(hWnd,lpText,lpCaption,uType|MB_OK,wLanguageId);
895 return ERROR_CALL_NOT_IMPLEMENTED;
898 UINT WINAPI MsiEnumProductsA(DWORD index, LPSTR lpguid)
901 WCHAR szwGuid[GUID_SIZE];
903 TRACE("%ld %p\n",index,lpguid);
905 if (NULL == lpguid) {
906 return ERROR_INVALID_PARAMETER;
908 r = MsiEnumProductsW(index, szwGuid);
909 if( r == ERROR_SUCCESS )
910 WideCharToMultiByte(CP_ACP, 0, szwGuid, -1, lpguid, GUID_SIZE, NULL, NULL);
915 UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid)
917 HKEY hkey = 0, hkeyFeatures = 0;
921 TRACE("%ld %p\n",index,lpguid);
923 if (NULL == lpguid) {
924 return ERROR_INVALID_PARAMETER;
926 r = RegOpenKeyW(HKEY_LOCAL_MACHINE, szInstaller, &hkey);
927 if( r != ERROR_SUCCESS )
930 r = RegOpenKeyW(hkey, szFeatures, &hkeyFeatures);
931 if( r != ERROR_SUCCESS )
934 r = RegEnumKeyW(hkeyFeatures, index, szKeyName, GUID_SIZE);
936 unsquash_guid(szKeyName, lpguid);
941 RegCloseKey(hkeyFeatures);
948 UINT WINAPI MsiEnumFeaturesA(LPCSTR szProduct, DWORD index,
949 LPSTR szFeature, LPSTR szParent)
952 WCHAR szwFeature[GUID_SIZE], szwParent[GUID_SIZE];
953 LPWSTR szwProduct = NULL;
955 TRACE("%s %ld %p %p\n",debugstr_a(szProduct),index,szFeature,szParent);
959 UINT len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
960 szwProduct = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
962 MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProduct, len );
964 return ERROR_FUNCTION_FAILED;
967 r = MsiEnumFeaturesW(szwProduct, index, szwFeature, szwParent);
968 if( r == ERROR_SUCCESS )
970 WideCharToMultiByte(CP_ACP, 0, szwFeature, -1,
971 szFeature, GUID_SIZE, NULL, NULL);
972 WideCharToMultiByte(CP_ACP, 0, szwParent, -1,
973 szParent, GUID_SIZE, NULL, NULL);
977 HeapFree( GetProcessHeap(), 0, szwProduct);
982 UINT WINAPI MsiEnumFeaturesW(LPCWSTR szProduct, DWORD index,
983 LPWSTR szFeature, LPWSTR szParent)
985 HKEY hkey = 0, hkeyFeatures = 0, hkeyProduct = 0;
987 WCHAR szRegName[GUID_SIZE];
989 TRACE("%s %ld %p %p\n",debugstr_w(szProduct),index,szFeature,szParent);
991 if( !squash_guid(szProduct, szRegName) )
992 return ERROR_INVALID_PARAMETER;
994 r = RegOpenKeyW(HKEY_LOCAL_MACHINE, szInstaller, &hkey);
995 if( r != ERROR_SUCCESS )
998 r = RegOpenKeyW(hkey, szFeatures, &hkeyFeatures);
999 if( r != ERROR_SUCCESS )
1002 r = RegOpenKeyW(hkeyFeatures, szRegName, &hkeyProduct);
1003 if( r != ERROR_SUCCESS )
1007 r = RegEnumValueW(hkeyProduct, index, szFeature, &sz, NULL, NULL, NULL, NULL);
1011 RegCloseKey(hkeyProduct);
1013 RegCloseKey(hkeyFeatures);
1020 UINT WINAPI MsiEnumComponentsA(DWORD index, LPSTR lpguid)
1023 WCHAR szwGuid[GUID_SIZE];
1025 TRACE("%ld %p\n",index,lpguid);
1027 r = MsiEnumComponentsW(index, szwGuid);
1028 if( r == ERROR_SUCCESS )
1029 WideCharToMultiByte(CP_ACP, 0, szwGuid, -1, lpguid, GUID_SIZE, NULL, NULL);
1034 UINT WINAPI MsiEnumComponentsW(DWORD index, LPWSTR lpguid)
1036 HKEY hkey = 0, hkeyComponents = 0;
1038 WCHAR szKeyName[33];
1040 TRACE("%ld %p\n",index,lpguid);
1042 r = RegOpenKeyW(HKEY_LOCAL_MACHINE, szInstaller, &hkey);
1043 if( r != ERROR_SUCCESS )
1046 r = RegOpenKeyW(hkey, szComponents, &hkeyComponents);
1047 if( r != ERROR_SUCCESS )
1050 r = RegEnumKeyW(hkeyComponents, index, szKeyName, GUID_SIZE);
1052 unsquash_guid(szKeyName, lpguid);
1056 if( hkeyComponents )
1057 RegCloseKey(hkeyComponents);
1064 UINT WINAPI MsiEnumClientsA(LPCSTR szComponent, DWORD index, LPSTR szProduct)
1067 WCHAR szwProduct[GUID_SIZE];
1068 LPWSTR szwComponent = NULL;
1070 TRACE("%s %ld %p\n",debugstr_a(szComponent),index,szProduct);
1074 UINT len = MultiByteToWideChar( CP_ACP, 0, szComponent, -1, NULL, 0 );
1075 szwComponent = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
1077 MultiByteToWideChar( CP_ACP, 0, szComponent, -1, szwComponent, len );
1079 return ERROR_FUNCTION_FAILED;
1082 r = MsiEnumClientsW(szComponent?szwComponent:NULL, index, szwProduct);
1083 if( r == ERROR_SUCCESS )
1085 WideCharToMultiByte(CP_ACP, 0, szwProduct, -1,
1086 szProduct, GUID_SIZE, NULL, NULL);
1090 HeapFree( GetProcessHeap(), 0, szwComponent);
1095 UINT WINAPI MsiEnumClientsW(LPCWSTR szComponent, DWORD index, LPWSTR szProduct)
1097 HKEY hkey = 0, hkeyComponents = 0, hkeyComp = 0;
1099 WCHAR szRegName[GUID_SIZE], szValName[GUID_SIZE];
1101 TRACE("%s %ld %p\n",debugstr_w(szComponent),index,szProduct);
1103 if( !squash_guid(szComponent, szRegName) )
1104 return ERROR_INVALID_PARAMETER;
1106 r = RegOpenKeyW(HKEY_LOCAL_MACHINE, szInstaller, &hkey);
1107 if( r != ERROR_SUCCESS )
1110 r = RegOpenKeyW(hkey, szComponents, &hkeyComponents);
1111 if( r != ERROR_SUCCESS )
1114 r = RegOpenKeyW(hkeyComponents, szRegName, &hkeyComp);
1115 if( r != ERROR_SUCCESS )
1119 r = RegEnumValueW(hkeyComp, index, szValName, &sz, NULL, NULL, NULL, NULL);
1120 if( r != ERROR_SUCCESS )
1123 unsquash_guid(szValName, szProduct);
1127 RegCloseKey(hkeyComp);
1128 if( hkeyComponents )
1129 RegCloseKey(hkeyComponents);
1136 UINT WINAPI MsiEnumComponentQualifiersA(
1137 LPSTR szComponent, DWORD iIndex, LPSTR lpQualifierBuf, DWORD* pcchQualifierBuf, LPSTR lpApplicationDataBuf, DWORD* pcchApplicationDataBuf)
1139 FIXME("%s 0x%08lx %p %p %p %p\n", debugstr_a(szComponent), iIndex, lpQualifierBuf, pcchQualifierBuf, lpApplicationDataBuf, pcchApplicationDataBuf);
1140 return ERROR_CALL_NOT_IMPLEMENTED;
1143 UINT WINAPI MsiEnumComponentQualifiersW(
1144 LPWSTR szComponent, DWORD iIndex, LPWSTR lpQualifierBuf, DWORD* pcchQualifierBuf, LPWSTR lpApplicationDataBuf, DWORD* pcchApplicationDataBuf)
1146 FIXME("%s 0x%08lx %p %p %p %p\n", debugstr_w(szComponent), iIndex, lpQualifierBuf, pcchQualifierBuf, lpApplicationDataBuf, pcchApplicationDataBuf);
1147 return ERROR_CALL_NOT_IMPLEMENTED;
1150 UINT WINAPI MsiProvideAssemblyA(
1151 LPCSTR szAssemblyName, LPCSTR szAppContext, DWORD dwInstallMode, DWORD dwAssemblyInfo, LPSTR lpPathBuf, DWORD* pcchPathBuf)
1153 FIXME("%s %s 0x%08lx 0x%08lx %p %p\n",
1154 debugstr_a(szAssemblyName), debugstr_a(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf, pcchPathBuf);
1155 return ERROR_CALL_NOT_IMPLEMENTED;
1158 UINT WINAPI MsiProvideAssemblyW(
1159 LPCWSTR szAssemblyName, LPCWSTR szAppContext, DWORD dwInstallMode, DWORD dwAssemblyInfo, LPWSTR lpPathBuf, DWORD* pcchPathBuf)
1161 FIXME("%s %s 0x%08lx 0x%08lx %p %p\n",
1162 debugstr_w(szAssemblyName), debugstr_w(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf, pcchPathBuf);
1163 return ERROR_CALL_NOT_IMPLEMENTED;
1166 UINT WINAPI MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor, LPSTR szPath, DWORD *pcchPath, DWORD *pcchArgs )
1168 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor), szPath, pcchPath, pcchArgs );
1169 return ERROR_CALL_NOT_IMPLEMENTED;
1172 UINT WINAPI MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor, LPWSTR szPath, DWORD *pcchPath, DWORD *pcchArgs )
1174 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor), szPath, pcchPath, pcchArgs );
1175 return ERROR_CALL_NOT_IMPLEMENTED;
1178 HRESULT WINAPI MsiGetFileSignatureInformationA(
1179 LPCSTR szSignedObjectPath, DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, BYTE* pbHashData, DWORD* pcbHashData)
1181 FIXME("%s 0x%08lx %p %p %p\n", debugstr_a(szSignedObjectPath), dwFlags, ppcCertContext, pbHashData, pcbHashData);
1182 return ERROR_CALL_NOT_IMPLEMENTED;
1185 HRESULT WINAPI MsiGetFileSignatureInformationW(
1186 LPCWSTR szSignedObjectPath, DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, BYTE* pbHashData, DWORD* pcbHashData)
1188 FIXME("%s 0x%08lx %p %p %p\n", debugstr_w(szSignedObjectPath), dwFlags, ppcCertContext, pbHashData, pcbHashData);
1189 return ERROR_CALL_NOT_IMPLEMENTED;
1192 UINT WINAPI MsiGetProductPropertyA( MSIHANDLE hProduct, LPCSTR szProperty,
1193 LPSTR szValue, DWORD *pccbValue )
1195 FIXME("%ld %s %p %p\n", hProduct, debugstr_a(szProperty), szValue, pccbValue);
1196 return ERROR_CALL_NOT_IMPLEMENTED;
1199 UINT WINAPI MsiGetProductPropertyW( MSIHANDLE hProduct, LPCWSTR szProperty,
1200 LPWSTR szValue, DWORD *pccbValue )
1202 FIXME("%ld %s %p %p\n", hProduct, debugstr_w(szProperty), szValue, pccbValue);
1203 return ERROR_CALL_NOT_IMPLEMENTED;
1206 UINT WINAPI MsiVerifyPackageA( LPCSTR szPackage )
1209 LPWSTR szPack = NULL;
1211 TRACE("%s\n", debugstr_a(szPackage) );
1215 len = MultiByteToWideChar( CP_ACP, 0, szPackage, -1, NULL, 0 );
1216 szPack = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1218 return ERROR_OUTOFMEMORY;
1219 MultiByteToWideChar( CP_ACP, 0, szPackage, -1, szPack, len );
1222 r = MsiVerifyPackageW( szPack );
1224 HeapFree( GetProcessHeap(), 0, szPack );
1229 UINT WINAPI MsiVerifyPackageW( LPCWSTR szPackage )
1234 TRACE("%s\n", debugstr_w(szPackage) );
1236 r = MsiOpenDatabaseW( szPackage, MSIDBOPEN_READONLY, &handle );
1237 MsiCloseHandle( handle );
1242 INSTALLSTATE WINAPI MsiGetComponentPathA(LPCSTR szProduct, LPCSTR szComponent,
1243 LPSTR lpPathBuf, DWORD* pcchBuf)
1247 LPWSTR szwProduct= NULL;
1248 LPWSTR szwComponent= NULL;
1249 LPWSTR lpwPathBuf= NULL;
1253 len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
1254 szwProduct= HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1256 return ERROR_OUTOFMEMORY;
1257 MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProduct, len );
1262 len = MultiByteToWideChar( CP_ACP, 0, szComponent, -1, NULL, 0 );
1263 szwComponent= HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1265 return ERROR_OUTOFMEMORY;
1266 MultiByteToWideChar( CP_ACP, 0, szComponent, -1, szwComponent, len );
1269 if (pcchBuf && *pcchBuf > 0)
1270 lpwPathBuf = HeapAlloc( GetProcessHeap(), 0, *pcchBuf * sizeof(WCHAR));
1274 rc = MsiGetComponentPathW(szwProduct, szwComponent, lpwPathBuf, pcchBuf);
1276 HeapFree( GetProcessHeap(), 0, szwProduct);
1277 HeapFree( GetProcessHeap(), 0, szwComponent);
1280 WideCharToMultiByte(CP_ACP, 0, lpwPathBuf, *pcchBuf,
1281 lpPathBuf, GUID_SIZE, NULL, NULL);
1282 HeapFree( GetProcessHeap(), 0, lpwPathBuf);
1288 INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent,
1289 LPWSTR lpPathBuf, DWORD* pcchBuf)
1291 FIXME("STUB: (%s %s %p %p)\n", debugstr_w(szProduct),
1292 debugstr_w(szComponent), lpPathBuf, pcchBuf);
1294 return INSTALLSTATE_UNKNOWN;
1297 INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
1301 LPWSTR szwProduct= NULL;
1302 LPWSTR szwFeature= NULL;
1306 len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
1307 szwProduct= HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1309 return ERROR_OUTOFMEMORY;
1310 MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProduct, len );
1315 len = MultiByteToWideChar( CP_ACP, 0, szFeature, -1, NULL, 0 );
1316 szwFeature= HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1318 return ERROR_OUTOFMEMORY;
1319 MultiByteToWideChar( CP_ACP, 0, szFeature, -1, szwFeature, len );
1322 rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
1324 HeapFree( GetProcessHeap(), 0, szwProduct);
1325 HeapFree( GetProcessHeap(), 0, szwFeature);
1330 INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
1332 FIXME("STUB: (%s %s)\n", debugstr_w(szProduct), debugstr_w(szFeature));
1333 return INSTALLSTATE_UNKNOWN;
1336 UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf, DWORD* pcchVersionBuf, LPSTR lpLangBuf, DWORD* pcchLangBuf)
1340 LPWSTR szwFilePath = NULL;
1341 LPWSTR lpwVersionBuff = NULL;
1342 LPWSTR lpwLangBuff = NULL;
1345 len = MultiByteToWideChar( CP_ACP, 0, szFilePath, -1, NULL, 0 );
1346 szwFilePath = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1348 return ERROR_OUTOFMEMORY;
1349 MultiByteToWideChar( CP_ACP, 0, szFilePath, -1, szwFilePath, len );
1352 if(lpVersionBuf && pcchVersionBuf && *pcchVersionBuf) {
1353 lpwVersionBuff = HeapAlloc(GetProcessHeap(), 0, *pcchVersionBuf * sizeof(WCHAR));
1354 if( !lpwVersionBuff)
1355 return ERROR_OUTOFMEMORY;
1358 if(lpLangBuf && pcchLangBuf && *pcchLangBuf) {
1359 lpwLangBuff = HeapAlloc(GetProcessHeap(), 0, *pcchVersionBuf * sizeof(WCHAR));
1361 return ERROR_OUTOFMEMORY;
1364 ret = MsiGetFileVersionW(szwFilePath, lpwVersionBuff, pcchVersionBuf, lpwLangBuff, pcchLangBuf);
1367 WideCharToMultiByte(CP_ACP, 0, lpwVersionBuff, -1, lpVersionBuf, *pcchVersionBuf, NULL, NULL);
1369 WideCharToMultiByte(CP_ACP, 0, lpwLangBuff, -1, lpLangBuf, *pcchLangBuf, NULL, NULL);
1371 if(szwFilePath) HeapFree(GetProcessHeap(), 0, szwFilePath);
1372 if(lpwVersionBuff) HeapFree(GetProcessHeap(), 0, lpwVersionBuff);
1373 if(lpwLangBuff) HeapFree(GetProcessHeap(), 0, lpwLangBuff);
1378 UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf, DWORD* pcchVersionBuf, LPWSTR lpLangBuf, DWORD* pcchLangBuf)
1380 static const WCHAR szVersionResource[] = {'\\',0};
1381 static const WCHAR szVersionFormat[] = {'%','d','.','%','d','.','%','d','.','%','d',0};
1382 static const WCHAR szLangFormat[] = {'%','d',0};
1385 LPVOID lpVer = NULL;
1386 VS_FIXEDFILEINFO *ffi;
1390 TRACE("(%s,%p,%ld,%p,%ld)\n", debugstr_w(szFilePath),
1391 lpVersionBuf, pcchVersionBuf?*pcchVersionBuf:0,
1392 lpLangBuf, pcchLangBuf?*pcchLangBuf:0);
1394 dwVerLen = GetFileVersionInfoSizeW(szFilePath, NULL);
1396 return GetLastError();
1398 lpVer = HeapAlloc(GetProcessHeap(), 0, dwVerLen);
1400 ret = ERROR_OUTOFMEMORY;
1404 if(!GetFileVersionInfoW(szFilePath, 0, dwVerLen, lpVer)) {
1405 ret = GetLastError();
1408 if(lpVersionBuf && pcchVersionBuf && *pcchVersionBuf) {
1409 if(VerQueryValueW(lpVer, szVersionResource, (LPVOID*)&ffi, &puLen) && puLen > 0) {
1410 wsprintfW(tmp, szVersionFormat, HIWORD(ffi->dwFileVersionMS), LOWORD(ffi->dwFileVersionMS), HIWORD(ffi->dwFileVersionLS), LOWORD(ffi->dwFileVersionLS));
1411 lstrcpynW(lpVersionBuf, tmp, *pcchVersionBuf);
1412 *pcchVersionBuf = strlenW(lpVersionBuf);
1416 *pcchVersionBuf = 0;
1420 if(lpLangBuf && pcchLangBuf && *pcchLangBuf) {
1421 DWORD lang = GetUserDefaultLangID();
1422 FIXME("Retrieve language from file\n");
1423 wsprintfW(tmp, szLangFormat, lang);
1424 lstrcpynW(lpLangBuf, tmp, *pcchLangBuf);
1425 *pcchLangBuf = strlenW(lpLangBuf);
1429 if(lpVer) HeapFree(GetProcessHeap(), 0, lpVer);
1434 /******************************************************************
1437 * @todo: maybe we can check here if MsiServer service is declared no ?
1439 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
1440 if (fdwReason == DLL_PROCESS_ATTACH) {
1441 DisableThreadLibraryCalls(hinstDLL);
1445 gUILevel = INSTALLUILEVEL_BASIC;
1451 /* FIXME: Initialisation */
1452 } else if (fdwReason == DLL_PROCESS_DETACH) {
1453 /* FIXME: Cleanup */
1456 static const WCHAR szMSIServerSvc[] = { 'M','S','I','S','e','r','v','e','r',0 };
1457 static const WCHAR szNull[] = { 0 };
1458 if (!strcmpW(lpServiceName, szMSIServerSvc)) {
1459 hKey = CreateServiceW(hSCManager,
1462 SC_MANAGER_ALL_ACCESS,
1463 SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS,
1465 SERVICE_ERROR_IGNORE,
1477 /* IUnknown fields */
1478 IClassFactoryVtbl *lpVtbl;
1480 } IClassFactoryImpl;
1482 static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
1483 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1484 FIXME("(%p, %s, %p): stub\n",This,debugstr_guid(riid),ppobj);
1485 return E_NOINTERFACE;
1488 static ULONG WINAPI MsiCF_AddRef(LPCLASSFACTORY iface) {
1489 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1490 return ++(This->ref);
1493 static ULONG WINAPI MsiCF_Release(LPCLASSFACTORY iface) {
1494 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1495 /* static class, won't be freed */
1496 return --(This->ref);
1499 static HRESULT WINAPI MsiCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
1500 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1501 FIXME ("(%p, %p, %s, %p): to implement\n", This, pOuter, debugstr_guid(riid), ppobj);
1505 static HRESULT WINAPI MsiCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
1506 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1507 FIXME("(%p, %d): stub\n", This, dolock);
1511 static IClassFactoryVtbl MsiCF_Vtbl = {
1512 MsiCF_QueryInterface,
1515 MsiCF_CreateInstance,
1519 static IClassFactoryImpl Msi_CF = {&MsiCF_Vtbl, 1 };
1521 /******************************************************************
1522 * DllGetClassObject (MSI.@)
1524 HRESULT WINAPI MSI_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
1525 FIXME("(%s, %s, %p): almost a stub.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
1526 if (IsEqualCLSID (rclsid, &CLSID_IMsiServer)) {
1527 *ppv = (LPVOID) &Msi_CF;
1528 IClassFactory_AddRef((IClassFactory*)*ppv);
1530 } else if (IsEqualCLSID (rclsid, &CLSID_IMsiServerMessage)) {
1531 *ppv = (LPVOID) &Msi_CF;
1532 IClassFactory_AddRef((IClassFactory*)*ppv);
1534 } else if (IsEqualCLSID (rclsid, &CLSID_IMsiServerX1)) {
1535 *ppv = (LPVOID) &Msi_CF;
1536 IClassFactory_AddRef((IClassFactory*)*ppv);
1538 } else if (IsEqualCLSID (rclsid, &CLSID_IMsiServerX2)) {
1539 *ppv = (LPVOID) &Msi_CF;
1540 IClassFactory_AddRef((IClassFactory*)*ppv);
1542 } else if (IsEqualCLSID (rclsid, &CLSID_IMsiServerX3)) {
1543 *ppv = (LPVOID) &Msi_CF;
1544 IClassFactory_AddRef((IClassFactory*)*ppv);
1547 WARN("(%s, %s, %p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
1548 return CLASS_E_CLASSNOTAVAILABLE;
1551 /******************************************************************
1552 * DllGetVersion (MSI.@)
1554 HRESULT WINAPI MSI_DllGetVersion(DLLVERSIONINFO *pdvi)
1558 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
1559 return E_INVALIDARG;
1561 pdvi->dwMajorVersion = MSI_MAJORVERSION;
1562 pdvi->dwMinorVersion = MSI_MINORVERSION;
1563 pdvi->dwBuildNumber = MSI_BUILDNUMBER;
1564 pdvi->dwPlatformID = 1;
1569 /******************************************************************
1570 * DllCanUnloadNow (MSI.@)
1572 BOOL WINAPI MSI_DllCanUnloadNow(void)
1577 UINT WINAPI MsiEnumRelatedProductsA (LPCSTR lpUpgradeCode, DWORD dwReserved,
1578 DWORD iProductIndex, LPSTR lpProductBuf)
1580 FIXME("STUB: (%s, %li %li %s)\n",lpUpgradeCode, dwReserved, iProductIndex,
1582 return ERROR_CALL_NOT_IMPLEMENTED;