ReactOS  0.4.13-dev-479-gec9c8fd
install.c File Reference
#include "setupapi_private.h"
#include <winsvc.h>
#include <ndk/cmfuncs.h>
Include dependency graph for install.c:

Go to the source code of this file.

Classes

struct  files_callback_info
 
struct  registry_callback_info
 
struct  register_dll_info
 
struct  needs_callback_info
 

Typedefs

typedef BOOL(* iterate_fields_func) (HINF hinf, PCWSTR field, void *arg)
 
typedef HRESULT(WINAPICOINITIALIZE) (IN LPVOID pvReserved)
 
typedef HRESULT(WINAPICOCREATEINSTANCE) (IN REFCLSID rclsid, IN LPUNKNOWN pUnkOuter, IN DWORD dwClsContext, IN REFIID riid, OUT LPVOID *ppv)
 
typedef HRESULT(WINAPICOUNINITIALIZE) (VOID)
 

Functions

static BOOL GetLineText (HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR *value)
 
static WCHARget_field_string (INFCONTEXT *context, DWORD index, WCHAR *buffer, WCHAR *static_buffer, DWORD *size)
 
static BOOL copy_files_callback (HINF hinf, PCWSTR field, void *arg)
 
static BOOL delete_files_callback (HINF hinf, PCWSTR field, void *arg)
 
static BOOL rename_files_callback (HINF hinf, PCWSTR field, void *arg)
 
static HKEY get_root_key (const WCHAR *name, HKEY def_root)
 
static void append_multi_sz_value (HKEY hkey, const WCHAR *value, const WCHAR *strings, DWORD str_size)
 
static void delete_multi_sz_value (HKEY hkey, const WCHAR *value, const WCHAR *string)
 
static BOOL do_reg_operation (HKEY hkey, const WCHAR *value, INFCONTEXT *context, INT flags)
 
static BOOL registry_callback (HINF hinf, PCWSTR field, void *arg)
 
static BOOL do_register_dll (const struct register_dll_info *info, const WCHAR *path, INT flags, INT timeout, const WCHAR *args)
 
static BOOL register_dlls_callback (HINF hinf, PCWSTR field, void *arg)
 
static BOOL update_ini_callback (HINF hinf, PCWSTR field, void *arg)
 
static BOOL update_ini_fields_callback (HINF hinf, PCWSTR field, void *arg)
 
static BOOL ini2reg_callback (HINF hinf, PCWSTR field, void *arg)
 
static BOOL logconf_callback (HINF hinf, PCWSTR field, void *arg)
 
static BOOL bitreg_callback (HINF hinf, PCWSTR field, void *arg)
 
static BOOL Concatenate (int DirId, LPCWSTR SubDirPart, LPCWSTR NamePart, LPWSTR *pFullName)
 
static BOOL profile_items_callback (IN HINF hInf, IN PCWSTR SectionName, IN PVOID Arg)
 
static BOOL copy_inf_callback (HINF hinf, PCWSTR field, void *arg)
 
static BOOL iterate_section_fields (HINF hinf, PCWSTR section, PCWSTR key, iterate_fields_func callback, void *arg)
 
BOOL WINAPI SetupInstallFilesFromInfSectionA (HINF hinf, HINF hlayout, HSPFILEQ queue, PCSTR section, PCSTR src_root, UINT flags)
 
BOOL WINAPI SetupInstallFilesFromInfSectionW (HINF hinf, HINF hlayout, HSPFILEQ queue, PCWSTR section, PCWSTR src_root, UINT flags)
 
BOOL WINAPI SetupInstallFromInfSectionA (HWND owner, HINF hinf, PCSTR section, UINT flags, HKEY key_root, PCSTR src_root, UINT copy_flags, PSP_FILE_CALLBACK_A callback, PVOID context, HDEVINFO devinfo, PSP_DEVINFO_DATA devinfo_data)
 
static BOOL include_callback (HINF hinf, PCWSTR field, void *arg)
 
static BOOL needs_callback (HINF hinf, PCWSTR field, void *arg)
 
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)
 
void WINAPI InstallHinfSectionW (HWND hwnd, HINSTANCE handle, LPCWSTR cmdline, INT show)
 
void WINAPI InstallHinfSectionA (HWND hwnd, HINSTANCE handle, LPCSTR cmdline, INT show)
 
BOOL WINAPI SetupInstallServicesFromInfSectionW (HINF Inf, PCWSTR SectionName, DWORD Flags)
 
BOOL WINAPI SetupInstallServicesFromInfSectionA (HINF Inf, PCSTR SectionName, DWORD Flags)
 
BOOL WINAPI SetupInstallServicesFromInfSectionExA (HINF hinf, PCSTR sectionname, DWORD flags, HDEVINFO devinfo, PSP_DEVINFO_DATA devinfo_data, PVOID reserved1, PVOID reserved2)
 
static BOOL GetIntField (HINF hinf, PCWSTR section_name, PCWSTR key_name, INT *value)
 
BOOL GetStringField (PINFCONTEXT context, DWORD index, PWSTR *value)
 
static VOID FixupServiceBinaryPath (IN DWORD ServiceType, IN OUT LPWSTR *ServiceBinary)
 
static BOOL InstallOneService (struct DeviceInfoSet *list, IN HINF hInf, IN LPCWSTR ServiceSection, IN LPCWSTR ServiceName, IN UINT ServiceFlags)
 
BOOL WINAPI SetupInstallServicesFromInfSectionExW (HINF hinf, PCWSTR sectionname, DWORD flags, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PVOID reserved1, PVOID reserved2)
 
BOOL WINAPI SetupCopyOEMInfA (IN PCSTR SourceInfFileName, IN PCSTR OEMSourceMediaLocation, IN DWORD OEMSourceMediaType, IN DWORD CopyStyle, OUT PSTR DestinationInfFileName OPTIONAL, IN DWORD DestinationInfFileNameSize, OUT PDWORD RequiredSize OPTIONAL, OUT PSTR *DestinationInfFileNameComponent OPTIONAL)
 
static int compare_files (HANDLE file1, HANDLE file2)
 
BOOL WINAPI SetupCopyOEMInfW (IN PCWSTR SourceInfFileName, IN PCWSTR OEMSourceMediaLocation, IN DWORD OEMSourceMediaType, IN DWORD CopyStyle, OUT PWSTR DestinationInfFileName OPTIONAL, IN DWORD DestinationInfFileNameSize, OUT PDWORD RequiredSize OPTIONAL, OUT PWSTR *DestinationInfFileNameComponent OPTIONAL)
 

Variables

static const WCHAR BackSlash [] = {'\\',0}
 
static const WCHAR GroupOrderListKey [] = {'S','Y','S','T','E','M','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','G','r','o','u','p','O','r','d','e','r','L','i','s','t',0}
 
static const WCHAR InfDirectory [] = {'i','n','f','\\',0}
 
static const WCHAR OemFileMask [] = {'o','e','m','*','.','i','n','f',0}
 
static const WCHAR OemFileSpecification [] = {'o','e','m','%','l','u','.','i','n','f',0}
 
static const WCHAR DotLnk [] = {'.','l','n','k',0}
 
static const WCHAR DotServices [] = {'.','S','e','r','v','i','c','e','s',0}
 
static const WCHAR DependenciesKey [] = {'D','e','p','e','n','d','e','n','c','i','e','s',0}
 
static const WCHAR DescriptionKey [] = {'D','e','s','c','r','i','p','t','i','o','n',0}
 
static const WCHAR DisplayNameKey [] = {'D','i','s','p','l','a','y','N','a','m','e',0}
 
static const WCHAR ErrorControlKey [] = {'E','r','r','o','r','C','o','n','t','r','o','l',0}
 
static const WCHAR LoadOrderGroupKey [] = {'L','o','a','d','O','r','d','e','r','G','r','o','u','p',0}
 
static const WCHAR SecurityKey [] = {'S','e','c','u','r','i','t','y',0}
 
static const WCHAR ServiceBinaryKey [] = {'S','e','r','v','i','c','e','B','i','n','a','r','y',0}
 
static const WCHAR ServiceTypeKey [] = {'S','e','r','v','i','c','e','T','y','p','e',0}
 
static const WCHAR StartTypeKey [] = {'S','t','a','r','t','T','y','p','e',0}
 
static const WCHAR Name [] = {'N','a','m','e',0}
 
static const WCHAR CmdLine [] = {'C','m','d','L','i','n','e',0}
 
static const WCHAR SubDir [] = {'S','u','b','D','i','r',0}
 
static const WCHAR WorkingDir [] = {'W','o','r','k','i','n','g','D','i','r',0}
 
static const WCHAR IconPath [] = {'I','c','o','n','P','a','t','h',0}
 
static const WCHAR IconIndex [] = {'I','c','o','n','I','n','d','e','x',0}
 
static const WCHAR HotKey [] = {'H','o','t','K','e','y',0}
 
static const WCHAR InfoTip [] = {'I','n','f','o','T','i','p',0}
 
static const WCHAR DisplayResource [] = {'D','i','s','p','l','a','y','R','e','s','o','u','r','c','e',0}
 
static const WCHAR AddService [] = {'A','d','d','S','e','r','v','i','c','e',0}
 
static const WCHAR CopyFiles [] = {'C','o','p','y','F','i','l','e','s',0}
 
static const WCHAR DelFiles [] = {'D','e','l','F','i','l','e','s',0}
 
static const WCHAR RenFiles [] = {'R','e','n','F','i','l','e','s',0}
 
static const WCHAR Ini2Reg [] = {'I','n','i','2','R','e','g',0}
 
static const WCHAR LogConf [] = {'L','o','g','C','o','n','f',0}
 
static const WCHAR AddReg [] = {'A','d','d','R','e','g',0}
 
static const WCHAR DelReg [] = {'D','e','l','R','e','g',0}
 
static const WCHAR BitReg [] = {'B','i','t','R','e','g',0}
 
static const WCHAR UpdateInis [] = {'U','p','d','a','t','e','I','n','i','s',0}
 
static const WCHAR CopyINF [] = {'C','o','p','y','I','N','F',0}
 
static const WCHAR UpdateIniFields [] = {'U','p','d','a','t','e','I','n','i','F','i','e','l','d','s',0}
 
static const WCHAR RegisterDlls [] = {'R','e','g','i','s','t','e','r','D','l','l','s',0}
 
static const WCHAR UnregisterDlls [] = {'U','n','r','e','g','i','s','t','e','r','D','l','l','s',0}
 
static const WCHAR ProfileItems [] = {'P','r','o','f','i','l','e','I','t','e','m','s',0}
 
static const WCHAR Include [] = {'I','n','c','l','u','d','e',0}
 
static const WCHAR Needs [] = {'N','e','e','d','s',0}
 
static const WCHAR DotSecurity [] = {'.','S','e','c','u','r','i','t','y',0}
 

Typedef Documentation

◆ COCREATEINSTANCE

typedef HRESULT(WINAPI * COCREATEINSTANCE) (IN REFCLSID rclsid, IN LPUNKNOWN pUnkOuter, IN DWORD dwClsContext, IN REFIID riid, OUT LPVOID *ppv)

Definition at line 101 of file install.c.

◆ COINITIALIZE

typedef HRESULT(WINAPI * COINITIALIZE) (IN LPVOID pvReserved)

Definition at line 100 of file install.c.

◆ COUNINITIALIZE

typedef HRESULT(WINAPI * COUNINITIALIZE) (VOID)

Definition at line 102 of file install.c.

◆ iterate_fields_func

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

Definition at line 98 of file install.c.

Function Documentation

◆ append_multi_sz_value()

static void append_multi_sz_value ( HKEY  hkey,
const WCHAR value,
const WCHAR strings,
DWORD  str_size 
)
static

Definition at line 222 of file install.c.

224 {
225  DWORD size, type, total;
226  WCHAR *buffer, *p;
227 
228  if (RegQueryValueExW( hkey, value, NULL, &type, NULL, &size )) return;
229  if (type != REG_MULTI_SZ) return;
230 
231  size = size + str_size * sizeof(WCHAR) ;
232  if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size))) return;
233  if (RegQueryValueExW( hkey, value, NULL, NULL, (BYTE *)buffer, &size )) goto done;
234 
235  /* compare each string against all the existing ones */
236  total = size;
237  while (*strings)
238  {
239  int len = strlenW(strings) + 1;
240 
241  for (p = buffer; *p; p += strlenW(p) + 1)
242  if (!strcmpiW( p, strings )) break;
243 
244  if (!*p) /* not found, need to append it */
245  {
246  memcpy( p, strings, len * sizeof(WCHAR) );
247  p[len] = 0;
248  total += len * sizeof(WCHAR);
249  }
250  strings += len;
251  }
252  if (total != size)
253  {
254  TRACE( "setting value %s to %s\n", debugstr_w(value), debugstr_w(buffer) );
255  RegSetValueExW( hkey, value, 0, REG_MULTI_SZ, (BYTE *)buffer, total + sizeof(WCHAR) );
256  }
257  done:
258  HeapFree( GetProcessHeap(), 0, buffer );
259 }
DWORD size
Definition: install.c:3631
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei const GLchar *const * strings
Definition: glext.h:7622
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
#define strcmpiW(s1, s2)
Definition: unicode.h:39
GLfloat GLfloat p
Definition: glext.h:8902
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by do_reg_operation().

◆ bitreg_callback()

static BOOL bitreg_callback ( HINF  hinf,
PCWSTR  field,
void arg 
)
static

Definition at line 831 of file install.c.

832 {
833  FIXME( "should do bitreg %s\n", debugstr_w(field) );
834  return TRUE;
835 }
#define TRUE
Definition: types.h:120
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: parser.c:43

Referenced by SetupInstallFromInfSectionW().

◆ compare_files()

static int compare_files ( HANDLE  file1,
HANDLE  file2 
)
static

Definition at line 2270 of file install.c.

