ReactOS 0.4.17-dev-806-gffa4164
advpack.c File Reference
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winreg.h"
#include "winternl.h"
#include "winnls.h"
#include "setupapi.h"
#include "advpub.h"
#include "wine/debug.h"
#include "advpack_private.h"
Include dependency graph for advpack.c:

Go to the source code of this file.

Macros

#define MAX_FIELD_LENGTH   512
 
#define PREFIX_LEN   5
 

Typedefs

typedef HRESULT(WINAPIDLLREGISTER) (void)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (advpack)
 
static void strip_quotes (WCHAR *buffer, DWORD *size)
 
static void get_dest_dir (HINF hInf, PCWSTR pszSection, PWSTR pszBuffer, DWORD dwSize)
 
void set_ldids (HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir)
 
HRESULT WINAPI CloseINFEngine (HINF hInf)
 
BOOL WINAPI IsNTAdmin (DWORD reserved, LPDWORD pReserved)
 
DWORD WINAPI NeedRebootInit (VOID)
 
BOOL WINAPI NeedReboot (DWORD dwRebootCheck)
 
HRESULT WINAPI OpenINFEngineA (LPCSTR pszInfFilename, LPCSTR pszInstallSection, DWORD dwFlags, HINF *phInf, PVOID pvReserved)
 
HRESULT WINAPI OpenINFEngineW (LPCWSTR pszInfFilename, LPCWSTR pszInstallSection, DWORD dwFlags, HINF *phInf, PVOID pvReserved)
 
HRESULT WINAPI RebootCheckOnInstallA (HWND hWnd, LPCSTR pszINF, LPCSTR pszSec, DWORD dwReserved)
 
HRESULT WINAPI RebootCheckOnInstallW (HWND hWnd, LPCWSTR pszINF, LPCWSTR pszSec, DWORD dwReserved)
 
HRESULT do_ocx_reg (HMODULE hocx, BOOL do_reg, const WCHAR *flags, const WCHAR *param)
 
HRESULT WINAPI RegisterOCX (HWND hWnd, HINSTANCE hInst, LPCSTR cmdline, INT show)
 
HRESULT WINAPI SetPerUserSecValuesA (PERUSERSECTIONA *pPerUser)
 
HRESULT WINAPI SetPerUserSecValuesW (PERUSERSECTIONW *pPerUser)
 
HRESULT WINAPI TranslateInfStringA (LPCSTR pszInfFilename, LPCSTR pszInstallSection, LPCSTR pszTranslateSection, LPCSTR pszTranslateKey, LPSTR pszBuffer, DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved)
 
HRESULT WINAPI TranslateInfStringW (LPCWSTR pszInfFilename, LPCWSTR pszInstallSection, LPCWSTR pszTranslateSection, LPCWSTR pszTranslateKey, LPWSTR pszBuffer, DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved)
 
HRESULT WINAPI TranslateInfStringExA (HINF hInf, LPCSTR pszInfFilename, LPCSTR pszTranslateSection, LPCSTR pszTranslateKey, LPSTR pszBuffer, DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved)
 
HRESULT WINAPI TranslateInfStringExW (HINF hInf, LPCWSTR pszInfFilename, LPCWSTR pszTranslateSection, LPCWSTR pszTranslateKey, LPWSTR pszBuffer, DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved)
 
HRESULT WINAPI UserInstStubWrapperA (HWND hWnd, HINSTANCE hInstance, LPSTR pszParms, INT nShow)
 
HRESULT WINAPI UserInstStubWrapperW (HWND hWnd, HINSTANCE hInstance, LPWSTR pszParms, INT nShow)
 
HRESULT WINAPI UserUnInstStubWrapperA (HWND hWnd, HINSTANCE hInstance, LPSTR pszParms, INT nShow)
 
HRESULT WINAPI UserUnInstStubWrapperW (HWND hWnd, HINSTANCE hInstance, LPWSTR pszParms, INT nShow)
 

Variables

static const WCHAR setup_key [] = L"SOFTWARE\\Microsoft\\Active Setup\\Installed Components"
 

Macro Definition Documentation

◆ MAX_FIELD_LENGTH

#define MAX_FIELD_LENGTH   512

Definition at line 40 of file advpack.c.

◆ PREFIX_LEN

#define PREFIX_LEN   5

Definition at line 41 of file advpack.c.

Typedef Documentation

◆ DLLREGISTER

typedef HRESULT(WINAPI * DLLREGISTER) (void)

Definition at line 38 of file advpack.c.

Function Documentation

◆ CloseINFEngine()

HRESULT WINAPI CloseINFEngine ( HINF  hInf)

Definition at line 184 of file advpack.c.

