ReactOS  0.4.14-dev-358-gbef841c
install.c File Reference
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winreg.h"
#include "winternl.h"
#include "winnls.h"
#include "setupapi.h"
#include "advpub.h"
#include "ole2.h"
#include "wine/debug.h"
#include "advpack_private.h"
Include dependency graph for install.c:

Go to the source code of this file.

Classes

struct  _ADVInfo
 
struct  SETUPCOMMAND_PARAMS
 
struct  SETUPCOMMAND_PARAMSW
 

Macros

#define SPAPI_ERROR   0xE0000000L
 
#define SPAPI_PREFIX   0x800F0000L
 
#define SPAPI_MASK   0xFFFFL
 
#define HRESULT_FROM_SPAPI(x)   ((HRESULT)((x & SPAPI_MASK) | SPAPI_PREFIX))
 
#define ADV_HRESULT(x)   ((x & SPAPI_ERROR) ? HRESULT_FROM_SPAPI(x) : HRESULT_FROM_WIN32(x))
 
#define ADV_SUCCESS   0
 
#define ADV_FAILURE   1
 

Typedefs

typedef struct _ADVInfo ADVInfo
 
typedef HRESULT(* iterate_fields_func) (HINF hinf, PCWSTR field, const void *arg)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (advpack)
 
static HRESULT del_dirs_callback (HINF hinf, PCWSTR field, const void *arg)
 
static HRESULT per_user_install_callback (HINF hinf, PCWSTR field, const void *arg)
 
static HRESULT register_ocxs_callback (HINF hinf, PCWSTR field, const void *arg)
 
static HRESULT run_setup_commands_callback (HINF hinf, PCWSTR field, const void *arg)
 
LPWSTR get_parameter (LPWSTR *params, WCHAR separator, BOOL quoted)
 
static BOOL is_full_path (LPCWSTR path)
 
static WCHARget_field_string (INFCONTEXT *context, DWORD index, WCHAR *buffer, const WCHAR *static_buffer, DWORD *size)
 
static HRESULT iterate_section_fields (HINF hinf, PCWSTR section, PCWSTR key, iterate_fields_func callback, void *arg)
 
static HRESULT check_admin_rights (const ADVInfo *info)
 
static HRESULT spapi_install (const ADVInfo *info)
 
static HRESULT adv_install (ADVInfo *info)
 
static HRESULT get_working_dir (ADVInfo *info, LPCWSTR inf_filename, LPCWSTR working_dir)
 
static HRESULT install_init (LPCWSTR inf_filename, LPCWSTR install_sec, LPCWSTR working_dir, DWORD flags, ADVInfo *info)
 
static void install_release (const ADVInfo *info)
 
static HRESULT DoInfInstallW (const SETUPCOMMAND_PARAMSW *setup)
 
HRESULT WINAPI DoInfInstall (const SETUPCOMMAND_PARAMS *setup)
 
HRESULT WINAPI ExecuteCabA (HWND hwnd, CABINFOA *pCab, LPVOID pReserved)
 
HRESULT WINAPI ExecuteCabW (HWND hwnd, CABINFOW *pCab, LPVOID pReserved)
 
INT WINAPI LaunchINFSectionA (HWND hWnd, HINSTANCE hInst, LPSTR cmdline, INT show)
 
INT WINAPI LaunchINFSectionW (HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT show)
 
HRESULT WINAPI LaunchINFSectionExA (HWND hWnd, HINSTANCE hInst, LPSTR cmdline, INT show)
 
HRESULT WINAPI LaunchINFSectionExW (HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT show)
 
HRESULT launch_exe (LPCWSTR cmd, LPCWSTR dir, HANDLE *phEXE)
 
HRESULT WINAPI RunSetupCommandA (HWND hWnd, LPCSTR szCmdName, LPCSTR szInfSection, LPCSTR szDir, LPCSTR lpszTitle, HANDLE *phEXE, DWORD dwFlags, LPVOID pvReserved)
 
HRESULT WINAPI RunSetupCommandW (HWND hWnd, LPCWSTR szCmdName, LPCWSTR szInfSection, LPCWSTR szDir, LPCWSTR lpszTitle, HANDLE *phEXE, DWORD dwFlags, LPVOID pvReserved)
 

Variables

static const WCHAR CheckAdminRights []
 
static const WCHAR DelDirs [] = {'D','e','l','D','i','r','s',0}
 
static const WCHAR PerUserInstall [] = {'P','e','r','U','s','e','r','I','n','s','t','a','l','l',0}
 
static const WCHAR RegisterOCXs [] = {'R','e','g','i','s','t','e','r','O','C','X','s',0}
 
static const WCHAR RunPreSetupCommands []
 
static const WCHAR RunPostSetupCommands []
 

Macro Definition Documentation

◆ ADV_FAILURE

#define ADV_FAILURE   1

Definition at line 46 of file install.c.

◆ ADV_HRESULT

#define ADV_HRESULT (   x)    ((x & SPAPI_ERROR) ? HRESULT_FROM_SPAPI(x) : HRESULT_FROM_WIN32(x))

Definition at line 43 of file install.c.

◆ ADV_SUCCESS

#define ADV_SUCCESS   0

Definition at line 45 of file install.c.

◆ HRESULT_FROM_SPAPI

#define HRESULT_FROM_SPAPI (   x)    ((HRESULT)((x & SPAPI_MASK) | SPAPI_PREFIX))

Definition at line 41 of file install.c.

◆ SPAPI_ERROR

#define SPAPI_ERROR   0xE0000000L

Definition at line 38 of file install.c.

◆ SPAPI_MASK

#define SPAPI_MASK   0xFFFFL

Definition at line 40 of file install.c.

◆ SPAPI_PREFIX

#define SPAPI_PREFIX   0x800F0000L

Definition at line 39 of file install.c.

Typedef Documentation

◆ ADVInfo

◆ iterate_fields_func

typedef HRESULT(* iterate_fields_func) (HINF hinf, PCWSTR field, const void *arg)

Definition at line 60 of file install.c.

Function Documentation

◆ adv_install()

static HRESULT adv_install ( ADVInfo info)
static

Definition at line 351 of file install.c.