2271 {
2272  char buffer1[2048];
2273  char buffer2[2048];
2274  DWORD size1;
2275  DWORD size2;
2276 
2277  while( ReadFile(file1, buffer1, sizeof(buffer1), &size1, NULL) &&
2278  ReadFile(file2, buffer2, sizeof(buffer2), &size2, NULL) )
2279  {
2280  int ret;
2281  if (size1 != size2)
2282  return size1 > size2 ? 1 : -1;
2283  if (!size1)
2284  return 0;
2285  ret = memcmp( buffer1, buffer2, size1 );
2286  if (ret)
2287  return ret;
2288  }
2289 
2290  return 0;
2291 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123

Referenced by find_hash(), and SetupCopyOEMInfW().

◆ Concatenate()

static BOOL Concatenate ( int  DirId,
LPCWSTR  SubDirPart,
LPCWSTR  NamePart,
LPWSTR pFullName 
)
static

Definition at line 837 of file install.c.

838 {
839  DWORD dwRequired = 0;
840  LPCWSTR Dir;
842 
843  *pFullName = NULL;
844 
845  Dir = DIRID_get_string(DirId);
846  if (Dir)
847  dwRequired += wcslen(Dir) + 1;
848  if (SubDirPart)
849  dwRequired += wcslen(SubDirPart) + 1;
850  if (NamePart)
851  dwRequired += wcslen(NamePart);
852  dwRequired = dwRequired * sizeof(WCHAR) + sizeof(UNICODE_NULL);
853 
854  FullName = MyMalloc(dwRequired);
855  if (!FullName)
856  {
858  return FALSE;
859  }
860  FullName[0] = UNICODE_NULL;
861 
862  if (Dir)
863  {
864  wcscat(FullName, Dir);
865  if (FullName[wcslen(FullName) - 1] != '\\')
867  }
868  if (SubDirPart)
869  {
870  wcscat(FullName, SubDirPart);
871  if (FullName[wcslen(FullName) - 1] != '\\')
873  }
874  if (NamePart)
875  wcscat(FullName, NamePart);
876 
877  *pFullName = FullName;
878  return TRUE;
879 }
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PSTRING FullName
Definition: rtlfuncs.h:1649
#define SetLastError(x)
Definition: compat.h:409
static const WCHAR BackSlash[]
Definition: install.c:28
const WCHAR * DIRID_get_string(int dirid)
Definition: dirid.c:159
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by profile_items_callback().

◆ copy_files_callback()

static BOOL copy_files_callback ( HINF  hinf,
PCWSTR  field,
void arg 
)
static

Definition at line 157 of file install.c.

158 {
159  struct files_callback_info *info = arg;
160 
161  if (field[0] == '@') /* special case: copy single file */
162  SetupQueueDefaultCopyW( info->queue, info->layout ? info->layout : hinf, info->src_root, NULL, field+1, info->copy_flags );
163  else
164  SetupQueueCopySectionW( info->queue, info->src_root, info->layout ? info->layout : hinf, hinf, field, info->copy_flags );
165  return TRUE;
166 }
#define TRUE
Definition: types.h:120
BOOL WINAPI SetupQueueCopySectionW(HSPFILEQ queue, PCWSTR src_root, HINF hinf, HINF hlist, PCWSTR section, DWORD style)
Definition: queue.c:820
void * arg
Definition: msvc.h:12
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:43
BOOL WINAPI SetupQueueDefaultCopyW(HSPFILEQ queue, HINF hinf, PCWSTR src_root, PCWSTR src_file, PCWSTR dst_file, DWORD style)
Definition: queue.c:671

Referenced by SetupInstallFilesFromInfSectionW(), and SetupInstallFromInfSectionW().

◆ copy_inf_callback()

static BOOL copy_inf_callback ( HINF  hinf,
PCWSTR  field,
void arg 
)
static

Definition at line 1155 of file install.c.

1156 {
1157  FIXME( "should do copy inf %s\n", debugstr_w(field) );
1158  return TRUE;
1159 }
#define TRUE
Definition: types.h:120
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: parser.c:43

Referenced by SetupInstallFromInfSectionW().

◆ delete_files_callback()

static BOOL delete_files_callback ( HINF  hinf,
PCWSTR  field,
void arg 
)
static

Definition at line 174 of file install.c.

175 {
176  struct files_callback_info *info = arg;
177  SetupQueueDeleteSectionW( info->queue, hinf, 0, field );
178  return TRUE;
179 }
#define TRUE
Definition: types.h:120
void * arg
Definition: msvc.h:12
BOOL WINAPI SetupQueueDeleteSectionW(HSPFILEQ queue, HINF hinf, HINF hlist, PCWSTR section)
Definition: queue.c:918
Definition: parser.c:43

Referenced by SetupInstallFromInfSectionW().

◆ delete_multi_sz_value()

static void delete_multi_sz_value ( HKEY  hkey,
const WCHAR value,
const WCHAR string 
)
static

Definition at line 267 of file install.c.

268 {
269  DWORD size, type;
270  WCHAR *buffer, *src, *dst;
271 
272  if (RegQueryValueExW( hkey, value, NULL, &type, NULL, &size )) return;
273  if (type != REG_MULTI_SZ) return;
274  /* allocate double the size, one for value before and one for after */
275  if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size * 2))) return;
276  if (RegQueryValueExW( hkey, value, NULL, NULL, (BYTE *)buffer, &size )) goto done;
277  src = buffer;
278  dst = buffer + size;
279  while (*src)
280  {
281  int len = strlenW(src) + 1;
282  if (strcmpiW( src, string ))
283  {
284  memcpy( dst, src, len * sizeof(WCHAR) );
285  dst += len;
286  }
287  src += len;
288  }
289  *dst++ = 0;
290  if (dst != buffer + 2*size) /* did we remove something? */
291  {
292  TRACE( "setting value %s to %s\n", debugstr_w(value), debugstr_w(buffer + size) );
293  RegSetValueExW( hkey, value, 0, REG_MULTI_SZ,
294  (BYTE *)(buffer + size), dst - (buffer + size) );
295  }
296  done:
297  HeapFree( GetProcessHeap(), 0, buffer );
298 }
DWORD size
Definition: install.c:3631
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
#define strcmpiW(s1, s2)
Definition: unicode.h:39
GLenum GLenum dst
Definition: glext.h:6340
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by do_reg_operation().

◆ do_reg_operation()

static BOOL do_reg_operation ( HKEY  hkey,
const WCHAR value,
INFCONTEXT context,
INT  flags 
)
static

Definition at line 306 of file install.c.

