mfplat: Implement GetScanline0AndPitch() for d3d11 buffers.
[wine/zf.git] / dlls / appwiz.cpl / addons.c
blobb2e726422daba1e424995b484d94eeca66ea13b2
1 /*
2 * Copyright 2006-2010 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include <fcntl.h>
21 #include <stdio.h>
22 #include <errno.h>
24 #define COBJMACROS
25 #define NONAMELESSUNION
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "cpl.h"
31 #include "winreg.h"
32 #include "ole2.h"
33 #include "commctrl.h"
34 #include "advpub.h"
35 #include "wininet.h"
36 #include "shellapi.h"
37 #include "urlmon.h"
38 #include "msi.h"
39 #include "bcrypt.h"
41 #include "appwiz.h"
42 #include "res.h"
44 #include "wine/debug.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(appwizcpl);
48 #define GECKO_VERSION "2.47.2"
49 #ifdef __i386__
50 #define GECKO_ARCH "x86"
51 #define GECKO_SHA "e520ce7336cd420cd09c91337d87e74bb420300fd5cbc6f724c1802766b6a61d"
52 #elif defined(__x86_64__)
53 #define GECKO_ARCH "x86_64"
54 #define GECKO_SHA "0596761024823ff3c21f13e1cd5cd3e89dccc698294d62974d8930aeda86ce45"
55 #else
56 #define GECKO_ARCH ""
57 #define GECKO_SHA "???"
58 #endif
60 #define MONO_VERSION "6.0.0"
61 #if defined(__i386__) || defined(__x86_64__)
62 #define MONO_ARCH "x86"
63 #define MONO_SHA "5c7af5976d101be359a77045c9cc8fc40feac028263d00e731578864e8b183d0"
64 #else
65 #define MONO_ARCH ""
66 #define MONO_SHA "???"
67 #endif
69 typedef struct {
70 const char *version;
71 const WCHAR *file_name;
72 const WCHAR *subdir_name;
73 const char *sha;
74 const char *url_default;
75 const char *config_key;
76 const char *url_config_key;
77 const char *dir_config_key;
78 LPCWSTR dialog_template;
79 } addon_info_t;
81 /* Download addon files over HTTP because Wine depends on an external library
82 * for TLS, so we can't be sure that HTTPS will work. The integrity of each file
83 * is checked with a hardcoded cryptographically secure hash. */
84 static const addon_info_t addons_info[] = {
86 GECKO_VERSION,
87 L"wine-gecko-" GECKO_VERSION "-" GECKO_ARCH ".msi",
88 L"gecko",
89 GECKO_SHA,
90 "http://source.winehq.org/winegecko.php",
91 "MSHTML", "GeckoUrl", "GeckoCabDir",
92 MAKEINTRESOURCEW(ID_DWL_GECKO_DIALOG)
95 MONO_VERSION,
96 L"wine-mono-" MONO_VERSION "-" MONO_ARCH ".msi",
97 L"mono",
98 MONO_SHA,
99 "http://source.winehq.org/winemono.php",
100 "Dotnet", "MonoUrl", "MonoCabDir",
101 MAKEINTRESOURCEW(ID_DWL_MONO_DIALOG)
105 static const addon_info_t *addon;
107 static HWND install_dialog = NULL;
108 static LPWSTR url = NULL;
109 static IBinding *dwl_binding;
110 static WCHAR *msi_file;
112 extern const char * CDECL wine_get_version(void);
114 static WCHAR * (CDECL *p_wine_get_dos_file_name)(const char*);
116 static BOOL sha_check(const WCHAR *file_name)
118 const unsigned char *file_map;
119 HANDLE file, map;
120 DWORD size, i;
121 BCRYPT_HASH_HANDLE hash = NULL;
122 BCRYPT_ALG_HANDLE alg = NULL;
123 UCHAR sha[32];
124 char buf[1024];
125 BOOL ret = FALSE;
127 file = CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
128 if(file == INVALID_HANDLE_VALUE) {
129 WARN("Could not open file: %u\n", GetLastError());
130 return FALSE;
133 size = GetFileSize(file, NULL);
135 map = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL);
136 CloseHandle(file);
137 if(!map)
138 return FALSE;
140 file_map = MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0);
141 CloseHandle(map);
142 if(!file_map)
143 return FALSE;
145 if(BCryptOpenAlgorithmProvider(&alg, BCRYPT_SHA256_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0))
146 goto end;
147 if(BCryptCreateHash(alg, &hash, NULL, 0, NULL, 0, 0))
148 goto end;
149 if(BCryptHashData(hash, (UCHAR *)file_map, size, 0))
150 goto end;
151 if(BCryptFinishHash(hash, sha, sizeof(sha), 0))
152 goto end;
154 for(i=0; i < sizeof(sha); i++)
155 sprintf(buf + i * 2, "%02x", sha[i]);
157 ret = !strcmp(buf, addon->sha);
158 if(!ret)
159 WARN("Got %s, expected %s\n", buf, addon->sha);
161 end:
162 UnmapViewOfFile(file_map);
163 if(hash) BCryptDestroyHash(hash);
164 if(alg) BCryptCloseAlgorithmProvider(alg, 0);
165 return ret;
168 static void set_status(DWORD id)
170 HWND status = GetDlgItem(install_dialog, ID_DWL_STATUS);
171 WCHAR buf[64];
173 LoadStringW(hInst, id, buf, ARRAY_SIZE(buf));
174 SendMessageW(status, WM_SETTEXT, 0, (LPARAM)buf);
177 enum install_res {
178 INSTALL_OK = 0,
179 INSTALL_FAILED,
180 INSTALL_NEXT,
183 static enum install_res install_file(const WCHAR *file_name)
185 ULONG res;
187 res = MsiInstallProductW(file_name, NULL);
188 if(res == ERROR_PRODUCT_VERSION)
189 res = MsiInstallProductW(file_name, L"REINSTALL=ALL REINSTALLMODE=vomus");
190 if(res != ERROR_SUCCESS) {
191 ERR("MsiInstallProduct failed: %u\n", res);
192 return INSTALL_FAILED;
195 return INSTALL_OK;
198 static enum install_res install_from_dos_file(const WCHAR *dir, const WCHAR *subdir, const WCHAR *file_name)
200 WCHAR *path;
201 enum install_res ret;
202 int len = lstrlenW( dir );
203 int size = len + 1;
205 size += lstrlenW( subdir ) + lstrlenW( file_name ) + 2;
206 if (!(path = heap_alloc( size * sizeof(WCHAR) ))) return INSTALL_FAILED;
208 lstrcpyW( path, dir );
209 if (!wcsncmp( path, L"\\??\\", 4 )) path[1] = '\\'; /* change \??\ into \\?\ */
210 if (len && path[len-1] != '/' && path[len-1] != '\\') path[len++] = '\\';
212 lstrcpyW( path + len, subdir );
213 lstrcatW( path, L"\\" );
214 lstrcatW( path, file_name );
216 if (GetFileAttributesW( path ) == INVALID_FILE_ATTRIBUTES)
218 TRACE( "%s not found\n", debugstr_w(path) );
219 heap_free( path );
220 return INSTALL_NEXT;
223 ret = install_file( path );
225 heap_free( path );
226 return ret;
229 static enum install_res install_from_unix_file(const char *dir, const WCHAR *subdir, const WCHAR *file_name)
231 WCHAR *dos_dir;
232 enum install_res ret = INSTALL_NEXT;
234 if (p_wine_get_dos_file_name && (dos_dir = p_wine_get_dos_file_name( dir )))
236 ret = install_from_dos_file( dos_dir, subdir, file_name );
237 heap_free( dos_dir );
239 return ret;
242 static HKEY open_config_key(void)
244 HKEY hkey, ret;
245 DWORD res;
247 /* @@ Wine registry key: HKCU\Software\Wine\$config_key */
248 res = RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Wine", &hkey);
249 if(res != ERROR_SUCCESS)
250 return NULL;
252 res = RegOpenKeyA(hkey, addon->config_key, &ret);
253 RegCloseKey(hkey);
254 return res == ERROR_SUCCESS ? ret : NULL;
257 static enum install_res install_from_registered_dir(void)
259 char *package_dir;
260 HKEY hkey;
261 DWORD res, type, size = MAX_PATH;
262 enum install_res ret;
264 hkey = open_config_key();
265 if(!hkey)
266 return INSTALL_NEXT;
268 package_dir = heap_alloc(size);
269 res = RegGetValueA(hkey, NULL, addon->dir_config_key, RRF_RT_ANY, &type, (PBYTE)package_dir, &size);
270 if(res == ERROR_MORE_DATA) {
271 package_dir = heap_realloc(package_dir, size);
272 res = RegGetValueA(hkey, NULL, addon->dir_config_key, RRF_RT_ANY, &type, (PBYTE)package_dir, &size);
274 RegCloseKey(hkey);
275 if(res == ERROR_FILE_NOT_FOUND) {
276 heap_free(package_dir);
277 return INSTALL_NEXT;
278 } else if(res != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ)) {
279 heap_free(package_dir);
280 return INSTALL_FAILED;
283 ret = install_from_unix_file(package_dir, L"", addon->file_name);
285 heap_free(package_dir);
286 return ret;
289 static enum install_res install_from_default_dir(void)
291 const WCHAR *package_dir;
292 WCHAR *dir_buf = NULL;
293 enum install_res ret = INSTALL_NEXT;
295 if ((package_dir = _wgetenv( L"WINEBUILDDIR" )))
297 dir_buf = heap_alloc( lstrlenW(package_dir) * sizeof(WCHAR) + sizeof(L"\\..\\") );
298 lstrcpyW( dir_buf, package_dir );
299 lstrcatW( dir_buf, L"\\..\\" );
300 package_dir = dir_buf;
302 else package_dir = _wgetenv( L"WINEDATADIR" );
304 if (package_dir)
306 ret = install_from_dos_file(package_dir, addon->subdir_name, addon->file_name);
307 heap_free(dir_buf);
310 if (ret == INSTALL_NEXT)
311 ret = install_from_unix_file(INSTALL_DATADIR "/wine/", addon->subdir_name, addon->file_name);
312 if (ret == INSTALL_NEXT && strcmp(INSTALL_DATADIR, "/usr/share") != 0)
313 ret = install_from_unix_file("/usr/share/wine/", addon->subdir_name, addon->file_name);
314 if (ret == INSTALL_NEXT)
315 ret = install_from_unix_file("/opt/wine/", addon->subdir_name, addon->file_name);
316 return ret;
319 static WCHAR *get_cache_file_name(BOOL ensure_exists)
321 const char *xdg_dir;
322 const WCHAR *home_dir;
323 WCHAR *cache_dir, *ret;
324 size_t len, size;
326 xdg_dir = getenv( "XDG_CACHE_HOME" );
327 if (xdg_dir && *xdg_dir && p_wine_get_dos_file_name)
329 if (!(cache_dir = p_wine_get_dos_file_name( xdg_dir ))) return NULL;
331 else if ((home_dir = _wgetenv( L"WINEHOMEDIR" )))
333 if (!(cache_dir = heap_alloc( lstrlenW(home_dir) * sizeof(WCHAR) + sizeof(L"\\.cache") ))) return NULL;
334 lstrcpyW( cache_dir, home_dir );
335 lstrcatW( cache_dir, L"\\.cache" );
336 cache_dir[1] = '\\'; /* change \??\ into \\?\ */
338 else return NULL;
340 if (ensure_exists && !CreateDirectoryW( cache_dir, NULL ) && GetLastError() != ERROR_ALREADY_EXISTS)
342 WARN( "%s does not exist and could not be created (%u)\n", debugstr_w(cache_dir), GetLastError() );
343 heap_free( cache_dir );
344 return NULL;
347 size = lstrlenW( cache_dir ) + ARRAY_SIZE(L"\\wine") + lstrlenW( addon->file_name ) + 1;
348 if (!(ret = heap_alloc( size * sizeof(WCHAR) )))
350 heap_free( cache_dir );
351 return NULL;
353 lstrcpyW( ret, cache_dir );
354 lstrcatW( ret, L"\\wine" );
355 heap_free( cache_dir );
357 if (ensure_exists && !CreateDirectoryW( ret, NULL ) && GetLastError() != ERROR_ALREADY_EXISTS)
359 WARN( "%s does not exist and could not be created (%u)\n", debugstr_w(ret), GetLastError() );
360 heap_free( ret );
361 return NULL;
363 len = lstrlenW( ret );
364 ret[len++] = '\\';
365 lstrcpyW( ret + len, addon->file_name );
367 TRACE( "got %s\n", debugstr_w(ret) );
368 return ret;
371 static enum install_res install_from_cache(void)
373 WCHAR *cache_file_name;
374 enum install_res res;
376 cache_file_name = get_cache_file_name(FALSE);
377 if(!cache_file_name)
378 return INSTALL_NEXT;
380 if(!sha_check(cache_file_name)) {
381 WARN("could not validate checksum\n");
382 DeleteFileW(cache_file_name);
383 heap_free(cache_file_name);
384 return INSTALL_NEXT;
387 res = install_file(cache_file_name);
388 heap_free(cache_file_name);
389 return res;
392 static IInternetBindInfo InstallCallbackBindInfo;
394 static HRESULT WINAPI InstallCallback_QueryInterface(IBindStatusCallback *iface,
395 REFIID riid, void **ppv)
397 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IBindStatusCallback, riid)) {
398 *ppv = iface;
399 return S_OK;
402 if(IsEqualGUID(&IID_IInternetBindInfo, riid)) {
403 TRACE("IID_IInternetBindInfo\n");
404 *ppv = &InstallCallbackBindInfo;
405 return S_OK;
408 return E_INVALIDARG;
411 static ULONG WINAPI InstallCallback_AddRef(IBindStatusCallback *iface)
413 return 2;
416 static ULONG WINAPI InstallCallback_Release(IBindStatusCallback *iface)
418 return 1;
421 static HRESULT WINAPI InstallCallback_OnStartBinding(IBindStatusCallback *iface,
422 DWORD dwReserved, IBinding *pib)
424 set_status(IDS_DOWNLOADING);
426 IBinding_AddRef(pib);
427 dwl_binding = pib;
429 return S_OK;
432 static HRESULT WINAPI InstallCallback_GetPriority(IBindStatusCallback *iface,
433 LONG *pnPriority)
435 return E_NOTIMPL;
438 static HRESULT WINAPI InstallCallback_OnLowResource(IBindStatusCallback *iface,
439 DWORD dwReserved)
441 return E_NOTIMPL;
444 static HRESULT WINAPI InstallCallback_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
445 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
447 HWND progress = GetDlgItem(install_dialog, ID_DWL_PROGRESS);
449 if(ulProgressMax)
450 SendMessageW(progress, PBM_SETRANGE32, 0, ulProgressMax);
451 if(ulProgress)
452 SendMessageW(progress, PBM_SETPOS, ulProgress, 0);
454 return S_OK;
457 static HRESULT WINAPI InstallCallback_OnStopBinding(IBindStatusCallback *iface,
458 HRESULT hresult, LPCWSTR szError)
460 if(dwl_binding) {
461 IBinding_Release(dwl_binding);
462 dwl_binding = NULL;
465 if(FAILED(hresult)) {
466 if(hresult == E_ABORT)
467 TRACE("Binding aborted\n");
468 else
469 ERR("Binding failed %08x\n", hresult);
470 return S_OK;
473 if(!msi_file) {
474 ERR("No MSI file\n");
475 return E_FAIL;
478 set_status(IDS_INSTALLING);
479 EnableWindow(GetDlgItem(install_dialog, IDCANCEL), 0);
481 if(sha_check(msi_file)) {
482 WCHAR *cache_file_name;
484 install_file(msi_file);
486 cache_file_name = get_cache_file_name(TRUE);
487 if(cache_file_name) {
488 CopyFileW(msi_file, cache_file_name, FALSE);
489 heap_free(cache_file_name);
491 }else {
492 WCHAR message[256];
494 if(LoadStringW(hInst, IDS_INVALID_SHA, message, ARRAY_SIZE(message)))
495 MessageBoxW(NULL, message, NULL, MB_ICONERROR);
498 DeleteFileW(msi_file);
499 heap_free(msi_file);
500 msi_file = NULL;
502 EndDialog(install_dialog, 0);
503 return S_OK;
506 static HRESULT WINAPI InstallCallback_GetBindInfo(IBindStatusCallback *iface,
507 DWORD* grfBINDF, BINDINFO* pbindinfo)
509 TRACE("()\n");
511 *grfBINDF = BINDF_ASYNCHRONOUS;
512 return S_OK;
515 static HRESULT WINAPI InstallCallback_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF,
516 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
518 if(!msi_file) {
519 msi_file = heap_strdupW(pstgmed->u.lpszFileName);
520 TRACE("got file name %s\n", debugstr_w(msi_file));
523 return S_OK;
526 static HRESULT WINAPI InstallCallback_OnObjectAvailable(IBindStatusCallback *iface,
527 REFIID riid, IUnknown* punk)
529 ERR("\n");
530 return E_NOTIMPL;
533 static const IBindStatusCallbackVtbl InstallCallbackVtbl = {
534 InstallCallback_QueryInterface,
535 InstallCallback_AddRef,
536 InstallCallback_Release,
537 InstallCallback_OnStartBinding,
538 InstallCallback_GetPriority,
539 InstallCallback_OnLowResource,
540 InstallCallback_OnProgress,
541 InstallCallback_OnStopBinding,
542 InstallCallback_GetBindInfo,
543 InstallCallback_OnDataAvailable,
544 InstallCallback_OnObjectAvailable
547 static IBindStatusCallback InstallCallback = { &InstallCallbackVtbl };
549 static HRESULT WINAPI InstallCallbackBindInfo_QueryInterface(IInternetBindInfo *iface, REFIID riid, void **ppv)
551 return IBindStatusCallback_QueryInterface(&InstallCallback, riid, ppv);
554 static ULONG WINAPI InstallCallbackBindInfo_AddRef(IInternetBindInfo *iface)
556 return 2;
559 static ULONG WINAPI InstallCallbackBindInfo_Release(IInternetBindInfo *iface)
561 return 1;
564 static HRESULT WINAPI InstallCallbackBindInfo_GetBindInfo(IInternetBindInfo *iface, DWORD *bindf, BINDINFO *bindinfo)
566 ERR("\n");
567 return E_NOTIMPL;
570 static HRESULT WINAPI InstallCallbackBindInfo_GetBindString(IInternetBindInfo *iface, ULONG string_type,
571 WCHAR **strs, ULONG cnt, ULONG *fetched)
573 switch(string_type) {
574 case BINDSTRING_USER_AGENT:
575 TRACE("BINDSTRING_USER_AGENT\n");
577 *strs = CoTaskMemAlloc(sizeof(L"Wine Addon Downloader"));
578 if(!*strs)
579 return E_OUTOFMEMORY;
581 lstrcpyW(*strs, L"Wine Addon Downloader");
582 *fetched = 1;
583 return S_OK;
586 return E_NOTIMPL;
589 static const IInternetBindInfoVtbl InstallCallbackBindInfoVtbl = {
590 InstallCallbackBindInfo_QueryInterface,
591 InstallCallbackBindInfo_AddRef,
592 InstallCallbackBindInfo_Release,
593 InstallCallbackBindInfo_GetBindInfo,
594 InstallCallbackBindInfo_GetBindString
597 static IInternetBindInfo InstallCallbackBindInfo = { &InstallCallbackBindInfoVtbl };
599 static void append_url_params( WCHAR *url )
601 DWORD size = INTERNET_MAX_URL_LENGTH * sizeof(WCHAR);
602 DWORD len = lstrlenW(url);
604 lstrcpyW(url+len, L"?arch=");
605 len += lstrlenW(L"?arch=");
606 len += MultiByteToWideChar(CP_ACP, 0, GECKO_ARCH, sizeof(GECKO_ARCH),
607 url+len, size/sizeof(WCHAR)-len)-1;
608 lstrcpyW(url+len, L"&v=");
609 len += lstrlenW(L"&v=");
610 len += MultiByteToWideChar(CP_ACP, 0, addon->version, -1, url+len, size/sizeof(WCHAR)-len)-1;
611 lstrcpyW(url+len, L"&winev=");
612 len += lstrlenW(L"&winev=");
613 MultiByteToWideChar(CP_ACP, 0, wine_get_version(), -1, url+len, size/sizeof(WCHAR)-len);
616 static LPWSTR get_url(void)
618 DWORD size = INTERNET_MAX_URL_LENGTH*sizeof(WCHAR);
619 WCHAR *url, *config_key;
620 HKEY hkey;
621 DWORD res, type;
622 DWORD returned_size;
624 static const WCHAR httpW[] = {'h','t','t','p'};
626 url = heap_alloc(size);
627 returned_size = size;
629 hkey = open_config_key();
630 if (hkey)
632 config_key = heap_strdupAtoW(addon->url_config_key);
633 res = RegQueryValueExW(hkey, config_key, NULL, &type, (LPBYTE)url, &returned_size);
634 heap_free(config_key);
635 RegCloseKey(hkey);
636 if(res == ERROR_SUCCESS && type == REG_SZ) goto found;
639 MultiByteToWideChar( CP_ACP, 0, addon->url_default, -1, url, size / sizeof(WCHAR) );
641 found:
642 if (returned_size > sizeof(httpW) && !memcmp(url, httpW, sizeof(httpW))) append_url_params( url );
644 TRACE("Got URL %s\n", debugstr_w(url));
645 return url;
648 static BOOL start_download(void)
650 IBindCtx *bind_ctx;
651 IMoniker *mon;
652 IUnknown *tmp;
653 HRESULT hres;
655 hres = CreateURLMoniker(NULL, url, &mon);
656 if(FAILED(hres))
657 return FALSE;
659 hres = CreateAsyncBindCtx(0, &InstallCallback, NULL, &bind_ctx);
660 if(SUCCEEDED(hres)) {
661 hres = IMoniker_BindToStorage(mon, bind_ctx, NULL, &IID_IUnknown, (void**)&tmp);
662 IBindCtx_Release(bind_ctx);
664 IMoniker_Release(mon);
665 if(FAILED(hres))
666 return FALSE;
668 if(tmp)
669 IUnknown_Release(tmp);
670 return TRUE;
673 static void run_winebrowser(const WCHAR *url)
675 PROCESS_INFORMATION pi;
676 STARTUPINFOW si;
677 WCHAR app[MAX_PATH];
678 LONG len, url_len;
679 WCHAR *args;
680 BOOL ret;
682 url_len = lstrlenW(url);
684 len = GetSystemDirectoryW(app, MAX_PATH - ARRAY_SIZE(L"\\winebrowser.exe"));
685 lstrcpyW(app+len, L"\\winebrowser.exe");
686 len += ARRAY_SIZE(L"\\winebrowser.exe") - 1;
688 args = heap_alloc((len+1+url_len)*sizeof(WCHAR));
689 if(!args)
690 return;
692 memcpy(args, app, len*sizeof(WCHAR));
693 args[len++] = ' ';
694 memcpy(args+len, url, (url_len+1) * sizeof(WCHAR));
696 TRACE("starting %s\n", debugstr_w(args));
698 memset(&si, 0, sizeof(si));
699 si.cb = sizeof(si);
700 ret = CreateProcessW(app, args, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi);
701 heap_free(args);
702 if (ret) {
703 CloseHandle(pi.hThread);
704 CloseHandle(pi.hProcess);
708 static INT_PTR CALLBACK installer_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
710 switch(msg) {
711 case WM_INITDIALOG:
712 ShowWindow(GetDlgItem(hwnd, ID_DWL_PROGRESS), SW_HIDE);
713 install_dialog = hwnd;
714 return TRUE;
716 case WM_NOTIFY:
717 switch (((NMHDR *)lParam)->code)
719 case NM_CLICK:
720 case NM_RETURN:
721 if (wParam == ID_DWL_STATUS)
722 run_winebrowser(((NMLINK*)lParam)->item.szUrl);
723 break;
725 break;
727 case WM_COMMAND:
728 switch(wParam) {
729 case IDCANCEL:
730 if(dwl_binding)
731 IBinding_Abort(dwl_binding);
732 EndDialog(hwnd, 0);
733 return FALSE;
735 case ID_DWL_INSTALL:
736 ShowWindow(GetDlgItem(hwnd, ID_DWL_PROGRESS), SW_SHOW);
737 EnableWindow(GetDlgItem(hwnd, ID_DWL_INSTALL), 0);
738 if(!start_download())
739 EndDialog(install_dialog, 0);
743 return FALSE;
746 BOOL install_addon(addon_t addon_type)
748 if(!*GECKO_ARCH)
749 return FALSE;
751 addon = addons_info+addon_type;
753 p_wine_get_dos_file_name = (void *)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "wine_get_dos_file_name");
756 * Try to find addon .msi file in following order:
757 * - directory stored in $dir_config_key value of HKCU/Software/Wine/$config_key key
758 * - $datadir/$addon_subdir/
759 * - $INSTALL_DATADIR/wine/$addon_subdir/
760 * - /usr/share/wine/$addon_subdir/
761 * - /opt/wine/$addon_subdir/
762 * - download from URL stored in $url_config_key value of HKCU/Software/Wine/$config_key key
764 if (install_from_registered_dir() == INSTALL_NEXT
765 && install_from_default_dir() == INSTALL_NEXT
766 && install_from_cache() == INSTALL_NEXT
767 && (url = get_url()))
768 DialogBoxW(hInst, addon->dialog_template, 0, installer_proc);
770 heap_free(url);
771 url = NULL;
772 return TRUE;