352 {
353  HRESULT hr;
354 
356  if (hr != S_OK)
357  return hr;
358 
359  hr = iterate_section_fields(info->hinf, info->install_sec, RunPreSetupCommands,
361  if (hr != S_OK)
362  return hr;
363 
365  hr = iterate_section_fields(info->hinf, info->install_sec,
367  OleUninitialize();
368  if (hr != S_OK)
369  return hr;
370 
371  hr = iterate_section_fields(info->hinf, info->install_sec,
373  if (hr != S_OK)
374  return hr;
375 
376  hr = iterate_section_fields(info->hinf, info->install_sec, RunPostSetupCommands,
378  if (hr != S_OK)
379  return hr;
380 
381  hr = iterate_section_fields(info->hinf, info->install_sec,
383  if (hr != S_OK)
384  return hr;
385 
386  return hr;
387 }
static HRESULT register_ocxs_callback(HINF hinf, PCWSTR field, const void *arg)
Definition: install.c:137
HRESULT hr
Definition: shlfolder.c:183
static const WCHAR RegisterOCXs[]
Definition: install.c:68
static HRESULT iterate_section_fields(HINF hinf, PCWSTR section, PCWSTR key, iterate_fields_func callback, void *arg)
Definition: install.c:263
static HRESULT per_user_install_callback(HINF hinf, PCWSTR field, const void *arg)
Definition: install.c:100
static HRESULT check_admin_rights(const ADVInfo *info)
Definition: install.c:296
static const WCHAR DelDirs[]
Definition: install.c:66
smooth NULL
Definition: ftsmooth.c:416
static HRESULT run_setup_commands_callback(HINF hinf, PCWSTR field, const void *arg)
Definition: install.c:174
static HRESULT del_dirs_callback(HINF hinf, PCWSTR field, const void *arg)
Definition: install.c:77
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
Definition: ole2.c:169
#define S_OK
Definition: intsafe.h:59
static const WCHAR RunPostSetupCommands[]
Definition: install.c:72
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:230
static const WCHAR PerUserInstall[]
Definition: install.c:67
static const WCHAR RunPreSetupCommands[]
Definition: install.c:69

Referenced by DoInfInstallW(), ExecuteCabW(), LaunchINFSectionW(), and RunSetupCommandW().

◆ check_admin_rights()

static HRESULT check_admin_rights ( const ADVInfo info)
static

Definition at line 296 of file install.c.

297 {
298  INT check;
300  HRESULT hr = S_OK;
301 
302  if (!SetupFindFirstLineW(info->hinf, info->install_sec,
304  return S_OK;
305 
306  if (!SetupGetIntField(&context, 1, &check))
307  return S_OK;
308 
309  if (check == 1)
310  hr = IsNTAdmin(0, NULL) ? S_OK : E_FAIL;
311 
312  return hr;
313 }
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:54
HRESULT hr
Definition: shlfolder.c:183
Definition: http.c:6587
BOOL WINAPI IsNTAdmin(DWORD reserved, LPDWORD pReserved)
Definition: advpack.c:222
#define E_FAIL
Definition: ddrawi.h:102
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
void check(CONTEXT *pContext)
Definition: NtContinue.c:61
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI SetupGetIntField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT INT *IntegerValue)
Definition: infsupp.c:146
static const WCHAR CheckAdminRights[]
Definition: install.c:63

Referenced by adv_install().

◆ del_dirs_callback()

static HRESULT del_dirs_callback ( HINF  hinf,
PCWSTR  field,
const void arg 
)
static

Definition at line 77 of file install.c.

78 {
80  HRESULT hr = S_OK;
81  DWORD size;
82 
84 
85  for (; ok; ok = SetupFindNextLine(&context, &context))
86  {
88 
91  continue;
92 
94  hr = E_FAIL;
95  }
96 
97  return hr;
98 }
DWORD size
Definition: install.c:3631
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:54
HRESULT hr
Definition: shlfolder.c:183
Definition: http.c:6587
#define E_FAIL
Definition: ddrawi.h:102
HRESULT WINAPI DelNodeW(LPCWSTR pszFileOrDirName, DWORD dwFlags)
Definition: files.c:432
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define MAX_INF_STRING_LENGTH
Definition: infsupp.h:34
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:43
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI SetupFindNextLine(IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut)
Definition: infsupp.c:80
#define ADN_DEL_IF_EMPTY
Definition: advpub.h:143
BOOL WINAPI SetupGetLineTextW(PINFCONTEXT context, HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1756

Referenced by adv_install().

◆ DoInfInstall()

HRESULT WINAPI DoInfInstall ( const SETUPCOMMAND_PARAMS setup)

Definition at line 583 of file install.c.

584 {
587  HRESULT hr;
588 
589  if (!setup)
590  return E_INVALIDARG;
591 
593  RtlCreateUnicodeStringFromAsciiz(&inf, setup->inf_name);
596 
597  params.title = title.Buffer;
598  params.inf_name = inf.Buffer;
599  params.section_name = section.Buffer;
600  params.dir = dir.Buffer;
601  params.hwnd = setup->hwnd;
602 
603  hr = DoInfInstallW(&params);
604 
606  RtlFreeUnicodeString(&inf);
609 
610  return hr;
611 }
HRESULT hr
Definition: shlfolder.c:183
static HRESULT DoInfInstallW(const SETUPCOMMAND_PARAMSW *setup)
Definition: install.c:546
Definition: parser.c:55
static IMAGE_SECTION_HEADER section
Definition: loader.c:152
GLenum const GLfloat * params
Definition: glext.h:5645
#define E_INVALIDARG
Definition: ddrawi.h:101
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
unsigned int dir
Definition: maze.c:112
LONG HRESULT
Definition: typedefs.h:77
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
void setup(char *serport, int baud)
Definition: gdblib.c:169
static char title[]
Definition: ps.c:92

◆ DoInfInstallW()

static HRESULT DoInfInstallW ( const SETUPCOMMAND_PARAMSW setup)
static

Definition at line 546 of file install.c.

547 {
548  ADVInfo info;
549  HRESULT hr;
550 
551  TRACE("(%p)\n", setup);
552 
553  ZeroMemory(&info, sizeof(ADVInfo));
554 
555  hr = install_init(setup->inf_name, setup->section_name, setup->dir, 0, &info);
556  if (hr != S_OK)
557  goto done;
558 
559  hr = spapi_install(&info);
560  if (hr != S_OK)
561  goto done;
562 
563  hr = adv_install(&info);
564 
565 done:
567 
568  return S_OK;
569 }
static HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec, LPCWSTR working_dir, DWORD flags, ADVInfo *info)
Definition: install.c:441
HRESULT hr
Definition: shlfolder.c:183
#define ZeroMemory
Definition: winbase.h:1642
struct _test_info info[]
Definition: SetCursorPos.c:19
static HRESULT adv_install(ADVInfo *info)
Definition: install.c:351
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
static void install_release(const ADVInfo *info)
Definition: install.c:516
#define S_OK
Definition: intsafe.h:59
void setup(char *serport, int baud)
Definition: gdblib.c:169
static HRESULT spapi_install(const ADVInfo *info)
Definition: install.c:316

Referenced by DoInfInstall().

◆ ExecuteCabA()

HRESULT WINAPI ExecuteCabA ( HWND  hwnd,
CABINFOA pCab,
LPVOID  pReserved 
)

Definition at line 618 of file install.c.

619 {
620  UNICODE_STRING cab, inf, section;
621  CABINFOW cabinfo;
622  HRESULT hr;
623 
624  TRACE("(%p, %p, %p)\n", hwnd, pCab, pReserved);
625 
626  if (!pCab)
627  return E_INVALIDARG;
628 
629  if (pCab->pszCab)
630  {
632  cabinfo.pszCab = cab.Buffer;
633  }
634  else
635  cabinfo.pszCab = NULL;
636 
639 
640  MultiByteToWideChar(CP_ACP, 0, pCab->szSrcPath, -1, cabinfo.szSrcPath, ARRAY_SIZE(cabinfo.szSrcPath));
641 
642  cabinfo.pszInf = inf.Buffer;
643  cabinfo.pszSection = section.Buffer;
644  cabinfo.dwFlags = pCab->dwFlags;
645 
646  hr = ExecuteCabW(hwnd, &cabinfo, pReserved);
647 
648  if (pCab->pszCab)
649  RtlFreeUnicodeString(&cab);
650 
651  RtlFreeUnicodeString(&inf);
653 
654  return hr;
655 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
LPSTR pszCab
Definition: advpub.h:34
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:99
LPWSTR pszInf
Definition: advpub.h:44
HRESULT WINAPI ExecuteCabW(HWND hwnd, CABINFOW *pCab, LPVOID pReserved)
Definition: install.c:671
Definition: parser.c:55
static IMAGE_SECTION_HEADER section
Definition: loader.c:152
DWORD dwFlags
Definition: advpub.h:38
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
DWORD dwFlags
Definition: advpub.h:47
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define TRACE(s)
Definition: solgame.cpp:4
LPSTR pszSection
Definition: advpub.h:36
LONG HRESULT
Definition: typedefs.h:77
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define ARRAY_SIZE(a)
Definition: main.h:24
#define MultiByteToWideChar
Definition: compat.h:100
WCHAR szSrcPath[MAX_PATH]
Definition: advpub.h:46
LPWSTR pszCab
Definition: advpub.h:43
CHAR szSrcPath[MAX_PATH]
Definition: advpub.h:37
LPWSTR pszSection
Definition: advpub.h:45
LPSTR pszInf
Definition: advpub.h:35

◆ ExecuteCabW()

HRESULT WINAPI ExecuteCabW ( HWND  hwnd,
CABINFOW pCab,
LPVOID  pReserved 
)

Definition at line 671 of file install.c.

672 {
673  ADVInfo info;
674  HRESULT hr;
675 
676  TRACE("(%p, %p, %p)\n", hwnd, pCab, pReserved);
677 
678  ZeroMemory(&info, sizeof(ADVInfo));
679 
680  if (pCab->pszCab && *pCab->pszCab)
681  FIXME("Cab archive not extracted!\n");
682 
683  hr = install_init(pCab->pszInf, pCab->pszSection, pCab->szSrcPath, pCab->dwFlags, &info);
684  if (hr != S_OK)
685  goto done;
686 
687  hr = spapi_install(&info);
688  if (hr != S_OK)
689  goto done;
690 
691  hr = adv_install(&info);
692 
693 done:
695 
696  return hr;
697 }
static HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec, LPCWSTR working_dir, DWORD flags, ADVInfo *info)
Definition: install.c:441
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HRESULT hr
Definition: shlfolder.c:183
LPWSTR pszInf
Definition: advpub.h:44
#define ZeroMemory
Definition: winbase.h:1642
struct _test_info info[]
Definition: SetCursorPos.c:19
#define FIXME(fmt,...)
Definition: debug.h:110
DWORD dwFlags
Definition: advpub.h:47
static HRESULT adv_install(ADVInfo *info)
Definition: install.c:351
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
static void install_release(const ADVInfo *info)
Definition: install.c:516
#define S_OK
Definition: intsafe.h:59
static HRESULT spapi_install(const ADVInfo *info)
Definition: install.c:316
WCHAR szSrcPath[MAX_PATH]
Definition: advpub.h:46
LPWSTR pszCab
Definition: advpub.h:43
LPWSTR pszSection
Definition: advpub.h:45

Referenced by ExecuteCabA(), LaunchINFSectionExW(), and RegInstallW().

◆ get_field_string()

static WCHAR* get_field_string ( INFCONTEXT context,
DWORD  index,
WCHAR buffer,
const WCHAR static_buffer,
DWORD size 
)
static

Definition at line 242 of file install.c.

244 {
245  DWORD required;
246 
247  if (SetupGetStringFieldW(context, index, buffer, *size, &required)) return buffer;
248 
250  {
251  /* now grow the buffer */
252  if (buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer);
253  if (!(buffer = HeapAlloc(GetProcessHeap(), 0, required*sizeof(WCHAR)))) return NULL;
254  *size = required;
255  if (SetupGetStringFieldW(context, index, buffer, *size, &required)) return buffer;
256  }
257 
258  if (buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer);
259  return NULL;
260 }
Definition: http.c:6587
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HeapFree(x, y, z)
Definition: compat.h:402
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:184

Referenced by iterate_section_fields().

◆ get_parameter()

LPWSTR get_parameter ( LPWSTR params,
WCHAR  separator,
BOOL  quoted 
)

Definition at line 200 of file install.c.

201 {
202  LPWSTR token = *params;
203 
204  if (!*params)
205  return NULL;
206 
207  if (quoted && *token == '"')
208  {
209  WCHAR *end = wcschr(token + 1, '"');
210  if (end)
211  {
212  *end = 0;
213  *params = end + 1;
214  token = token + 1;
215  }
216  }
217 
219  if (*params)
220  *(*params)++ = '\0';
221 
222  if (!*token)
223  return NULL;
224 
225  return token;
226 }
static const WCHAR separator[]
Definition: asmname.c:65
GLuint GLuint end
Definition: gl.h:1545
GLenum const GLfloat * params
Definition: glext.h:5645
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 token
Definition: glfuncs.h:210
smooth NULL
Definition: ftsmooth.c:416
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DelNodeRunDLL32W(), LaunchINFSectionExW(), LaunchINFSectionW(), RegisterOCX(), and set_ldids().

◆ get_working_dir()

static HRESULT get_working_dir ( ADVInfo info,
LPCWSTR  inf_filename,
LPCWSTR  working_dir 
)
static

Definition at line 390 of file install.c.

391 {
393  LPCWSTR ptr;
394  DWORD len;
395 
396  static const WCHAR backslash[] = {'\\',0};
397  static const WCHAR inf_dir[] = {'\\','I','N','F',0};
398 
399  if ((ptr = wcsrchr(inf_filename, '\\')))
400  {
401  len = ptr - inf_filename + 1;
402  ptr = inf_filename;
403  }
404  else if (working_dir && *working_dir)
405  {
406  len = lstrlenW(working_dir) + 1;
407  ptr = working_dir;
408  }
409  else
410  {
412  lstrcatW(path, backslash);
413  lstrcatW(path, inf_filename);
414 
415  /* check if the INF file is in the current directory */
417  {
419  }
420  else
421  {
422  /* default to the windows\inf directory if all else fails */
424  lstrcatW(path, inf_dir);
425  }
426 
427  len = lstrlenW(path) + 1;
428  ptr = path;
429  }
430 
431  info->working_dir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
432  if (!info->working_dir)
433  return E_OUTOFMEMORY;
434 
435  lstrcpynW(info->working_dir, ptr, len);
436 
437  return S_OK;
438 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
GLsizei const GLchar ** path
Definition: glext.h:7234
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:421
#define lstrlenW
Definition: compat.h:415
#define lstrcpynW
Definition: compat.h:405
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
static PVOID ptr
Definition: dispmode.c:27
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
Definition: services.c:325
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

Referenced by install_init().

◆ install_init()

static HRESULT install_init ( LPCWSTR  inf_filename,
LPCWSTR  install_sec,
LPCWSTR  working_dir,
DWORD  flags,
ADVInfo info 
)
static

Definition at line 441 of file install.c.

443 {
444  DWORD len;
445  HRESULT hr;
446  LPCWSTR ptr, path;
447 
448  static const WCHAR backslash[] = {'\\',0};
449  static const WCHAR default_install[] = {
450  'D','e','f','a','u','l','t','I','n','s','t','a','l','l',0
451  };
452 
453  if (!(ptr = wcsrchr(inf_filename, '\\')))
454  ptr = inf_filename;
455 
456  len = lstrlenW(ptr);
457 
458  info->inf_filename = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
459  if (!info->inf_filename)
460  return E_OUTOFMEMORY;
461 
462  lstrcpyW(info->inf_filename, ptr);
463 
464  /* FIXME: determine the proper platform to install (NTx86, etc) */
465  if (!install_sec || !*install_sec)
466  {
467  len = sizeof(default_install) - 1;
468  ptr = default_install;
469  }
470  else
471  {
472  len = lstrlenW(install_sec);
473  ptr = install_sec;
474  }
475 
476  info->install_sec = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
477  if (!info->install_sec)
478  return E_OUTOFMEMORY;
479 
480  lstrcpyW(info->install_sec, ptr);
481 
482  hr = get_working_dir(info, inf_filename, working_dir);
483  if (FAILED(hr))
484  return hr;
485 
486  len = lstrlenW(info->working_dir) + lstrlenW(info->inf_filename) + 2;
487  info->inf_path = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
488  if (!info->inf_path)
489  return E_OUTOFMEMORY;
490 
491  lstrcpyW(info->inf_path, info->working_dir);
492  lstrcatW(info->inf_path, backslash);
493  lstrcatW(info->inf_path, info->inf_filename);
494 
495  /* RunSetupCommand opens unmodified filename parameter */
496  if (flags & RSC_FLAG_INF)
497  path = inf_filename;
498  else
499  path = info->inf_path;
500 
502  if (info->hinf == INVALID_HANDLE_VALUE)
503  return ADV_HRESULT(GetLastError());
504 
505  set_ldids(info->hinf, info->install_sec, info->working_dir);
506 
507  /* FIXME: check that the INF is advanced */
508 
509  info->flags = flags;
510  info->need_reboot = FALSE;
511 
512  return S_OK;
513 }
#define INF_STYLE_WIN4
Definition: infsupp.h:41
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
GLsizei const GLchar ** path
Definition: glext.h:7234
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
#define lstrlenW
Definition: compat.h:415
#define RSC_FLAG_INF
Definition: advpub.h:130
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
#define lstrcpyW
Definition: compat.h:414
Definition: services.c:325
void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir)
Definition: advpack.c:109
#define ADV_HRESULT(x)
Definition: install.c:43
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
static HRESULT get_working_dir(ADVInfo *info, LPCWSTR inf_filename, LPCWSTR working_dir)
Definition: install.c:390

Referenced by DoInfInstallW(), ExecuteCabW(), LaunchINFSectionW(), and RunSetupCommandW().

◆ install_release()

static void install_release ( const ADVInfo info)
static

Definition at line 516 of file install.c.

517 {
518  SetupCloseInfFile(info->hinf);
519 
520  HeapFree(GetProcessHeap(), 0, info->inf_path);
521  HeapFree(GetProcessHeap(), 0, info->inf_filename);
522  HeapFree(GetProcessHeap(), 0, info->install_sec);
523  HeapFree(GetProcessHeap(), 0, info->working_dir);
524 }
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43
#define GetProcessHeap()
Definition: compat.h:403
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by DoInfInstallW(), ExecuteCabW(), LaunchINFSectionW(), and RunSetupCommandW().

◆ is_full_path()

static BOOL is_full_path ( LPCWSTR  path)
static

Definition at line 228 of file install.c.

229 {
230  const int MIN_PATH_LEN = 3;
231 
232  if (!path || lstrlenW(path) < MIN_PATH_LEN)
233  return FALSE;
234 
235  if ((path[1] == ':' && path[2] == '\\') || (path[0] == '\\' && path[1] == '\\'))
236  return TRUE;
237 
238  return FALSE;
239 }
#define TRUE
Definition: types.h:120
#define lstrlenW
Definition: compat.h:415
Definition: services.c:325

Referenced by LaunchINFSectionExW().

◆ iterate_section_fields()

static HRESULT iterate_section_fields ( HINF  hinf,
PCWSTR  section,
PCWSTR  key,
iterate_fields_func  callback,
void arg 
)
static

Definition at line 263 of file install.c.

265 {
266  WCHAR static_buffer[200];
267  WCHAR *buffer = static_buffer;
268  DWORD size = ARRAY_SIZE(static_buffer);
270  HRESULT hr = E_FAIL;
271 
273  while (ok)
274  {
276 
277  for (i = 1; i <= count; i++)
278  {
279  if (!(buffer = get_field_string(&context, i, buffer, static_buffer, &size)))
280  goto done;
281 
282  if ((hr = callback(hinf, buffer, arg)) != S_OK)
283  goto done;
284  }
285 
287  }
288 
289  hr = S_OK;
290 
291  done:
292  if (buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer);
293  return hr;
294 }
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:54
HRESULT hr
Definition: shlfolder.c:183
Definition: http.c:6587
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
Definition: parser.c:55
#define E_FAIL
Definition: ddrawi.h:102
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
unsigned int BOOL
Definition: ntddk_ex.h:94
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG WINAPI SetupGetFieldCount(IN PINFCONTEXT Context)
Definition: infsupp.c:91
static WCHAR * get_field_string(INFCONTEXT *context, DWORD index, WCHAR *buffer, const WCHAR *static_buffer, DWORD *size)
Definition: install.c:242
#define S_OK
Definition: intsafe.h:59
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
#define HeapFree(x, y, z)
Definition: compat.h:402
BOOL WINAPI SetupFindNextMatchLineW(PINFCONTEXT context_in, PCWSTR key, PINFCONTEXT context_out)
Definition: parser.c:1694
Definition: path.c:42

Referenced by adv_install().

◆ launch_exe()

HRESULT launch_exe ( LPCWSTR  cmd,
LPCWSTR  dir,
HANDLE phEXE 
)

Definition at line 894 of file install.c.

895 {
896  STARTUPINFOW si;
898 
899  if (phEXE) *phEXE = NULL;
900 
901  ZeroMemory(&pi, sizeof(pi));
902  ZeroMemory(&si, sizeof(si));
903  si.cb = sizeof(si);
904 
907  NULL, dir, &si, &pi))
908  {
910  }
911 
912  CloseHandle(pi.hThread);
913 
914  if (phEXE)
915  {
916  *phEXE = pi.hProcess;
917  return S_ASYNCHRONOUS;
918  }
919 
920  /* wait for the child process to finish */
921  WaitForSingleObject(pi.hProcess, INFINITE);
922  CloseHandle(pi.hProcess);
923 
924  return S_OK;
925 }
#define CloseHandle
Definition: compat.h:406
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
Definition: ftp_var.h:139
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1642
#define CREATE_DEFAULT_ERROR_MODE
Definition: winbase.h:194
#define CREATE_NEW_PROCESS_GROUP
Definition: winbase.h:185
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4593
DWORD cb
Definition: winbase.h:824
#define S_ASYNCHRONOUS
Definition: advpub.h:29
static DWORD pi
Definition: protocol.c:150
#define S_OK
Definition: intsafe.h:59
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define INFINITE
Definition: serial.h:102

Referenced by run_setup_commands_callback(), RunSetupCommandW(), and UserInstStubWrapperW().

◆ LaunchINFSectionA()

INT WINAPI LaunchINFSectionA ( HWND  hWnd,
HINSTANCE  hInst,
LPSTR  cmdline,
INT  show 
)

Definition at line 704 of file install.c.

705 {
707  HRESULT hr;
708 
709  TRACE("(%p, %p, %s, %i)\n", hWnd, hInst, debugstr_a(cmdline), show);
710 
711  if (!cmdline)
712  return ADV_FAILURE;
713 
715 
716  hr = LaunchINFSectionW(hWnd, hInst, cmd.Buffer, show);
717 
719 
720  return hr;
721 }
HRESULT hr
Definition: shlfolder.c:183
Definition: ftp_var.h:139
HWND hWnd
Definition: settings.c:17
char * cmd
Definition: vfdcmd.c:85
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define ADV_FAILURE
Definition: install.c:46
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
HINSTANCE hInst
Definition: dxdiag.c:13
INT WINAPI LaunchINFSectionW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT show)
Definition: install.c:747

◆ LaunchINFSectionExA()

HRESULT WINAPI LaunchINFSectionExA ( HWND  hWnd,
HINSTANCE  hInst,
LPSTR  cmdline,
INT  show 
)

Definition at line 800 of file install.c.

801 {
803  HRESULT hr;
804 
805  TRACE("(%p, %p, %s, %i)\n", hWnd, hInst, debugstr_a(cmdline), show);
806 
807  if (!cmdline)
808  return ADV_FAILURE;
809 
811 
812  hr = LaunchINFSectionExW(hWnd, hInst, cmd.Buffer, show);
813 
815 
816  return hr;
817 }
HRESULT hr
Definition: shlfolder.c:183
Definition: ftp_var.h:139
HWND hWnd
Definition: settings.c:17
char * cmd
Definition: vfdcmd.c:85
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define ADV_FAILURE
Definition: install.c:46
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
HRESULT WINAPI LaunchINFSectionExW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT show)
Definition: install.c:846
HINSTANCE hInst
Definition: dxdiag.c:13

◆ LaunchINFSectionExW()

HRESULT WINAPI LaunchINFSectionExW ( HWND  hWnd,
HINSTANCE  hInst,
LPWSTR  cmdline,
INT  show 
)

Definition at line 846 of file install.c.

847 {
848  LPWSTR cmdline_copy, cmdline_ptr;
849  LPWSTR flags, ptr;
850  CABINFOW cabinfo;
851  HRESULT hr;
852 
853  TRACE("(%p, %p, %s, %d)\n", hWnd, hInst, debugstr_w(cmdline), show);
854 
855  if (!cmdline)
856  return ADV_FAILURE;
857 
858  cmdline_copy = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(cmdline) + 1) * sizeof(WCHAR));
859  cmdline_ptr = cmdline_copy;
860  lstrcpyW(cmdline_copy, cmdline);
861 
862  cabinfo.pszInf = get_parameter(&cmdline_ptr, ',', TRUE);
863  cabinfo.pszSection = get_parameter(&cmdline_ptr, ',', TRUE);
864  cabinfo.pszCab = get_parameter(&cmdline_ptr, ',', TRUE);
865  *cabinfo.szSrcPath = '\0';
866 
867  flags = get_parameter(&cmdline_ptr, ',', TRUE);
868  if (flags)
869  cabinfo.dwFlags = wcstol(flags, NULL, 10);
870 
871  if (!is_full_path(cabinfo.pszCab) && !is_full_path(cabinfo.pszInf))
872  {
873  HeapFree(GetProcessHeap(), 0, cmdline_copy);
874  return E_INVALIDARG;
875  }
876 
877  /* get the source path from the cab filename */
878  if (cabinfo.pszCab && *cabinfo.pszCab)
879  {
880  if (!is_full_path(cabinfo.pszCab))
881  lstrcpyW(cabinfo.szSrcPath, cabinfo.pszInf);
882  else
883  lstrcpyW(cabinfo.szSrcPath, cabinfo.pszCab);
884 
885  ptr = wcsrchr(cabinfo.szSrcPath, '\\');
886  *(++ptr) = '\0';
887  }
888 
889  hr = ExecuteCabW(hWnd, &cabinfo, NULL);
890  HeapFree(GetProcessHeap(), 0, cmdline_copy);
891  return SUCCEEDED(hr) ? ADV_SUCCESS : ADV_FAILURE;
892 }
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
LPWSTR pszInf
Definition: advpub.h:44
HWND hWnd
Definition: settings.c:17
TCHAR * cmdline
Definition: stretchblt.cpp:32
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
HRESULT WINAPI ExecuteCabW(HWND hwnd, CABINFOW *pCab, LPVOID pReserved)
Definition: install.c:671
#define lstrlenW
Definition: compat.h:415
static BOOL is_full_path(LPCWSTR path)
Definition: install.c:228
#define ADV_FAILURE
Definition: install.c:46
#define debugstr_w
Definition: kernel32.h:32
static PVOID ptr
Definition: dispmode.c:27
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
DWORD dwFlags
Definition: advpub.h:47
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
LPWSTR get_parameter(LPWSTR *params, WCHAR separator, BOOL quoted)
Definition: install.c:200
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
GLbitfield flags
Definition: glext.h:7161
HINSTANCE hInst
Definition: dxdiag.c:13
#define lstrcpyW
Definition: compat.h:414
#define ADV_SUCCESS
Definition: install.c:45
WCHAR * LPWSTR
Definition: xmlstorage.h:184
WCHAR szSrcPath[MAX_PATH]
Definition: advpub.h:46
LPWSTR pszCab
Definition: advpub.h:43
LPWSTR pszSection
Definition: advpub.h:45
#define HeapFree(x, y, z)
Definition: compat.h:402
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by LaunchINFSectionExA().

