ReactOS 0.4.15-dev-8138-g1e75ea8
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 []
 

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 199 of file advpack.c.

200{
201 TRACE("(%p)\n", hInf);
202
203 if (!hInf)
204 return E_INVALIDARG;
205
206 SetupCloseInfFile(hInf);
207 return S_OK;
208}
#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 442 of file advpack.c.

443{
444 DLLREGISTER reg_func;
445
446 if (do_reg)
447 reg_func = (DLLREGISTER)GetProcAddress(hocx, "DllRegisterServer");
448 else
449 reg_func = (DLLREGISTER)GetProcAddress(hocx, "DllUnregisterServer");
450
451 if (!reg_func)
452 return E_FAIL;
453
454 reg_func();
455 return S_OK;
456}
#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 68 of file advpack.c.

69{
71 WCHAR key[MAX_PATH + 2], value[MAX_PATH + 2];
72 WCHAR prefix[PREFIX_LEN + 2];
73 HKEY root, subkey = 0;
74 DWORD size;
75
76 static const WCHAR hklm[] = {'H','K','L','M',0};
77 static const WCHAR hkcu[] = {'H','K','C','U',0};
78
79 /* load the destination parameters */
80 SetupFindFirstLineW(hInf, pszSection, NULL, &context);
81 SetupGetStringFieldW(&context, 1, prefix, PREFIX_LEN + 2, &size);
82 strip_quotes(prefix, &size);
87
88 if (!lstrcmpW(prefix, hklm))
90 else if (!lstrcmpW(prefix, hkcu))
92 else
93 root = NULL;
94
95 size = dwSize * sizeof(WCHAR);
96
97 /* fallback to the default destination dir if reg fails */
98 if (RegOpenKeyW(root, key, &subkey) ||
99 RegQueryValueExW(subkey, value, NULL, NULL, (LPBYTE)pszBuffer, &size))
100 {
101 SetupGetStringFieldW(&context, 5, pszBuffer, dwSize, &size);
102 strip_quotes(pszBuffer, &size);
103 }
104
105 if (subkey) RegCloseKey(subkey);
106}
#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:53
#define MAX_PATH
Definition: compat.h:34
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
Definition: http.c:7252
Definition: copy.c:22
unsigned char * LPBYTE
Definition: typedefs.h:53
Definition: pdh_main.c:94
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
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by set_ldids().

◆ IsNTAdmin()

BOOL WINAPI IsNTAdmin ( DWORD  reserved,
LPDWORD  pReserved 
)

Definition at line 222 of file advpack.c.

223{
225 PTOKEN_GROUPS pTokenGroups;
226 BOOL bSidFound = FALSE;
227 DWORD dwSize, i;
228 HANDLE hToken;
229 PSID pSid;
230
231 TRACE("(%d, %p)\n", reserved, pReserved);
232
234 return FALSE;
235
236 if (!GetTokenInformation(hToken, TokenGroups, NULL, 0, &dwSize))
237 {
239 {
240 CloseHandle(hToken);
241 return FALSE;
242 }
243 }
244
245 pTokenGroups = HeapAlloc(GetProcessHeap(), 0, dwSize);
246 if (!pTokenGroups)
247 {
248 CloseHandle(hToken);
249 return FALSE;
250 }
251
252 if (!GetTokenInformation(hToken, TokenGroups, pTokenGroups, dwSize, &dwSize))
253 {
254 HeapFree(GetProcessHeap(), 0, pTokenGroups);
255 CloseHandle(hToken);
256 return FALSE;
257 }
258
259 CloseHandle(hToken);
260
262 DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &pSid))
263 {
264 HeapFree(GetProcessHeap(), 0, pTokenGroups);
265 return FALSE;
266 }
267
268 for (i = 0; i < pTokenGroups->GroupCount; i++)
269 {
270 if (EqualSid(pSid, pTokenGroups->Groups[i].Sid))
271 {
272 bSidFound = TRUE;
273 break;
274 }
275 }
276
277 HeapFree(GetProcessHeap(), 0, pTokenGroups);
278 FreeSid(pSid);
279
280 return bSidFound;
281}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#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 GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define GetCurrentProcess()
Definition: compat.h:759
#define HeapFree(x, y, z)
Definition: compat.h:735
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:74
SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY]
Definition: setypes.h:1018
$ULONG GroupCount
Definition: setypes.h:1014
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:581
#define TOKEN_QUERY
Definition: setypes.h:928
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:554
@ TokenGroups
Definition: setypes.h:967
#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 311 of file advpack.c.

