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 * strdupWtoA (const WCHAR * str )
161+ {
162+ char * ret = NULL ;
166163
164+ if (str ) {
165+ DWORD 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{
@@ -173,13 +179,13 @@ HRESULT WINAPI Modified_ExtractFilesW(LPCWSTR CabName, LPCWSTR ExpandDir)
173179 TRACE ("(%s, %s, %d)\n" , debugstr_w (CabName ), debugstr_w (ExpandDir ));
174180
175181 if (CabName ) {
176- cab_name = heap_strdupWtoA (CabName );
182+ cab_name = strdupWtoA (CabName );
177183 if (!cab_name )
178184 return E_OUTOFMEMORY ;
179185 }
180186
181187 if (ExpandDir ) {
182- expand_dir = heap_strdupWtoA (ExpandDir );
188+ expand_dir = strdupWtoA (ExpandDir );
183189 if (!expand_dir )
184190 hres = E_OUTOFMEMORY ;
185191 }
@@ -189,13 +195,12 @@ 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
197- #endif
198-
203+ #endif /* __REACTOS__ */
199204
200205static HRESULT extract_cab_file (install_ctx_t * ctx )
201206{
@@ -209,13 +214,13 @@ static HRESULT extract_cab_file(install_ctx_t *ctx)
209214 hres = ExtractFilesW (ctx -> cache_file , ctx -> tmp_dir , 0 , NULL , NULL , 0 );
210215#endif
211216 if (FAILED (hres )) {
212- WARN ("ExtractFilesW failed: %08x \n" , hres );
217+ WARN ("ExtractFilesW failed: %08lx \n" , hres );
213218 return hres ;
214219 }
215220
216221 path_len = lstrlenW (ctx -> tmp_dir );
217222 file_len = lstrlenW (ctx -> file_name );
218- ctx -> install_file = heap_alloc ((path_len + file_len + 2 ) * sizeof (WCHAR ));
223+ ctx -> install_file = malloc ((path_len + file_len + 2 ) * sizeof (WCHAR ));
219224 if (!ctx -> install_file )
220225 return E_OUTOFMEMORY ;
221226
@@ -226,19 +231,19 @@ static HRESULT extract_cab_file(install_ctx_t *ctx)
226231 /* NOTE: Assume that file_name contains ".cab" extension */
227232 ptr = ctx -> install_file + path_len + 1 + file_len - 3 ;
228233
229- memcpy (ptr , infW , sizeof (infW ));
234+ memcpy (ptr , L"inf" , sizeof (L"inf" ));
230235 if (file_exists (ctx -> install_file )) {
231236 ctx -> install_type = INSTALL_INF ;
232237 return S_OK ;
233238 }
234239
235- memcpy (ptr , dllW , sizeof (dllW ));
240+ memcpy (ptr , L"dll" , sizeof (L"dll" ));
236241 if (file_exists (ctx -> install_file )) {
237242 ctx -> install_type = INSTALL_DLL ;
238243 return S_OK ;
239244 }
240245
241- memcpy (ptr , ocxW , sizeof (ocxW ));
246+ memcpy (ptr , L"ocx" , sizeof (L"ocx" ));
242247 if (file_exists (ctx -> install_file )) {
243248 ctx -> install_type = INSTALL_DLL ;
244249 return S_OK ;
@@ -283,7 +288,7 @@ static void expand_command(install_ctx_t *ctx, const WCHAR *cmd, WCHAR *buf, siz
283288 memcpy (buf + len , prev_ptr , ptr - prev_ptr );
284289 len += ptr - prev_ptr ;
285290
286- if (!_wcsnicmp (ptr , expand_dirW , ARRAY_SIZE (expand_dirW ))) {
291+ if (!wcsnicmp (ptr , expand_dirW , ARRAY_SIZE (expand_dirW ))) {
287292 len2 = lstrlenW (ctx -> tmp_dir );
288293 if (buf )
289294 memcpy (buf + len , ctx -> tmp_dir , len2 * sizeof (WCHAR ));
@@ -312,30 +317,28 @@ static HRESULT process_hook_section(install_ctx_t *ctx, const WCHAR *sect_name)
312317 DWORD len ;
313318 HRESULT hres ;
314319
315- static const WCHAR runW [] = {'r' ,'u' ,'n' ,0 };
316-
317320 len = GetPrivateProfileStringW (sect_name , NULL , NULL , buf , ARRAY_SIZE (buf ), ctx -> install_file );
318321 if (!len )
319322 return S_OK ;
320323
321324 for (key = buf ; * key ; key += lstrlenW (key )+ 1 ) {
322- if (!wcsicmp (key , runW )) {
325+ if (!wcsicmp (key , L"run" )) {
323326 WCHAR * cmd ;
324327 size_t size ;
325328
326- len = GetPrivateProfileStringW (sect_name , runW , NULL , val , ARRAY_SIZE (val ), ctx -> install_file );
329+ len = GetPrivateProfileStringW (sect_name , L"run" , NULL , val , ARRAY_SIZE (val ), ctx -> install_file );
327330
328331 TRACE ("Run %s\n" , debugstr_w (val ));
329332
330333 expand_command (ctx , val , NULL , & size );
331334
332- cmd = heap_alloc (size * sizeof (WCHAR ));
335+ cmd = malloc (size * sizeof (WCHAR ));
333336 if (!cmd )
334- heap_free ( cmd ) ;
337+ return E_OUTOFMEMORY ;
335338
336339 expand_command (ctx , val , cmd , & size );
337340 hres = RunSetupCommandW (ctx -> hwnd , cmd , NULL , ctx -> tmp_dir , NULL , NULL , 0 , NULL );
338- heap_free (cmd );
341+ free (cmd );
339342 if (FAILED (hres ))
340343 return hres ;
341344 }else {
@@ -355,17 +358,14 @@ static HRESULT install_inf_file(install_ctx_t *ctx)
355358 DWORD len ;
356359 HRESULT hres ;
357360
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 );
361+ len = GetPrivateProfileStringW (L"Setup Hooks" , NULL , NULL , buf , ARRAY_SIZE (buf ), ctx -> install_file );
362362 if (len ) {
363363 default_install = FALSE;
364364
365365 for (key = buf ; * key ; key += lstrlenW (key )+ 1 ) {
366366 TRACE ("[Setup Hooks] key: %s\n" , debugstr_w (key ));
367367
368- len = GetPrivateProfileStringW (setup_hooksW , key , NULL , sect_name , ARRAY_SIZE (sect_name ),
368+ len = GetPrivateProfileStringW (L"Setup Hooks" , key , NULL , sect_name , ARRAY_SIZE (sect_name ),
369369 ctx -> install_file );
370370 if (!len ) {
371371 WARN ("Could not get key value\n" );
@@ -378,14 +378,14 @@ static HRESULT install_inf_file(install_ctx_t *ctx)
378378 }
379379 }
380380
381- len = GetPrivateProfileStringW (add_codeW , NULL , NULL , buf , ARRAY_SIZE (buf ), ctx -> install_file );
381+ len = GetPrivateProfileStringW (L"Add.Code" , NULL , NULL , buf , ARRAY_SIZE (buf ), ctx -> install_file );
382382 if (len ) {
383383 default_install = FALSE;
384384
385385 for (key = buf ; * key ; key += lstrlenW (key )+ 1 ) {
386386 TRACE ("[Add.Code] key: %s\n" , debugstr_w (key ));
387387
388- len = GetPrivateProfileStringW (add_codeW , key , NULL , sect_name , ARRAY_SIZE (sect_name ),
388+ len = GetPrivateProfileStringW (L"Add.Code" , key , NULL , sect_name , ARRAY_SIZE (sect_name ),
389389 ctx -> install_file );
390390 if (!len ) {
391391 WARN ("Could not get key value\n" );
@@ -395,7 +395,7 @@ static HRESULT install_inf_file(install_ctx_t *ctx)
395395 hres = RunSetupCommandW (ctx -> hwnd , ctx -> install_file , sect_name ,
396396 ctx -> tmp_dir , NULL , NULL , RSC_FLAG_INF , NULL );
397397 if (FAILED (hres )) {
398- WARN ("RunSetupCommandW failed: %08x \n" , hres );
398+ WARN ("RunSetupCommandW failed: %08lx \n" , hres );
399399 return hres ;
400400 }
401401 }
@@ -404,7 +404,7 @@ static HRESULT install_inf_file(install_ctx_t *ctx)
404404 if (default_install ) {
405405 hres = RunSetupCommandW (ctx -> hwnd , ctx -> install_file , NULL , ctx -> tmp_dir , NULL , NULL , RSC_FLAG_INF , NULL );
406406 if (FAILED (hres )) {
407- WARN ("RunSetupCommandW failed: %08x \n" , hres );
407+ WARN ("RunSetupCommandW failed: %08lx \n" , hres );
408408 return hres ;
409409 }
410410 }
@@ -472,7 +472,7 @@ static void update_counter(install_ctx_t *ctx, HWND hwnd)
472472 }else {
473473 WCHAR buf [100 ];
474474 LoadStringW (urlmon_instance , IDS_AXINSTALL_INSTALLN , buf , ARRAY_SIZE (buf ));
475- swprintf (text , buf , ctx -> counter );
475+ swprintf (text , ARRAY_SIZE ( text ), buf , ctx -> counter );
476476 }
477477
478478 SetDlgItemTextW (hwnd , ID_AXINSTALL_INSTALL_BTN , text );
@@ -483,7 +483,7 @@ static BOOL init_warning_dialog(HWND hwnd, install_ctx_t *ctx)
483483 BSTR display_uri ;
484484 HRESULT hres ;
485485
486- if (!SetPropW (hwnd , ctxW , ctx ))
486+ if (!SetPropW (hwnd , L"ctx" , ctx ))
487487 return FALSE;
488488
489489 hres = IUri_GetDisplayUri (ctx -> uri , & display_uri );
@@ -513,7 +513,7 @@ static INT_PTR WINAPI warning_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
513513 case WM_COMMAND :
514514 switch (wparam ) {
515515 case ID_AXINSTALL_INSTALL_BTN : {
516- install_ctx_t * ctx = GetPropW (hwnd , ctxW );
516+ install_ctx_t * ctx = GetPropW (hwnd , L"ctx" );
517517 if (ctx )
518518 ctx -> cancel = FALSE;
519519 EndDialog (hwnd , 0 );
@@ -524,7 +524,7 @@ static INT_PTR WINAPI warning_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
524524 return FALSE;
525525 }
526526 case WM_TIMER :
527- update_counter (GetPropW (hwnd , ctxW ), hwnd );
527+ update_counter (GetPropW (hwnd , L"ctx" ), hwnd );
528528 return TRUE;
529529 }
530530
@@ -589,7 +589,7 @@ static HRESULT install_file(install_ctx_t *ctx, const WCHAR *cache_file)
589589 if (!ext )
590590 ext = ptr ;
591591
592- if (!wcsicmp (ext , cab_extW )) {
592+ if (!wcsicmp (ext , L".cab" )) {
593593 hres = install_cab_file (ctx );
594594 }else {
595595 FIXME ("Unsupported extension %s\n" , debugstr_w (ext ));
@@ -606,15 +606,15 @@ static void failure_msgbox(install_ctx_t *ctx, HRESULT hres)
606606 WCHAR buf [1024 ], fmt [1024 ];
607607
608608 LoadStringW (urlmon_instance , IDS_AXINSTALL_FAILURE , fmt , ARRAY_SIZE (fmt ));
609- swprintf (buf , fmt , hres );
609+ swprintf (buf , ARRAY_SIZE ( buf ), fmt , hres );
610610 MessageBoxW (ctx -> hwnd , buf , NULL , MB_OK );
611611}
612612
613613static HRESULT distunit_on_stop (void * ctx , const WCHAR * cache_file , HRESULT hresult , const WCHAR * error_str )
614614{
615615 install_ctx_t * install_ctx = ctx ;
616616
617- TRACE ("(%p %s %08x %s)\n" , ctx , debugstr_w (cache_file ), hresult , debugstr_w (error_str ));
617+ TRACE ("(%p %s %08lx %s)\n" , ctx , debugstr_w (cache_file ), hresult , debugstr_w (error_str ));
618618
619619 if (hresult == S_OK ) {
620620 hresult = install_file (install_ctx , cache_file );
@@ -639,19 +639,19 @@ HRESULT WINAPI AsyncInstallDistributionUnit(const WCHAR *szDistUnit, const WCHAR
639639 install_ctx_t * ctx ;
640640 HRESULT hres ;
641641
642- TRACE ("(%s %s %s %x %x %s %p %p %x )\n" , debugstr_w (szDistUnit ), debugstr_w (szTYPE ), debugstr_w (szExt ),
642+ TRACE ("(%s %s %s %lx %lx %s %p %p %lx )\n" , debugstr_w (szDistUnit ), debugstr_w (szTYPE ), debugstr_w (szExt ),
643643 dwFileVersionMS , dwFileVersionLS , debugstr_w (szURL ), pbc , pvReserved , flags );
644644
645645 if (szDistUnit || szTYPE || szExt )
646646 FIXME ("Unsupported arguments\n" );
647647
648- ctx = heap_alloc_zero ( sizeof (* ctx ));
648+ ctx = calloc ( 1 , sizeof (* ctx ));
649649 if (!ctx )
650650 return E_OUTOFMEMORY ;
651651
652652 hres = CreateUri (szURL , 0 , 0 , & ctx -> uri );
653653 if (FAILED (hres )) {
654- heap_free (ctx );
654+ free (ctx );
655655 return E_OUTOFMEMORY ;
656656 }
657657
0 commit comments