◆ LaunchINFSectionW()

INT WINAPI LaunchINFSectionW ( HWND  hWnd,
HINSTANCE  hInst,
LPWSTR  cmdline,
INT  show 
)

Definition at line 747 of file install.c.

748 {
749  ADVInfo info;
750  LPWSTR cmdline_copy, cmdline_ptr;
751  LPWSTR inf_filename, install_sec;
752  LPWSTR str_flags;
753  DWORD flags = 0;
754  HRESULT hr = S_OK;
755 
756  TRACE("(%p, %p, %s, %d)\n", hWnd, hInst, debugstr_w(cmdline), show);
757 
758  if (!cmdline)
759  return ADV_FAILURE;
760 
761  cmdline_copy = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(cmdline) + 1) * sizeof(WCHAR));
762  cmdline_ptr = cmdline_copy;
763  lstrcpyW(cmdline_copy, cmdline);
764 
765  inf_filename = get_parameter(&cmdline_ptr, ',', TRUE);
766  install_sec = get_parameter(&cmdline_ptr, ',', TRUE);
767 
768  str_flags = get_parameter(&cmdline_ptr, ',', TRUE);
769  if (str_flags)
770  {
771  DWORD inf_flags = wcstol(str_flags, NULL, 10);
772  if (inf_flags & LIS_QUIET) flags |= RSC_FLAG_QUIET;
773  if (inf_flags & LIS_NOGRPCONV) flags |= RSC_FLAG_NGCONV;
774  }
775 
776  ZeroMemory(&info, sizeof(ADVInfo));
777 
778  hr = install_init(inf_filename, install_sec, NULL, flags, &info);
779  if (hr != S_OK)
780  goto done;
781 
782  hr = spapi_install(&info);
783  if (hr != S_OK)
784  goto done;
785 
786  hr = adv_install(&info);
787 
788 done:
790  HeapFree(GetProcessHeap(), 0, cmdline_copy);
791 
792  return SUCCEEDED(hr) ? ADV_SUCCESS : ADV_FAILURE;
793 }
static HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec, LPCWSTR working_dir, DWORD flags, ADVInfo *info)
Definition: install.c:441
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
HWND hWnd
Definition: settings.c:17
#define ZeroMemory
Definition: winbase.h:1642
TCHAR * cmdline
Definition: stretchblt.cpp:32
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define lstrlenW
Definition: compat.h:415
#define RSC_FLAG_NGCONV
Definition: advpub.h:133
struct _test_info info[]
Definition: SetCursorPos.c:19
#define LIS_NOGRPCONV
Definition: advpub.h:140
#define ADV_FAILURE
Definition: install.c:46
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
static HRESULT adv_install(ADVInfo *info)
Definition: install.c:351
LPWSTR get_parameter(LPWSTR *params, WCHAR separator, BOOL quoted)
Definition: install.c:200
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define LIS_QUIET
Definition: advpub.h:139
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
static void install_release(const ADVInfo *info)
Definition: install.c:516
#define S_OK
Definition: intsafe.h:59
HINSTANCE hInst
Definition: dxdiag.c:13
#define lstrcpyW
Definition: compat.h:414
#define ADV_SUCCESS
Definition: install.c:45
#define RSC_FLAG_QUIET
Definition: advpub.h:132
static HRESULT spapi_install(const ADVInfo *info)
Definition: install.c:316
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:402
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by LaunchINFSectionA().