312{
313 FIXME("(%d): stub\n", dwRebootCheck);
314 return FALSE;
315}
#define FIXME(fmt,...)
Definition: debug.h:114

Referenced by ApplyGeneralSettings(), and UpdateDriver().

◆ NeedRebootInit()

DWORD WINAPI NeedRebootInit ( VOID  )

Definition at line 291 of file advpack.c.

292{
293 FIXME("(VOID): stub\n");
294 return 0;
295}

◆ OpenINFEngineA()

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

Definition at line 322 of file advpack.c.

324{
325 UNICODE_STRING filenameW, installW;
326 HRESULT res;
327
328 TRACE("(%s, %s, %d, %p, %p)\n", debugstr_a(pszInfFilename),
329 debugstr_a(pszInstallSection), dwFlags, phInf, pvReserved);
330
331 if (!pszInfFilename || !phInf)
332 return E_INVALIDARG;
333
335 RtlCreateUnicodeStringFromAsciiz(&installW, pszInstallSection);
336
337 res = OpenINFEngineW(filenameW.Buffer, installW.Buffer,
338 dwFlags, phInf, pvReserved);
339
341 RtlFreeUnicodeString(&installW);
342
343 return res;
344}
HRESULT WINAPI OpenINFEngineW(LPCWSTR pszInfFilename, LPCWSTR pszInstallSection, DWORD dwFlags, HINF *phInf, PVOID pvReserved)
Definition: advpack.c:363
GLuint res
Definition: glext.h:9613
#define debugstr_a
Definition: kernel32.h:31
static const WCHAR filenameW[]
Definition: amstream.c:41
static LPCSTR DWORD void * pvReserved
Definition: str.c:196
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

◆ OpenINFEngineW()

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

Definition at line 363 of file advpack.c.

365{
366 TRACE("(%s, %s, %d, %p, %p)\n", debugstr_w(pszInfFilename),
367 debugstr_w(pszInstallSection), dwFlags, phInf, pvReserved);
368
369 if (!pszInfFilename || !phInf)
370 return E_INVALIDARG;
371
372 *phInf = SetupOpenInfFileW(pszInfFilename, NULL, INF_STYLE_WIN4, NULL);
373 if (*phInf == INVALID_HANDLE_VALUE)
375
376 set_ldids(*phInf, pszInstallSection, NULL);
377
378 return S_OK;
379}
void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir)
Definition: advpack.c:109
#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:41
#define debugstr_w
Definition: kernel32.h:32
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

Referenced by OpenINFEngineA().

◆ RebootCheckOnInstallA()

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

Definition at line 386 of file advpack.c.

388{
389 UNICODE_STRING infW, secW;
390 HRESULT res;
391
392 TRACE("(%p, %s, %s, %d)\n", hWnd, debugstr_a(pszINF),
393 debugstr_a(pszSec), dwReserved);
394
395 if (!pszINF || !pszSec)
396 return E_INVALIDARG;
397
400
402
405
406 return res;
407}
static const WCHAR infW[]
Definition: axinstall.c:35
HWND hWnd
Definition: settings.c:17
HRESULT WINAPI RebootCheckOnInstallW(HWND hWnd, LPCWSTR pszINF, LPCWSTR pszSec, DWORD dwReserved)
Definition: advpack.c:432
_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 432 of file advpack.c.

434{
435 FIXME("(%p, %s, %s, %d): stub\n", hWnd, debugstr_w(pszINF),
436 debugstr_w(pszSec), dwReserved);
437
438 return E_FAIL;
439}

Referenced by RebootCheckOnInstallA().