185{
186 TRACE("(%p)\n", hInf);
187
188 if (!hInf)
189 return E_INVALIDARG;
190
191 SetupCloseInfFile(hInf);
192 return S_OK;
193}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define S_OK
Definition: intsafe.h:52
#define TRACE(s)
Definition: solgame.cpp:4
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:45

◆ do_ocx_reg()

HRESULT do_ocx_reg ( HMODULE  hocx,
BOOL  do_reg,
const WCHAR flags,
const WCHAR param 
)

Definition at line 427 of file advpack.c.

428{
429 DLLREGISTER reg_func;
430
431 if (do_reg)
432 reg_func = (DLLREGISTER)GetProcAddress(hocx, "DllRegisterServer");
433 else
434 reg_func = (DLLREGISTER)GetProcAddress(hocx, "DllUnregisterServer");
435
436 if (!reg_func)
437 return E_FAIL;
438
439 reg_func();
440 return S_OK;
441}
#define E_FAIL
Definition: ddrawi.h:102
HRESULT(WINAPI * DLLREGISTER)(void)
Definition: advpack.c:38
#define GetProcAddress(x, y)
Definition: compat.h:753

Referenced by register_ocxs_callback(), and RegisterOCX().

◆ get_dest_dir()

static void get_dest_dir ( HINF  hInf,
PCWSTR  pszSection,
PWSTR  pszBuffer,
DWORD  dwSize 
)
static

Definition at line 62 of file advpack.c.

63{
65 WCHAR key[MAX_PATH + 2], value[MAX_PATH + 2];
67 HKEY root, subkey = 0;
68 DWORD size;
69
70 /* load the destination parameters */
71 SetupFindFirstLineW(hInf, pszSection, NULL, &context);
78
79 if (!lstrcmpW(prefix, L"HKLM"))
81 else if (!lstrcmpW(prefix, L"HKCU"))
83 else
84 root = NULL;
85
86 size = dwSize * sizeof(WCHAR);
87
88 /* fallback to the default destination dir if reg fails */
89 if (RegOpenKeyW(root, key, &subkey) ||
90 RegQueryValueExW(subkey, value, NULL, NULL, (LPBYTE)pszBuffer, &size))
91 {
92 SetupGetStringFieldW(&context, 5, pszBuffer, dwSize, &size);
93 strip_quotes(pszBuffer, &size);
94 }
95
96 if (subkey) RegCloseKey(subkey);
97}
#define RegCloseKey(hKey)
Definition: registry.h:49
struct _root root
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define PREFIX_LEN
Definition: advpack.c:41
static void strip_quotes(WCHAR *buffer, DWORD *size)
Definition: advpack.c:47
#define MAX_PATH
Definition: compat.h:34
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
short WCHAR
Definition: pedump.c:58
Definition: http.c:7252
Definition: copy.c:22
Character const *const prefix
Definition: tempnam.cpp:195
unsigned char * LPBYTE
Definition: typedefs.h:53
Definition: pdh_main.c:96
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:186
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:56
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by set_ldids().

◆ IsNTAdmin()

BOOL WINAPI IsNTAdmin ( DWORD  reserved,
LPDWORD  pReserved 
)

Definition at line 207 of file advpack.c.

208{
210 PTOKEN_GROUPS pTokenGroups;
211 BOOL bSidFound = FALSE;
212 DWORD dwSize, i;
213 HANDLE hToken;
214 PSID pSid;
215
216 TRACE("(%ld, %p)\n", reserved, pReserved);
217
219 return FALSE;
220
221 if (!GetTokenInformation(hToken, TokenGroups, NULL, 0, &dwSize))
222 {
224 {
225 CloseHandle(hToken);
226 return FALSE;
227 }
228 }
229
230 pTokenGroups = malloc(dwSize);
231 if (!pTokenGroups)
232 {
233 CloseHandle(hToken);
234 return FALSE;
235 }
236
237 if (!GetTokenInformation(hToken, TokenGroups, pTokenGroups, dwSize, &dwSize))
238 {
239 free(pTokenGroups);
240 CloseHandle(hToken);
241 return FALSE;
242 }
243
244 CloseHandle(hToken);
245
247 DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &pSid))
248 {
249 free(pTokenGroups);
250 return FALSE;
251 }
252
253 for (i = 0; i < pTokenGroups->GroupCount; i++)
254 {
255 if (EqualSid(pSid, pTokenGroups->Groups[i].Sid))
256 {
257 bSidFound = TRUE;
258 break;
259 }
260 }
261
262 free(pTokenGroups);
263 FreeSid(pSid);
264
265 return bSidFound;
266}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
Definition: security.c:674
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:698
BOOL WINAPI EqualSid(PSID pSid1, PSID pSid2)
Definition: security.c:829
#define CloseHandle
Definition: compat.h:739
#define GetCurrentProcess()
Definition: compat.h:759
r reserved
Definition: btrfs.c:3006
unsigned int BOOL
Definition: ntddk_ex.h:94
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
static PSID pSid
Definition: security.c:85
_Out_ PVOID pReserved
Definition: netsh.h:77
SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY]
Definition: setypes.h:1030
$ULONG GroupCount
Definition: setypes.h:1026
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:581
#define TOKEN_QUERY
Definition: setypes.h:940
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:554
@ TokenGroups
Definition: setypes.h:979
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:652

