static enum install_res install_from_registered_dir(void) { char *package_dir; HKEY hkey; DWORD res, type, size = MAX_PATH; enum install_res ret; hkey = open_config_key(); if(!hkey) return INSTALL_NEXT; package_dir = heap_alloc(size); res = RegGetValueA(hkey, NULL, addon->dir_config_key, RRF_RT_ANY, &type, (PBYTE)package_dir, &size); if(res == ERROR_MORE_DATA) { package_dir = heap_realloc(package_dir, size); res = RegGetValueA(hkey, NULL, addon->dir_config_key, RRF_RT_ANY, &type, (PBYTE)package_dir, &size); } RegCloseKey(hkey); if(res == ERROR_FILE_NOT_FOUND) { heap_free(package_dir); return INSTALL_NEXT; } else if(res != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ)) { heap_free(package_dir); return INSTALL_FAILED; } TRACE("Trying %s/%s\n", debugstr_a(package_dir), debugstr_a(addon->file_name)); ret = install_from_unix_file(package_dir, "", addon->file_name); heap_free(package_dir); return ret; }
static LPWSTR get_url(void) { DWORD size = INTERNET_MAX_URL_LENGTH*sizeof(WCHAR); WCHAR *url, *config_key; HKEY hkey; DWORD res, type; DWORD returned_size; static const WCHAR httpW[] = {'h','t','t','p'}; url = heap_alloc(size); returned_size = size; hkey = open_config_key(); if (hkey) { config_key = heap_strdupAtoW(addon->url_config_key); res = RegQueryValueExW(hkey, config_key, NULL, &type, (LPBYTE)url, &returned_size); heap_free(config_key); RegCloseKey(hkey); if(res == ERROR_SUCCESS && type == REG_SZ) goto found; } MultiByteToWideChar( CP_ACP, 0, addon->url_default, -1, url, size / sizeof(WCHAR) ); found: if (returned_size > sizeof(httpW) && !memcmp(url, httpW, sizeof(httpW))) append_url_params( url ); TRACE("Got URL %s\n", debugstr_w(url)); return url; }
static LPWSTR get_url(void) { DWORD size = INTERNET_MAX_URL_LENGTH*sizeof(WCHAR); WCHAR *url, *config_key; HKEY hkey; DWORD res, type; DWORD returned_size; static const WCHAR httpW[] = {'h','t','t','p'}; static const WCHAR arch_formatW[] = {'?','a','r','c','h','='}; static const WCHAR v_formatW[] = {'&','v','='}; hkey = open_config_key(); if(!hkey) return NULL; url = heap_alloc(size); returned_size = size; config_key = heap_strdupAtoW(addon->url_config_key); res = RegQueryValueExW(hkey, config_key, NULL, &type, (LPBYTE)url, &returned_size); heap_free(config_key); RegCloseKey(hkey); if(res != ERROR_SUCCESS || type != REG_SZ) { heap_free(url); return NULL; } if(returned_size > sizeof(httpW) && !memcmp(url, httpW, sizeof(httpW))) { DWORD len; len = strlenW(url); memcpy(url+len, arch_formatW, sizeof(arch_formatW)); len += sizeof(arch_formatW)/sizeof(WCHAR); len += MultiByteToWideChar(CP_ACP, 0, ARCH_STRING, sizeof(ARCH_STRING), url+len, size/sizeof(WCHAR)-len)-1; memcpy(url+len, v_formatW, sizeof(v_formatW)); len += sizeof(v_formatW)/sizeof(WCHAR); MultiByteToWideChar(CP_ACP, 0, addon->version, -1, url+len, size/sizeof(WCHAR)-len); } TRACE("Got URL %s\n", debugstr_w(url)); return url; }