◆ RegisterOCX()

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

Definition at line 480 of file advpack.c.

481{
482 LPWSTR ocx_filename, str_flags, param;
483 LPWSTR cmdline_copy, cmdline_ptr;
484 UNICODE_STRING cmdlineW;
485 HRESULT hr = E_FAIL;
486 HMODULE hm = NULL;
487 DWORD size;
488
489 TRACE("(%s)\n", debugstr_a(cmdline));
490
492
493 size = (lstrlenW(cmdlineW.Buffer) + 1) * sizeof(WCHAR);
494 cmdline_copy = HeapAlloc(GetProcessHeap(), 0, size);
495 cmdline_ptr = cmdline_copy;
496 lstrcpyW(cmdline_copy, cmdlineW.Buffer);
497
498 ocx_filename = get_parameter(&cmdline_ptr, ',', TRUE);
499 if (!ocx_filename || !*ocx_filename)
500 goto done;
501
502 str_flags = get_parameter(&cmdline_ptr, ',', TRUE);
503 param = get_parameter(&cmdline_ptr, ',', TRUE);
504
506 if (!hm)
507 goto done;
508
509 hr = do_ocx_reg(hm, TRUE, str_flags, param);
510
511done:
512 FreeLibrary(hm);
513 HeapFree(GetProcessHeap(), 0, cmdline_copy);
514 RtlFreeUnicodeString(&cmdlineW);
515
516 return hr;
517}
LPWSTR get_parameter(LPWSTR *params, WCHAR separator, BOOL quoted) DECLSPEC_HIDDEN
Definition: install.c:200
HRESULT do_ocx_reg(HMODULE hocx, BOOL do_reg, const WCHAR *flags, const WCHAR *param)
Definition: advpack.c:442
#define FreeLibrary(x)
Definition: compat.h:748
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
GLfloat param
Definition: glext.h:5796
HRESULT hr
Definition: shlfolder.c:183
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define LOAD_WITH_ALTERED_SEARCH_PATH
Definition: winbase.h:344
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ set_ldids()

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

Definition at line 109 of file advpack.c.