Referenced by check_admin_rights(), and START_TEST().

◆ NeedReboot()

BOOL WINAPI NeedReboot ( DWORD  dwRebootCheck)

Definition at line 296 of file advpack.c.

297{
298 FIXME("(%ld): stub\n", dwRebootCheck);
299 return FALSE;
300}
#define FIXME(fmt,...)
Definition: precomp.h:53

Referenced by ApplyGeneralSettings(), and UpdateDriver().

◆ NeedRebootInit()

DWORD WINAPI NeedRebootInit ( VOID  )

Definition at line 276 of file advpack.c.

277{
278 FIXME("(VOID): stub\n");
279 return 0;
280}

◆ OpenINFEngineA()

HRESULT WINAPI OpenINFEngineA ( LPCSTR  pszInfFilename,
LPCSTR  pszInstallSection,
DWORD  dwFlags,
HINF phInf,
PVOID  pvReserved 
)

Definition at line 307 of file advpack.c.

309{
310 UNICODE_STRING filenameW, installW;
311 HRESULT res;
312
313 TRACE("(%s, %s, %ld, %p, %p)\n", debugstr_a(pszInfFilename),
314 debugstr_a(pszInstallSection), dwFlags, phInf, pvReserved);
315
316 if (!pszInfFilename || !phInf)
317 return E_INVALIDARG;
318
320 RtlCreateUnicodeStringFromAsciiz(&installW, pszInstallSection);
321
322 res = OpenINFEngineW(filenameW.Buffer, installW.Buffer,
323 dwFlags, phInf, pvReserved);
324
326 RtlFreeUnicodeString(&installW);
327
328 return res;
329}
HRESULT WINAPI OpenINFEngineW(LPCWSTR pszInfFilename, LPCWSTR pszInstallSection, DWORD dwFlags, HINF *phInf, PVOID pvReserved)
Definition: advpack.c:348
GLuint res
Definition: glext.h:9613
#define debugstr_a
Definition: kernel32.h:31
static const WCHAR filenameW[]
Definition: amstream.c:41
static LPCWSTR LPVOID pvReserved
Definition: asmcache.c:749
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)

◆ OpenINFEngineW()

HRESULT WINAPI OpenINFEngineW ( LPCWSTR  pszInfFilename,
LPCWSTR  pszInstallSection,
DWORD  dwFlags,
HINF phInf,
PVOID  pvReserved 
)

Definition at line 348 of file advpack.c.

350{
351 TRACE("(%s, %s, %ld, %p, %p)\n", debugstr_w(pszInfFilename),
352 debugstr_w(pszInstallSection), dwFlags, phInf, pvReserved);
353
354 if (!pszInfFilename || !phInf)
355 return E_INVALIDARG;
356
357 *phInf = SetupOpenInfFileW(pszInfFilename, NULL, INF_STYLE_WIN4, NULL);
358 if (*phInf == INVALID_HANDLE_VALUE)
360
361 set_ldids(*phInf, pszInstallSection, NULL);
362
363 return S_OK;
364}
void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir)
Definition: advpack.c:100
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
#define INF_STYLE_WIN4
Definition: infsupp.h:43
#define debugstr_w
Definition: kernel32.h:32
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

Referenced by OpenINFEngineA().

◆ RebootCheckOnInstallA()

HRESULT WINAPI RebootCheckOnInstallA ( HWND  hWnd,
LPCSTR  pszINF,
LPCSTR  pszSec,
DWORD  dwReserved 
)

Definition at line 371 of file advpack.c.

373{
374 UNICODE_STRING infW, secW;
375 HRESULT res;
376
377 TRACE("(%p, %s, %s, %ld)\n", hWnd, debugstr_a(pszINF),
378 debugstr_a(pszSec), dwReserved);
379
380 if (!pszINF || !pszSec)
381 return E_INVALIDARG;
382
385
387
390
391 return res;
392}
HWND hWnd
Definition: settings.c:17
HRESULT WINAPI RebootCheckOnInstallW(HWND hWnd, LPCWSTR pszINF, LPCWSTR pszSec, DWORD dwReserved)
Definition: advpack.c:417
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95

◆ RebootCheckOnInstallW()

HRESULT WINAPI RebootCheckOnInstallW ( HWND  hWnd,
LPCWSTR  pszINF,
LPCWSTR  pszSec,
DWORD  dwReserved 
)

Definition at line 417 of file advpack.c.