307 {
308  DWORD type, size;
309 
310  if (flags & (FLG_ADDREG_DELREG_BIT | FLG_ADDREG_DELVAL)) /* deletion */
311  {
313  {
314  if ((flags & FLG_DELREG_MULTI_SZ_DELSTRING) == FLG_DELREG_MULTI_SZ_DELSTRING)
315  {
316  WCHAR *str;
317 
318  if (!SetupGetStringFieldW( context, 5, NULL, 0, &size ) || !size) return TRUE;
319  if (!(str = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) return FALSE;
321  delete_multi_sz_value( hkey, value, str );
322  HeapFree( GetProcessHeap(), 0, str );
323  }
324  else RegDeleteValueW( hkey, value );
325  }
326  else NtDeleteKey( hkey );
327  return TRUE;
328  }
329 
331 
333  {
334  BOOL exists = !RegQueryValueExW( hkey, value, NULL, NULL, NULL, NULL );
335  if (exists && (flags & FLG_ADDREG_NOCLOBBER)) return TRUE;
336  if (!exists && (flags & FLG_ADDREG_OVERWRITEONLY)) return TRUE;
337  }
338 
339  switch(flags & FLG_ADDREG_TYPE_MASK)
340  {
341  case FLG_ADDREG_TYPE_SZ: type = REG_SZ; break;
344  case FLG_ADDREG_TYPE_BINARY: type = REG_BINARY; break;
345  case FLG_ADDREG_TYPE_DWORD: type = REG_DWORD; break;
346  case FLG_ADDREG_TYPE_NONE: type = REG_NONE; break;
347  default: type = flags >> 16; break;
348  }
349 
350  if (!(flags & FLG_ADDREG_BINVALUETYPE) ||
352  {
353  static const WCHAR empty;
354  WCHAR *str = NULL;
355 
356  if (type == REG_MULTI_SZ)
357  {
358  if (!SetupGetMultiSzFieldW( context, 5, NULL, 0, &size )) size = 0;
359  if (size)
360  {
361  if (!(str = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) return FALSE;
363  }
364  if (flags & FLG_ADDREG_APPEND)
365  {
366  if (!str) return TRUE;
367  append_multi_sz_value( hkey, value, str, size );
368  HeapFree( GetProcessHeap(), 0, str );
369  return TRUE;
370  }
371  /* else fall through to normal string handling */
372  }
373  else
374  {
375  if (!SetupGetStringFieldW( context, 5, NULL, 0, &size )) size = 0;
376  if (size)
377  {
378  if (!(str = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) return FALSE;
380  }
381  }
382 
383  if (type == REG_DWORD)
384  {
385  DWORD dw = str ? strtoulW( str, NULL, 0 ) : 0;
386  TRACE( "setting dword %s to %x\n", debugstr_w(value), dw );
387  RegSetValueExW( hkey, value, 0, type, (BYTE *)&dw, sizeof(dw) );
388  }
389  else
390  {
391  TRACE( "setting value %s to %s\n", debugstr_w(value), debugstr_w(str) );
392  if (str) RegSetValueExW( hkey, value, 0, type, (BYTE *)str, size * sizeof(WCHAR) );
393  else RegSetValueExW( hkey, value, 0, type, (const BYTE *)&empty, sizeof(WCHAR) );
394  }
395  HeapFree( GetProcessHeap(), 0, str );
396  return TRUE;
397  }
398  else /* get the binary data */
399  {
400  BYTE *data = NULL;
401 
402  if (!SetupGetBinaryField( context, 5, NULL, 0, &size )) size = 0;
403  if (size)
404  {
405  if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return FALSE;
406  TRACE( "setting binary data %s len %d\n", debugstr_w(value), size );
408  }
409  RegSetValueExW( hkey, value, 0, type, data, size );
410  HeapFree( GetProcessHeap(), 0, data );
411  return TRUE;
412  }
413 }
DWORD size
Definition: install.c:3631
#define FLG_ADDREG_APPEND
Definition: registry.c:46
#define FLG_ADDREG_OVERWRITEONLY
Definition: registry.c:48
#define TRUE
Definition: types.h:120
#define FLG_ADDREG_TYPE_SZ
Definition: registry.c:49
#define FLG_ADDREG_NOCLOBBER
Definition: registry.c:44
Definition: http.c:6587
#define REG_BINARY
Definition: nt_native.h:1496
static const WCHAR empty[]
Definition: main.c:49
#define FLG_ADDREG_KEYONLY
Definition: registry.c:47
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FLG_ADDREG_DELVAL
Definition: registry.c:45
#define FLG_ADDREG_TYPE_MASK
Definition: registry.c:55
#define FLG_ADDREG_KEYONLY_COMMON
Definition: reginf.c:43
#define FLG_DELREG_KEYONLY_COMMON
Definition: reginf.c:44
#define FLG_ADDREG_TYPE_DWORD
Definition: registry.c:53
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI SetupGetBinaryField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PUCHAR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:126
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define debugstr_w
Definition: kernel32.h:32
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
static void append_multi_sz_value(HKEY hkey, const WCHAR *value, const WCHAR *strings, DWORD str_size)
Definition: install.c:222
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define TRACE(s)
Definition: solgame.cpp:4
#define FLG_ADDREG_TYPE_BINARY
Definition: registry.c:52
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID LPVOID DWORD dw
Definition: atlbase.h:40
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
ULONG WINAPI SetupGetFieldCount(IN PINFCONTEXT Context)
Definition: infsupp.c:91
#define FLG_ADDREG_BINVALUETYPE
Definition: registry.c:43
unsigned char BYTE
Definition: mem.h:68
NTSTATUS NTAPI NtDeleteKey(IN HANDLE KeyHandle)
Definition: ntapi.c:408
BOOL WINAPI SetupGetMultiSzFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:162
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2355
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define FLG_ADDREG_DELREG_BIT
Definition: reginf.c:45
static void delete_multi_sz_value(HKEY hkey, const WCHAR *value, const WCHAR *string)
Definition: install.c:267
#define FLG_ADDREG_TYPE_EXPAND_SZ
Definition: registry.c:51
#define strtoulW(s1, s2, b)
Definition: unicode.h:41
#define REG_NONE
Definition: nt_native.h:1492
#define REG_DWORD
Definition: sdbapi.c:596
#define HeapFree(x, y, z)
Definition: compat.h:394
#define FLG_ADDREG_TYPE_NONE
Definition: registry.c:54
#define FLG_ADDREG_TYPE_MULTI_SZ
Definition: registry.c:50
#define REG_SZ
Definition: layer.c:22
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:184

Referenced by registry_callback().

◆ do_register_dll()

static BOOL do_register_dll ( const struct register_dll_info info,
const WCHAR path,
INT  flags,
INT  timeout,
const WCHAR args 
)
static

Definition at line 529 of file install.c.

531 {
532  HMODULE module;
533  HRESULT res;
535 #ifdef __WINESRC__
537 #endif
538 
539  status.cbSize = sizeof(status);
540  status.FileName = path;
541  status.FailureCode = SPREG_SUCCESS;
542  status.Win32Error = ERROR_SUCCESS;
543 
544  if (info->callback)
545  {
546  switch(info->callback( info->callback_context, SPFILENOTIFY_STARTREGISTRATION,
547  (UINT_PTR)&status, !info->unregister ))
548  {
549  case FILEOP_ABORT:
551  return FALSE;
552  case FILEOP_SKIP:
553  return TRUE;
554  case FILEOP_DOIT:
555  break;
556  }
557  }
558 
560  {
561  WARN( "could not load %s\n", debugstr_w(path) );
562  status.FailureCode = SPREG_LOADLIBRARY;
563  status.Win32Error = GetLastError();
564  goto done;
565  }
566 
567 #ifdef __WINESRC__
569  {
570  /* file is an executable, not a dll */
573  WCHAR *cmd_line;
574  BOOL res;
575  static const WCHAR format[] = {'"','%','s','"',' ','%','s',0};
576  static const WCHAR default_args[] = {'/','R','e','g','S','e','r','v','e','r',0};
577 
578  FreeLibrary( module );
579  module = NULL;
580  if (!args) args = default_args;
581  cmd_line = HeapAlloc( GetProcessHeap(), 0, (strlenW(path) + strlenW(args) + 4) * sizeof(WCHAR) );
582  sprintfW( cmd_line, format, path, args );
583  memset( &startup, 0, sizeof(startup) );
584  startup.cb = sizeof(startup);
585  TRACE( "executing %s\n", debugstr_w(cmd_line) );
586  res = CreateProcessW( NULL, cmd_line, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info );
587  HeapFree( GetProcessHeap(), 0, cmd_line );
588  if (!res)
589  {
590  status.FailureCode = SPREG_LOADLIBRARY;
591  status.Win32Error = GetLastError();
592  goto done;
593  }
594  CloseHandle( info.hThread );
595 
596  if (WaitForSingleObject( info.hProcess, timeout*1000 ) == WAIT_TIMEOUT)
597  {
598  /* timed out, kill the process */
599  TerminateProcess( info.hProcess, 1 );
600  status.FailureCode = SPREG_TIMEOUT;
601  status.Win32Error = ERROR_TIMEOUT;
602  }
603  CloseHandle( info.hProcess );
604  goto done;
605  }
606 #endif // __WINESRC__
607 
609  {
610  const char *entry_point = info->unregister ? "DllUnregisterServer" : "DllRegisterServer";
611  HRESULT (WINAPI *func)(void) = (void *)GetProcAddress( module, entry_point );
612 
613  if (!func)
614  {
615  status.FailureCode = SPREG_GETPROCADDR;
616  status.Win32Error = GetLastError();
617  goto done;
618  }
619 
620  TRACE( "calling %s in %s\n", entry_point, debugstr_w(path) );
621  res = func();
622 
623  if (FAILED(res))
624  {
625  WARN( "calling %s in %s returned error %x\n", entry_point, debugstr_w(path), res );
626  status.FailureCode = SPREG_REGSVR;
627  status.Win32Error = res;
628  goto done;
629  }
630  }
631 
633  {
634  HRESULT (WINAPI *func)(BOOL,LPCWSTR) = (void *)GetProcAddress( module, "DllInstall" );
635 
636  if (!func)
637  {
638  status.FailureCode = SPREG_GETPROCADDR;
639  status.Win32Error = GetLastError();
640  goto done;
641  }
642 
643  TRACE( "calling DllInstall(%d,%s) in %s\n",
644  !info->unregister, debugstr_w(args), debugstr_w(path) );
645  res = func( !info->unregister, args );
646 
647  if (FAILED(res))
648  {
649  WARN( "calling DllInstall in %s returned error %x\n", debugstr_w(path), res );
650  status.FailureCode = SPREG_REGSVR;
651  status.Win32Error = res;
652  goto done;
653  }
654  }
655 
656 done:
657  if (module) FreeLibrary( module );
658  if (info->callback) info->callback( info->callback_context, SPFILENOTIFY_ENDREGISTRATION,
659  (UINT_PTR)&status, !info->unregister );
660  return TRUE;
661 }
GLenum func
Definition: glext.h:6028
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
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
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define FLG_REGSVR_DLLINSTALL
Definition: setupapi.h:403
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define SPFILENOTIFY_STARTREGISTRATION
Definition: setupapi.h:565
GLsizei const GLchar ** path
Definition: glext.h:7234
#define ERROR_TIMEOUT
Definition: winerror.h:941
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:286
#define WARN(fmt,...)
Definition: debug.h:111
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int startup(int argc, const char *argv[])
Definition: startup.c:430
#define SPREG_GETPROCADDR
Definition: setupapi.h:649
Definition: dhcpd.h:245
#define LOAD_WITH_ALTERED_SEARCH_PATH
Definition: winbase.h:339
static HRESULT(WINAPI *pRunSetupCommand)(HWND
Definition: match.c:390
IMAGE_NT_HEADERS nt
Definition: module.c:50
#define IMAGE_FILE_DLL
Definition: pedump.c:169
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define FILEOP_ABORT
Definition: fileqsup.h:47
#define ERROR_OPERATION_ABORTED
Definition: winerror.h:575
struct _test_info info[]
Definition: SetCursorPos.c:19
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL(WINAPI *pCheckTokenMembership)(HANDLE
#define FLG_REGSVR_DLLREGISTER
Definition: setupapi.h:402
#define debugstr_w
Definition: kernel32.h:32
#define SPREG_REGSVR
Definition: setupapi.h:650
smooth NULL
Definition: ftsmooth.c:416
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
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:4623
#define FILEOP_DOIT
Definition: fileqsup.h:48
#define TRACE(s)
Definition: solgame.cpp:4
#define FreeLibrary(x)
Definition: compat.h:405
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define WINAPI
Definition: msvc.h:8
#define SetLastError(x)
Definition: compat.h:409
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
GLbitfield flags
Definition: glext.h:7161
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define SPFILENOTIFY_ENDREGISTRATION
Definition: setupapi.h:566
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1562
#define FILEOP_SKIP
Definition: fileqsup.h:49
Definition: services.c:325
#define sprintfW
Definition: unicode.h:58
#define RtlImageNtHeader
Definition: compat.h:457
GLuint res
Definition: glext.h:9613
#define GetProcAddress(x, y)
Definition: compat.h:410
#define SPREG_TIMEOUT
Definition: setupapi.h:652
#define SPREG_LOADLIBRARY
Definition: setupapi.h:648
#define memset(x, y, z)
Definition: compat.h:39
static SERVICE_STATUS status
Definition: service.c:31
#define SPREG_SUCCESS
Definition: setupapi.h:647
#define HeapFree(x, y, z)
Definition: compat.h:394
Definition: ps.c:97

Referenced by register_dlls_callback().

◆ FixupServiceBinaryPath()

static VOID FixupServiceBinaryPath ( IN DWORD  ServiceType,
IN OUT LPWSTR ServiceBinary 
)
static

Definition at line 1731 of file install.c.

1734 {
1735  LPWSTR Buffer;
1736  WCHAR ReactOSDir[MAX_PATH];
1737  DWORD RosDirLength, ServiceLength, Win32Length;
1738 
1739  GetWindowsDirectoryW(ReactOSDir, MAX_PATH);
1740  RosDirLength = strlenW(ReactOSDir);
1741  ServiceLength = strlenW(*ServiceBinary);
1742 
1743  /* Check and fix two things:
1744  1. Get rid of C:\ReactOS and use relative
1745  path instead.
1746  2. Add %SystemRoot% for Win32 services */
1747 
1748  if (ServiceLength < RosDirLength)
1749  return;
1750 
1751  if (!wcsnicmp(*ServiceBinary, ReactOSDir, RosDirLength))
1752  {
1753  /* Yes, the first part is the C:\ReactOS\, just skip it */
1754  MoveMemory(*ServiceBinary, *ServiceBinary + RosDirLength + 1,
1755  (ServiceLength - RosDirLength) * sizeof(WCHAR));
1756 
1757  /* Handle Win32-services differently */
1758  if (ServiceType & SERVICE_WIN32)
1759  {
1760  Win32Length = (ServiceLength - RosDirLength) * sizeof(WCHAR)
1761  - sizeof(L'\\') + sizeof(L"%SystemRoot%\\");
1762  Buffer = MyMalloc(Win32Length);
1763 
1764  wcscpy(Buffer, L"%SystemRoot%\\");
1765  wcscat(Buffer, *ServiceBinary);
1766  MyFree(*ServiceBinary);
1767 
1768  *ServiceBinary = Buffer;
1769  }
1770  }
1771 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define MoveMemory
Definition: winbase.h:1632
_Check_return_ _CRTIMP int __cdecl wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define SERVICE_WIN32
Definition: cmtypes.h:962
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
WCHAR * LPWSTR
Definition: xmlstorage.h:184
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128

Referenced by InstallOneService().

◆ get_field_string()

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

Definition at line 133 of file install.c.

135 {
136  DWORD required;
137 
138  if (SetupGetStringFieldW( context, index, buffer, *size, &required )) return buffer;
140  {
141  /* now grow the buffer */
142  if (buffer != static_buffer) HeapFree( GetProcessHeap(), 0, buffer );
143  if (!(buffer = HeapAlloc( GetProcessHeap(), 0, required*sizeof(WCHAR) ))) return NULL;
144  *size = required;
145  if (SetupGetStringFieldW( context, index, buffer, *size, &required )) return buffer;
146  }
147  if (buffer != static_buffer) HeapFree( GetProcessHeap(), 0, buffer );
148  return NULL;
149 }
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:395
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:394
#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_root_key()

static HKEY get_root_key ( const WCHAR name,
HKEY  def_root 
)
static

Definition at line 200 of file install.c.

201 {
202  static const WCHAR HKCR[] = {'H','K','C','R',0};
203  static const WCHAR HKCU[] = {'H','K','C','U',0};
204  static const WCHAR HKLM[] = {'H','K','L','M',0};
205  static const WCHAR HKU[] = {'H','K','U',0};
206  static const WCHAR HKR[] = {'H','K','R',0};
207 
208  if (!strcmpiW( name, HKCR )) return HKEY_CLASSES_ROOT;
209  if (!strcmpiW( name, HKCU )) return HKEY_CURRENT_USER;
210  if (!strcmpiW( name, HKLM )) return HKEY_LOCAL_MACHINE;
211  if (!strcmpiW( name, HKU )) return HKEY_USERS;
212  if (!strcmpiW( name, HKR )) return def_root;
213  return 0;
214 }
#define HKEY_USERS
Definition: winreg.h:13
static const WCHAR HKCR[]
Definition: reginf.c:56
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static const WCHAR HKU[]
Definition: reginf.c:59
static const WCHAR HKLM[]
Definition: reginf.c:58
static const WCHAR HKR[]
Definition: reginf.c:60
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define strcmpiW(s1, s2)
Definition: unicode.h:39
static const WCHAR HKCU[]
Definition: reginf.c:57
Definition: name.c:36
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by registry_callback().

◆ GetIntField()

static BOOL GetIntField ( HINF  hinf,
PCWSTR  section_name,
PCWSTR  key_name,
INT value 
)
static

Definition at line 1672 of file install.c.

1673 {
1674  LPWSTR buffer, end;
1675  INT res;
1676 
1677  if (! GetLineText( hinf, section_name, key_name, &buffer ) )
1678  return FALSE;
1679 
1680  res = wcstol( buffer, &end, 0 );
1681  if (end != buffer && !*end)
1682  {
1684  *value = res;
1685  return TRUE;
1686  }
1687  else
1688  {
1691  return FALSE;
1692  }
1693 }
#define TRUE
Definition: types.h:120
GLuint buffer
Definition: glext.h:5915
GLuint GLuint end
Definition: gl.h:1545
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
int32_t INT
Definition: typedefs.h:56
#define GetProcessHeap()
Definition: compat.h:395
#define SetLastError(x)
Definition: compat.h:409
static BOOL GetLineText(HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR *value)
Definition: install.c:1643
#define ERROR_INVALID_DATA
Definition: winerror.h:116
GLuint res
Definition: glext.h:9613
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by InstallOneService().

◆ GetLineText()

static BOOL GetLineText ( HINF  hinf,
PCWSTR  section_name,
PCWSTR  key_name,
PWSTR value 
)
static

Definition at line 1643 of file install.c.

1644 {
1645  DWORD required;
1646  PWSTR buf = NULL;
1647 
1648  *value = NULL;
1649 
1650  if (! SetupGetLineTextW( NULL, hinf, section_name, key_name, NULL, 0, &required )
1652  return FALSE;
1653 
1654  buf = HeapAlloc( GetProcessHeap(), 0, required * sizeof(WCHAR) );
1655  if ( ! buf )
1656  {
1658  return FALSE;
1659  }
1660 
1661  if (! SetupGetLineTextW( NULL, hinf, section_name, key_name, buf, required, &required ) )
1662  {
1663  HeapFree( GetProcessHeap(), 0, buf );
1664  return FALSE;
1665  }
1666 
1667  *value = buf;
1668  return TRUE;
1669 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
uint16_t * PWSTR
Definition: typedefs.h:54
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
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 GetIntField(), InstallOneService(), and profile_items_callback().

◆ GetStringField()

BOOL GetStringField ( PINFCONTEXT  context,
DWORD  index,
PWSTR value 
)

Definition at line 1696 of file install.c.

1697 {
1699  BOOL ret;
1700 
1702  context,
1703  index,
1704  NULL, 0,
1705  &RequiredSize);
1706  if (!ret)
1707  return FALSE;
1708  else if (RequiredSize == 0)
1709  {
1710  *value = NULL;
1711  return TRUE;
1712  }
1713 
1714  /* We got the needed size for the buffer */
1715  *value = MyMalloc(RequiredSize * sizeof(WCHAR));
1716  if (!*value)
1717  {
1719  return FALSE;
1720  }
1722  context,
1723  index,
1724  *value, RequiredSize, NULL);
1725  if (!ret)
1726  MyFree(*value);
1727 
1728  return ret;
1729 }
#define TRUE
Definition: types.h:120
Definition: http.c:6587
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:184

Referenced by profile_items_callback(), SetupDiInstallDeviceInterfaces(), and SetupInstallServicesFromInfSectionExW().

◆ include_callback()

static BOOL include_callback ( HINF  hinf,
PCWSTR  field,
void arg 
)
static

Definition at line 1289 of file install.c.

1290 {
1291  return SetupOpenAppendInfFileW( field, hinf, NULL );
1292 }
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:43
BOOL WINAPI SetupOpenAppendInfFileW(PCWSTR name, HINF parent_hinf, UINT *error)
Definition: parser.c:1346

Referenced by SetupInstallFromInfSectionW(), and SetupInstallServicesFromInfSectionExW().

◆ ini2reg_callback()

static BOOL ini2reg_callback ( HINF  hinf,
PCWSTR  field,
void arg 
)
static

Definition at line 819 of file install.c.

820 {
821  FIXME( "should do ini2reg %s\n", debugstr_w(field) );
822  return TRUE;
823 }
#define TRUE
Definition: types.h:120
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: parser.c:43

Referenced by SetupInstallFromInfSectionW().

◆ InstallHinfSectionA()

void WINAPI InstallHinfSectionA ( HWND  hwnd,
HINSTANCE  handle,
LPCSTR  cmdline,
INT  show 
)

Definition at line 1594 of file install.c.

1595 {
1596  UNICODE_STRING cmdlineW;
1597 
1598  if (RtlCreateUnicodeStringFromAsciiz( &cmdlineW, cmdline ))
1599  {
1600  InstallHinfSectionW( hwnd, handle, cmdlineW.Buffer, show );
1601  RtlFreeUnicodeString( &cmdlineW );
1602  }
1603 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
TCHAR * cmdline
Definition: stretchblt.cpp:32
void WINAPI InstallHinfSectionW(HWND hwnd, HINSTANCE handle, LPCWSTR cmdline, INT show)
Definition: install.c:1461
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)

◆ InstallHinfSectionW()

void WINAPI InstallHinfSectionW ( HWND  hwnd,
HINSTANCE  handle,
LPCWSTR  cmdline,
INT  show 
)

Definition at line 1461 of file install.c.

1462 {
1463  BOOL ret = FALSE;
1464  WCHAR *s, *path, section[MAX_PATH];
1465  void *callback_context = NULL;
1466  DWORD SectionNameLength;
1467  UINT mode;
1468  HINF hinf = INVALID_HANDLE_VALUE;
1469  BOOL bRebootRequired = FALSE;
1470 
1471  TRACE("hwnd %p, handle %p, cmdline %s\n", hwnd, handle, debugstr_w(cmdline));
1472 
1474 
1475  if (!(s = strchrW( section, ' ' ))) goto cleanup;
1476  *s++ = 0;
1477  while (*s == ' ') s++;
1478  mode = atoiW( s );
1479 
1480  /* quoted paths are not allowed on native, the rest of the command line is taken as the path */
1481  if (!(s = strchrW( s, ' ' ))) goto cleanup;
1482  while (*s == ' ') s++;
1483  path = s;
1484 
1485  if (mode & 0x80)
1486  {
1487  FIXME("default path of the installation not changed\n");
1488  mode &= ~0x80;
1489  }
1490 
1492  if (hinf == INVALID_HANDLE_VALUE)
1493  {
1494  WARN("SetupOpenInfFileW(%s) failed (Error %u)\n", path, GetLastError());
1495  goto cleanup;
1496  }
1497 
1499  hinf, section, section, sizeof(section)/sizeof(section[0]), &SectionNameLength, NULL );
1500  if (!ret)
1501  {
1502  WARN("SetupDiGetActualSectionToInstallW() failed (Error %u)\n", GetLastError());
1503  goto cleanup;
1504  }
1505  if (SectionNameLength > MAX_PATH - strlenW(DotServices))
1506  {
1507  WARN("Section name '%s' too long\n", section);
1508  goto cleanup;
1509  }
1510 
1511  /* Copy files and add registry entries */
1516  NULL, NULL );
1517  if (!ret)
1518  {
1519  WARN("SetupInstallFromInfSectionW() failed (Error %u)\n", GetLastError());
1520  goto cleanup;
1521  }
1522  /* FIXME: need to check if some files were in use and need reboot
1523  * bReboot = ...;
1524  */
1525 
1526  /* Install services */
1530  ret = TRUE;
1531  if (!ret)
1532  {
1533  WARN("SetupInstallServicesFromInfSectionW() failed (Error %u)\n", GetLastError());
1534  goto cleanup;
1535  }
1537  {
1538  bRebootRequired = TRUE;
1539  }
1540 
1541  /* Check if we need to reboot */
1542  switch (mode)
1543  {
1544  case 0:
1545  /* Never reboot */
1546  break;
1547  case 1:
1548  /* Always reboot */
1549  ExitWindowsEx(EWX_REBOOT, SHTDN_REASON_MAJOR_APPLICATION |
1550  SHTDN_REASON_MINOR_INSTALLATION | SHTDN_REASON_FLAG_PLANNED);
1551  break;
1552  case 2:
1553  /* Query user before rebooting */
1555  break;
1556  case 3:
1557  /* Reboot if necessary */
1558  if (bRebootRequired)
1559  {
1560  ExitWindowsEx(EWX_REBOOT, SHTDN_REASON_MAJOR_APPLICATION |
1561  SHTDN_REASON_MINOR_INSTALLATION | SHTDN_REASON_FLAG_PLANNED);
1562  }
1563  break;
1564  case 4:
1565  /* If necessary, query user before rebooting */
1566  if (bRebootRequired)
1567  {
1569  }
1570  break;
1571  default:
1572  break;
1573  }
1574 
1575 cleanup:
1576  if ( callback_context )
1578  if ( hinf != INVALID_HANDLE_VALUE )
1579  SetupCloseInfFile( hinf );
1580 
1581 #ifdef CORE_11689_IS_FIXED
1582  // TODO: Localize the error string.
1584  {
1585  MessageBoxW(hwnd, section, L"setupapi.dll: An error happened...", MB_ICONERROR | MB_OK);
1586  }
1587 #endif
1588 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI SetupDiGetActualSectionToInstallW(HINF InfHandle, PCWSTR InfSectionName, PWSTR InfSectionWithExt, DWORD InfSectionWithExtSize, PDWORD RequiredSize, PWSTR *Extension)
Definition: devinst.c:1985
#define ERROR_SECTION_NOT_FOUND
Definition: setupapi.h:288
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define INF_STYLE_WIN4
Definition: infsupp.h:41
GLsizei const GLchar ** path
Definition: glext.h:7234
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define WARN(fmt,...)
Definition: debug.h:111
#define ERROR_SUCCESS_REBOOT_REQUIRED
Definition: winerror.h:1215
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
TCHAR * cmdline
Definition: stretchblt.cpp:32
Definition: parser.c:55
#define EWX_REBOOT
Definition: winuser.h:633
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43
#define lstrcpynW
Definition: compat.h:397
#define SP_COPY_IN_USE_NEEDS_REBOOT
Definition: setupapi.h:480
#define PSPGF_NONINTERACTIVE
#define SP_COPY_NEWER
Definition: setupapi.h:473
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
INT WINAPI SetupPromptReboot(HSPFILEQ file_queue, HWND owner, BOOL scan_only)
Definition: stubs.c:35
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
static const WCHAR DotServices[]
Definition: install.c:34
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
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:1323
int ret
static const WCHAR L[]
Definition: oid.c:1250
UINT WINAPI SetupDefaultQueueCallbackW(PVOID context, UINT notification, UINT_PTR param1, UINT_PTR param2)
Definition: queue.c:1777
#define MB_ICONERROR
Definition: winuser.h:781
void WINAPI SetupTermDefaultQueueCallback(PVOID context)
Definition: queue.c:1704
GLdouble s
Definition: gl.h:2039
#define SPINST_ALL
Definition: setupapi.h:596
GLenum mode
Definition: glext.h:6217
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
BOOL WINAPI SetupInstallServicesFromInfSectionW(HINF Inf, PCWSTR SectionName, DWORD Flags)
Definition: install.c:1608
PVOID WINAPI SetupInitDefaultQueueCallback(HWND owner)
Definition: queue.c:1677
Definition: services.c:325
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
unsigned int UINT
Definition: ndis.h:50
DWORD GlobalSetupFlags
Definition: misc.c:845
#define MB_OK
Definition: winuser.h:784
char * cleanup(char *str)
Definition: wpickclick.c:99
WINE_UNICODE_INLINE int atoiW(const WCHAR *str)
Definition: unicode.h:315

Referenced by InstallHinfSectionA(), and run_cmdline().

◆ InstallOneService()

static BOOL InstallOneService ( struct DeviceInfoSet list,
IN HINF  hInf,
IN LPCWSTR  ServiceSection,
IN LPCWSTR  ServiceName,
IN UINT  ServiceFlags 
)
static

Definition at line 1773 of file install.c.

1779 {
1780  SC_HANDLE hSCManager = NULL;
1781  SC_HANDLE hService = NULL;
1782  LPDWORD GroupOrder = NULL;
1783  LPQUERY_SERVICE_CONFIGW ServiceConfig = NULL;
1784  HKEY hServicesKey, hServiceKey;
1785  LONG rc;
1786  BOOL ret = FALSE;
1787 
1788  HKEY hGroupOrderListKey = NULL;
1789  LPWSTR ServiceBinary = NULL;
1790  LPWSTR LoadOrderGroup = NULL;
1791  LPWSTR DisplayName = NULL;
1793  LPWSTR Dependencies = NULL;
1796  INT ServiceType, StartType, ErrorControl;
1797  DWORD dwRegType;
1798  DWORD tagId = (DWORD)-1;
1799  BOOL useTag;
1800 
1801  if (!GetIntField(hInf, ServiceSection, ServiceTypeKey, &ServiceType))
1802  {
1804  goto cleanup;
1805  }
1806  if (!GetIntField(hInf, ServiceSection, StartTypeKey, &StartType))
1807  {
1809  goto cleanup;
1810  }
1811  if (!GetIntField(hInf, ServiceSection, ErrorControlKey, &ErrorControl))
1812  {
1814  goto cleanup;
1815  }
1816  useTag = (ServiceType == SERVICE_BOOT_START || ServiceType == SERVICE_SYSTEM_START);
1817 
1819  if (hSCManager == NULL)
1820  goto cleanup;
1821 
1822  if (!GetLineText(hInf, ServiceSection, ServiceBinaryKey, &ServiceBinary))
1823  {
1825  goto cleanup;
1826  }
1827 
1828  /* Adjust binary path according to the service type */
1829  FixupServiceBinaryPath(ServiceType, &ServiceBinary);
1830 
1831  /* Don't check return value, as these fields are optional and
1832  * GetLineText initialize output parameter even on failure */
1833  GetLineText(hInf, ServiceSection, LoadOrderGroupKey, &LoadOrderGroup);
1834  GetLineText(hInf, ServiceSection, DisplayNameKey, &DisplayName);
1835  GetLineText(hInf, ServiceSection, DescriptionKey, &Description);
1836  GetLineText(hInf, ServiceSection, DependenciesKey, &Dependencies);
1837 
1838  /* If there is no group, we must not request a tag */
1839  if (!LoadOrderGroup || !*LoadOrderGroup)
1840  useTag = FALSE;
1841 
1842  hService = OpenServiceW(
1843  hSCManager,
1844  ServiceName,
1846  if (hService == NULL && GetLastError() != ERROR_SERVICE_DOES_NOT_EXIST)
1847  goto cleanup;
1848 
1849  if (hService && (ServiceFlags & SPSVCINST_DELETEEVENTLOGENTRY))
1850  {
1851  ret = DeleteService(hService);
1853  goto cleanup;
1854  }
1855 
1856  if (hService == NULL)
1857  {
1858  /* Create new service */
1859  hService = CreateServiceW(
1860  hSCManager,
1861  ServiceName,
1862  DisplayName,
1863  WRITE_DAC,
1864  ServiceType,
1865  StartType,
1866  ErrorControl,
1867  ServiceBinary,
1868  LoadOrderGroup,
1869  useTag ? &tagId : NULL,
1870  Dependencies,
1871  NULL, NULL);
1872  if (hService == NULL)
1873  goto cleanup;
1874  }
1875  else
1876  {
1877  DWORD bufferSize;
1878  /* Read current configuration */
1879  if (!QueryServiceConfigW(hService, NULL, 0, &bufferSize))
1880  {
1882  goto cleanup;
1883  ServiceConfig = MyMalloc(bufferSize);
1884  if (!ServiceConfig)
1885  {
1887  goto cleanup;
1888  }
1889  if (!QueryServiceConfigW(hService, ServiceConfig, bufferSize, &bufferSize))
1890  goto cleanup;
1891  }
1892  tagId = ServiceConfig->dwTagId;
1893 
1894  /* Update configuration */
1896  hService,
1897  ServiceType,
1898  (ServiceFlags & SPSVCINST_NOCLOBBER_STARTTYPE) ? SERVICE_NO_CHANGE : StartType,
1899  (ServiceFlags & SPSVCINST_NOCLOBBER_ERRORCONTROL) ? SERVICE_NO_CHANGE : ErrorControl,
1900  ServiceBinary,
1901  (ServiceFlags & SPSVCINST_NOCLOBBER_LOADORDERGROUP && ServiceConfig->lpLoadOrderGroup) ? NULL : LoadOrderGroup,
1902  useTag ? &tagId : NULL,
1903  (ServiceFlags & SPSVCINST_NOCLOBBER_DEPENDENCIES && ServiceConfig->lpDependencies) ? NULL : Dependencies,
1904  NULL, NULL,
1905  (ServiceFlags & SPSVCINST_NOCLOBBER_DISPLAYNAME && ServiceConfig->lpDisplayName) ? NULL : DisplayName);
1906  if (!ret)
1907  goto cleanup;
1908  }
1909 
1910  /* Set security */
1911  if (GetLineText(hInf, ServiceSection, SecurityKey, &SecurityDescriptor))
1912  {
1914  if (!ret)
1915  goto cleanup;
1917  if (!ret)
1918  goto cleanup;
1919  }
1920 
1921  /* FIXME: use Description and SPSVCINST_NOCLOBBER_DESCRIPTION */
1922 
1923  if (useTag)
1924  {
1925  /* Add the tag to SYSTEM\CurrentControlSet\Control\GroupOrderList key */
1926  LPCWSTR lpLoadOrderGroup;
1927  DWORD bufferSize;
1928 
1929  lpLoadOrderGroup = LoadOrderGroup;
1930  if ((ServiceFlags & SPSVCINST_NOCLOBBER_LOADORDERGROUP) && ServiceConfig && ServiceConfig->lpLoadOrderGroup)
1931  lpLoadOrderGroup = ServiceConfig->lpLoadOrderGroup;
1932 
1933  rc = RegOpenKeyW(
1934  list ? list->HKLM : HKEY_LOCAL_MACHINE,
1936  &hGroupOrderListKey);
1937  if (rc != ERROR_SUCCESS)
1938  {
1939  SetLastError(rc);
1940  goto cleanup;
1941  }
1942  rc = RegQueryValueExW(hGroupOrderListKey, lpLoadOrderGroup, NULL, &dwRegType, NULL, &bufferSize);
1943  if (rc == ERROR_FILE_NOT_FOUND)
1944  bufferSize = sizeof(DWORD);
1945  else if (rc != ERROR_SUCCESS)
1946  {
1947  SetLastError(rc);
1948  goto cleanup;
1949  }
1950  else if (dwRegType != REG_BINARY || bufferSize == 0 || bufferSize % sizeof(DWORD) != 0)
1951  {
1953  goto cleanup;
1954  }
1955  /* Allocate buffer to store existing data + the new tag */
1956  GroupOrder = MyMalloc(bufferSize + sizeof(DWORD));
1957  if (!GroupOrder)
1958  {
1960  goto cleanup;
1961  }
1962  if (rc == ERROR_SUCCESS)
1963  {
1964  /* Read existing data */
1965  rc = RegQueryValueExW(
1966  hGroupOrderListKey,
1967  lpLoadOrderGroup,
1968  NULL,
1969  NULL,
1970  (BYTE*)GroupOrder,
1971  &bufferSize);
1972  if (rc != ERROR_SUCCESS)
1973  {
1974  SetLastError(rc);
1975  goto cleanup;
1976  }
1977  if (ServiceFlags & SPSVCINST_TAGTOFRONT)
1978  memmove(&GroupOrder[2], &GroupOrder[1], bufferSize - sizeof(DWORD));
1979  }
1980  else
1981  {
1982  GroupOrder[0] = 0;
1983  }
1984  GroupOrder[0]++;
1985  if (ServiceFlags & SPSVCINST_TAGTOFRONT)
1986  GroupOrder[1] = tagId;
1987  else
1988  GroupOrder[bufferSize / sizeof(DWORD)] = tagId;
1989 
1990  rc = RegSetValueExW(
1991  hGroupOrderListKey,
1992  lpLoadOrderGroup,
1993  0,
1994  REG_BINARY,
1995  (BYTE*)GroupOrder,
1996  bufferSize + sizeof(DWORD));
1997  if (rc != ERROR_SUCCESS)
1998  {
1999  SetLastError(rc);
2000  goto cleanup;
2001  }
2002  }
2003 
2004  /* Handle AddReg and DelReg */
2005  rc = RegOpenKeyExW(
2006  list ? list->HKLM : HKEY_LOCAL_MACHINE,
2008  0,
2009  READ_CONTROL,
2010  &hServicesKey);
2011  if (rc != ERROR_SUCCESS)
2012  {
2013  SetLastError(rc);
2014  goto cleanup;
2015  }
2016  rc = RegOpenKeyExW(
2017  hServicesKey,
2018  ServiceName,
2019  0,
2020  KEY_READ | KEY_WRITE,
2021  &hServiceKey);
2023  if (rc != ERROR_SUCCESS)
2024  {
2025  SetLastError(rc);
2026  goto cleanup;
2027  }
2028 
2030  NULL,
2031  hInf,
2032  ServiceSection,
2034  hServiceKey,
2035  NULL,
2036  0,
2037  NULL,
2038  NULL,
2039  NULL,
2040  NULL);
2041  RegCloseKey(hServiceKey);
2042 
2043 cleanup:
2044  if (hSCManager != NULL)
2046  if (hService != NULL)
2047  CloseServiceHandle(hService);
2048  if (hGroupOrderListKey != NULL)
2049  RegCloseKey(hGroupOrderListKey);
2050  if (sd != NULL)
2051  LocalFree(sd);
2052  MyFree(ServiceConfig);
2053  MyFree(ServiceBinary);
2054  MyFree(LoadOrderGroup);
2055  MyFree(DisplayName);
2057  MyFree(Dependencies);
2059  MyFree(GroupOrder);
2060 
2061  TRACE("Returning %d\n", ret);
2062  return ret;
2063 }
static HANDLE DWORD
Definition: install.c:28
#define SPSVCINST_NOCLOBBER_DISPLAYNAME
Definition: setupapi.h:623
#define SERVICE_SYSTEM_START
Definition: cmtypes.h:974
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define SPSVCINST_DELETEEVENTLOGENTRY
Definition: setupapi.h:622
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR ServiceTypeKey[]
Definition: install.c:43
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define SERVICES_ACTIVE_DATABASE
Definition: winsvc.h:564
#define REG_BINARY
Definition: nt_native.h:1496
SC_HANDLE WINAPI CreateServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, LPCWSTR lpDisplayName, DWORD dwDesiredAccess, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCWSTR lpBinaryPathName, LPCWSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCWSTR lpDependencies, LPCWSTR lpServiceStartName, LPCWSTR lpPassword)
Definition: scm.c:808
#define KEY_READ
Definition: nt_native.h:1023
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:182
BOOL WINAPI QueryServiceConfigW(SC_HANDLE hService, LPQUERY_SERVICE_CONFIGW lpServiceConfig, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2234
LPWSTR lpLoadOrderGroup
Definition: winsvc.h:160
static const WCHAR SecurityKey[]
Definition: install.c:41
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define SPSVCINST_TAGTOFRONT
Definition: setupapi.h:620
static const WCHAR Description[]
Definition: oid.c:1266
BOOL WINAPI DeleteService(SC_HANDLE hService)
Definition: scm.c:916
static const WCHAR DisplayNameKey[]
Definition: install.c:38
int32_t INT
Definition: typedefs.h:56
#define SERVICE_NO_CHANGE
Definition: winsvc.h:20
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
BOOL WINAPI ChangeServiceConfigW(SC_HANDLE hService, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCWSTR lpBinaryPathName, LPCWSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCWSTR lpDependencies, LPCWSTR lpServiceStartName, LPCWSTR lpPassword, LPCWSTR lpDisplayName)
Definition: scm.c:480
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2103
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:577
#define SPINST_REGISTRY
Definition: setupapi.h:585
static BOOL GetIntField(HINF hinf, PCWSTR section_name, PCWSTR key_name, INT *value)
Definition: install.c:1672
smooth NULL
Definition: ftsmooth.c:416
#define REGSTR_PATH_SERVICES
Definition: regstr.h:47
#define SERVICE_BOOT_START
Definition: cmtypes.h:973
#define ERROR_SERVICE_MARKED_FOR_DELETE
Definition: winerror.h:623
#define SC_MANAGER_CREATE_SERVICE
Definition: winsvc.h:15
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
static HANDLE hServicesKey
Definition: devinst.c:21
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_BAD_SERVICE_INSTALLSECT
Definition: setupapi.h:314
LPTSTR ServiceName
Definition: ServiceMain.c:15
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
static const WCHAR DependenciesKey[]
Definition: install.c:36
#define SERVICE_CHANGE_CONFIG
Definition: winsvc.h:54
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WRITE_DAC
Definition: nt_native.h:59
#define SetLastError(x)
Definition: compat.h:409
static const WCHAR StartTypeKey[]
Definition: install.c:44
#define READ_CONTROL
Definition: nt_native.h:58
static const WCHAR sd[]
Definition: suminfo.c:287
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:1323
int ret
static BOOL GetLineText(HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR *value)
Definition: install.c:1643
static const WCHAR ErrorControlKey[]
Definition: install.c:39
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2011
unsigned char BYTE
Definition: mem.h:68
Definition: _list.h:228
SC_HANDLE hSCManager
Definition: sc.c:12
static const WCHAR LoadOrderGroupKey[]
Definition: install.c:40
#define SPSVCINST_NOCLOBBER_ERRORCONTROL
Definition: setupapi.h:625
static const WCHAR DescriptionKey[]
Definition: install.c:37
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
BOOL WINAPI SetServiceObjectSecurity(SC_HANDLE hService, SECURITY_INFORMATION dwSecurityInformation, PSECURITY_DESCRIPTOR lpSecurityDescriptor)
Definition: scm.c:2717
#define ERROR_SERVICE_DOES_NOT_EXIST
Definition: winerror.h:611
#define SPSVCINST_NOCLOBBER_DEPENDENCIES
Definition: setupapi.h:627
#define SPSVCINST_NOCLOBBER_STARTTYPE
Definition: setupapi.h:624
uint32_t * LPDWORD
Definition: typedefs.h:57
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
char * cleanup(char *str)
Definition: wpickclick.c:99
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
#define SERVICE_QUERY_CONFIG
Definition: winsvc.h:53
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
static const WCHAR GroupOrderListKey[]
Definition: install.c:29
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define SPSVCINST_NOCLOBBER_LOADORDERGROUP
Definition: setupapi.h:626
static VOID FixupServiceBinaryPath(IN DWORD ServiceType, IN OUT LPWSTR *ServiceBinary)
Definition: install.c:1731
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
#define DACL_SECURITY_INFORMATION
Definition: setypes.h:125
#define SDDL_REVISION_1
Definition: sddl.h:30
#define DELETE
Definition: nt_native.h:57
static const WCHAR ServiceBinaryKey[]
Definition: install.c:42
BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorW(LPCWSTR StringSecurityDescriptor, DWORD StringSDRevision, PSECURITY_DESCRIPTOR *SecurityDescriptor, PULONG SecurityDescriptorSize)
Definition: security.c:2738
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by SetupInstallServicesFromInfSectionExW().

◆ iterate_section_fields()

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

Definition at line 1167 of file install.c.

1169 {
1170  WCHAR static_buffer[200];
1171  WCHAR *buffer = static_buffer;
1172  DWORD size = sizeof(static_buffer)/sizeof(WCHAR);
1174  BOOL ret = FALSE;
1175 
1176  BOOL ok = SetupFindFirstLineW( hinf, section, key, &context );
1177  while (ok)
1178  {
1180  for (i = 1; i <= count; i++)
1181  {
1182  if (!(buffer = get_field_string( &context, i, buffer, static_buffer, &size )))
1183  goto done;
1184  if (!callback( hinf, buffer, arg ))
1185  {
1186  WARN("callback failed for %s %s err %d\n",
1188  goto done;
1189  }
1190  }
1192  }
1193  ret = TRUE;
1194  done:
1195  if (buffer != static_buffer) HeapFree( GetProcessHeap(), 0, buffer );
1196  return ret;
1197 }
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
Definition: http.c:6587
static WCHAR * get_field_string(INFCONTEXT *context, DWORD index, WCHAR *buffer, WCHAR *static_buffer, DWORD *size)
Definition: install.c:133
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WARN(fmt,...)
Definition: debug.h:111
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
Definition: parser.c:55
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
#define debugstr_w
Definition: kernel32.h:32
#define ok(value,...)
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
ULONG WINAPI SetupGetFieldCount(IN PINFCONTEXT Context)
Definition: infsupp.c:91
unsigned int UINT
Definition: ndis.h:50
#define HeapFree(x, y, z)
Definition: compat.h:394
BOOL WINAPI SetupFindNextMatchLineW(PINFCONTEXT context_in, PCWSTR key, PINFCONTEXT context_out)
Definition: parser.c:1694
Definition: path.c:42

Referenced by SetupInstallFilesFromInfSectionW(), SetupInstallFromInfSectionW(), and SetupInstallServicesFromInfSectionExW().

◆ logconf_callback()

static BOOL logconf_callback ( HINF  hinf,
PCWSTR  field,
void arg 
)
static

Definition at line 825 of file install.c.

826 {
827  FIXME( "should do logconf %s\n", debugstr_w(field) );
828  return TRUE;
829 }
#define TRUE
Definition: types.h:120
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: parser.c:43

Referenced by SetupInstallFromInfSectionW().

◆ needs_callback()

static BOOL needs_callback ( HINF  hinf,
PCWSTR  field,
void arg 
)
static

Definition at line 1300 of file install.c.

1301 {
1302  struct needs_callback_info *info = arg;
1303 
1304  switch (info->type)
1305  {
1306  case 0:
1307  return SetupInstallFromInfSectionW(info->owner, *(HINF*)hinf, field, info->flags,
1308  info->key_root, info->src_root, info->copy_flags, info->callback,
1309  info->context, info->devinfo, info->devinfo_data);
1310  case 1:
1311  return SetupInstallServicesFromInfSectionExW(*(HINF*)hinf, field, info->flags,
1312  info->devinfo, info->devinfo_data, info->reserved1, info->reserved2);
1313  default:
1314  ERR("Unknown info type %u\n", info->type);
1315  return FALSE;
1316  }
1317 }
BOOL WINAPI SetupInstallServicesFromInfSectionExW(HINF hinf, PCWSTR sectionname, DWORD flags, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PVOID reserved1, PVOID reserved2)
Definition: install.c:2069
void * arg
Definition: msvc.h:12
Definition: parser.c:43
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:1323
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by SetupInstallFromInfSectionW(), and SetupInstallServicesFromInfSectionExW().

◆ profile_items_callback()

static BOOL profile_items_callback ( IN HINF  hInf,
IN PCWSTR  SectionName,
IN PVOID  Arg 
)
static

Definition at line 887 of file install.c.

891 {
893  LPWSTR LinkSubDir = NULL, LinkName = NULL;
894  INT LinkAttributes = 0;
895  INT LinkFolder = 0;
896  INT FileDirId = 0;
897  INT CSIDL = CSIDL_COMMON_PROGRAMS;
898  LPWSTR FileSubDir = NULL;
899  INT DirId = 0;
900  LPWSTR SubDirPart = NULL, NamePart = NULL;
901  LPWSTR FullLinkName = NULL, FullFileName = NULL, FullWorkingDir = NULL, FullIconName = NULL;
902  INT IconIdx = 0;
903  LPWSTR lpHotKey = NULL, lpInfoTip = NULL;
904  LPWSTR DisplayName = NULL;
905  INT DisplayResId = 0;
906  BOOL ret = FALSE;
908 
909  IShellLinkW *psl;
910  IPersistFile *ppf;
911  HMODULE hOle32 = NULL;
912  COINITIALIZE pCoInitialize;
913  COCREATEINSTANCE pCoCreateInstance;
914  COUNINITIALIZE pCoUninitialize;
915  HRESULT hr;
916 
917  TRACE("hInf %p, SectionName %s, Arg %p\n",
918  hInf, debugstr_w(SectionName), Arg);
919 
920  /* Read 'Name' entry */
921  if (!SetupFindFirstLineW(hInf, SectionName, Name, &Context))
922  goto cleanup;
923  if (!GetStringField(&Context, 1, &LinkName))
924  goto cleanup;
925  if (SetupGetFieldCount(&Context) >= 2)
926  {
927  if (!SetupGetIntField(&Context, 2, &LinkAttributes))
928  goto cleanup;
929  }
930  if (SetupGetFieldCount(&Context) >= 3)
931  {
932  if (!SetupGetIntField(&Context, 3, &LinkFolder))
933  goto cleanup;
934  }
935 
936  /* Read 'CmdLine' entry */
937  if (!SetupFindFirstLineW(hInf, SectionName, CmdLine, &Context))
938  goto cleanup;
939  Index = 1;
940  if (!SetupGetIntField(&Context, Index++, &FileDirId))
941  goto cleanup;
942  if (SetupGetFieldCount(&Context) >= 3)
943  {
944  if (!GetStringField(&Context, Index++, &FileSubDir))
945  goto cleanup;
946  }
947  if (!GetStringField(&Context, Index++, &NamePart))
948  goto cleanup;
949  if (!Concatenate(FileDirId, FileSubDir, NamePart, &FullFileName))
950  goto cleanup;
951  MyFree(NamePart);
952  NamePart = NULL;
953 
954  /* Read 'SubDir' entry */
955  if ((LinkAttributes & FLG_PROFITEM_GROUP) == 0 && SetupFindFirstLineW(hInf, SectionName, SubDir, &Context))
956  {
957  if (!GetStringField(&Context, 1, &LinkSubDir))
958  goto cleanup;
959  }
960 
961  /* Read 'WorkingDir' entry */
962  if (SetupFindFirstLineW(hInf, SectionName, WorkingDir, &Context))
963  {
964  if (!SetupGetIntField(&Context, 1, &DirId))
965  goto cleanup;
966  if (SetupGetFieldCount(&Context) >= 2)
967  {
968  if (!GetStringField(&Context, 2, &SubDirPart))
969  goto cleanup;
970  }
971  if (!Concatenate(DirId, SubDirPart, NULL, &FullWorkingDir))
972  goto cleanup;
973  MyFree(SubDirPart);
974  SubDirPart = NULL;
975  }
976  else
977  {
978  if (!Concatenate(FileDirId, FileSubDir, NULL, &FullWorkingDir))
979  goto cleanup;
980  }
981 
982  /* Read 'IconPath' entry */
983  if (SetupFindFirstLineW(hInf, SectionName, IconPath, &Context))
984  {
985  Index = 1;
986  if (!SetupGetIntField(&Context, Index++, &DirId))
987  goto cleanup;
988  if (SetupGetFieldCount(&Context) >= 3)
989  {
990  if (!GetStringField(&Context, Index++, &SubDirPart))
991  goto cleanup;
992  }
993  if (!GetStringField(&Context, Index, &NamePart))
994  goto cleanup;
995  if (!Concatenate(DirId, SubDirPart, NamePart, &FullIconName))
996  goto cleanup;
997  MyFree(SubDirPart);
998  MyFree(NamePart);
999  SubDirPart = NamePart = NULL;
1000  }
1001  else
1002  {
1003  FullIconName = pSetupDuplicateString(FullFileName);
1004  if (!FullIconName)
1005  goto cleanup;
1006  }
1007 
1008  /* Read 'IconIndex' entry */
1009  if (SetupFindFirstLineW(hInf, SectionName, IconIndex, &Context))
1010  {
1011  if (!SetupGetIntField(&Context, 1, &IconIdx))
1012  goto cleanup;
1013  }
1014 
1015  /* Read 'HotKey' and 'InfoTip' entries */
1016  GetLineText(hInf, SectionName, HotKey, &lpHotKey);
1017  GetLineText(hInf, SectionName, InfoTip, &lpInfoTip);
1018 
1019  /* Read 'DisplayResource' entry */
1020  if (SetupFindFirstLineW(hInf, SectionName, DisplayResource, &Context))
1021  {
1022  if (!GetStringField(&Context, 1, &DisplayName))
1023  goto cleanup;
1024  if (!SetupGetIntField(&Context, 2, &DisplayResId))
1025  goto cleanup;
1026  }
1027 
1028  /* Some debug */
1029  TRACE("Link is %s\\%s, attributes 0x%x\n", debugstr_w(LinkSubDir), debugstr_w(LinkName), LinkAttributes);
1030  TRACE("File is %s\n", debugstr_w(FullFileName));
1031  TRACE("Working dir %s\n", debugstr_w(FullWorkingDir));
1032  TRACE("Icon is %s, %d\n", debugstr_w(FullIconName), IconIdx);
1033  TRACE("Hotkey %s\n", debugstr_w(lpHotKey));
1034  TRACE("InfoTip %s\n", debugstr_w(lpInfoTip));
1035  TRACE("Display %s, %d\n", DisplayName, DisplayResId);
1036 
1037  /* Load ole32.dll */
1038  hOle32 = LoadLibraryA("ole32.dll");
1039  if (!hOle32)
1040  goto cleanup;
1041  pCoInitialize = (COINITIALIZE)GetProcAddress(hOle32, "CoInitialize");
1042  if (!pCoInitialize)
1043  goto cleanup;
1044  pCoCreateInstance = (COCREATEINSTANCE)GetProcAddress(hOle32, "CoCreateInstance");
1045  if (!pCoCreateInstance)
1046  goto cleanup;
1047  pCoUninitialize = (COUNINITIALIZE)GetProcAddress(hOle32, "CoUninitialize");
1048  if (!pCoUninitialize)
1049  goto cleanup;
1050 
1051  /* Create shortcut */
1052  hr = pCoInitialize(NULL);
1053  if (!SUCCEEDED(hr))
1054  {
1057  else
1059  goto cleanup;
1060  }
1061  hr = pCoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLinkW, (LPVOID*)&psl);
1062  if (SUCCEEDED(hr))
1063  {
1064  /* Fill link properties */
1065  hr = IShellLinkW_SetPath(psl, FullFileName);
1066  if (SUCCEEDED(hr))
1067  hr = IShellLinkW_SetArguments(psl, L"");
1068  if (SUCCEEDED(hr))
1069  hr = IShellLinkW_SetWorkingDirectory(psl, FullWorkingDir);
1070  if (SUCCEEDED(hr))
1071  hr = IShellLinkW_SetIconLocation(psl, FullIconName, IconIdx);
1072  if (SUCCEEDED(hr) && lpHotKey)
1073  FIXME("Need to store hotkey %s in shell link\n", debugstr_w(lpHotKey));
1074  if (SUCCEEDED(hr) && lpInfoTip)
1075  hr = IShellLinkW_SetDescription(psl, lpInfoTip);
1076  if (SUCCEEDED(hr) && DisplayName)
1077  FIXME("Need to store display name %s, %d in shell link\n", debugstr_w(DisplayName), DisplayResId);
1078  if (SUCCEEDED(hr))
1079  {
1080  hr = IShellLinkW_QueryInterface(psl, &IID_IPersistFile, (LPVOID*)&ppf);
1081  if (SUCCEEDED(hr))
1082  {
1083  Required = (MAX_PATH + 1 +
1084  ((LinkSubDir != NULL) ? wcslen(LinkSubDir) : 0) +
1085  ((LinkName != NULL) ? wcslen(LinkName) : 0)) * sizeof(WCHAR);
1086  FullLinkName = MyMalloc(Required);
1087  if (!FullLinkName)
1088  hr = E_OUTOFMEMORY;
1089  else
1090  {
1091  if (LinkAttributes & (FLG_PROFITEM_DELETE | FLG_PROFITEM_GROUP))
1092  FIXME("Need to handle FLG_PROFITEM_DELETE and FLG_PROFITEM_GROUP\n");
1093  if (LinkAttributes & FLG_PROFITEM_CSIDL)
1094  CSIDL = LinkFolder;
1095  else if (LinkAttributes & FLG_PROFITEM_CURRENTUSER)
1096  CSIDL = CSIDL_PROGRAMS;
1097 
1099  NULL,
1100  FullLinkName,
1101  CSIDL,
1102  TRUE))
1103  {
1104  if (FullLinkName[wcslen(FullLinkName) - 1] != '\\')
1105  wcscat(FullLinkName, BackSlash);
1106  if (LinkSubDir)
1107  {
1108  wcscat(FullLinkName, LinkSubDir);
1109  if (FullLinkName[wcslen(FullLinkName) - 1] != '\\')
1110  wcscat(FullLinkName, BackSlash);
1111  }
1112  wcscat(FullLinkName, LinkName);
1113  wcscat(FullLinkName, DotLnk);
1114  hr = IPersistFile_Save(ppf, FullLinkName, TRUE);
1115  }
1116  else
1118  }
1119  IPersistFile_Release(ppf);
1120  }
1121  }
1122  IShellLinkW_Release(psl);
1123  }
1124  pCoUninitialize();
1125  if (SUCCEEDED(hr))
1126  ret = TRUE;
1127  else
1128  {
1131  else
1133  }
1134 
1135 cleanup:
1136  MyFree(LinkSubDir);
1137  MyFree(LinkName);
1138  MyFree(FileSubDir);
1139  MyFree(SubDirPart);
1140  MyFree(NamePart);
1141  MyFree(FullFileName);
1142  MyFree(FullWorkingDir);
1143  MyFree(FullIconName);
1144  MyFree(FullLinkName);
1145  MyFree(lpHotKey);
1146  MyFree(lpInfoTip);
1147  MyFree(DisplayName);
1148  if (hOle32)
1149  FreeLibrary(hOle32);
1150 
1151  TRACE("Returning %d\n", ret);
1152  return ret;
1153 }
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:54
#define FLG_PROFITEM_CURRENTUSER
Definition: setupapi.h:398
#define TRUE
Definition: types.h:120
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define FLG_PROFITEM_CSIDL
Definition: setupapi.h:401
#define FLG_PROFITEM_GROUP
Definition: setupapi.h:400
HRESULT hr
Definition: shlfolder.c:183
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define E_FAIL
Definition: ddrawi.h:102
int32_t INT
Definition: typedefs.h:56
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2025
static const WCHAR CmdLine[]
Definition: install.c:47
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
LPWSTR WINAPI pSetupDuplicateString(LPCWSTR lpSrc)
Definition: misc.c:198
unsigned int BOOL
Definition: ntddk_ex.h:94
#define HRESULT_FACILITY(hr)
Definition: winerror.h:79
static const WCHAR DotLnk[]
Definition: install.c:33
static const WCHAR WorkingDir[]
Definition: install.c:49
#define debugstr_w
Definition: kernel32.h:32
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define FLG_PROFITEM_DELETE
Definition: setupapi.h:399
#define FIXME(fmt,...)
Definition: debug.h:110
HRESULT(WINAPI * COCREATEINSTANCE)(IN REFCLSID rclsid, IN LPUNKNOWN pUnkOuter, IN DWORD dwClsContext, IN REFIID riid, OUT LPVOID *ppv)
Definition: install.c:101
smooth NULL
Definition: ftsmooth.c:416
HRESULT(WINAPI * COUNINITIALIZE)(VOID)
Definition: install.c:102
static const WCHAR HotKey[]
Definition: install.c:52
#define TRACE(s)
Definition: solgame.cpp:4
#define FreeLibrary(x)
Definition: compat.h:405
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static const WCHAR IconIndex[]
Definition: install.c:51
static const WCHAR BackSlash[]
Definition: install.c:28
int ret
ULONG WINAPI SetupGetFieldCount(IN PINFCONTEXT Context)
Definition: infsupp.c:91
static BOOL GetLineText(HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR *value)
Definition: install.c:1643
static const WCHAR L[]
Definition: oid.c:1250
static const WCHAR InfoTip[]
Definition: install.c:53
static const WCHAR DisplayResource[]
Definition: install.c:54
HRESULT(WINAPI * COINITIALIZE)(IN LPVOID pvReserved)
Definition: install.c:100
#define FACILITY_WIN32
Definition: winerror.h:27
BOOL GetStringField(PINFCONTEXT context, DWORD index, PWSTR *value)
Definition: install.c:1696
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2566
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR IconPath[]
Definition: install.c:50
const GUID IID_IPersistFile
#define HRESULT_CODE(hr)
Definition: winerror.h:76
BOOL WINAPI SetupGetIntField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT INT *IntegerValue)
Definition: infsupp.c:146
struct tagContext Context
Definition: acpixf.h:1012
char * cleanup(char *str)
Definition: wpickclick.c:99
#define GetProcAddress(x, y)
Definition: compat.h:410
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
static const WCHAR SubDir[]
Definition: install.c:48
struct _MEMORY_AREA struct _MM_REQUIRED_RESOURCES * Required
Definition: newmm.h:66
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define CSIDL_PROGRAMS
Definition: shlobj.h:2005
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static BOOL Concatenate(int DirId, LPCWSTR SubDirPart, LPCWSTR NamePart, LPWSTR *pFullName)
Definition: install.c:837
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by SetupInstallFromInfSectionW().

◆ register_dlls_callback()

static BOOL register_dlls_callback ( HINF  hinf,
PCWSTR  field,
void arg 
)
static

Definition at line 669 of file install.c.

670 {
671  struct register_dll_info *info = arg;
673  BOOL ret = TRUE;
675 
676  for (; ok; ok = SetupFindNextLine( &context, &context ))
677  {
678  WCHAR *path, *args, *p;
680  INT flags, timeout;
681 
682  /* get directory */
683  if (!(path = PARSER_get_dest_dir( &context ))) continue;
684 
685  /* get dll name */
686  if (!SetupGetStringFieldW( &context, 3, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
687  goto done;
688  if (!(p = HeapReAlloc( GetProcessHeap(), 0, path,
689  (strlenW(path) + strlenW(buffer) + 2) * sizeof(WCHAR) ))) goto done;
690  path = p;
691  p += strlenW(p);
692  if (p == path || p[-1] != '\\') *p++ = '\\';
693  strcpyW( p, buffer );
694 
695  /* get flags */
696  if (!SetupGetIntField( &context, 4, &flags )) flags = 0;
697 
698  /* get timeout */
699  if (!SetupGetIntField( &context, 5, &timeout )) timeout = 60;
700 
701  /* get command line */
702  args = NULL;
703  if (SetupGetStringFieldW( &context, 6, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
704  args = buffer;
705 
707 
708  done:
709  HeapFree( GetProcessHeap(), 0, path );
710  if (!ret) break;
711  }
712  return ret;
713 }
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
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static BOOL do_register_dll(const struct register_dll_info *info, const WCHAR *path, INT flags, INT timeout, const WCHAR *args)
Definition: install.c:529
Definition: http.c:6587
GLsizei const GLchar ** path
Definition: glext.h:7234
GLuint buffer
Definition: glext.h:5915
void * arg
Definition: msvc.h:12
Definition: dhcpd.h:245
WCHAR * PARSER_get_dest_dir(INFCONTEXT *context)
Definition: parser.c:1116
Definition: match.c:390
int32_t INT
Definition: typedefs.h:56
GLbitfield GLuint64 timeout
Definition: glext.h:7164
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define MAX_INF_STRING_LENGTH
Definition: infsupp.h:34
#define GetProcessHeap()
Definition: compat.h:395
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:43
GLbitfield flags
Definition: glext.h:7161
int ret
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define HeapReAlloc
Definition: compat.h:393
Definition: services.c:325
BOOL WINAPI SetupFindNextLine(IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut)
Definition: infsupp.c:80
BOOL WINAPI SetupGetIntField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT INT *IntegerValue)
Definition: infsupp.c:146
GLfloat GLfloat p
Definition: glext.h:8902
#define args
Definition: format.c:66
#define HeapFree(x, y, z)
Definition: compat.h:394
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:184

Referenced by SetupInstallFromInfSectionW().

◆ registry_callback()

static BOOL registry_callback ( HINF  hinf,
PCWSTR  field,
void arg 
)
static

Definition at line 421 of file install.c.

422 {
423  struct registry_callback_info *info = arg;
424  LPWSTR security_key, security_descriptor;
425  INFCONTEXT context, security_context;
427  SECURITY_ATTRIBUTES security_attributes = { 0, };
428  HKEY root_key, hkey;
429  DWORD required;
430 
432  if (!ok)
433  return TRUE;
434 
435  /* Check for .Security section */
436  security_key = MyMalloc( (strlenW( field ) + strlenW( DotSecurity )) * sizeof(WCHAR) + sizeof(UNICODE_NULL) );
437  if (!security_key)
438  {
440  return FALSE;
441  }
442  strcpyW( security_key, field );
443  strcatW( security_key, DotSecurity );
444  ok = SetupFindFirstLineW( hinf, security_key, NULL, &security_context );
445  MyFree(security_key);
446  if (ok)
447  {
448  if (!SetupGetLineTextW( &security_context, NULL, NULL, NULL, NULL, 0, &required ))
449  return FALSE;
450  security_descriptor = MyMalloc( required * sizeof(WCHAR) );
451  if (!security_descriptor)
452  {
454  return FALSE;
455  }
456  if (!SetupGetLineTextW( &security_context, NULL, NULL, NULL, security_descriptor, required, NULL ))
457  return FALSE;
459  MyFree( security_descriptor );
460  if (!ok)
461  return FALSE;
462  security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES);
463  security_attributes.lpSecurityDescriptor = sd;
464  }
465 
466  for (ok = TRUE; ok; ok = SetupFindNextLine( &context, &context ))
467  {
469  INT flags;
470 
471  /* get root */
472  if (!SetupGetStringFieldW( &context, 1, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
473  continue;
474  if (!(root_key = get_root_key( buffer, info->default_root )))
475  continue;
476 
477  /* get key */
478  if (!SetupGetStringFieldW( &context, 2, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
479  *buffer = 0;
480 
481  /* get flags */
482  if (!SetupGetIntField( &context, 4, &flags )) flags = 0;
483 
484  if (!info->delete)
485  {
486  if (flags & FLG_ADDREG_DELREG_BIT) continue; /* ignore this entry */
487  }
488  else
489  {
491  else if (!(flags & FLG_ADDREG_DELREG_BIT)) continue; /* ignore this entry */
492  }
493 
494  if (info->delete || (flags & FLG_ADDREG_OVERWRITEONLY))
495  {
496  if (RegOpenKeyW( root_key, buffer, &hkey )) continue; /* ignore if it doesn't exist */
497  }
499  sd ? &security_attributes : NULL, &hkey, NULL ))
500  {
501  ERR( "could not create key %p %s\n", root_key, debugstr_w(buffer) );
502  continue;
503  }
504  TRACE( "key %p %s\n", root_key, debugstr_w(buffer) );
505 
506  /* get value name */
507  if (!SetupGetStringFieldW( &context, 3, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
508  *buffer = 0;
509 
510  /* and now do it */
511  if (!do_reg_operation( hkey, buffer, &context, flags ))
512  {
513  if (hkey != root_key) RegCloseKey( hkey );
514  if (sd) LocalFree( sd );
515  return FALSE;
516  }
517  if (hkey != root_key) RegCloseKey( hkey );
518  }
519  if (sd) LocalFree( sd );
520  return TRUE;
521 }
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:54
#define FLG_ADDREG_OVERWRITEONLY
Definition: registry.c:48
static HKEY get_root_key(const WCHAR *name, HKEY def_root)
Definition: install.c:200
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
Definition: http.c:6587
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
GLuint buffer
Definition: glext.h:5915
void * arg
Definition: msvc.h:12
int32_t INT
Definition: typedefs.h:56
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
#define debugstr_w
Definition: kernel32.h:32
#define ok(value,...)
struct reiserfs_key root_key
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define MAX_INF_STRING_LENGTH
Definition: infsupp.h:34
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:43
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
GLbitfield flags
Definition: glext.h:7161
static const WCHAR DotSecurity[]
Definition: install.c:122
static const WCHAR sd[]
Definition: suminfo.c:287
#define ERR(fmt,...)
Definition: debug.h:109
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
LPVOID lpSecurityDescriptor
Definition: compat.h:181
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
BOOL WINAPI SetupFindNextLine(IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut)
Definition: infsupp.c:80
static BOOL do_reg_operation(HKEY hkey, const WCHAR *value, INFCONTEXT *context, INT flags)
Definition: install.c:306
#define FLG_ADDREG_DELREG_BIT
Definition: reginf.c:45
BOOL WINAPI SetupGetIntField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT INT *IntegerValue)
Definition: infsupp.c:146
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
#define SDDL_REVISION_1
Definition: sddl.h:30
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorW(LPCWSTR StringSecurityDescriptor, DWORD StringSDRevision, PSECURITY_DESCRIPTOR *SecurityDescriptor, PULONG SecurityDescriptorSize)
Definition: security.c:2738
BOOL WINAPI SetupGetLineTextW(PINFCONTEXT context, HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1756
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:184

Referenced by SetupInstallFromInfSectionW().

◆ rename_files_callback()

static BOOL rename_files_callback ( HINF  hinf,
PCWSTR  field,
void arg 
)
static

Definition at line 187 of file install.c.

188 {
189  struct files_callback_info *info = arg;
190  SetupQueueRenameSectionW( info->queue, hinf, 0, field );
191  return TRUE;
192 }
#define TRUE
Definition: types.h:120
BOOL WINAPI SetupQueueRenameSectionW(HSPFILEQ queue, HINF hinf, HINF hlist, PCWSTR section)
Definition: queue.c:967
void * arg
Definition: msvc.h:12
Definition: parser.c:43

Referenced by SetupInstallFromInfSectionW().

◆ SetupCopyOEMInfA()

BOOL WINAPI SetupCopyOEMInfA ( IN PCSTR  SourceInfFileName,
IN PCSTR  OEMSourceMediaLocation,
IN DWORD  OEMSourceMediaType,
IN DWORD  CopyStyle,
OUT PSTR DestinationInfFileName  OPTIONAL,
IN DWORD  DestinationInfFileNameSize,
OUT PDWORD RequiredSize  OPTIONAL,
OUT PSTR *DestinationInfFileNameComponent  OPTIONAL 
)

Definition at line 2187 of file install.c.

2196 {
2197  PWSTR SourceInfFileNameW = NULL;
2198  PWSTR OEMSourceMediaLocationW = NULL;
2199  PWSTR DestinationInfFileNameW = NULL;
2200  PWSTR DestinationInfFileNameComponentW = NULL;
2201  BOOL ret = FALSE;
2202  DWORD size;
2203 
2204  TRACE("%s %s 0x%lx 0x%lx %p 0%lu %p %p\n",
2205  SourceInfFileName, OEMSourceMediaLocation, OEMSourceMediaType,
2206  CopyStyle, DestinationInfFileName, DestinationInfFileNameSize,
2207  RequiredSize, DestinationInfFileNameComponent);
2208 
2209  if (!DestinationInfFileName && DestinationInfFileNameSize > 0)
2211  else if (!(SourceInfFileNameW = pSetupMultiByteToUnicode(SourceInfFileName, CP_ACP)))
2213  else if (OEMSourceMediaType != SPOST_NONE && !(OEMSourceMediaLocationW = pSetupMultiByteToUnicode(OEMSourceMediaLocation, CP_ACP)))
2215  else
2216  {
2217  if (DestinationInfFileNameSize != 0)
2218  {
2219  DestinationInfFileNameW = MyMalloc(DestinationInfFileNameSize * sizeof(WCHAR));
2220  if (!DestinationInfFileNameW)
2221  {
2223  goto cleanup;
2224  }
2225  }
2226 
2228  SourceInfFileNameW,
2229  OEMSourceMediaLocationW,
2230  OEMSourceMediaType,
2231  CopyStyle,
2232  DestinationInfFileNameW,
2233  DestinationInfFileNameSize,
2234  &size,
2235  DestinationInfFileNameComponent ? &DestinationInfFileNameComponentW : NULL);
2236  if (!ret)
2237  {
2238  if (RequiredSize) *RequiredSize = size;
2239  goto cleanup;
2240  }
2241 
2242  if (DestinationInfFileNameSize != 0)
2243  {
2244  if (WideCharToMultiByte(CP_ACP, 0, DestinationInfFileNameW, -1,
2245  DestinationInfFileName, DestinationInfFileNameSize, NULL, NULL) == 0)
2246  {
2247  DestinationInfFileName[0] = '\0';
2248  goto cleanup;
2249  }
2250  }
2251  if (DestinationInfFileNameComponent)
2252  {
2253  if (DestinationInfFileNameComponentW)
2254  *DestinationInfFileNameComponent = &DestinationInfFileName[DestinationInfFileNameComponentW - DestinationInfFileNameW];
2255  else
2256  *DestinationInfFileNameComponent = NULL;
2257  }
2258  ret = TRUE;
2259  }
2260 
2261 cleanup:
2262  MyFree(SourceInfFileNameW);
2263  MyFree(OEMSourceMediaLocationW);
2264  MyFree(DestinationInfFileNameW);
2265  TRACE("Returning %d\n", ret);
2267  return ret;
2268 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
DWORD size
Definition: install.c:3631
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WideCharToMultiByte
Definition: compat.h:101
uint16_t * PWSTR
Definition: typedefs.h:54
#define CP_ACP
Definition: compat.h:99
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
LPWSTR WINAPI pSetupMultiByteToUnicode(LPCSTR lpMultiByteStr, UINT uCodePage)
Definition: misc.c:281
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI SetupCopyOEMInfW(IN PCWSTR SourceInfFileName, IN PCWSTR OEMSourceMediaLocation, IN DWORD OEMSourceMediaType, IN DWORD CopyStyle, OUT PWSTR DestinationInfFileName OPTIONAL, IN DWORD DestinationInfFileNameSize, OUT PDWORD RequiredSize OPTIONAL, OUT PWSTR *DestinationInfFileNameComponent OPTIONAL)
Definition: install.c:2296
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
#define SPOST_NONE
Definition: setupapi.h:604
char * cleanup(char *str)
Definition: wpickclick.c:99
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128

◆ SetupCopyOEMInfW()

BOOL WINAPI SetupCopyOEMInfW ( IN PCWSTR  SourceInfFileName,
IN PCWSTR  OEMSourceMediaLocation,
IN DWORD  OEMSourceMediaType,
IN DWORD  CopyStyle,
OUT PWSTR DestinationInfFileName  OPTIONAL,
IN DWORD  DestinationInfFileNameSize,
OUT PDWORD RequiredSize  OPTIONAL,
OUT PWSTR *DestinationInfFileNameComponent  OPTIONAL 
)

Definition at line 2296 of file install.c.

2305 {
2306  BOOL ret = FALSE;
2307 
2308  TRACE("%s %s 0x%lx 0x%lx %p 0%lu %p %p\n",
2309  debugstr_w(SourceInfFileName), debugstr_w(OEMSourceMediaLocation), OEMSourceMediaType,
2310  CopyStyle, DestinationInfFileName, DestinationInfFileNameSize,
2311  RequiredSize, DestinationInfFileNameComponent);
2312 
2313  if (!SourceInfFileName)
2315  else if (OEMSourceMediaType != SPOST_NONE && OEMSourceMediaType != SPOST_PATH && OEMSourceMediaType != SPOST_URL)
2318  {
2319  TRACE("Unknown flags: 0x%08lx\n", CopyStyle & ~(SP_COPY_DELETESOURCE | SP_COPY_REPLACEONLY | SP_COPY_NOOVERWRITE | SP_COPY_OEMINF_CATALOG_ONLY));
2321  }
2322  else if (!DestinationInfFileName && DestinationInfFileNameSize > 0)
2324  else if (CopyStyle & SP_COPY_OEMINF_CATALOG_ONLY)
2325  {
2326  FIXME("CopyStyle 0x%x not supported\n", SP_COPY_OEMINF_CATALOG_ONLY);
2328  }
2329  else
2330  {
2331  HANDLE hSearch = INVALID_HANDLE_VALUE;
2332  WIN32_FIND_DATAW FindFileData;
2333  BOOL AlreadyExists;
2334  DWORD NextFreeNumber = 0;
2335  SIZE_T len;
2336  LPWSTR pFullFileName = NULL;
2337  LPWSTR pFileName; /* Pointer into pFullFileName buffer */
2338  HANDLE hSourceFile = INVALID_HANDLE_VALUE;
2339 
2340  if (OEMSourceMediaType == SPOST_PATH || OEMSourceMediaType == SPOST_URL)
2341  FIXME("OEMSourceMediaType 0x%lx ignored\n", OEMSourceMediaType);
2342 
2343  /* Check if source file exists, and open it */
2344  if (strchrW(SourceInfFileName, '\\' ) || strchrW(SourceInfFileName, '/' ))
2345  {
2346  WCHAR *path;
2347 
2348  if (!(len = GetFullPathNameW(SourceInfFileName, 0, NULL, NULL)))
2349  return FALSE;
2350  if (!(path = MyMalloc(len * sizeof(WCHAR))))
2351  {
2353  return FALSE;
2354  }
2355  GetFullPathNameW(SourceInfFileName, len, path, NULL);
2356  hSourceFile = CreateFileW(
2359  NULL, OPEN_EXISTING, 0, NULL);
2360  MyFree(path);
2361  }
2362  else /* try Windows directory */
2363  {
2364  WCHAR *path, *p;
2365  static const WCHAR Inf[] = {'\\','i','n','f','\\',0};
2366  static const WCHAR System32[] = {'\\','s','y','s','t','e','m','3','2','\\',0};
2367 
2368  len = GetWindowsDirectoryW(NULL, 0) + strlenW(SourceInfFileName) + 12;
2369  if (!(path = MyMalloc(len * sizeof(WCHAR))))
2370  {
2372  return FALSE;
2373  }
2375  p = path + strlenW(path);
2376  strcpyW(p, Inf);
2377  strcatW(p, SourceInfFileName);
2378  hSourceFile = CreateFileW(
2381  NULL, OPEN_EXISTING, 0, NULL);
2382  if (hSourceFile == INVALID_HANDLE_VALUE)
2383  {
2384  strcpyW(p, System32);
2385  strcatW(p, SourceInfFileName);
2386  hSourceFile = CreateFileW(
2389  NULL, OPEN_EXISTING, 0, NULL);
2390  }
2391  MyFree(path);
2392  }
2393  if (hSourceFile == INVALID_HANDLE_VALUE)
2394  {
2396  goto cleanup;
2397  }
2398 
2399  /* Prepare .inf file specification */
2400  len = MAX_PATH + 1 + strlenW(InfDirectory) + 13;
2401  pFullFileName = MyMalloc(len * sizeof(WCHAR));
2402  if (!pFullFileName)
2403  {
2405  goto cleanup;
2406  }
2407  len = GetSystemWindowsDirectoryW(pFullFileName, MAX_PATH);
2408  if (len == 0 || len > MAX_PATH)
2409  goto cleanup;
2410  if (pFullFileName[strlenW(pFullFileName) - 1] != '\\')
2411  strcatW(pFullFileName, BackSlash);
2412  strcatW(pFullFileName, InfDirectory);
2413  pFileName = &pFullFileName[strlenW(pFullFileName)];
2414 
2415  /* Search if the specified .inf file already exists in %WINDIR%\Inf */
2416  AlreadyExists = FALSE;
2417  strcpyW(pFileName, OemFileMask);
2418  hSearch = FindFirstFileW(pFullFileName, &FindFileData);
2419  if (hSearch != INVALID_HANDLE_VALUE)
2420  {
2421  LARGE_INTEGER SourceFileSize;
2422 
2423  if (GetFileSizeEx(hSourceFile, &SourceFileSize))
2424  {
2425  do
2426  {
2427  LARGE_INTEGER DestFileSize;
2428  HANDLE hDestFile;
2429 
2430  strcpyW(pFileName, FindFileData.cFileName);
2431  hDestFile = CreateFileW(
2432  pFullFileName, FILE_READ_DATA | FILE_READ_ATTRIBUTES,
2434  NULL, OPEN_EXISTING, 0, NULL);
2435  if (hDestFile != INVALID_HANDLE_VALUE)
2436  {
2437  if (GetFileSizeEx(hDestFile, &DestFileSize)
2438  && DestFileSize.QuadPart == SourceFileSize.QuadPart
2439  && !compare_files(hSourceFile, hDestFile))
2440  {
2441  TRACE("%s already exists as %s\n",
2442  debugstr_w(SourceInfFileName), debugstr_w(pFileName));
2443  AlreadyExists = TRUE;
2444  }
2445  }
2446  } while (!AlreadyExists && FindNextFileW(hSearch, &FindFileData));
2447  }
2448  FindClose(hSearch);
2449  hSearch = INVALID_HANDLE_VALUE;
2450  }
2451 
2452  if (!AlreadyExists && CopyStyle & SP_COPY_REPLACEONLY)
2453  {
2454  /* FIXME: set DestinationInfFileName, RequiredSize, DestinationInfFileNameComponent */
2456  goto cleanup;
2457  }
2458  else if (AlreadyExists && (CopyStyle & SP_COPY_NOOVERWRITE))
2459  {
2460  DWORD Size = strlenW(pFileName) + 1;
2461 
2462  if (RequiredSize)
2463  *RequiredSize = Size;
2464  if (DestinationInfFileNameSize == 0)
2466  else if (DestinationInfFileNameSize < Size)
2468  else
2469  {
2471  strcpyW(DestinationInfFileName, pFileName);
2472  }
2473  goto cleanup;
2474  }
2475 
2476  /* Search the number to give to OEM??.INF */
2477  strcpyW(pFileName, OemFileMask);
2478  hSearch = FindFirstFileW(pFullFileName, &FindFileData);
2479  if (hSearch == INVALID_HANDLE_VALUE)
2480  {
2482  goto cleanup;
2483  }
2484  else
2485  {
2486  do
2487  {
2488  DWORD CurrentNumber;
2489  if (swscanf(FindFileData.cFileName, OemFileSpecification, &CurrentNumber) == 1
2490  && CurrentNumber <= 99999)
2491  {
2492  if (CurrentNumber >= NextFreeNumber)
2493  NextFreeNumber = CurrentNumber + 1;
2494  }
2495  } while (FindNextFileW(hSearch, &FindFileData));
2496  }
2497 
2498  if (NextFreeNumber > 99999)
2499  {
2500  ERR("Too much custom .inf files\n");
2502  goto cleanup;
2503  }
2504 
2505  /* Create the full path: %WINDIR%\Inf\OEM{XXXXX}.inf */
2506  sprintfW(pFileName, OemFileSpecification, NextFreeNumber);
2507  TRACE("Next available file is %s\n", debugstr_w(pFileName));
2508 
2509  if (!CopyFileW(SourceInfFileName, pFullFileName, TRUE))
2510  {
2511  TRACE("CopyFileW() failed with error 0x%lx\n", GetLastError());
2512  goto cleanup;
2513  }
2514 
2515  len = strlenW(pFullFileName) + 1;
2516  if (RequiredSize)
2517  *RequiredSize = len;
2518  if (DestinationInfFileName)
2519  {
2520  if (DestinationInfFileNameSize >= len)
2521  {
2522  strcpyW(DestinationInfFileName, pFullFileName);
2523  if (DestinationInfFileNameComponent)
2524  *DestinationInfFileNameComponent = &DestinationInfFileName[pFileName - pFullFileName];
2525  }
2526  else
2527  {
2529  goto cleanup;
2530  }
2531  }
2532 
2533  if (CopyStyle & SP_COPY_DELETESOURCE)
2534  {
2535  if (!DeleteFileW(SourceInfFileName))
2536  {
2537  TRACE("DeleteFileW() failed with error 0x%lx\n", GetLastError());
2538  goto cleanup;
2539  }
2540  }
2541 
2542  ret = TRUE;
2543 
2544 cleanup:
2545  if (hSourceFile != INVALID_HANDLE_VALUE)
2546  CloseHandle(hSourceFile);
2547  if (hSearch != INVALID_HANDLE_VALUE)
2548  FindClose(hSearch);
2549  MyFree(pFullFileName);
2550  }
2551 
2552  TRACE("Returning %d\n", ret);
2554  return ret;
2555 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
#define ERROR_FILE_EXISTS
Definition: winerror.h:165
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2396
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
static const WCHAR OemFileSpecification[]
Definition: install.c:32
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
static int compare_files(HANDLE file1, HANDLE file2)
Definition: install.c:2270
GLsizei const GLchar ** path
Definition: glext.h:7234
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define SP_COPY_OEMINF_CATALOG_ONLY
Definition: setupapi.h:489
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1105
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FILE_READ_DATA
Definition: nt_native.h:628
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
static const WCHAR InfDirectory[]
Definition: install.c:30
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define OPEN_EXISTING
Definition: compat.h:426
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
#define SP_COPY_NOOVERWRITE
Definition: setupapi.h:475
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SPOST_PATH
Definition: setupapi.h:605
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define GetFileSizeEx
Definition: compat.h:414
static const WCHAR BackSlash[]
Definition: install.c:28
int ret
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
static const WCHAR OemFileMask[]
Definition: install.c:31
GLenum GLsizei len
Definition: glext.h:6722
#define SP_COPY_REPLACEONLY
Definition: setupapi.h:472
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define ERR(fmt,...)
Definition: debug.h:109
ULONG_PTR SIZE_T
Definition: typedefs.h:78
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define SP_COPY_DELETESOURCE
Definition: setupapi.h:471
Definition: services.c:325
#define sprintfW
Definition: unicode.h:58
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
#define SPOST_NONE
Definition: setupapi.h:604
#define CreateFileW
Definition: compat.h:400
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
char * cleanup(char *str)
Definition: wpickclick.c:99
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
#define SPOST_URL
Definition: setupapi.h:606
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_Check_return_ _CRTIMP int __cdecl swscanf(_In_z_ const wchar_t *_Src, _In_z_ _Scanf_format_string_ const wchar_t *_Format,...)
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583
LONGLONG QuadPart
Definition: typedefs.h:112
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by SetupCopyOEMInfA(), and SetupDiInstallDevice().

◆ SetupInstallFilesFromInfSectionA()

BOOL WINAPI SetupInstallFilesFromInfSectionA ( HINF  hinf,
HINF  hlayout,
HSPFILEQ  queue,
PCSTR  section,
PCSTR  src_root,
UINT  flags 
)

Definition at line 1203 of file install.c.

1205 {
1206  UNICODE_STRING sectionW;
1207  BOOL ret = FALSE;
1208 
1209  if (!RtlCreateUnicodeStringFromAsciiz( &sectionW, section ))
1210  {
1212  return FALSE;
1213  }
1214  if (!src_root)
1215  ret = SetupInstallFilesFromInfSectionW( hinf, hlayout, queue, sectionW.Buffer,
1216  NULL, flags );
1217  else
1218  {
1219  UNICODE_STRING srcW;
1221  {
1222  ret = SetupInstallFilesFromInfSectionW( hinf, hlayout, queue, sectionW.Buffer,
1223  srcW.Buffer, flags );
1224  RtlFreeUnicodeString( &srcW );
1225  }
1227  }
1228  RtlFreeUnicodeString( &sectionW );
1229  return ret;
1230 }
BOOL WINAPI SetupInstallFilesFromInfSectionW(HINF hinf, HINF hlayout, HSPFILEQ queue, PCWSTR section, PCWSTR src_root, UINT flags)
Definition: install.c:1236
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
Definition: parser.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: _queue.h:59
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
GLbitfield flags
Definition: glext.h:7161
int ret

◆ SetupInstallFilesFromInfSectionW()

BOOL WINAPI SetupInstallFilesFromInfSectionW ( HINF  hinf,
HINF  hlayout,
HSPFILEQ  queue,
PCWSTR  section,
PCWSTR  src_root,
UINT  flags 
)

Definition at line 1236 of file install.c.

1238 {
1239  struct files_callback_info info;
1240 
1241  info.queue = queue;
1242  info.src_root = src_root;
1243  info.copy_flags = flags;
1244  info.layout = hlayout;
1246 }
HSPFILEQ queue
Definition: install.c:59
Definition: parser.c:55
static const WCHAR CopyFiles[]
Definition: install.c:106
static BOOL copy_files_callback(HINF hinf, PCWSTR field, void *arg)
Definition: install.c:157
GLbitfield flags
Definition: glext.h:7161
static BOOL iterate_section_fields(HINF hinf, PCWSTR section, PCWSTR key, iterate_fields_func callback, void *arg)
Definition: install.c:1167

Referenced by SetupInstallFilesFromInfSectionA().

◆ SetupInstallFromInfSectionA()

BOOL WINAPI SetupInstallFromInfSectionA ( HWND  owner,
HINF  hinf,
PCSTR  section,
UINT  flags,
HKEY  key_root,
PCSTR  src_root,
UINT  copy_flags,
PSP_FILE_CALLBACK_A  callback,
PVOID  context,
HDEVINFO  devinfo,
PSP_DEVINFO_DATA  devinfo_data 
)

Definition at line 1252 of file install.c.

1256 {
1257  UNICODE_STRING sectionW, src_rootW;
1258  struct callback_WtoA_context ctx;
1259  BOOL ret = FALSE;
1260 
1261  src_rootW.Buffer = NULL;
1262  if (src_root && !RtlCreateUnicodeStringFromAsciiz( &src_rootW, src_root ))
1263  {
1265  return FALSE;
1266  }
1267 
1268  if (RtlCreateUnicodeStringFromAsciiz( &sectionW, section ))
1269  {
1270  ctx.orig_context = context;
1271  ctx.orig_handler = callback;
1272  ret = SetupInstallFromInfSectionW( owner, hinf, sectionW.Buffer, flags, key_root,
1273  src_rootW.Buffer, copy_flags, QUEUE_callback_WtoA,
1274  &ctx, devinfo, devinfo_data );
1275  RtlFreeUnicodeString( &sectionW );
1276  }
1278 
1279  RtlFreeUnicodeString( &src_rootW );
1280  return ret;
1281 }
Definition: http.c:6587
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
Definition: parser.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
GLbitfield flags
Definition: glext.h:7161
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:1323
int ret
UINT CALLBACK QUEUE_callback_WtoA(void *context, UINT notification, UINT_PTR param1, UINT_PTR param2)
Definition: queue.c:187

Referenced by test_install_from().

◆ SetupInstallFromInfSectionW()

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 at line 1323 of file install.c.

1327 {
1328  struct needs_callback_info needs_info;
1329 
1330  /* Parse 'Include' and 'Needs' directives */
1332  needs_info.type = 0;
1333  needs_info.owner = owner;
1334  needs_info.flags = flags;
1335  needs_info.key_root = key_root;
1336  needs_info.src_root = src_root;
1337  needs_info.copy_flags = copy_flags;
1338  needs_info.callback = callback;
1339  needs_info.context = context;
1340  needs_info.devinfo = devinfo;
1341  needs_info.devinfo_data = devinfo_data;
1342  iterate_section_fields( hinf, section, Needs, needs_callback, &needs_info);
1343 
1344  if (flags & SPINST_FILES)
1345  {
1346  SP_DEVINSTALL_PARAMS_W install_params;
1347  struct files_callback_info info;
1348  HSPFILEQ queue = NULL;
1349  BOOL use_custom_queue;
1350  BOOL ret;
1351 
1352  install_params.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
1353  use_custom_queue = SetupDiGetDeviceInstallParamsW(devinfo, devinfo_data, &install_params) && (install_params.Flags & DI_NOVCP);
1354  if (!use_custom_queue && ((queue = SetupOpenFileQueue()) == (HSPFILEQ)INVALID_HANDLE_VALUE ))
1355  return FALSE;
1356  info.queue = use_custom_queue ? install_params.FileQueue : queue;
1357  info.src_root = src_root;
1358  info.copy_flags = copy_flags;
1359  info.layout = hinf;
1363  if (!use_custom_queue)
1364  {
1365  if (ret)
1368  }
1369  if (!ret) return FALSE;
1370  }
1371  if (flags & SPINST_INIFILES)
1372  {
1376  return FALSE;
1377  }
1378  if (flags & SPINST_INI2REG)
1379  {
1381  return FALSE;
1382  }
1383  if (flags & SPINST_LOGCONFIG)
1384  {
1386  return FALSE;
1387  }
1388  if (flags & SPINST_REGSVR)
1389  {
1390  struct register_dll_info info;
1391 
1392  info.unregister = FALSE;
1393  if (flags & SPINST_REGISTERCALLBACKAWARE)
1394  {
1395  info.callback = callback;
1396  info.callback_context = context;
1397  }
1398  else info.callback = NULL;
1399 
1401  return FALSE;
1402 
1403 #ifdef __WINESRC__
1404  if (!iterate_section_fields( hinf, section, WineFakeDlls, fake_dlls_callback, NULL ))
1405  return FALSE;
1406 #endif // __WINESRC__
1407  }
1408  if (flags & SPINST_UNREGSVR)
1409  {
1410  struct register_dll_info info;
1411 
1412  info.unregister = TRUE;
1413  if (flags & SPINST_REGISTERCALLBACKAWARE)
1414  {
1415  info.callback = callback;
1416  info.callback_context = context;
1417  }
1418  else info.callback = NULL;
1419 
1421  return FALSE;
1422  }
1423  if (flags & SPINST_REGISTRY)
1424  {
1426 
1427  info.default_root = key_root;
1428  info.delete = TRUE;
1430  return FALSE;
1431  info.delete = FALSE;
1433  return FALSE;
1434  }
1435  if (flags & SPINST_BITREG)
1436  {
1438  return FALSE;
1439  }
1440  if (flags & SPINST_PROFILEITEMS)
1441  {
1443  return FALSE;
1444  }
1445  if (flags & SPINST_COPYINF)
1446  {
1448  return FALSE;
1449  }
1450 
1451  return TRUE;
1452 }
static BOOL register_dlls_callback(HINF hinf, PCWSTR field, void *arg)
Definition: install.c:669
static const WCHAR Include[]
Definition: install.c:120
#define TRUE
Definition: types.h:120
static BOOL update_ini_callback(HINF hinf, PCWSTR field, void *arg)
Definition: install.c:764
#define SPINST_INIFILES
Definition: setupapi.h:584
static const WCHAR Ini2Reg[]
Definition: install.c:109
static const WCHAR UpdateInis[]
Definition: install.c:114
static BOOL include_callback(HINF hinf, PCWSTR field, void *arg)
Definition: install.c:1289
#define SPINST_REGSVR
Definition: setupapi.h:589
static BOOL logconf_callback(HINF hinf, PCWSTR field, void *arg)
Definition: install.c:825
static const WCHAR UnregisterDlls[]
Definition: install.c:118
Definition: http.c:6587
static const WCHAR DelFiles[]
Definition: install.c:107
#define SPINST_BITREG
Definition: setupapi.h:588
static const WCHAR LogConf[]
Definition: install.c:110
static const WCHAR Needs[]
Definition: install.c:121
static BOOL update_ini_fields_callback(HINF hinf, PCWSTR field, void *arg)
Definition: install.c:813
HSPFILEQ WINAPI SetupOpenFileQueue(VOID)
Definition: fileqsup.c:161
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
static BOOL registry_callback(HINF hinf, PCWSTR field, void *arg)
Definition: install.c:421
HSPFILEQ queue
Definition: install.c:59
static BOOL needs_callback(HINF hinf, PCWSTR field, void *arg)
Definition: install.c:1300
Definition: parser.c:55
static const WCHAR CopyINF[]
Definition: install.c:115
static BOOL rename_files_callback(HINF hinf, PCWSTR field, void *arg)
Definition: install.c:187
static const WCHAR DelReg[]
Definition: install.c:112
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR RegisterDlls[]
Definition: install.c:117
BOOL WINAPI SetupDiGetDeviceInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, OUT PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4456
static const WCHAR CopyFiles[]
Definition: install.c:106
static BOOL copy_files_callback(HINF hinf, PCWSTR field, void *arg)
Definition: install.c:157
Definition: _queue.h:59
#define DI_NOVCP
Definition: setupapi.h:49
#define SPINST_REGISTRY
Definition: setupapi.h:585
smooth NULL
Definition: ftsmooth.c:416
static BOOL delete_files_callback(HINF hinf, PCWSTR field, void *arg)
Definition: install.c:174
#define SPINST_FILES
Definition: setupapi.h:587
static const WCHAR RenFiles[]
Definition: install.c:108
#define SPINST_UNREGSVR
Definition: setupapi.h:590
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
static BOOL copy_inf_callback(HINF hinf, PCWSTR field, void *arg)
Definition: install.c:1155
SP_DEVINSTALL_PARAMS_A SP_DEVINSTALL_PARAMS
Definition: setupapi.h:1150
static const WCHAR BitReg[]
Definition: install.c:113
BOOL WINAPI SetupCommitFileQueueW(IN HWND Owner, IN HSPFILEQ QueueHandle, IN PSP_FILE_CALLBACK_W MsgHandler, IN PVOID Context OPTIONAL)
Definition: fileqsup.c:617
GLbitfield flags
Definition: glext.h:7161
int ret
static BOOL profile_items_callback(IN HINF hInf, IN PCWSTR SectionName, IN PVOID Arg)
Definition: install.c:887
static const WCHAR AddReg[]
Definition: install.c:111
#define SPINST_PROFILEITEMS
Definition: setupapi.h:591
static BOOL ini2reg_callback(HINF hinf, PCWSTR field, void *arg)
Definition: install.c:819
HDEVINFO devinfo
Definition: install.c:92
LPCWSTR src_root
Definition: install.c:88
PSP_DEVINFO_DATA devinfo_data
Definition: install.c:93
#define SPINST_LOGCONFIG
Definition: setupapi.h:583
static BOOL iterate_section_fields(HINF hinf, P