110{
115 DWORD size;
116 int ldid;
117
118 static const WCHAR source_dir[] = {'S','o','u','r','c','e','D','i','r',0};
119
120 static const WCHAR custDestW[] = {
121 'C','u','s','t','o','m','D','e','s','t','i','n','a','t','i','o','n',0
122 };
123
124 if (!SetupGetLineTextW(NULL, hInf, pszInstallSection, custDestW,
126 return;
127
128 if (!SetupFindFirstLineW(hInf, field, NULL, &context))
129 return;
130
131 do
132 {
133 LPWSTR value, ptr, key, key_copy = NULL;
134 DWORD flags = 0;
135
138
139 /* SetupGetLineTextW returns the value if there is only one key, but
140 * returns the whole line if there is more than one key
141 */
142 if (!(value = wcschr(line, '=')))
143 {
145 key = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
146 key_copy = key;
148 value = line;
149 }
150 else
151 {
152 key = line;
153 *(value++) = '\0';
154 }
155
156 /* remove leading whitespace from the value */
157 while (*value == ' ')
158 value++;
159
160 /* Extract the flags */
161 ptr = wcschr(value, ',');
162 if (ptr) {
163 *ptr = '\0';
164 flags = wcstol(ptr+1, NULL, 10);
165 }
166
167 /* set dest to pszWorkingDir if key is SourceDir */
168 if (pszWorkingDir && !lstrcmpiW(value, source_dir))
169 lstrcpynW(dest, pszWorkingDir, MAX_PATH);
170 else
172
173 /* If prompting required, provide dialog to request path */
174 if (flags & 0x04)
175 FIXME("Need to support changing paths - default will be used\n");
176
177 /* set all ldids to dest */
178 while ((ptr = get_parameter(&key, ',', FALSE)))
179 {
180 ldid = wcstol(ptr, NULL, 10);
181 SetupSetDirectoryIdW(hInf, ldid, dest);
182 }
183 HeapFree(GetProcessHeap(), 0, key_copy);
184 } while (SetupFindNextLine(&context, &context));
185}
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:68
#define wcschr
Definition: compat.h:17
#define lstrcpynW
Definition: compat.h:738
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4261
BOOL WINAPI SetupGetLineTextW(PINFCONTEXT context, HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1756
GLbitfield flags
Definition: glext.h:7161
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
static PVOID ptr
Definition: dispmode.c:27
static char * dest
Definition: rtl.c:135
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 524 of file advpack.c.

525{
526 PERUSERSECTIONW perUserW;
527
528 TRACE("(%p)\n", pPerUser);
529
530 if (!pPerUser)
531 return E_INVALIDARG;
532
533 MultiByteToWideChar(CP_ACP, 0, pPerUser->szGUID, -1, perUserW.szGUID, ARRAY_SIZE(perUserW.szGUID));
534 MultiByteToWideChar(CP_ACP, 0, pPerUser->szDispName, -1, perUserW.szDispName, ARRAY_SIZE(perUserW.szDispName));
535 MultiByteToWideChar(CP_ACP, 0, pPerUser->szLocale, -1, perUserW.szLocale, ARRAY_SIZE(perUserW.szLocale));
536 MultiByteToWideChar(CP_ACP, 0, pPerUser->szStub, -1, perUserW.szStub, ARRAY_SIZE(perUserW.szStub));
537 MultiByteToWideChar(CP_ACP, 0, pPerUser->szVersion, -1, perUserW.szVersion, ARRAY_SIZE(perUserW.szVersion));
538 MultiByteToWideChar(CP_ACP, 0, pPerUser->szCompID, -1, perUserW.szCompID, ARRAY_SIZE(perUserW.szCompID));
539 perUserW.dwIsInstalled = pPerUser->dwIsInstalled;
540 perUserW.bRollback = pPerUser->bRollback;
541
542 return SetPerUserSecValuesW(&perUserW);
543}
#define ARRAY_SIZE(A)
Definition: main.h:33
HRESULT WINAPI SetPerUserSecValuesW(PERUSERSECTIONW *pPerUser)
Definition: advpack.c:558
#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 558 of file advpack.c.

559{
560 HKEY setup, guid;
561
562 static const WCHAR stub_path[] = {'S','t','u','b','P','a','t','h',0};
563 static const WCHAR version[] = {'V','e','r','s','i','o','n',0};
564 static const WCHAR locale[] = {'L','o','c','a','l','e',0};
565 static const WCHAR compid[] = {'C','o','m','p','o','n','e','n','t','I','D',0};
566 static const WCHAR isinstalled[] = {'I','s','I','n','s','t','a','l','l','e','d',0};
567
568 TRACE("(%p)\n", pPerUser);
569
570 if (!pPerUser || !*pPerUser->szGUID)
571 return S_OK;
572
574 NULL, &setup, NULL))
575 {
576 return E_FAIL;
577 }
578
579 if (RegCreateKeyExW(setup, pPerUser->szGUID, 0, NULL, 0, KEY_ALL_ACCESS,
580 NULL, &guid, NULL))
581 {
583 return E_FAIL;
584 }
585
586 if (*pPerUser->szStub)
587 {
588 RegSetValueExW(guid, stub_path, 0, REG_SZ, (LPBYTE)pPerUser->szStub,
589 (lstrlenW(pPerUser->szStub) + 1) * sizeof(WCHAR));
590 }
591
592 if (*pPerUser->szVersion)
593 {
595 (lstrlenW(pPerUser->szVersion) + 1) * sizeof(WCHAR));
596 }
597
598 if (*pPerUser->szLocale)
599 {
601 (lstrlenW(pPerUser->szLocale) + 1) * sizeof(WCHAR));
602 }
603
604 if (*pPerUser->szCompID)
605 {
606 RegSetValueExW(guid, compid, 0, REG_SZ, (LPBYTE)pPerUser->szCompID,
607 (lstrlenW(pPerUser->szCompID) + 1) * sizeof(WCHAR));
608 }
609
610 if (*pPerUser->szDispName)
611 {
613 (lstrlenW(pPerUser->szDispName) + 1) * sizeof(WCHAR));
614 }
615
616 RegSetValueExW(guid, isinstalled, 0, REG_DWORD,
617 (LPBYTE)&pPerUser->dwIsInstalled, sizeof(DWORD));
618
621
622 return S_OK;
623}
Definition: _locale.h:75
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
static const WCHAR version[]
Definition: asmname.c:66
#define REG_SZ
Definition: layer.c:22
const GUID * guid
static BOOL setup(void)
Definition: enum_files.c:97
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define KEY_WRITE
Definition: nt_native.h:1031
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by per_user_install_callback(), and SetPerUserSecValuesA().

