3030
3131WINE_DEFAULT_DEBUG_CHANNEL (urlmon );
3232
33- static const WCHAR ctxW [] = {'c' ,'t' ,'x' ,0 };
34- static const WCHAR cab_extW [] = {'.' ,'c' ,'a' ,'b' ,0 };
35- static const WCHAR infW [] = {'i' ,'n' ,'f' ,0 };
36- static const WCHAR dllW [] = {'d' ,'l' ,'l' ,0 };
37- static const WCHAR ocxW [] = {'o' ,'c' ,'x' ,0 };
38-
3933enum install_type {
4034 INSTALL_UNKNOWN ,
4135 INSTALL_DLL ,
@@ -63,8 +57,8 @@ static void release_install_ctx(install_ctx_t *ctx)
6357 IUri_Release (ctx -> uri );
6458 if (ctx -> callback )
6559 IBindStatusCallback_Release (ctx -> callback );
66- heap_free (ctx -> install_file );
67- heap_free (ctx );
60+ free (ctx -> install_file );
61+ free (ctx );
6862}
6963
7064static inline BOOL file_exists (const WCHAR * file_name )
@@ -163,7 +157,19 @@ HRESULT WINAPI Modified_ExtractFilesA(LPCSTR CabName, LPCSTR ExpandDir)
163157 return res ;
164158}
165159
160+ static inline char * heap_strdupWtoA (const WCHAR * str )
161+ {
162+ char * ret = NULL ;
166163
164+ if (str ) {
165+ size_t size = WideCharToMultiByte (CP_ACP , 0 , str , -1 , NULL , 0 , NULL , NULL );
166+ ret = malloc (size );
167+ if (ret )
168+ WideCharToMultiByte (CP_ACP , 0 , str , -1 , ret , size , NULL , NULL );
169+ }
170+
171+ return ret ;
172+ }
167173
168174HRESULT WINAPI Modified_ExtractFilesW (LPCWSTR CabName , LPCWSTR ExpandDir )
169175{
@@ -189,8 +195,8 @@ HRESULT WINAPI Modified_ExtractFilesW(LPCWSTR CabName, LPCWSTR ExpandDir)
189195 if (SUCCEEDED (hres ))
190196 hres = Modified_ExtractFilesA (cab_name , expand_dir );
191197
192- heap_free (cab_name );
193- heap_free (expand_dir );
198+ free (cab_name );
199+ free (expand_dir );
194200 return hres ;
195201}
196202
@@ -209,13 +215,13 @@ static HRESULT extract_cab_file(install_ctx_t *ctx)
209215 hres = ExtractFilesW (ctx -> cache_file , ctx -> tmp_dir , 0 , NULL , NULL , 0 );
210216#endif
211217 if (FAILED (hres )) {
212- WARN ("ExtractFilesW failed: %08x \n" , hres );
218+ WARN ("ExtractFilesW failed: %08lx \n" , hres );
213219 return hres ;
214220 }
215221
216222 path_len = lstrlenW (ctx -> tmp_dir );
217223 file_len = lstrlenW (ctx -> file_name );
218- ctx -> install_file = heap_alloc ((path_len + file_len + 2 ) * sizeof (WCHAR ));
224+ ctx -> install_file = malloc ((path_len + file_len + 2 ) * sizeof (WCHAR ));
219225 if (!ctx -> install_file )
220226 return E_OUTOFMEMORY ;
221227
@@ -226,19 +232,19 @@ static HRESULT extract_cab_file(install_ctx_t *ctx)
226232 /* NOTE: Assume that file_name contains ".cab" extension */
227233 ptr = ctx -> install_file + path_len + 1 + file_len - 3 ;
228234
229- memcpy (ptr , infW , sizeof (infW ));
235+ memcpy (ptr , L"inf" , sizeof (L"inf" ));
230236 if (file_exists (ctx -> install_file )) {
231237 ctx -> install_type = INSTALL_INF ;
232238 return S_OK ;
233239 }
234240
235- memcpy (ptr , dllW , sizeof (dllW ));
241+ memcpy (ptr , L"dll" , sizeof (L"dll" ));
236242 if (file_exists (ctx -> install_file )) {
237243 ctx -> install_type = INSTALL_DLL ;
238244 return S_OK ;
239245 }
240246
241- memcpy (ptr , ocxW , sizeof (ocxW ));
247+ memcpy (ptr , L"ocx" , sizeof (L"ocx" ));
242248 if (file_exists (ctx -> install_file )) {
243249 ctx -> install_type = INSTALL_DLL ;
244250 return S_OK ;
@@ -283,7 +289,7 @@ static void expand_command(install_ctx_t *ctx, const WCHAR *cmd, WCHAR *buf, siz
283289 memcpy (buf + len , prev_ptr , ptr - prev_ptr );
284290 len += ptr - prev_ptr ;
285291
286- if (!_wcsnicmp (ptr , expand_dirW , ARRAY_SIZE (expand_dirW ))) {
292+ if (!wcsnicmp (ptr , expand_dirW , ARRAY_SIZE (expand_dirW ))) {
287293 len2 = lstrlenW (ctx -> tmp_dir );
288294 if (buf )
289295 memcpy (buf + len , ctx -> tmp_dir , len2 * sizeof (WCHAR ));
@@ -312,30 +318,28 @@ static HRESULT process_hook_section(install_ctx_t *ctx, const WCHAR *sect_name)
312318 DWORD len ;
313319 HRESULT hres ;
314320
315- static const WCHAR runW [] = {'r' ,'u' ,'n' ,0 };
316-
317321 len = GetPrivateProfileStringW (sect_name , NULL , NULL , buf , ARRAY_SIZE (buf ), ctx -> install_file );
318322 if (!len )
319323 return S_OK ;
320324
321325 for (key = buf ; * key ; key += lstrlenW (key )+ 1 ) {
322- if (!wcsicmp (key , runW )) {
326+ if (!wcsicmp (key , L"run" )) {
323327 WCHAR * cmd ;
324328 size_t size ;
325329
326- len = GetPrivateProfileStringW (sect_name , runW , NULL , val , ARRAY_SIZE (val ), ctx -> install_file );
330+ len = GetPrivateProfileStringW (sect_name , L"run" , NULL , val , ARRAY_SIZE (val ), ctx -> install_file );
327331
328332 TRACE ("Run %s\n" , debugstr_w (val ));
329333
330334 expand_command (ctx , val , NULL , & size );
331335
332- cmd = heap_alloc (size * sizeof (WCHAR ));
336+ cmd = malloc (size * sizeof (WCHAR ));
333337 if (!cmd )
334- heap_free ( cmd ) ;
338+ return E_OUTOFMEMORY ;
335339
336340 expand_command (ctx , val , cmd , & size );
337341 hres = RunSetupCommandW (ctx -> hwnd , cmd , NULL , ctx -> tmp_dir , NULL , NULL , 0 , NULL );
338- heap_free (cmd );
342+ free (cmd );
339343 if (FAILED (hres ))
340344 return hres ;
341345 }else {
@@ -355,17 +359,14 @@ static HRESULT install_inf_file(install_ctx_t *ctx)
355359 DWORD len ;
356360 HRESULT hres ;
357361
358- static const WCHAR setup_hooksW [] = {'S' ,'e' ,'t' ,'u' ,'p' ,' ' ,'H' ,'o' ,'o' ,'k' ,'s' ,0 };
359- static const WCHAR add_codeW [] = {'A' ,'d' ,'d' ,'.' ,'C' ,'o' ,'d' ,'e' ,0 };
360-
361- len = GetPrivateProfileStringW (setup_hooksW , NULL , NULL , buf , ARRAY_SIZE (buf ), ctx -> install_file );
362+ len = GetPrivateProfileStringW (L"Setup Hooks" , NULL , NULL , buf , ARRAY_SIZE (buf ), ctx -> install_file );
362363 if (len ) {
363364 default_install = FALSE;
364365
365366 for (key = buf ; * key ; key += lstrlenW (key )+ 1 ) {
366367 TRACE ("[Setup Hooks] key: %s\n" , debugstr_w (key ));
367368
368- len = GetPrivateProfileStringW (setup_hooksW , key , NULL , sect_name , ARRAY_SIZE (sect_name ),
369+ len = GetPrivateProfileStringW (L"Setup Hooks" , key , NULL , sect_name , ARRAY_SIZE (sect_name ),
369370 ctx -> install_file );
370371 if (!len ) {
371372 WARN ("Could not get key value\n" );
@@ -378,14 +379,14 @@ static HRESULT install_inf_file(install_ctx_t *ctx)
378379 }
379380 }
380381
381- len = GetPrivateProfileStringW (add_codeW , NULL , NULL , buf , ARRAY_SIZE (buf ), ctx -> install_file );
382+ len = GetPrivateProfileStringW (L"Add.Code" , NULL , NULL , buf , ARRAY_SIZE (buf ), ctx -> install_file );
382383 if (len ) {
383384 default_install = FALSE;
384385
385386 for (key = buf ; * key ; key += lstrlenW (key )+ 1 ) {
386387 TRACE ("[Add.Code] key: %s\n" , debugstr_w (key ));
387388
388- len = GetPrivateProfileStringW (add_codeW , key , NULL , sect_name , ARRAY_SIZE (sect_name ),
389+ len = GetPrivateProfileStringW (L"Add.Code" , key , NULL , sect_name , ARRAY_SIZE (sect_name ),
389390 ctx -> install_file );
390391 if (!len ) {
391392 WARN ("Could not get key value\n" );
@@ -395,7 +396,7 @@ static HRESULT install_inf_file(install_ctx_t *ctx)
395396 hres = RunSetupCommandW (ctx -> hwnd , ctx -> install_file , sect_name ,
396397 ctx -> tmp_dir , NULL , NULL , RSC_FLAG_INF , NULL );
397398 if (FAILED (hres )) {
398- WARN ("RunSetupCommandW failed: %08x \n" , hres );
399+ WARN ("RunSetupCommandW failed: %08lx \n" , hres );
399400 return hres ;
400401 }
401402 }
@@ -404,7 +405,7 @@ static HRESULT install_inf_file(install_ctx_t *ctx)
404405 if (default_install ) {
405406 hres = RunSetupCommandW (ctx -> hwnd , ctx -> install_file , NULL , ctx -> tmp_dir , NULL , NULL , RSC_FLAG_INF , NULL );
406407 if (FAILED (hres )) {
407- WARN ("RunSetupCommandW failed: %08x \n" , hres );
408+ WARN ("RunSetupCommandW failed: %08lx \n" , hres );
408409 return hres ;
409410 }
410411 }
@@ -472,7 +473,7 @@ static void update_counter(install_ctx_t *ctx, HWND hwnd)
472473 }else {
473474 WCHAR buf [100 ];
474475 LoadStringW (urlmon_instance , IDS_AXINSTALL_INSTALLN , buf , ARRAY_SIZE (buf ));
475- swprintf (text , buf , ctx -> counter );
476+ swprintf (text , ARRAY_SIZE ( text ), buf , ctx -> counter );
476477 }
477478
478479 SetDlgItemTextW (hwnd , ID_AXINSTALL_INSTALL_BTN , text );
@@ -483,7 +484,7 @@ static BOOL init_warning_dialog(HWND hwnd, install_ctx_t *ctx)
483484 BSTR display_uri ;
484485 HRESULT hres ;
485486
486- if (!SetPropW (hwnd , ctxW , ctx ))
487+ if (!SetPropW (hwnd , L"ctx" , ctx ))
487488 return FALSE;
488489
489490 hres = IUri_GetDisplayUri (ctx -> uri , & display_uri );
@@ -513,7 +514,7 @@ static INT_PTR WINAPI warning_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
513514 case WM_COMMAND :
514515 switch (wparam ) {
515516 case ID_AXINSTALL_INSTALL_BTN : {
516- install_ctx_t * ctx = GetPropW (hwnd , ctxW );
517+ install_ctx_t * ctx = GetPropW (hwnd , L"ctx" );
517518 if (ctx )
518519 ctx -> cancel = FALSE;
519520 EndDialog (hwnd , 0 );
@@ -524,7 +525,7 @@ static INT_PTR WINAPI warning_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
524525 return FALSE;
525526 }
526527 case WM_TIMER :
527- update_counter (GetPropW (hwnd , ctxW ), hwnd );
528+ update_counter (GetPropW (hwnd , L"ctx" ), hwnd );
528529 return TRUE;
529530 }
530531
@@ -589,7 +590,7 @@ static HRESULT install_file(install_ctx_t *ctx, const WCHAR *cache_file)
589590 if (!ext )
590591 ext = ptr ;
591592
592- if (!wcsicmp (ext , cab_extW )) {
593+ if (!wcsicmp (ext , L".cab" )) {
593594 hres = install_cab_file (ctx );
594595 }else {
595596 FIXME ("Unsupported extension %s\n" , debugstr_w (ext ));
@@ -606,15 +607,15 @@ static void failure_msgbox(install_ctx_t *ctx, HRESULT hres)
606607 WCHAR buf [1024 ], fmt [1024 ];
607608
608609 LoadStringW (urlmon_instance , IDS_AXINSTALL_FAILURE , fmt , ARRAY_SIZE (fmt ));
609- swprintf (buf , fmt , hres );
610+ swprintf (buf , ARRAY_SIZE ( buf ), fmt , hres );
610611 MessageBoxW (ctx -> hwnd , buf , NULL , MB_OK );
611612}
612613
613614static HRESULT distunit_on_stop (void * ctx , const WCHAR * cache_file , HRESULT hresult , const WCHAR * error_str )
614615{
615616 install_ctx_t * install_ctx = ctx ;
616617
617- TRACE ("(%p %s %08x %s)\n" , ctx , debugstr_w (cache_file ), hresult , debugstr_w (error_str ));
618+ TRACE ("(%p %s %08lx %s)\n" , ctx , debugstr_w (cache_file ), hresult , debugstr_w (error_str ));
618619
619620 if (hresult == S_OK ) {
620621 hresult = install_file (install_ctx , cache_file );
@@ -639,19 +640,19 @@ HRESULT WINAPI AsyncInstallDistributionUnit(const WCHAR *szDistUnit, const WCHAR
639640 install_ctx_t * ctx ;
640641 HRESULT hres ;
641642
642- TRACE ("(%s %s %s %x %x %s %p %p %x )\n" , debugstr_w (szDistUnit ), debugstr_w (szTYPE ), debugstr_w (szExt ),
643+ TRACE ("(%s %s %s %lx %lx %s %p %p %lx )\n" , debugstr_w (szDistUnit ), debugstr_w (szTYPE ), debugstr_w (szExt ),
643644 dwFileVersionMS , dwFileVersionLS , debugstr_w (szURL ), pbc , pvReserved , flags );
644645
645646 if (szDistUnit || szTYPE || szExt )
646647 FIXME ("Unsupported arguments\n" );
647648
648- ctx = heap_alloc_zero ( sizeof (* ctx ));
649+ ctx = calloc ( 1 , sizeof (* ctx ));
649650 if (!ctx )
650651 return E_OUTOFMEMORY ;
651652
652653 hres = CreateUri (szURL , 0 , 0 , & ctx -> uri );
653654 if (FAILED (hres )) {
654- heap_free (ctx );
655+ free (ctx );
655656 return E_OUTOFMEMORY ;
656657 }
657658
0 commit comments