419{
420 FIXME("(%p, %s, %s, %ld): stub\n", hWnd, debugstr_w(pszINF),
421 debugstr_w(pszSec), dwReserved);
422
423 return E_FAIL;
424}

Referenced by RebootCheckOnInstallA().

◆ RegisterOCX()

HRESULT WINAPI RegisterOCX ( HWND  hWnd,
HINSTANCE  hInst,
LPCSTR  cmdline,
INT  show 
)

Definition at line 465 of file advpack.c.

466{
467 LPWSTR ocx_filename, str_flags, param;
468 LPWSTR cmdline_copy, cmdline_ptr;
469 UNICODE_STRING cmdlineW;
470 HRESULT hr = E_FAIL;
471 HMODULE hm = NULL;
472
473 TRACE("(%s)\n", debugstr_a(cmdline));
474
476
477 cmdline_copy = wcsdup(cmdlineW.Buffer);
478 cmdline_ptr = cmdline_copy;
479
480 ocx_filename = get_parameter(&cmdline_ptr, ',', TRUE);
481 if (!ocx_filename || !*ocx_filename)
482 goto done;
483
484 str_flags = get_parameter(&cmdline_ptr, ',', TRUE);
485 param = get_parameter(&cmdline_ptr, ',', TRUE);
486
488 if (!hm)
489 goto done;
490
491 hr = do_ocx_reg(hm, TRUE, str_flags, param);
492
493done:
494 FreeLibrary(hm);
495 free(cmdline_copy);
496 RtlFreeUnicodeString(&cmdlineW);
497
498 return hr;
499}
LPWSTR get_parameter(LPWSTR *params, WCHAR separator, BOOL quoted)
Definition: install.c:178
HRESULT hr
Definition: delayimp.cpp:582
HRESULT do_ocx_reg(HMODULE hocx, BOOL do_reg, const WCHAR *flags, const WCHAR *param)
Definition: advpack.c:427
#define FreeLibrary(x)
Definition: compat.h:748
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
GLfloat param
Definition: glext.h:5796
TCHAR * cmdline
Definition: stretchblt.cpp:32
uint16_t * LPWSTR
Definition: typedefs.h:56
#define LOAD_WITH_ALTERED_SEARCH_PATH
Definition: winbase.h:340

◆ set_ldids()

void set_ldids ( HINF  hInf,
LPCWSTR  pszInstallSection,
LPCWSTR  pszWorkingDir 
)

Definition at line 100 of file advpack.c.