◆ strip_quotes()

static void strip_quotes ( WCHAR buffer,
DWORD size 
)
static

Definition at line 53 of file advpack.c.

54{
55 if (buffer[0] == '\'' && (*size > 1) && buffer[*size-2]=='\'')
56 {
57 *size -= 2;
58 buffer[*size] = 0x00;
59 memmove(buffer, buffer + 1, *size * sizeof(WCHAR));
60 }
61}
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 630 of file advpack.c.

633{
634 UNICODE_STRING filenameW, installW;
635 UNICODE_STRING translateW, keyW;
636 LPWSTR bufferW;
637 HRESULT res;
638 DWORD len = 0;
639
640 TRACE("(%s, %s, %s, %s, %p, %d, %p, %p)\n",
641 debugstr_a(pszInfFilename), debugstr_a(pszInstallSection),
642 debugstr_a(pszTranslateSection), debugstr_a(pszTranslateKey),
643 pszBuffer, dwBufferSize,pdwRequiredSize, pvReserved);
644
645 if (!pszInfFilename || !pszTranslateSection ||
646 !pszTranslateKey || !pdwRequiredSize)
647 return E_INVALIDARG;
648
650 RtlCreateUnicodeStringFromAsciiz(&installW, pszInstallSection);
651 RtlCreateUnicodeStringFromAsciiz(&translateW, pszTranslateSection);
652 RtlCreateUnicodeStringFromAsciiz(&keyW, pszTranslateKey);
653
654 res = TranslateInfStringW(filenameW.Buffer, installW.Buffer,
655 translateW.Buffer, keyW.Buffer, NULL,
656 dwBufferSize, &len, NULL);
657
658 if (res == S_OK)
659 {
660 bufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
661
662 res = TranslateInfStringW(filenameW.Buffer, installW.Buffer,
663 translateW.Buffer, keyW.Buffer, bufferW,
664 len, &len, NULL);
665 if (res == S_OK)
666 {
667 *pdwRequiredSize = WideCharToMultiByte(CP_ACP, 0, bufferW, -1,
668 NULL, 0, NULL, NULL);
669
670 if (dwBufferSize >= *pdwRequiredSize)
671 {
672 WideCharToMultiByte(CP_ACP, 0, bufferW, -1, pszBuffer,
673 dwBufferSize, NULL, NULL);
674 }
675 else
677 }
678
679 HeapFree(GetProcessHeap(), 0, bufferW);
680 }
681
683 RtlFreeUnicodeString(&installW);
684 RtlFreeUnicodeString(&translateW);
686
687 return res;
688}
HRESULT WINAPI TranslateInfStringW(LPCWSTR pszInfFilename, LPCWSTR pszInstallSection, LPCWSTR pszTranslateSection, LPCWSTR pszTranslateKey, LPWSTR pszBuffer, DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved)
Definition: advpack.c:710
#define WideCharToMultiByte
Definition: compat.h:111
GLenum GLsizei len
Definition: glext.h:6722
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:2345

◆ TranslateInfStringExA()

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

Definition at line 750 of file advpack.c.

