ReactOS  0.4.13-dev-259-g5ca9c9c
axinstall.c File Reference
#include <assert.h>
#include "urlmon_main.h"
#include "resource.h"
#include "advpub.h"
#include "fdi.h"
#include "wine/debug.h"
Include dependency graph for axinstall.c:

Go to the source code of this file.

Classes

struct  install_ctx_t
 

Macros

#define OEMRESOURCE
 

Enumerations

enum  install_type { INSTALL_UNKNOWN, INSTALL_DLL, INSTALL_INF }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (urlmon)
 
static void release_install_ctx (install_ctx_t *ctx)
 
static BOOL file_exists (const WCHAR *file_name)
 
static HRESULT extract_cab_file (install_ctx_t *ctx)
 
static HRESULT setup_dll (install_ctx_t *ctx)
 
static void expand_command (install_ctx_t *ctx, const WCHAR *cmd, WCHAR *buf, size_t *size)
 
static HRESULT process_hook_section (install_ctx_t *ctx, const WCHAR *sect_name)
 
static HRESULT install_inf_file (install_ctx_t *ctx)
 
static HRESULT install_cab_file (install_ctx_t *ctx)
 
static void update_counter (install_ctx_t *ctx, HWND hwnd)
 
static BOOL init_warning_dialog (HWND hwnd, install_ctx_t *ctx)
 
static INT_PTR WINAPI warning_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static BOOL install_warning (install_ctx_t *ctx)
 
static HRESULT install_file (install_ctx_t *ctx, const WCHAR *cache_file)
 
static void failure_msgbox (install_ctx_t *ctx, HRESULT hres)
 
static HRESULT distunit_on_stop (void *ctx, const WCHAR *cache_file, HRESULT hresult, const WCHAR *error_str)
 
HRESULT WINAPI AsyncInstallDistributionUnit (const WCHAR *szDistUnit, const WCHAR *szTYPE, const WCHAR *szExt, DWORD dwFileVersionMS, DWORD dwFileVersionLS, const WCHAR *szURL, IBindCtx *pbc, void *pvReserved, DWORD flags)
 

Variables

static const WCHAR ctxW [] = {'c','t','x',0}
 
static const WCHAR cab_extW [] = {'.','c','a','b',0}
 
static const WCHAR infW [] = {'i','n','f',0}
 
static const WCHAR dllW [] = {'d','l','l',0}
 
static const WCHAR ocxW [] = {'o','c','x',0}
 

Macro Definition Documentation

◆ OEMRESOURCE

#define OEMRESOURCE

Definition at line 19 of file axinstall.c.

Enumeration Type Documentation

◆ install_type

Enumerator
INSTALL_UNKNOWN 
INSTALL_DLL 
INSTALL_INF 

Definition at line 39 of file axinstall.c.

Function Documentation

◆ AsyncInstallDistributionUnit()

HRESULT WINAPI AsyncInstallDistributionUnit ( const WCHAR szDistUnit,
const WCHAR szTYPE,
const WCHAR szExt,
DWORD  dwFileVersionMS,
DWORD  dwFileVersionLS,
const WCHAR szURL,
IBindCtx pbc,
void pvReserved,
DWORD  flags 
)

Definition at line 507 of file axinstall.c.