101{
106 DWORD size;
107 int ldid;
108
109 if (!SetupGetLineTextW(NULL, hInf, pszInstallSection, L"CustomDestination",
111 return;
112
113 if (!SetupFindFirstLineW(hInf, field, NULL, &context))
114 return;
115
116 do
117 {
118 LPWSTR value, ptr, key, key_copy = NULL;
119 DWORD flags = 0;
120
123
124 /* SetupGetLineTextW returns the value if there is only one key, but
125 * returns the whole line if there is more than one key
126 */
127 if (!(value = wcschr(line, '=')))
128 {
130 key = malloc(size * sizeof(WCHAR));
131 key_copy = key;
133 value = line;
134 }
135 else
136 {
137 key = line;
138 *(value++) = '\0';
139 }
140
141 /* remove leading whitespace from the value */
142 while (*value == ' ')
143 value++;
144
145 /* Extract the flags */
146 ptr = wcschr(value, ',');
147 if (ptr) {
148 *ptr = '\0';
149 flags = wcstol(ptr+1, NULL, 10);
150 }
151
152 /* set dest to pszWorkingDir if key is SourceDir */
153 if (pszWorkingDir && !lstrcmpiW(value, L"SourceDir"))
154 lstrcpynW(dest, pszWorkingDir, MAX_PATH);
155 else
157
158 /* If prompting required, provide dialog to request path */
159 if (flags & 0x04)
160 FIXME("Need to support changing paths - default will be used\n");
161
162 /* set all ldids to dest */
163 while ((ptr = get_parameter(&key, ',', FALSE)))
164 {
165 ldid = wcstol(ptr, NULL, 10);
166 SetupSetDirectoryIdW(hInf, ldid, dest);
167 }
168 free(key_copy);
169 } while (SetupFindNextLine(&context, &context));
170}
BOOL WINAPI SetupSetDirectoryIdW(HINF hinf, DWORD id, PCWSTR dir)
Definition: dirid.c:256
#define MAX_FIELD_LENGTH
Definition: advpack.c:40
static void get_dest_dir(HINF hInf, PCWSTR pszSection, PWSTR pszBuffer, DWORD dwSize)
Definition: advpack.c:62
#define wcschr
Definition: compat.h:17
#define lstrcpynW
Definition: compat.h:738
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
_ACRTIMP __msvcrt_long __cdecl wcstol(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2752
BOOL WINAPI SetupGetLineTextW(PINFCONTEXT context, HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1763
GLbitfield flags
Definition: glext.h:7161
static PVOID ptr
Definition: dispmode.c:27
static char * dest
Definition: rtl.c:149
Definition: parser.c:44
Definition: parser.c:49
BOOL WINAPI SetupFindNextLine(IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut)
Definition: infsupp.c:82

Referenced by install_init(), OpenINFEngineW(), and TranslateInfStringW().

◆ SetPerUserSecValuesA()

HRESULT WINAPI SetPerUserSecValuesA ( PERUSERSECTIONA pPerUser)

Definition at line 506 of file advpack.c.

507{
508 PERUSERSECTIONW perUserW;
509
510 TRACE("(%p)\n", pPerUser);
511
512 if (!pPerUser)
513 return E_INVALIDARG;
514
515 MultiByteToWideChar(CP_ACP, 0, pPerUser->szGUID, -1, perUserW.szGUID, ARRAY_SIZE(perUserW.szGUID));
516 MultiByteToWideChar(CP_ACP, 0, pPerUser->szDispName, -1, perUserW.szDispName, ARRAY_SIZE(perUserW.szDispName));
517 MultiByteToWideChar(CP_ACP, 0, pPerUser->szLocale, -1, perUserW.szLocale, ARRAY_SIZE(perUserW.szLocale));
518 MultiByteToWideChar(CP_ACP, 0, pPerUser->szStub, -1, perUserW.szStub, ARRAY_SIZE(perUserW.szStub));
519 MultiByteToWideChar(CP_ACP, 0, pPerUser->szVersion, -1, perUserW.szVersion, ARRAY_SIZE(perUserW.szVersion));
520 MultiByteToWideChar(CP_ACP, 0, pPerUser->szCompID, -1, perUserW.szCompID, ARRAY_SIZE(perUserW.szCompID));
521 perUserW.dwIsInstalled = pPerUser->dwIsInstalled;
522 perUserW.bRollback = pPerUser->bRollback;
523
524 return SetPerUserSecValuesW(&perUserW);
525}
#define ARRAY_SIZE(A)
Definition: main.h:20
HRESULT WINAPI SetPerUserSecValuesW(PERUSERSECTIONW *pPerUser)
Definition: advpack.c:540
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
CHAR szVersion[32]
Definition: advpub.h:59
CHAR szDispName[128]
Definition: advpub.h:56
DWORD dwIsInstalled
Definition: advpub.h:61
CHAR szCompID[128]
Definition: advpub.h:60
CHAR szGUID[39+20]
Definition: advpub.h:55
CHAR szStub[MAX_PATH *4]
Definition: advpub.h:58
CHAR szLocale[10]
Definition: advpub.h:57
BOOL bRollback
Definition: advpub.h:62
WCHAR szStub[MAX_PATH *4]
Definition: advpub.h:70
BOOL bRollback
Definition: advpub.h:74
DWORD dwIsInstalled
Definition: advpub.h:73
WCHAR szLocale[10]
Definition: advpub.h:69
WCHAR szGUID[39+20]
Definition: advpub.h:67
WCHAR szVersion[32]
Definition: advpub.h:71
WCHAR szDispName[128]
Definition: advpub.h:68
WCHAR szCompID[128]
Definition: advpub.h:72

◆ SetPerUserSecValuesW()

HRESULT WINAPI SetPerUserSecValuesW ( PERUSERSECTIONW pPerUser)

Definition at line 540 of file advpack.c.

541{
542 HKEY setup, guid;
543
544 TRACE("(%p)\n", pPerUser);
545
546 if (!pPerUser || !*pPerUser->szGUID)
547 return S_OK;
548
550 NULL, &setup, NULL))
551 {
552 return E_FAIL;
553 }
554
555 if (RegCreateKeyExW(setup, pPerUser->szGUID, 0, NULL, 0, KEY_ALL_ACCESS,
556 NULL, &guid, NULL))
557 {
559 return E_FAIL;
560 }
561
562 if (*pPerUser->szStub)
563 {
564 RegSetValueExW(guid, L"StubPath", 0, REG_SZ, (BYTE *)pPerUser->szStub,
565 (lstrlenW(pPerUser->szStub) + 1) * sizeof(WCHAR));
566 }
567
568 if (*pPerUser->szVersion)
569 {
570 RegSetValueExW(guid, L"Version", 0, REG_SZ, (BYTE *)pPerUser->szVersion,
571 (lstrlenW(pPerUser->szVersion) + 1) * sizeof(WCHAR));
572 }
573
574 if (*pPerUser->szLocale)
575 {
576 RegSetValueExW(guid, L"Locale", 0, REG_SZ, (BYTE *)pPerUser->szLocale,
577 (lstrlenW(pPerUser->szLocale) + 1) * sizeof(WCHAR));
578 }
579
580 if (*pPerUser->szCompID)
581 {
582 RegSetValueExW(guid, L"ComponentID", 0, REG_SZ, (BYTE *)pPerUser->szCompID,
583 (lstrlenW(pPerUser->szCompID) + 1) * sizeof(WCHAR));
584 }
585
586 if (*pPerUser->szDispName)
587 {
589 (lstrlenW(pPerUser->szDispName) + 1) * sizeof(WCHAR));
590 }
591
592 RegSetValueExW(guid, L"IsInstalled", 0, REG_DWORD,
593 (LPBYTE)&pPerUser->dwIsInstalled, sizeof(DWORD));
594
597
598 return S_OK;
599}
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:1096
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:4882
static const WCHAR setup_key[]
Definition: advpack.c:44
#define lstrlenW
Definition: compat.h:750
GUID guid
Definition: version.c:147
#define REG_SZ
Definition: layer.c:22
static BOOL setup(void)
Definition: enum_files.c:97
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
#define KEY_WRITE
Definition: nt_native.h:1034
#define REG_DWORD
Definition: sdbapi.c:615
unsigned char BYTE
Definition: xxhash.c:193

Referenced by per_user_install_callback(), and SetPerUserSecValuesA().

◆ strip_quotes()

static void strip_quotes ( WCHAR buffer,
DWORD size 
)
static

Definition at line 47 of file advpack.c.

48{
49 if (buffer[0] == '\'' && (*size > 1) && buffer[*size-2]=='\'')
50 {
51 *size -= 2;
52 buffer[*size] = 0x00;
53 memmove(buffer, buffer + 1, *size * sizeof(WCHAR));
54 }
55}
GLuint buffer
Definition: glext.h:5915
#define memmove(s1, s2, n)
Definition: mkisofs.h:881

Referenced by get_dest_dir().

◆ TranslateInfStringA()

HRESULT WINAPI TranslateInfStringA ( LPCSTR  pszInfFilename,
LPCSTR  pszInstallSection,
LPCSTR  pszTranslateSection,
LPCSTR  pszTranslateKey,
LPSTR  pszBuffer,
DWORD  dwBufferSize,
PDWORD  pdwRequiredSize,
PVOID  pvReserved 
)

Definition at line 606 of file advpack.c.

609{
610 UNICODE_STRING filenameW, installW;
611 UNICODE_STRING translateW, keyW;
612 LPWSTR bufferW;
613 HRESULT res;
614 DWORD len = 0;
615
616 TRACE("(%s, %s, %s, %s, %p, %ld, %p, %p)\n",
617 debugstr_a(pszInfFilename), debugstr_a(pszInstallSection),
618 debugstr_a(pszTranslateSection), debugstr_a(pszTranslateKey),
619 pszBuffer, dwBufferSize,pdwRequiredSize, pvReserved);
620
621 if (!pszInfFilename || !pszTranslateSection ||
622 !pszTranslateKey || !pdwRequiredSize)
623 return E_INVALIDARG;
624
626 RtlCreateUnicodeStringFromAsciiz(&installW, pszInstallSection);
627 RtlCreateUnicodeStringFromAsciiz(&translateW, pszTranslateSection);
628 RtlCreateUnicodeStringFromAsciiz(&keyW, pszTranslateKey);
629
630 res = TranslateInfStringW(filenameW.Buffer, installW.Buffer,
631 translateW.Buffer, keyW.Buffer, NULL,
632 dwBufferSize, &len, NULL);
633
634 if (res == S_OK)
635 {
636 bufferW = malloc(len * sizeof(WCHAR));
637
638 res = TranslateInfStringW(filenameW.Buffer, installW.Buffer,
639 translateW.Buffer, keyW.Buffer, bufferW,
640 len, &len, NULL);
641 if (res == S_OK)
642 {
643 *pdwRequiredSize = WideCharToMultiByte(CP_ACP, 0, bufferW, -1,
644 NULL, 0, NULL, NULL);
645
646 if (dwBufferSize >= *pdwRequiredSize)
647 {
648 WideCharToMultiByte(CP_ACP, 0, bufferW, -1, pszBuffer,
649 dwBufferSize, NULL, NULL);
650 }
651 else
653 }
654
655 free(bufferW);
656 }
657
659 RtlFreeUnicodeString(&installW);
660 RtlFreeUnicodeString(&translateW);
662
663 return res;
664}
HRESULT WINAPI TranslateInfStringW(LPCWSTR pszInfFilename, LPCWSTR pszInstallSection, LPCWSTR pszTranslateSection, LPCWSTR pszTranslateKey, LPWSTR pszBuffer, DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved)
Definition: advpack.c:686
#define WideCharToMultiByte
Definition: compat.h:111
GLenum GLsizei len
Definition: glext.h:6722
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:3437

◆ TranslateInfStringExA()

HRESULT WINAPI TranslateInfStringExA ( HINF  hInf,
LPCSTR  pszInfFilename,
LPCSTR  pszTranslateSection,
LPCSTR  pszTranslateKey,
LPSTR  pszBuffer,
DWORD  dwBufferSize,
PDWORD  pdwRequiredSize,
PVOID  pvReserved 
)

Definition at line 726 of file advpack.c.

730{
731 UNICODE_STRING filenameW, sectionW, keyW;
732 LPWSTR bufferW;
733 HRESULT res;
734 DWORD len = 0;
735
736 TRACE("(%p, %s, %s, %s, %p, %ld, %p, %p)\n", hInf, debugstr_a(pszInfFilename),
737 debugstr_a(pszTranslateSection), debugstr_a(pszTranslateKey),
738 pszBuffer, dwBufferSize, pdwRequiredSize, pvReserved);
739
740 if (!pszInfFilename || !pszTranslateSection ||
741 !pszTranslateKey || !pdwRequiredSize)
742 return E_INVALIDARG;
743
745 RtlCreateUnicodeStringFromAsciiz(&sectionW, pszTranslateSection);
746 RtlCreateUnicodeStringFromAsciiz(&keyW, pszTranslateKey);
747
748 res = TranslateInfStringExW(hInf, filenameW.Buffer, sectionW.Buffer,
749 keyW.Buffer, NULL, 0, &len, NULL);
750
751 if (res == S_OK)
752 {
753 bufferW = malloc(len * sizeof(WCHAR));
754
755 res = TranslateInfStringExW(hInf, filenameW.Buffer, sectionW.Buffer,
756 keyW.Buffer, bufferW, len, &len, NULL);
757
758 if (res == S_OK)
759 {
760 *pdwRequiredSize = WideCharToMultiByte(CP_ACP, 0, bufferW, -1,
761 NULL, 0, NULL, NULL);
762
763 if (dwBufferSize >= *pdwRequiredSize)
764 {
765 WideCharToMultiByte(CP_ACP, 0, bufferW, -1, pszBuffer,
766 dwBufferSize, NULL, NULL);
767 }
768 else
770 }
771
772 free(bufferW);
773 }
774
776 RtlFreeUnicodeString(&sectionW);
778
779 return res;
780}
HRESULT WINAPI TranslateInfStringExW(HINF hInf, LPCWSTR pszInfFilename, LPCWSTR pszTranslateSection, LPCWSTR pszTranslateKey, LPWSTR pszBuffer, DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved)
Definition: advpack.c:811

◆ TranslateInfStringExW()

HRESULT WINAPI TranslateInfStringExW ( HINF  hInf,
LPCWSTR  pszInfFilename,
LPCWSTR  pszTranslateSection,
LPCWSTR  pszTranslateKey,
LPWSTR  pszBuffer,
DWORD  dwBufferSize,
PDWORD  pdwRequiredSize,
PVOID  pvReserved 
)

Definition at line 811 of file advpack.c.

815{
816 TRACE("(%p, %s, %s, %s, %p, %ld, %p, %p)\n", hInf, debugstr_w(pszInfFilename),
817 debugstr_w(pszTranslateSection), debugstr_w(pszTranslateKey),
818 pszBuffer, dwBufferSize, pdwRequiredSize, pvReserved);
819
820 if (!hInf || !pszInfFilename || !pszTranslateSection || !pszTranslateKey)
821 return E_INVALIDARG;
822
823 if (!SetupGetLineTextW(NULL, hInf, pszTranslateSection, pszTranslateKey,
824 pszBuffer, dwBufferSize, pdwRequiredSize))
825 {
826 if (dwBufferSize < *pdwRequiredSize)
828
830 }
831
832 return S_OK;
833}
#define SPAPI_E_LINE_NOT_FOUND
Definition: winerror.h:4677

Referenced by TranslateInfStringExA().

◆ TranslateInfStringW()

HRESULT WINAPI TranslateInfStringW ( LPCWSTR  pszInfFilename,
LPCWSTR  pszInstallSection,
LPCWSTR  pszTranslateSection,
LPCWSTR  pszTranslateKey,
LPWSTR  pszBuffer,
DWORD  dwBufferSize,
PDWORD  pdwRequiredSize,
PVOID  pvReserved 
)

Definition at line 686 of file advpack.c.

689{
690 HINF hInf;
691 HRESULT hret = S_OK;
692
693 TRACE("(%s, %s, %s, %s, %p, %ld, %p, %p)\n",
694 debugstr_w(pszInfFilename), debugstr_w(pszInstallSection),
695 debugstr_w(pszTranslateSection), debugstr_w(pszTranslateKey),
696 pszBuffer, dwBufferSize,pdwRequiredSize, pvReserved);
697
698 if (!pszInfFilename || !pszTranslateSection ||
699 !pszTranslateKey || !pdwRequiredSize)
700 return E_INVALIDARG;
701
702 hInf = SetupOpenInfFileW(pszInfFilename, NULL, INF_STYLE_WIN4, NULL);
703 if (hInf == INVALID_HANDLE_VALUE)
705
706 set_ldids(hInf, pszInstallSection, NULL);
707
708 if (!SetupGetLineTextW(NULL, hInf, pszTranslateSection, pszTranslateKey,
709 pszBuffer, dwBufferSize, pdwRequiredSize))
710 {
711 if (dwBufferSize < *pdwRequiredSize)
713 else
715 }
716
717 SetupCloseInfFile(hInf);
718 return hret;
719}

Referenced by TranslateInfStringA().

◆ UserInstStubWrapperA()

HRESULT WINAPI UserInstStubWrapperA ( HWND  hWnd,
HINSTANCE  hInstance,
LPSTR  pszParms,
INT  nShow 
)

Definition at line 840 of file advpack.c.

842{
843 UNICODE_STRING parmsW;
844 HRESULT res;
845
846 TRACE("(%p, %p, %s, %i)\n", hWnd, hInstance, debugstr_a(pszParms), nShow);
847
848 if (!pszParms)
849 return E_INVALIDARG;
850
851 RtlCreateUnicodeStringFromAsciiz(&parmsW, pszParms);
852
853 res = UserInstStubWrapperW(hWnd, hInstance, parmsW.Buffer, nShow);
854
855 RtlFreeUnicodeString(&parmsW);
856
857 return res;
858}
HINSTANCE hInstance
Definition: charmap.c:19
HRESULT WINAPI UserInstStubWrapperW(HWND hWnd, HINSTANCE hInstance, LPWSTR pszParms, INT nShow)
Definition: advpack.c:881

◆ UserInstStubWrapperW()

HRESULT WINAPI UserInstStubWrapperW ( HWND  hWnd,
HINSTANCE  hInstance,
LPWSTR  pszParms,
INT  nShow 
)

Definition at line 881 of file advpack.c.

883{
884 HKEY setup, guid;
886 DWORD size = sizeof(stub);
887 HRESULT hr = S_OK;
888 BOOL res;
889
890 TRACE("(%p, %p, %s, %i)\n", hWnd, hInstance, debugstr_w(pszParms), nShow);
891
892 if (!pszParms || !*pszParms)
893 return E_INVALIDARG;
894
896 {
897 return E_FAIL;
898 }
899
900 if (RegOpenKeyExW(setup, pszParms, 0, KEY_READ, &guid))
901 {
903 return E_FAIL;
904 }
905
906 res = RegQueryValueExW(guid, L"RealStubPath", NULL, NULL, (BYTE *)stub, &size);
907 if (res || !*stub)
908 goto done;
909
910 /* launch the user stub wrapper */
912
913done:
916
917 return hr;
918}
HRESULT launch_exe(LPCWSTR cmd, LPCWSTR dir, HANDLE *phEXE)
Definition: install.c:850
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
#define KEY_READ
Definition: nt_native.h:1026
Definition: stubgen.c:11
struct _stub stub

Referenced by UserInstStubWrapperA().

◆ UserUnInstStubWrapperA()

HRESULT WINAPI UserUnInstStubWrapperA ( HWND  hWnd,
HINSTANCE  hInstance,
LPSTR  pszParms,
INT  nShow 
)

Definition at line 925 of file advpack.c.

927{
928 UNICODE_STRING parmsW;
929 HRESULT res;
930
931 TRACE("(%p, %p, %s, %i)\n", hWnd, hInstance, debugstr_a(pszParms), nShow);
932
933 if (!pszParms)
934 return E_INVALIDARG;
935
936 RtlCreateUnicodeStringFromAsciiz(&parmsW, pszParms);
937
939
940 RtlFreeUnicodeString(&parmsW);
941
942 return res;
943}
HRESULT WINAPI UserUnInstStubWrapperW(HWND hWnd, HINSTANCE hInstance, LPWSTR pszParms, INT nShow)
Definition: advpack.c:948

◆ UserUnInstStubWrapperW()

HRESULT WINAPI UserUnInstStubWrapperW ( HWND  hWnd,
HINSTANCE  hInstance,
LPWSTR  pszParms,
INT  nShow 
)

Definition at line 948 of file advpack.c.

950{
951 FIXME("(%p, %p, %s, %i): stub\n", hWnd, hInstance, debugstr_w(pszParms), nShow);
952
953 return E_FAIL;
954}

Referenced by UserUnInstStubWrapperA().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( advpack  )

Variable Documentation

◆ setup_key