◆ per_user_install_callback()

static HRESULT per_user_install_callback ( HINF  hinf,
PCWSTR  field,
const void arg 
)
static

Definition at line 100 of file install.c.

101 {
102  PERUSERSECTIONW per_user;
104  DWORD size;
105 
106  static const WCHAR disp_name[] = {'D','i','s','p','l','a','y','N','a','m','e',0};
107  static const WCHAR version[] = {'V','e','r','s','i','o','n',0};
108  static const WCHAR is_installed[] = {'I','s','I','n','s','t','a','l','l','e','d',0};
109  static const WCHAR comp_id[] = {'C','o','m','p','o','n','e','n','t','I','D',0};
110  static const WCHAR guid[] = {'G','U','I','D',0};
111  static const WCHAR locale[] = {'L','o','c','a','l','e',0};
112  static const WCHAR stub_path[] = {'S','t','u','b','P','a','t','h',0};
113 
114  per_user.bRollback = FALSE;
115  per_user.dwIsInstalled = 0;
116 
117  SetupGetLineTextW(NULL, hinf, field, disp_name, per_user.szDispName, ARRAY_SIZE(per_user.szDispName), &size);
118 
119  SetupGetLineTextW(NULL, hinf, field, version, per_user.szVersion, ARRAY_SIZE(per_user.szVersion), &size);
120 
121  if (SetupFindFirstLineW(hinf, field, is_installed, &context))
122  {
123  SetupGetIntField(&context, 1, (PINT)&per_user.dwIsInstalled);
124  }
125 
126  SetupGetLineTextW(NULL, hinf, field, comp_id, per_user.szCompID, ARRAY_SIZE(per_user.szCompID), &size);
127 
128  SetupGetLineTextW(NULL, hinf, field, guid, per_user.szGUID, ARRAY_SIZE(per_user.szGUID), &size);
129 
130  SetupGetLineTextW(NULL, hinf, field, locale, per_user.szLocale, ARRAY_SIZE(per_user.szLocale), &size);
131 
132  SetupGetLineTextW(NULL, hinf, field, stub_path, per_user.szStub, ARRAY_SIZE(per_user.szStub), &size);
133 
134  return SetPerUserSecValuesW(&per_user);
135 }
WCHAR szStub[MAX_PATH *4]
Definition: advpub.h:70
DWORD size
Definition: install.c:3631
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:54
Definition: http.c:6587
BOOL bRollback
Definition: advpub.h:74
WCHAR szDispName[128]
Definition: advpub.h:68
DWORD dwIsInstalled
Definition: advpub.h:73
HRESULT WINAPI SetPerUserSecValuesW(PERUSERSECTIONW *pPerUser)
Definition: advpack.c:558
WCHAR szGUID[39+20]
Definition: advpub.h:67
const GUID * guid
Definition: _locale.h:75
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:66
int * PINT
Definition: windef.h:177
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:43
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR szLocale[10]
Definition: advpub.h:69
WCHAR szVersion[32]
Definition: advpub.h:71
WCHAR szCompID[128]
Definition: advpub.h:72
#define ARRAY_SIZE(a)
Definition: main.h:24
BOOL WINAPI SetupGetIntField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT INT *IntegerValue)
Definition: infsupp.c:146
BOOL WINAPI SetupGetLineTextW(PINFCONTEXT context, HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1756

Referenced by adv_install().

◆ register_ocxs_callback()

static HRESULT register_ocxs_callback ( HINF  hinf,
PCWSTR  field,
const void arg 
)
static

Definition at line 137 of file install.c.

138 {
139  HMODULE hm;
141  HRESULT hr = S_OK;
142 
144 
145  for (; ok; ok = SetupFindNextLine(&context, &context))
146  {
148 
149  /* get OCX filename */
151  continue;
152 
154  if (hm)
155  {
156  if (do_ocx_reg(hm, TRUE, NULL, NULL) != S_OK)
157  hr = E_FAIL;
158 
159  FreeLibrary(hm);
160  }
161  else
162  hr = E_FAIL;
163 
164  if (FAILED(hr))
165  {
166  /* FIXME: display a message box */
167  break;
168  }
169  }
170 
171  return hr;
172 }
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:54
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
Definition: http.c:6587
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
GLuint buffer
Definition: glext.h:5915
#define LOAD_WITH_ALTERED_SEARCH_PATH
Definition: winbase.h:339
#define E_FAIL
Definition: ddrawi.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define FreeLibrary(x)
Definition: compat.h:413
#define MAX_INF_STRING_LENGTH
Definition: infsupp.h:34
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:43
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI SetupFindNextLine(IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut)
Definition: infsupp.c:80
HRESULT do_ocx_reg(HMODULE hocx, BOOL do_reg, const WCHAR *flags, const WCHAR *param)
Definition: advpack.c:442
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:184

Referenced by adv_install().

◆ run_setup_commands_callback()

static HRESULT run_setup_commands_callback ( HINF  hinf,
PCWSTR  field,
const void arg 
)
static

Definition at line 174 of file install.c.

175 {
176  const ADVInfo *info = (const ADVInfo *)arg;
178  HRESULT hr = S_OK;
179  DWORD size;
180 
182 
183  for (; ok; ok = SetupFindNextLine(&context, &context))
184  {
186 
189  continue;
190 
191  if (launch_exe(buffer, info->working_dir, NULL) != S_OK)
192  hr = E_FAIL;
193  }
194 
195  return hr;
196 }
DWORD size
Definition: install.c:3631
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:54
HRESULT hr
Definition: shlfolder.c:183
Definition: http.c:6587
GLuint buffer
Definition: glext.h:5915
#define E_FAIL
Definition: ddrawi.h:102
HRESULT launch_exe(LPCWSTR cmd, LPCWSTR dir, HANDLE *phEXE)
Definition: install.c:894
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define MAX_INF_STRING_LENGTH
Definition: infsupp.h:34
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:43
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI SetupFindNextLine(IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut)
Definition: infsupp.c:80
BOOL WINAPI SetupGetLineTextW(PINFCONTEXT context, HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1756

Referenced by adv_install().

◆ RunSetupCommandA()

HRESULT WINAPI RunSetupCommandA ( HWND  hWnd,
LPCSTR  szCmdName,
LPCSTR  szInfSection,
LPCSTR  szDir,
LPCSTR  lpszTitle,
HANDLE phEXE,
DWORD  dwFlags,
LPVOID  pvReserved 
)

Definition at line 932 of file install.c.

936 {
937  UNICODE_STRING cmdname, infsec;
939  HRESULT hr;
940 
941  TRACE("(%p, %s, %s, %s, %s, %p, %d, %p)\n",
942  hWnd, debugstr_a(szCmdName), debugstr_a(szInfSection),
943  debugstr_a(szDir), debugstr_a(lpszTitle),
944  phEXE, dwFlags, pvReserved);
945 
946  if (!szCmdName || !szDir)
947  return E_INVALIDARG;
948 
949  RtlCreateUnicodeStringFromAsciiz(&cmdname, szCmdName);
950  RtlCreateUnicodeStringFromAsciiz(&infsec, szInfSection);
953 
954  hr = RunSetupCommandW(hWnd, cmdname.Buffer, infsec.Buffer, dir.Buffer,
955  title.Buffer, phEXE, dwFlags, pvReserved);
956 
957  RtlFreeUnicodeString(&cmdname);
958  RtlFreeUnicodeString(&infsec);
961 
962  return hr;
963 }
HRESULT hr
Definition: shlfolder.c:183
HWND hWnd
Definition: settings.c:17
#define E_INVALIDARG
Definition: ddrawi.h:101
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
unsigned int dir
Definition: maze.c:112
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
static LPCSTR DWORD void * pvReserved
Definition: str.c:196
HRESULT WINAPI RunSetupCommandW(HWND hWnd, LPCWSTR szCmdName, LPCWSTR szInfSection, LPCWSTR szDir, LPCWSTR lpszTitle, HANDLE *phEXE, DWORD dwFlags, LPVOID pvReserved)
Definition: install.c:990
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static char title[]
Definition: ps.c:92

◆ RunSetupCommandW()

HRESULT WINAPI RunSetupCommandW ( HWND  hWnd,
LPCWSTR  szCmdName,
LPCWSTR  szInfSection,
LPCWSTR  szDir,
LPCWSTR  lpszTitle,
HANDLE phEXE,
DWORD  dwFlags,
LPVOID  pvReserved 
)

Definition at line 990 of file install.c.

994 {
995  ADVInfo info;
996  HRESULT hr;
997 
998  TRACE("(%p, %s, %s, %s, %s, %p, %d, %p)\n",
999  hWnd, debugstr_w(szCmdName), debugstr_w(szInfSection),
1000  debugstr_w(szDir), debugstr_w(lpszTitle),
1001  phEXE, dwFlags, pvReserved);
1002 
1004  FIXME("Unhandled flag: RSC_FLAG_UPDHLPDLLS\n");
1005 
1006  if (!szCmdName || !szDir)
1007  return E_INVALIDARG;
1008 
1009  if (!(dwFlags & RSC_FLAG_INF))
1010  return launch_exe(szCmdName, szDir, phEXE);
1011 
1012  ZeroMemory(&info, sizeof(ADVInfo));
1013 
1014  hr = install_init(szCmdName, szInfSection, szDir, dwFlags, &info);
1015  if (hr != S_OK)
1016  goto done;
1017 
1018  hr = spapi_install(&info);
1019  if (hr != S_OK)
1020  goto done;
1021 
1022  hr = adv_install(&info);
1023 
1024 done:
1026 
1027  return hr;
1028 }
static HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec, LPCWSTR working_dir, DWORD flags, ADVInfo *info)
Definition: install.c:441
HRESULT hr
Definition: shlfolder.c:183
HWND hWnd
Definition: settings.c:17
#define ZeroMemory
Definition: winbase.h:1642
#define RSC_FLAG_INF
Definition: advpub.h:130
HRESULT launch_exe(LPCWSTR cmd, LPCWSTR dir, HANDLE *phEXE)
Definition: install.c:894
struct _test_info info[]
Definition: SetCursorPos.c:19
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
static HRESULT adv_install(ADVInfo *info)
Definition: install.c:351
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
static LPCSTR DWORD void * pvReserved
Definition: str.c:196
#define RSC_FLAG_UPDHLPDLLS
Definition: advpub.h:134
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static void install_release(const ADVInfo *info)
Definition: install.c:516
#define S_OK
Definition: intsafe.h:59
static HRESULT spapi_install(const ADVInfo *info)
Definition: install.c:316

Referenced by install_inf_file(), process_hook_section(), and RunSetupCommandA().

◆ spapi_install()

static HRESULT spapi_install ( const ADVInfo info)
static

Definition at line 316 of file install.c.

317 {
318  BOOL ret;
319  HRESULT res;
320  PVOID context;
321 
323  if (!context)
324  return ADV_HRESULT(GetLastError());
325 
326  ret = SetupInstallFromInfSectionW(NULL, info->hinf, info->install_sec,
327  SPINST_FILES, NULL, info->working_dir,
329  context, NULL, NULL);
330  if (!ret)
331  {
334 
335  return res;
336  }
337 
339 
340  ret = SetupInstallFromInfSectionW(NULL, info->hinf, info->install_sec,
343  NULL, NULL, NULL, NULL);
344  if (!ret)
345  return ADV_HRESULT(GetLastError());
346 
347  return S_OK;
348 }
#define SPINST_INIFILES
Definition: setupapi.h:584
#define SPINST_REGSVR
Definition: setupapi.h:589
Definition: http.c:6587
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define SP_COPY_NEWER
Definition: setupapi.h:473
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SPINST_REGISTRY
Definition: setupapi.h:585
smooth NULL
Definition: ftsmooth.c:416
#define SPINST_FILES
Definition: setupapi.h:587
LONG HRESULT
Definition: typedefs.h:77
BOOL WINAPI SetupInstallFromInfSectionW(HWND owner, HINF hinf, PCWSTR section, UINT flags, HKEY key_root, PCWSTR src_root, UINT copy_flags, PSP_FILE_CALLBACK_W callback, PVOID context, HDEVINFO devinfo, PSP_DEVINFO_DATA devinfo_data)
Definition: install.c:1324
int ret
UINT WINAPI SetupDefaultQueueCallbackW(PVOID context, UINT notification, UINT_PTR param1, UINT_PTR param2)
Definition: queue.c:1777
void WINAPI SetupTermDefaultQueueCallback(PVOID context)
Definition: queue.c:1704
PVOID WINAPI SetupInitDefaultQueueCallbackEx(HWND owner, HWND progress, UINT msg, DWORD reserved1, PVOID reserved2)
Definition: queue.c:1686
#define S_OK
Definition: intsafe.h:59
GLuint res
Definition: glext.h:9613
#define ADV_HRESULT(x)
Definition: install.c:43
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by DoInfInstallW(), ExecuteCabW(), LaunchINFSectionW(), and RunSetupCommandW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( advpack  )

Variable Documentation

◆ CheckAdminRights

const WCHAR CheckAdminRights[]
static
Initial value:
= {
'C','h','e','c','k','A','d','m','i','n','R','i','g','h','t','s',0
}

Definition at line 63 of file install.c.

Referenced by check_admin_rights().

◆ DelDirs

const WCHAR DelDirs[] = {'D','e','l','D','i','r','s',0}
static

Definition at line 66 of file install.c.

Referenced by adv_install().

◆ PerUserInstall

const WCHAR PerUserInstall[] = {'P','e','r','U','s','e','r','I','n','s','t','a','l','l',0}
static

Definition at line 67 of file install.c.

Referenced by adv_install().

◆ RegisterOCXs

const WCHAR RegisterOCXs[] = {'R','e','g','i','s','t','e','r','O','C','X','s',0}
static

Definition at line 68 of file install.c.

Referenced by adv_install().

◆ RunPostSetupCommands

const WCHAR RunPostSetupCommands[]
static
Initial value:
= {
'R','u','n','P','o','s','t','S','e','t','u','p','C','o','m','m','a','n','d','s',0
}

Definition at line 72 of file install.c.

Referenced by adv_install().

◆ RunPreSetupCommands

const WCHAR RunPreSetupCommands[]
static
Initial value:
= {
'R','u','n','P','r','e','S','e','t','u','p','C','o','m','m','a','n','d','s',0
}

Definition at line 69 of file install.c.

Referenced by adv_install().