509 {
510  install_ctx_t *ctx;
511  HRESULT hres;
512 
513  TRACE("(%s %s %s %x %x %s %p %p %x)\n", debugstr_w(szDistUnit), debugstr_w(szTYPE), debugstr_w(szExt),
514  dwFileVersionMS, dwFileVersionLS, debugstr_w(szURL), pbc, pvReserved, flags);
515 
516  if(szDistUnit || szTYPE || szExt)
517  FIXME("Unsupported arguments\n");
518 
519  ctx = heap_alloc_zero(sizeof(*ctx));
520  if(!ctx)
521  return E_OUTOFMEMORY;
522 
523  hres = CreateUri(szURL, 0, 0, &ctx->uri);
524  if(FAILED(hres)) {
525  heap_free(ctx);
526  return E_OUTOFMEMORY;
527  }
528 
529  ctx->callback = bsc_from_bctx(pbc);
530 
531  hres = download_to_cache(ctx->uri, distunit_on_stop, ctx, ctx->callback);
532  if(hres == MK_S_ASYNCHRONOUS)
533  ctx->release_on_stop = TRUE;
534  else
535  release_install_ctx(ctx);
536 
537  return hres;
538 }
IBindStatusCallback * bsc_from_bctx(IBindCtx *bctx)
Definition: bindctx.c:70
static HRESULT distunit_on_stop(void *ctx, const WCHAR *cache_file, HRESULT hresult, const WCHAR *error_str)
Definition: axinstall.c:484
#define TRUE
Definition: types.h:120
IUri * uri
Definition: axinstall.c:46
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static LPCSTR DWORD void * pvReserved
Definition: str.c:196
HRESULT download_to_cache(IUri *uri, stop_cache_binding_proc_t proc, void *ctx, IBindStatusCallback *callback)
Definition: download.c:375
GLbitfield flags
Definition: glext.h:7161
BOOL release_on_stop
Definition: axinstall.c:48
static void release_install_ctx(install_ctx_t *ctx)
Definition: axinstall.c:60
HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IUri **ppURI)
Definition: uri.c:5701
IBindStatusCallback * callback
Definition: axinstall.c:47
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by install_codebase().

◆ distunit_on_stop()

static HRESULT distunit_on_stop ( void ctx,
const WCHAR cache_file,
HRESULT  hresult,
const WCHAR error_str 
)
static

Definition at line 484 of file axinstall.c.

485 {
486  install_ctx_t *install_ctx = ctx;
487 
488  TRACE("(%p %s %08x %s)\n", ctx, debugstr_w(cache_file), hresult, debugstr_w(error_str));
489 
490  if(hresult == S_OK) {
491  hresult = install_file(install_ctx, cache_file);
492  if(FAILED(hresult))
493  failure_msgbox(ctx, hresult);
494  }
495 
496  if(install_ctx->callback)
497  IBindStatusCallback_OnStopBinding(install_ctx->callback, hresult, error_str);
498 
499  if(install_ctx->release_on_stop)
500  release_install_ctx(install_ctx);
501  return S_OK;
502 }
static void failure_msgbox(install_ctx_t *ctx, HRESULT hres)
Definition: axinstall.c:475
#define debugstr_w
Definition: kernel32.h:32
static const WCHAR * cache_file
Definition: protocol.c:102
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
static HRESULT install_file(install_ctx_t *ctx, const WCHAR *cache_file)
Definition: axinstall.c:430
BOOL release_on_stop
Definition: axinstall.c:48
static void release_install_ctx(install_ctx_t *ctx)
Definition: axinstall.c:60
IBindStatusCallback * callback
Definition: axinstall.c:47

Referenced by AsyncInstallDistributionUnit().

◆ expand_command()

static void expand_command ( install_ctx_t ctx,
const WCHAR cmd,
WCHAR buf,
size_t size 
)
static

Definition at line 145 of file axinstall.c.