754{
755 UNICODE_STRING filenameW, sectionW, keyW;
756 LPWSTR bufferW;
757 HRESULT res;
758 DWORD len = 0;
759
760 TRACE("(%p, %s, %s, %s, %p, %d, %p, %p)\n", hInf, debugstr_a(pszInfFilename),
761 debugstr_a(pszTranslateSection), debugstr_a(pszTranslateKey),
762 pszBuffer, dwBufferSize, pdwRequiredSize, pvReserved);
763
764 if (!pszInfFilename || !pszTranslateSection ||
765 !pszTranslateKey || !pdwRequiredSize)
766 return E_INVALIDARG;
767
769 RtlCreateUnicodeStringFromAsciiz(&sectionW, pszTranslateSection);
770 RtlCreateUnicodeStringFromAsciiz(&keyW, pszTranslateKey);
771
772 res = TranslateInfStringExW(hInf, filenameW.Buffer, sectionW.Buffer,
773 keyW.Buffer, NULL, 0, &len, NULL);
774
775 if (res == S_OK)
776 {
777 bufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
778
779 res = TranslateInfStringExW(hInf, filenameW.Buffer, sectionW.Buffer,
780 keyW.Buffer, bufferW, len, &len, NULL);
781
782 if (res == S_OK)
783 {
784 *pdwRequiredSize = WideCharToMultiByte(CP_ACP, 0, bufferW, -1,
785 NULL, 0, NULL, NULL);
786
787 if (dwBufferSize >= *pdwRequiredSize)
788 {
789 WideCharToMultiByte(CP_ACP, 0, bufferW, -1, pszBuffer,
790 dwBufferSize, NULL, NULL);
791 }
792 else
794 }
795
796 HeapFree(GetProcessHeap(), 0, bufferW);
797 }
798
800 RtlFreeUnicodeString(&sectionW);
802
803 return res;
804}
HRESULT WINAPI TranslateInfStringExW(HINF hInf, LPCWSTR pszInfFilename, LPCWSTR pszTranslateSection, LPCWSTR pszTranslateKey, LPWSTR pszBuffer, DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved)
Definition: advpack.c:835

◆ TranslateInfStringExW()

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

Definition at line 835 of file advpack.c.

839{
840 TRACE("(%p, %s, %s, %s, %p, %d, %p, %p)\n", hInf, debugstr_w(pszInfFilename),
841 debugstr_w(pszTranslateSection), debugstr_w(pszTranslateKey),
842 pszBuffer, dwBufferSize, pdwRequiredSize, pvReserved);
843
844 if (!hInf || !pszInfFilename || !pszTranslateSection || !pszTranslateKey)
845 return E_INVALIDARG;
846
847 if (!SetupGetLineTextW(NULL, hInf, pszTranslateSection, pszTranslateKey,
848 pszBuffer, dwBufferSize, pdwRequiredSize))
849 {
850 if (dwBufferSize < *pdwRequiredSize)
852
854 }
855
856 return S_OK;
857}
#define SPAPI_E_LINE_NOT_FOUND
Definition: winerror.h:3144

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 710 of file advpack.c.

713{
714 HINF hInf;
715 HRESULT hret = S_OK;
716
717 TRACE("(%s, %s, %s, %s, %p, %d, %p, %p)\n",
718 debugstr_w(pszInfFilename), debugstr_w(pszInstallSection),
719 debugstr_w(pszTranslateSection), debugstr_w(pszTranslateKey),
720 pszBuffer, dwBufferSize,pdwRequiredSize, pvReserved);
721
722 if (!pszInfFilename || !pszTranslateSection ||
723 !pszTranslateKey || !pdwRequiredSize)
724 return E_INVALIDARG;
725
726 hInf = SetupOpenInfFileW(pszInfFilename, NULL, INF_STYLE_WIN4, NULL);
727 if (hInf == INVALID_HANDLE_VALUE)
729
730 set_ldids(hInf, pszInstallSection, NULL);
731
732 if (!SetupGetLineTextW(NULL, hInf, pszTranslateSection, pszTranslateKey,
733 pszBuffer, dwBufferSize, pdwRequiredSize))
734 {
735 if (dwBufferSize < *pdwRequiredSize)
737 else
739 }
740
741 SetupCloseInfFile(hInf);
742 return hret;
743}