146 {
147  const WCHAR *ptr = cmd, *prev_ptr = cmd;
148  size_t len = 0, len2;
149 
150  static const WCHAR expand_dirW[] = {'%','E','X','T','R','A','C','T','_','D','I','R','%'};
151 
152  while((ptr = strchrW(ptr, '%'))) {
153  if(buf)
154  memcpy(buf+len, prev_ptr, ptr-prev_ptr);
155  len += ptr-prev_ptr;
156 
157  if(!strncmpiW(ptr, expand_dirW, ARRAY_SIZE(expand_dirW))) {
158  len2 = strlenW(ctx->tmp_dir);
159  if(buf)
160  memcpy(buf+len, ctx->tmp_dir, len2*sizeof(WCHAR));
161  len += len2;
162  ptr += ARRAY_SIZE(expand_dirW);
163  }else {
164  FIXME("Can't expand %s\n", debugstr_w(ptr));
165  if(buf)
166  buf[len] = '%';
167  len++;
168  ptr++;
169  }
170 
171  prev_ptr = ptr;
172  }
173 
174  if(buf)
175  strcpyW(buf+len, prev_ptr);
176  *size = len + strlenW(prev_ptr) + 1;
177 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * tmp_dir
Definition: axinstall.c:52
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
char * cmd
Definition: vfdcmd.c:85
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define ARRAY_SIZE(a)
Definition: main.h:24

Referenced by process_hook_section().

◆ extract_cab_file()

static HRESULT extract_cab_file ( install_ctx_t ctx)
static

Definition at line 75 of file axinstall.c.

76 {
77  size_t path_len, file_len;
78  WCHAR *ptr;
79  HRESULT hres;
80 
81  hres = ExtractFilesW(ctx->cache_file, ctx->tmp_dir, 0, NULL, NULL, 0);
82  if(FAILED(hres)) {
83  WARN("ExtractFilesW failed: %08x\n", hres);
84  return hres;
85  }
86 
87  path_len = strlenW(ctx->tmp_dir);
88  file_len = strlenW(ctx->file_name);
89  ctx->install_file = heap_alloc((path_len+file_len+2)*sizeof(WCHAR));
90  if(!ctx->install_file)
91  return E_OUTOFMEMORY;
92 
93  memcpy(ctx->install_file, ctx->tmp_dir, path_len*sizeof(WCHAR));
94  ctx->install_file[path_len] = '\\';
95  memcpy(ctx->install_file+path_len+1, ctx->file_name, (file_len+1)*sizeof(WCHAR));
96 
97  /* NOTE: Assume that file_name contains ".cab" extension */
98  ptr = ctx->install_file+path_len+1+file_len-3;
99 
100  memcpy(ptr, infW, sizeof(infW));
101  if(file_exists(ctx->install_file)) {
102  ctx->install_type = INSTALL_INF;
103  return S_OK;
104  }
105 
106  memcpy(ptr, dllW, sizeof(dllW));
107  if(file_exists(ctx->install_file)) {
108  ctx->install_type = INSTALL_DLL;
109  return S_OK;
110  }
111 
112  memcpy(ptr, ocxW, sizeof(ocxW));
113  if(file_exists(ctx->install_file)) {
114  ctx->install_type = INSTALL_DLL;
115  return S_OK;
116  }
117 
118  FIXME("No known install file\n");
119  return E_NOTIMPL;
120 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * tmp_dir
Definition: axinstall.c:52
#define WARN(fmt,...)
Definition: debug.h:111
WCHAR * install_file
Definition: axinstall.c:50
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
enum install_type install_type
Definition: axinstall.c:54
static const WCHAR dllW[]
Definition: axinstall.c:36
HRESULT hres
Definition: protocol.c:465
static const WCHAR infW[]
Definition: axinstall.c:35
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static BOOL file_exists(const WCHAR *file_name)
Definition: axinstall.c:70
const WCHAR * cache_file
Definition: axinstall.c:51
#define S_OK
Definition: intsafe.h:59
static DWORD path_len
Definition: batch.c:31
#define E_NOTIMPL
Definition: ddrawi.h:99
const WCHAR * file_name
Definition: axinstall.c:53
HRESULT WINAPI ExtractFilesW(LPCWSTR CabName, LPCWSTR ExpandDir, DWORD Flags, LPCWSTR FileList, LPVOID LReserved, DWORD Reserved)
Definition: files.c:780
static const WCHAR ocxW[]
Definition: axinstall.c:37

Referenced by install_cab_file().

◆ failure_msgbox()

static void failure_msgbox ( install_ctx_t ctx,
HRESULT  hres 
)
static

Definition at line 475 of file axinstall.c.

476 {
477  WCHAR buf[1024], fmt[1024];
478 
480  sprintfW(buf, fmt, hres);
481  MessageBoxW(ctx->hwnd, buf, NULL, MB_OK);
482 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
smooth NULL
Definition: ftsmooth.c:416
HRESULT hres
Definition: protocol.c:465
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
HINSTANCE urlmon_instance
Definition: urlmon_main.c:43
#define ARRAY_SIZE(a)
Definition: main.h:24
#define sprintfW
Definition: unicode.h:58
#define IDS_AXINSTALL_FAILURE
Definition: resource.h:26
#define MB_OK
Definition: winuser.h:784
Definition: dsound.c:943

Referenced by distunit_on_stop().

◆ file_exists()

static BOOL file_exists ( const WCHAR file_name)
inlinestatic

Definition at line 70 of file axinstall.c.

71 {
73 }
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
static LPCWSTR file_name
Definition: protocol.c:146

Referenced by check_directory(), create_cache(), extract_cab_file(), and HandleCommandLine().

◆ init_warning_dialog()

static BOOL init_warning_dialog ( HWND  hwnd,
install_ctx_t ctx 
)
static

Definition at line 352 of file axinstall.c.

353 {
354  BSTR display_uri;
355  HRESULT hres;
356 
357  if(!SetPropW(hwnd, ctxW, ctx))
358  return FALSE;
359 
360  hres = IUri_GetDisplayUri(ctx->uri, &display_uri);
361  if(FAILED(hres))
362  return FALSE;
363 
365  SysFreeString(display_uri);
366 
368  (WPARAM)LoadIconW(0, (const WCHAR*)OIC_WARNING), 0);
369 
370  ctx->counter = 4;
371  update_counter(ctx, hwnd);
372  ctx->timer = SetTimer(hwnd, 1, 1000, NULL);
373  return TRUE;
374 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define STM_SETICON
Definition: winuser.h:2053
#define TRUE
Definition: types.h:120
#define ID_AXINSTALL_ICON
Definition: resource.h:24
static const WCHAR ctxW[]
Definition: axinstall.c:33
static void update_counter(install_ctx_t *ctx, HWND hwnd)
Definition: axinstall.c:331
#define OIC_WARNING
Definition: winuser.h:1154
UINT_PTR WPARAM
Definition: windef.h:207
IUri * uri
Definition: axinstall.c:46
OLECHAR * BSTR
Definition: compat.h:1934
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
INT_PTR timer
Definition: axinstall.c:57
HRESULT hres
Definition: protocol.c:465
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:274
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define ID_AXINSTALL_LOCATION
Definition: resource.h:22

Referenced by warning_proc().

◆ install_cab_file()

static HRESULT install_cab_file ( install_ctx_t ctx)
static

Definition at line 286 of file axinstall.c.

287 {
288  WCHAR tmp_path[MAX_PATH], tmp_dir[MAX_PATH];
289  BOOL res = FALSE, leave_temp = FALSE;
290  DWORD i;
291  HRESULT hres;
292 
293  GetTempPathW(ARRAY_SIZE(tmp_path), tmp_path);
294 
295  for(i=0; !res && i < 100; i++) {
296  GetTempFileNameW(tmp_path, NULL, GetTickCount() + i*17037, tmp_dir);
297  res = CreateDirectoryW(tmp_dir, NULL);
298  }
299  if(!res)
300  return E_FAIL;
301 
302  ctx->tmp_dir = tmp_dir;
303 
304  TRACE("Using temporary directory %s\n", debugstr_w(tmp_dir));
305 
306  hres = extract_cab_file(ctx);
307  if(SUCCEEDED(hres)) {
308  if(ctx->callback)
309  IBindStatusCallback_OnProgress(ctx->callback, 0, 0, BINDSTATUS_INSTALLINGCOMPONENTS, ctx->install_file);
310 
311  switch(ctx->install_type) {
312  case INSTALL_INF:
313  hres = install_inf_file(ctx);
314  break;
315  case INSTALL_DLL:
316  FIXME("Installing DLL, registering in temporary location\n");
317  hres = setup_dll(ctx);
318  if(SUCCEEDED(hres))
319  leave_temp = TRUE;
320  break;
321  default:
322  assert(0);
323  }
324  }
325 
326  if(!leave_temp)
328  return hres;
329 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
#define TRUE
Definition: types.h:120
static HRESULT install_inf_file(install_ctx_t *ctx)
Definition: axinstall.c:221
const WCHAR * tmp_dir
Definition: axinstall.c:52
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
#define assert(x)
Definition: debug.h:53
#define E_FAIL
Definition: ddrawi.h:102
WCHAR * install_file
Definition: axinstall.c:50
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
enum install_type install_type
Definition: axinstall.c:54
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
static HRESULT extract_cab_file(install_ctx_t *ctx)
Definition: axinstall.c:75
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
Definition: filename.c:84
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ARRAY_SIZE(a)
Definition: main.h:24
GLuint res
Definition: glext.h:9613
static HRESULT setup_dll(install_ctx_t *ctx)
Definition: axinstall.c:122
IBindStatusCallback * callback
Definition: axinstall.c:47
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by install_file().

◆ install_file()

static HRESULT install_file ( install_ctx_t ctx,
const WCHAR cache_file 
)
static

Definition at line 430 of file axinstall.c.

431 {
432  BSTR path;
433  HRESULT hres;
434 
435  TRACE("%s\n", debugstr_w(cache_file));
436 
437  ctx->cache_file = cache_file;
438 
439  if(!install_warning(ctx)) {
440  TRACE("Installation cancelled\n");
441  return S_OK;
442  }
443 
444  hres = IUri_GetPath(ctx->uri, &path);
445  if(SUCCEEDED(hres)) {
446  const WCHAR *ptr, *ptr2, *ext;
447 
448  ptr = strrchrW(path, '/');
449  if(!ptr)
450  ptr = path;
451  else
452  ptr++;
453 
454  ptr2 = strrchrW(ptr, '\\');
455  if(ptr2)
456  ptr = ptr2+1;
457 
458  ctx->file_name = ptr;
459  ext = strrchrW(ptr, '.');
460  if(!ext)
461  ext = ptr;
462 
463  if(!strcmpiW(ext, cab_extW)) {
464  hres = install_cab_file(ctx);
465  }else {
466  FIXME("Unsupported extension %s\n", debugstr_w(ext));
467  hres = E_NOTIMPL;
468  }
470  }
471 
472  return hres;
473 }
GLsizei const GLchar ** path
Definition: glext.h:7234
IUri * uri
Definition: axinstall.c:46
OLECHAR * BSTR
Definition: compat.h:1934
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
static const WCHAR * cache_file
Definition: protocol.c:102
char ext[3]
Definition: mkdosfs.c:358
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static BOOL install_warning(install_ctx_t *ctx)
Definition: axinstall.c:405
#define strcmpiW(s1, s2)
Definition: unicode.h:39
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
static const WCHAR cab_extW[]
Definition: axinstall.c:34
const WCHAR * cache_file
Definition: axinstall.c:51
#define S_OK
Definition: intsafe.h:59
#define E_NOTIMPL
Definition: ddrawi.h:99
Definition: services.c:325
const WCHAR * file_name
Definition: axinstall.c:53
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:274
static HRESULT install_cab_file(install_ctx_t *ctx)
Definition: axinstall.c:286
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by distunit_on_stop().

◆ install_inf_file()

static HRESULT install_inf_file ( install_ctx_t ctx)
static

Definition at line 221 of file axinstall.c.

222 {
223  WCHAR buf[2048], sect_name[128];
224  BOOL default_install = TRUE;
225  const WCHAR *key;
226  DWORD len;
227  HRESULT hres;
228 
229  static const WCHAR setup_hooksW[] = {'S','e','t','u','p',' ','H','o','o','k','s',0};
230  static const WCHAR add_codeW[] = {'A','d','d','.','C','o','d','e',0};
231 
232  len = GetPrivateProfileStringW(setup_hooksW, NULL, NULL, buf, ARRAY_SIZE(buf), ctx->install_file);
233  if(len) {
234  default_install = FALSE;
235 
236  for(key = buf; *key; key += strlenW(key)+1) {
237  TRACE("[Setup Hooks] key: %s\n", debugstr_w(key));
238 
239  len = GetPrivateProfileStringW(setup_hooksW, key, NULL, sect_name, ARRAY_SIZE(sect_name),
240  ctx->install_file);
241  if(!len) {
242  WARN("Could not get key value\n");
243  return E_FAIL;
244  }
245 
246  hres = process_hook_section(ctx, sect_name);
247  if(FAILED(hres))
248  return hres;
249  }
250  }
251 
253  if(len) {
254  default_install = FALSE;
255 
256  for(key = buf; *key; key += strlenW(key)+1) {
257  TRACE("[Add.Code] key: %s\n", debugstr_w(key));
258 
259  len = GetPrivateProfileStringW(add_codeW, key, NULL, sect_name, ARRAY_SIZE(sect_name),
260  ctx->install_file);
261  if(!len) {
262  WARN("Could not get key value\n");
263  return E_FAIL;
264  }
265 
266  hres = RunSetupCommandW(ctx->hwnd, ctx->install_file, sect_name,
267  ctx->tmp_dir, NULL, NULL, RSC_FLAG_INF, NULL);
268  if(FAILED(hres)) {
269  WARN("RunSetupCommandW failed: %08x\n", hres);
270  return hres;
271  }
272  }
273  }
274 
275  if(default_install) {
277  if(FAILED(hres)) {
278  WARN("RunSetupCommandW failed: %08x\n", hres);
279  return hres;
280  }
281  }
282 
283  return S_OK;
284 }
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * tmp_dir
Definition: axinstall.c:52
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define WARN(fmt,...)
Definition: debug.h:111
#define E_FAIL
Definition: ddrawi.h:102
#define RSC_FLAG_INF
Definition: advpub.h:130
WCHAR * install_file
Definition: axinstall.c:50
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
static HRESULT process_hook_section(install_ctx_t *ctx, const WCHAR *sect_name)
Definition: axinstall.c:179
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI RunSetupCommandW(HWND hWnd, LPCWSTR szCmdName, LPCWSTR szInfSection, LPCWSTR szDir, LPCWSTR lpszTitle, HANDLE *phEXE, DWORD dwFlags, LPVOID pvReserved)
Definition: install.c:991
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY key
Definition: reg.c:42
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
#define ARRAY_SIZE(a)
Definition: main.h:24
Definition: path.c:42

Referenced by install_cab_file().

◆ install_warning()

static BOOL install_warning ( install_ctx_t ctx)
static

Definition at line 405 of file axinstall.c.

406 {
407  IWindowForBindingUI *window_iface;
408  HWND parent_hwnd = NULL;
409  HRESULT hres;
410 
411  if(!ctx->callback) {
412  FIXME("no callback\n");
413  return FALSE;
414  }
415 
416  hres = IBindStatusCallback_QueryInterface(ctx->callback, &IID_IWindowForBindingUI, (void**)&window_iface);
417  if(FAILED(hres))
418  return FALSE;
419 
420  hres = IWindowForBindingUI_GetWindow(window_iface, &IID_ICodeInstall, &ctx->hwnd);
421  IWindowForBindingUI_Release(window_iface);
422  if(FAILED(hres))
423  return FALSE;
424 
425  ctx->cancel = TRUE;
427  return !ctx->cancel;
428 }
#define TRUE
Definition: types.h:120
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define ID_AXINSTALL_WARNING_DLG
Definition: resource.h:21
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
HRESULT hres
Definition: protocol.c:465
HINSTANCE urlmon_instance
Definition: urlmon_main.c:43
static INT_PTR WINAPI warning_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: axinstall.c:376
LONG HRESULT
Definition: typedefs.h:77
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
IBindStatusCallback * callback
Definition: axinstall.c:47

Referenced by install_file().

◆ process_hook_section()

static HRESULT process_hook_section ( install_ctx_t ctx,
const WCHAR sect_name 
)
static

Definition at line 179 of file axinstall.c.

180 {
181  WCHAR buf[2048], val[2*MAX_PATH];
182  const WCHAR *key;
183  DWORD len;
184  HRESULT hres;
185 
186  static const WCHAR runW[] = {'r','u','n',0};
187 
189  if(!len)
190  return S_OK;
191 
192  for(key = buf; *key; key += strlenW(key)+1) {
193  if(!strcmpiW(key, runW)) {
194  WCHAR *cmd;
195  size_t size;
196 
197  len = GetPrivateProfileStringW(sect_name, runW, NULL, val, ARRAY_SIZE(val), ctx->install_file);
198 
199  TRACE("Run %s\n", debugstr_w(val));
200 
201  expand_command(ctx, val, NULL, &size);
202 
203  cmd = heap_alloc(size*sizeof(WCHAR));
204  if(!cmd)
205  heap_free(cmd);
206 
207  expand_command(ctx, val, cmd, &size);
208  hres = RunSetupCommandW(ctx->hwnd, cmd, NULL, ctx->tmp_dir, NULL, NULL, 0, NULL);
209  heap_free(cmd);
210  if(FAILED(hres))
211  return hres;
212  }else {
213  FIXME("Unsupported hook %s\n", debugstr_w(key));
214  return E_NOTIMPL;
215  }
216  }
217 
218  return S_OK;
219 }
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * tmp_dir
Definition: axinstall.c:52
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
Definition: ftp_var.h:139
char * cmd
Definition: vfdcmd.c:85
WCHAR * install_file
Definition: axinstall.c:50
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
GLuint GLfloat * val
Definition: glext.h:7180
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI RunSetupCommandW(HWND hWnd, LPCWSTR szCmdName, LPCWSTR szInfSection, LPCWSTR szDir, LPCWSTR lpszTitle, HANDLE *phEXE, DWORD dwFlags, LPVOID pvReserved)
Definition: install.c:991
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY key
Definition: reg.c:42
GLenum GLsizei len
Definition: glext.h:6722
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define S_OK
Definition: intsafe.h:59
#define ARRAY_SIZE(a)
Definition: main.h:24
#define E_NOTIMPL
Definition: ddrawi.h:99
static void expand_command(install_ctx_t *ctx, const WCHAR *cmd, WCHAR *buf, size_t *size)
Definition: axinstall.c:145
Definition: path.c:42
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by install_inf_file().

◆ release_install_ctx()

static void release_install_ctx ( install_ctx_t ctx)
static

Definition at line 60 of file axinstall.c.

61 {
62  if(ctx->uri)
63  IUri_Release(ctx->uri);
64  if(ctx->callback)
65  IBindStatusCallback_Release(ctx->callback);
66  heap_free(ctx->install_file);
67  heap_free(ctx);
68 }
IUri * uri
Definition: axinstall.c:46
WCHAR * install_file
Definition: axinstall.c:50
IBindStatusCallback * callback
Definition: axinstall.c:47
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by AsyncInstallDistributionUnit(), and distunit_on_stop().

◆ setup_dll()

static HRESULT setup_dll ( install_ctx_t ctx)
static

Definition at line 122 of file axinstall.c.

123 {
124  HMODULE module;
125  HRESULT hres;
126 
127  HRESULT (WINAPI *reg_func)(void);
128 
130  if(!module)
131  return E_FAIL;
132 
133  reg_func = (void*)GetProcAddress(module, "DllRegisterServer");
134  if(reg_func) {
135  hres = reg_func();
136  }else {
137  WARN("no DllRegisterServer function\n");
138  hres = E_FAIL;
139  }
140 
142  return hres;
143 }
#define HRESULT
Definition: msvc.h:9
HMODULE module
Definition: main.cpp:47
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define WARN(fmt,...)
Definition: debug.h:111
#define E_FAIL
Definition: ddrawi.h:102
WCHAR * install_file
Definition: axinstall.c:50
#define LoadLibraryW(x)
Definition: compat.h:404
#define FreeLibrary(x)
Definition: compat.h:405
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
#define WINAPI
Definition: msvc.h:8
#define GetProcAddress(x, y)
Definition: compat.h:410

Referenced by install_cab_file().

◆ update_counter()

static void update_counter ( install_ctx_t ctx,
HWND  hwnd 
)
static

Definition at line 331 of file axinstall.c.

332 {
333  WCHAR text[100];
334 
335  if(--ctx->counter <= 0) {
336  HWND button_hwnd;
337 
338  KillTimer(hwnd, ctx->timer);
340 
341  button_hwnd = GetDlgItem(hwnd, ID_AXINSTALL_INSTALL_BTN);
342  EnableWindow(button_hwnd, TRUE);
343  }else {
344  WCHAR buf[100];
346  sprintfW(text, buf, ctx->counter);
347  }
348 
350 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define IDS_AXINSTALL_INSTALL
Definition: resource.h:28
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
const WCHAR * text
Definition: package.c:1827
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
INT_PTR timer
Definition: axinstall.c:57
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
HINSTANCE urlmon_instance
Definition: urlmon_main.c:43
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define IDS_AXINSTALL_INSTALLN
Definition: resource.h:27
#define ARRAY_SIZE(a)
Definition: main.h:24
#define sprintfW
Definition: unicode.h:58
#define ID_AXINSTALL_INSTALL_BTN
Definition: resource.h:23

Referenced by init_warning_dialog(), and warning_proc().

◆ warning_proc()

static INT_PTR WINAPI warning_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 376 of file axinstall.c.

377 {
378  switch(msg) {
379  case WM_INITDIALOG: {
381  EndDialog(hwnd, 0);
382  return TRUE;
383  }
384  case WM_COMMAND:
385  switch(wparam) {
387  install_ctx_t *ctx = GetPropW(hwnd, ctxW);
388  if(ctx)
389  ctx->cancel = FALSE;
390  EndDialog(hwnd, 0);
391  return FALSE;
392  }
393  case IDCANCEL:
394  EndDialog(hwnd, 0);
395  return FALSE;
396  }
397  case WM_TIMER:
399  return TRUE;
400  }
401 
402  return FALSE;
403 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
static const WCHAR ctxW[]
Definition: axinstall.c:33
static void update_counter(install_ctx_t *ctx, HWND hwnd)
Definition: axinstall.c:331
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define WM_TIMER
Definition: winuser.h:1718
#define WM_COMMAND
Definition: winuser.h:1716
static BOOL init_warning_dialog(HWND hwnd, install_ctx_t *ctx)
Definition: axinstall.c:352
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
#define msg(x)
Definition: auth_time.c:54
#define ID_AXINSTALL_INSTALL_BTN
Definition: resource.h:23
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
static UINT WPARAM wparam
Definition: combo.c:716

Referenced by install_warning().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( urlmon  )

Variable Documentation

◆ cab_extW

const WCHAR cab_extW[] = {'.','c','a','b',0}
static

Definition at line 34 of file axinstall.c.

Referenced by install_file().

◆ ctxW

const WCHAR ctxW[] = {'c','t','x',0}
static

Definition at line 33 of file axinstall.c.

Referenced by init_warning_dialog(), and warning_proc().

◆ dllW

const WCHAR dllW[] = {'d','l','l',0}
static

Definition at line 36 of file axinstall.c.

Referenced by extract_cab_file(), get_object_dll_path(), and test_SearchPathW().

◆ infW

const WCHAR infW[] = {'i','n','f',0}
static

◆ ocxW

const WCHAR ocxW[] = {'o','c','x',0}
static

Definition at line 37 of file axinstall.c.

Referenced by extract_cab_file().