Referenced by TranslateInfStringA().

◆ UserInstStubWrapperA()

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

Definition at line 864 of file advpack.c.

866{
867 UNICODE_STRING parmsW;
868 HRESULT res;
869
870 TRACE("(%p, %p, %s, %i)\n", hWnd, hInstance, debugstr_a(pszParms), nShow);
871
872 if (!pszParms)
873 return E_INVALIDARG;
874
875 RtlCreateUnicodeStringFromAsciiz(&parmsW, pszParms);
876
877 res = UserInstStubWrapperW(hWnd, hInstance, parmsW.Buffer, nShow);
878
879 RtlFreeUnicodeString(&parmsW);
880
881 return res;
882}
HINSTANCE hInstance
Definition: charmap.c:19
HRESULT WINAPI UserInstStubWrapperW(HWND hWnd, HINSTANCE hInstance, LPWSTR pszParms, INT nShow)
Definition: advpack.c:905

◆ UserInstStubWrapperW()

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

Definition at line 905 of file advpack.c.

907{
908 HKEY setup, guid;
910 DWORD size = sizeof(stub);
911 HRESULT hr = S_OK;
912 BOOL res;
913
914 static const WCHAR real_stub_path[] = {
915 'R','e','a','l','S','t','u','b','P','a','t','h',0
916 };
917
918 TRACE("(%p, %p, %s, %i)\n", hWnd, hInstance, debugstr_w(pszParms), nShow);
919
920 if (!pszParms || !*pszParms)
921 return E_INVALIDARG;
922
924 {
925 return E_FAIL;
926 }
927
928 if (RegOpenKeyExW(setup, pszParms, 0, KEY_READ, &guid))
929 {
931 return E_FAIL;
932 }
933
934 res = RegQueryValueExW(guid, real_stub_path, NULL, NULL, (LPBYTE)stub, &size);
935 if (res || !*stub)
936 goto done;
937
938 /* launch the user stub wrapper */
940
941done:
944
945 return hr;
946}
HRESULT launch_exe(LPCWSTR cmd, LPCWSTR dir, HANDLE *phEXE) DECLSPEC_HIDDEN
Definition: install.c:894
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
#define KEY_READ
Definition: nt_native.h:1023
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 953 of file advpack.c.

955{
956 UNICODE_STRING parmsW;
957 HRESULT res;
958
959 TRACE("(%p, %p, %s, %i)\n", hWnd, hInstance, debugstr_a(pszParms), nShow);
960
961 if (!pszParms)
962 return E_INVALIDARG;
963
964 RtlCreateUnicodeStringFromAsciiz(&parmsW, pszParms);
965
967
968 RtlFreeUnicodeString(&parmsW);
969
970 return res;
971}
HRESULT WINAPI UserUnInstStubWrapperW(HWND hWnd, HINSTANCE hInstance, LPWSTR pszParms, INT nShow)
Definition: advpack.c:976

◆ UserUnInstStubWrapperW()

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

Definition at line 976 of file advpack.c.

978{
979 FIXME("(%p, %p, %s, %i): stub\n", hWnd, hInstance, debugstr_w(pszParms), nShow);
980
981 return E_FAIL;
982}

Referenced by UserUnInstStubWrapperA().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( advpack  )

Variable Documentation

◆ setup_key

const WCHAR setup_key[]
static
Initial value:
= {
'S','O','F','T','W','A','R','E','\\',
'M','i','c','r','o','s','o','f','t','\\',
'A','c','t','i','v','e',' ','S','e','t','u','p','\\',
'I','n','s','t','a','l','l','e','d',' ',
'C','o','m','p','o','n','e','n','t','s',0
}

Definition at line 44 of file advpack.c.

Referenced by import_plaintext_key(), import_private_key(), import_public_key(), import_symmetric_key(), RSAENH_CPDecrypt(), RSAENH_CPDeriveKey(), RSAENH_CPEncrypt(), RSAENH_CPGenKey(), RSAENH_CPSetKeyParam(), SetPerUserSecValuesW(), and UserInstStubWrapperW().