2004-09-27 22:39:40 +02:00
|
|
|
/*
|
|
|
|
* Advpack main
|
|
|
|
*
|
|
|
|
* Copyright 2004 Huw D M Davies
|
2005-04-27 11:37:25 +02:00
|
|
|
* Copyright 2005 Sami Aario
|
2004-09-27 22:39:40 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-09-27 22:39:40 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2019-05-27 15:50:49 +02:00
|
|
|
#include <stdlib.h>
|
2004-11-01 22:07:53 +01:00
|
|
|
|
2004-10-07 06:20:24 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2004-11-01 22:07:53 +01:00
|
|
|
#include "winuser.h"
|
2004-12-02 19:09:53 +01:00
|
|
|
#include "winreg.h"
|
2006-03-09 06:29:40 +01:00
|
|
|
#include "winternl.h"
|
2005-01-20 21:03:13 +01:00
|
|
|
#include "winnls.h"
|
2004-11-01 22:07:53 +01:00
|
|
|
#include "setupapi.h"
|
|
|
|
#include "advpub.h"
|
2004-10-07 06:20:24 +02:00
|
|
|
#include "wine/debug.h"
|
2006-04-18 23:13:26 +02:00
|
|
|
#include "advpack_private.h"
|
2004-09-27 22:39:40 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(advpack);
|
|
|
|
|
2005-03-14 18:16:03 +01:00
|
|
|
typedef HRESULT (WINAPI *DLLREGISTER) (void);
|
|
|
|
|
2006-02-21 04:40:59 +01:00
|
|
|
#define MAX_FIELD_LENGTH 512
|
|
|
|
#define PREFIX_LEN 5
|
|
|
|
|
2006-04-11 08:26:44 +02:00
|
|
|
/* registry path of the Installed Components key for per-user stubs */
|
|
|
|
static const WCHAR setup_key[] = {
|
|
|
|
'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
|
|
|
|
};
|
|
|
|
|
2007-08-10 23:28:34 +02:00
|
|
|
/* Strip single quotes from a token - note size includes NULL */
|
|
|
|
static void strip_quotes(WCHAR *buffer, DWORD *size)
|
|
|
|
{
|
|
|
|
if (buffer[0] == '\'' && (*size > 1) && buffer[*size-2]=='\'')
|
|
|
|
{
|
|
|
|
*size -= 2;
|
|
|
|
buffer[*size] = 0x00;
|
|
|
|
memmove(buffer, buffer + 1, *size * sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-21 04:40:59 +01:00
|
|
|
/* parses the destination directory parameters from pszSection
|
|
|
|
* the parameters are of the form: root,key,value,unknown,fallback
|
|
|
|
* we first read the reg value root\\key\\value and if that fails,
|
|
|
|
* use fallback as the destination directory
|
|
|
|
*/
|
2006-03-09 06:29:40 +01:00
|
|
|
static void get_dest_dir(HINF hInf, PCWSTR pszSection, PWSTR pszBuffer, DWORD dwSize)
|
2006-02-21 04:40:59 +01:00
|
|
|
{
|
|
|
|
INFCONTEXT context;
|
2008-05-29 17:35:03 +02:00
|
|
|
WCHAR key[MAX_PATH + 2], value[MAX_PATH + 2];
|
|
|
|
WCHAR prefix[PREFIX_LEN + 2];
|
2008-06-20 14:46:24 +02:00
|
|
|
HKEY root, subkey = 0;
|
2006-02-21 04:40:59 +01:00
|
|
|
DWORD size;
|
|
|
|
|
2006-03-09 06:29:40 +01:00
|
|
|
static const WCHAR hklm[] = {'H','K','L','M',0};
|
|
|
|
static const WCHAR hkcu[] = {'H','K','C','U',0};
|
|
|
|
|
2006-02-21 04:40:59 +01:00
|
|
|
/* load the destination parameters */
|
2006-03-09 06:29:40 +01:00
|
|
|
SetupFindFirstLineW(hInf, pszSection, NULL, &context);
|
2008-05-29 17:35:03 +02:00
|
|
|
SetupGetStringFieldW(&context, 1, prefix, PREFIX_LEN + 2, &size);
|
2007-08-10 23:28:34 +02:00
|
|
|
strip_quotes(prefix, &size);
|
2008-05-29 17:35:03 +02:00
|
|
|
SetupGetStringFieldW(&context, 2, key, MAX_PATH + 2, &size);
|
2007-08-10 23:28:34 +02:00
|
|
|
strip_quotes(key, &size);
|
2008-05-29 17:35:03 +02:00
|
|
|
SetupGetStringFieldW(&context, 3, value, MAX_PATH + 2, &size);
|
2007-08-10 23:28:34 +02:00
|
|
|
strip_quotes(value, &size);
|
2006-02-21 04:40:59 +01:00
|
|
|
|
2006-03-09 06:29:40 +01:00
|
|
|
if (!lstrcmpW(prefix, hklm))
|
2006-02-21 04:40:59 +01:00
|
|
|
root = HKEY_LOCAL_MACHINE;
|
2006-03-09 06:29:40 +01:00
|
|
|
else if (!lstrcmpW(prefix, hkcu))
|
2006-02-21 04:40:59 +01:00
|
|
|
root = HKEY_CURRENT_USER;
|
|
|
|
else
|
|
|
|
root = NULL;
|
|
|
|
|
2006-03-09 06:29:40 +01:00
|
|
|
size = dwSize * sizeof(WCHAR);
|
2006-02-21 04:40:59 +01:00
|
|
|
|
|
|
|
/* fallback to the default destination dir if reg fails */
|
2006-03-09 06:29:40 +01:00
|
|
|
if (RegOpenKeyW(root, key, &subkey) ||
|
|
|
|
RegQueryValueExW(subkey, value, NULL, NULL, (LPBYTE)pszBuffer, &size))
|
2006-02-21 04:40:59 +01:00
|
|
|
{
|
2007-08-10 23:28:34 +02:00
|
|
|
SetupGetStringFieldW(&context, 5, pszBuffer, dwSize, &size);
|
|
|
|
strip_quotes(pszBuffer, &size);
|
2006-02-21 04:40:59 +01:00
|
|
|
}
|
|
|
|
|
2008-06-20 14:46:24 +02:00
|
|
|
if (subkey) RegCloseKey(subkey);
|
2006-02-21 04:40:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* loads the LDIDs specified in the install section of an INF */
|
2006-04-20 08:36:39 +02:00
|
|
|
void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir)
|
2006-02-21 04:40:59 +01:00
|
|
|
{
|
2006-03-09 06:29:40 +01:00
|
|
|
WCHAR field[MAX_FIELD_LENGTH];
|
2006-04-18 23:14:05 +02:00
|
|
|
WCHAR line[MAX_FIELD_LENGTH];
|
2006-03-09 06:29:40 +01:00
|
|
|
WCHAR dest[MAX_PATH];
|
2006-02-21 04:40:59 +01:00
|
|
|
INFCONTEXT context;
|
|
|
|
DWORD size;
|
|
|
|
int ldid;
|
|
|
|
|
2006-04-18 23:14:34 +02:00
|
|
|
static const WCHAR source_dir[] = {'S','o','u','r','c','e','D','i','r',0};
|
|
|
|
|
2006-03-09 06:29:40 +01:00
|
|
|
static const WCHAR custDestW[] = {
|
|
|
|
'C','u','s','t','o','m','D','e','s','t','i','n','a','t','i','o','n',0
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!SetupGetLineTextW(NULL, hInf, pszInstallSection, custDestW,
|
2006-02-21 04:40:59 +01:00
|
|
|
field, MAX_FIELD_LENGTH, &size))
|
|
|
|
return;
|
|
|
|
|
2006-03-09 06:29:40 +01:00
|
|
|
if (!SetupFindFirstLineW(hInf, field, NULL, &context))
|
2006-02-21 04:40:59 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2006-04-18 23:14:05 +02:00
|
|
|
LPWSTR value, ptr, key, key_copy = NULL;
|
2007-08-10 00:56:17 +02:00
|
|
|
DWORD flags = 0;
|
2006-02-21 04:40:59 +01:00
|
|
|
|
2006-04-18 23:14:05 +02:00
|
|
|
SetupGetLineTextW(&context, NULL, NULL, NULL,
|
|
|
|
line, MAX_FIELD_LENGTH, &size);
|
|
|
|
|
|
|
|
/* SetupGetLineTextW returns the value if there is only one key, but
|
|
|
|
* returns the whole line if there is more than one key
|
|
|
|
*/
|
2019-05-27 15:50:49 +02:00
|
|
|
if (!(value = wcschr(line, '=')))
|
2006-04-18 23:14:05 +02:00
|
|
|
{
|
|
|
|
SetupGetStringFieldW(&context, 0, NULL, 0, &size);
|
|
|
|
key = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
|
|
|
|
key_copy = key;
|
|
|
|
SetupGetStringFieldW(&context, 0, key, size, &size);
|
|
|
|
value = line;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
key = line;
|
|
|
|
*(value++) = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove leading whitespace from the value */
|
|
|
|
while (*value == ' ')
|
|
|
|
value++;
|
|
|
|
|
2007-08-10 00:56:17 +02:00
|
|
|
/* Extract the flags */
|
2019-05-27 15:50:49 +02:00
|
|
|
ptr = wcschr(value, ',');
|
2007-08-10 00:56:17 +02:00
|
|
|
if (ptr) {
|
2006-04-18 23:14:05 +02:00
|
|
|
*ptr = '\0';
|
2019-05-27 15:50:49 +02:00
|
|
|
flags = wcstol(ptr+1, NULL, 10);
|
2007-08-10 00:56:17 +02:00
|
|
|
}
|
2006-04-18 23:14:05 +02:00
|
|
|
|
2006-04-18 23:14:34 +02:00
|
|
|
/* set dest to pszWorkingDir if key is SourceDir */
|
|
|
|
if (pszWorkingDir && !lstrcmpiW(value, source_dir))
|
|
|
|
lstrcpynW(dest, pszWorkingDir, MAX_PATH);
|
|
|
|
else
|
|
|
|
get_dest_dir(hInf, value, dest, MAX_PATH);
|
2006-04-18 23:14:05 +02:00
|
|
|
|
2007-08-10 00:56:17 +02:00
|
|
|
/* If prompting required, provide dialog to request path */
|
|
|
|
if (flags & 0x04)
|
|
|
|
FIXME("Need to support changing paths - default will be used\n");
|
|
|
|
|
2006-04-18 23:14:05 +02:00
|
|
|
/* set all ldids to dest */
|
2013-07-22 23:48:19 +02:00
|
|
|
while ((ptr = get_parameter(&key, ',', FALSE)))
|
2006-04-18 23:14:05 +02:00
|
|
|
{
|
2019-05-27 15:50:49 +02:00
|
|
|
ldid = wcstol(ptr, NULL, 10);
|
2006-04-18 23:14:05 +02:00
|
|
|
SetupSetDirectoryIdW(hInf, ldid, dest);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, key_copy);
|
2006-02-21 04:40:59 +01:00
|
|
|
} while (SetupFindNextLine(&context, &context));
|
|
|
|
}
|
|
|
|
|
2006-01-14 17:10:16 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CloseINFEngine (ADVPACK.@)
|
|
|
|
*
|
2006-01-21 19:21:45 +01:00
|
|
|
* Closes a handle to an INF file opened with OpenINFEngine.
|
2006-01-14 17:10:16 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
2006-01-21 19:21:45 +01:00
|
|
|
* hInf [I] Handle to the INF file to close.
|
2006-01-14 17:10:16 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: E_FAIL.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CloseINFEngine(HINF hInf)
|
|
|
|
{
|
2006-02-21 04:42:25 +01:00
|
|
|
TRACE("(%p)\n", hInf);
|
2006-01-14 17:10:16 +01:00
|
|
|
|
2006-02-27 20:50:03 +01:00
|
|
|
if (!hInf)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2006-02-21 04:42:25 +01:00
|
|
|
SetupCloseInfFile(hInf);
|
|
|
|
return S_OK;
|
2006-01-14 17:10:16 +01:00
|
|
|
}
|
|
|
|
|
2005-09-06 11:25:25 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IsNTAdmin (ADVPACK.@)
|
2005-12-02 11:25:05 +01:00
|
|
|
*
|
|
|
|
* Checks if the user has admin privileges.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* reserved [I] Reserved. Must be 0.
|
|
|
|
* pReserved [I] Reserved. Must be NULL.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE if user has admin rights, FALSE otherwise.
|
2005-09-06 11:25:25 +02:00
|
|
|
*/
|
2006-04-11 07:08:54 +02:00
|
|
|
BOOL WINAPI IsNTAdmin(DWORD reserved, LPDWORD pReserved)
|
2005-09-06 11:25:25 +02:00
|
|
|
{
|
2006-01-21 19:18:32 +01:00
|
|
|
SID_IDENTIFIER_AUTHORITY SidAuthority = {SECURITY_NT_AUTHORITY};
|
|
|
|
PTOKEN_GROUPS pTokenGroups;
|
|
|
|
BOOL bSidFound = FALSE;
|
|
|
|
DWORD dwSize, i;
|
|
|
|
HANDLE hToken;
|
|
|
|
PSID pSid;
|
|
|
|
|
2006-10-07 04:06:59 +02:00
|
|
|
TRACE("(%d, %p)\n", reserved, pReserved);
|
2006-01-21 19:18:32 +01:00
|
|
|
|
|
|
|
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!GetTokenInformation(hToken, TokenGroups, NULL, 0, &dwSize))
|
|
|
|
{
|
|
|
|
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
{
|
|
|
|
CloseHandle(hToken);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pTokenGroups = HeapAlloc(GetProcessHeap(), 0, dwSize);
|
|
|
|
if (!pTokenGroups)
|
|
|
|
{
|
|
|
|
CloseHandle(hToken);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!GetTokenInformation(hToken, TokenGroups, pTokenGroups, dwSize, &dwSize))
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, pTokenGroups);
|
|
|
|
CloseHandle(hToken);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(hToken);
|
|
|
|
|
|
|
|
if (!AllocateAndInitializeSid(&SidAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID,
|
|
|
|
DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &pSid))
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, pTokenGroups);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < pTokenGroups->GroupCount; i++)
|
|
|
|
{
|
|
|
|
if (EqualSid(pSid, pTokenGroups->Groups[i].Sid))
|
|
|
|
{
|
|
|
|
bSidFound = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, pTokenGroups);
|
|
|
|
FreeSid(pSid);
|
|
|
|
|
|
|
|
return bSidFound;
|
2005-09-06 11:25:25 +02:00
|
|
|
}
|
|
|
|
|
2005-01-20 21:03:13 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* NeedRebootInit (ADVPACK.@)
|
2005-12-02 11:25:05 +01:00
|
|
|
*
|
|
|
|
* Sets up conditions for reboot checking.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Value required by NeedReboot.
|
2005-01-20 21:03:13 +01:00
|
|
|
*/
|
|
|
|
DWORD WINAPI NeedRebootInit(VOID)
|
|
|
|
{
|
2006-04-11 07:17:13 +02:00
|
|
|
FIXME("(VOID): stub\n");
|
2005-01-20 21:03:13 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NeedReboot (ADVPACK.@)
|
2005-12-02 11:25:05 +01:00
|
|
|
*
|
|
|
|
* Determines whether a reboot is required.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* dwRebootCheck [I] Value from NeedRebootInit.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE if a reboot is needed, FALSE otherwise.
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* Unimplemented.
|
2005-01-20 21:03:13 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI NeedReboot(DWORD dwRebootCheck)
|
|
|
|
{
|
2006-10-07 04:06:59 +02:00
|
|
|
FIXME("(%d): stub\n", dwRebootCheck);
|
2005-01-20 21:03:13 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-01-14 17:10:16 +01:00
|
|
|
/***********************************************************************
|
2006-02-24 16:09:42 +01:00
|
|
|
* OpenINFEngineA (ADVPACK.@)
|
2006-01-14 17:10:16 +01:00
|
|
|
*
|
2006-03-09 06:29:40 +01:00
|
|
|
* See OpenINFEngineW.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI OpenINFEngineA(LPCSTR pszInfFilename, LPCSTR pszInstallSection,
|
|
|
|
DWORD dwFlags, HINF *phInf, PVOID pvReserved)
|
|
|
|
{
|
|
|
|
UNICODE_STRING filenameW, installW;
|
|
|
|
HRESULT res;
|
|
|
|
|
2006-10-07 04:06:59 +02:00
|
|
|
TRACE("(%s, %s, %d, %p, %p)\n", debugstr_a(pszInfFilename),
|
2006-04-11 07:17:13 +02:00
|
|
|
debugstr_a(pszInstallSection), dwFlags, phInf, pvReserved);
|
2006-03-09 06:29:40 +01:00
|
|
|
|
|
|
|
if (!pszInfFilename || !phInf)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&filenameW, pszInfFilename);
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&installW, pszInstallSection);
|
|
|
|
|
|
|
|
res = OpenINFEngineW(filenameW.Buffer, installW.Buffer,
|
|
|
|
dwFlags, phInf, pvReserved);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&filenameW);
|
|
|
|
RtlFreeUnicodeString(&installW);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* OpenINFEngineW (ADVPACK.@)
|
|
|
|
*
|
2006-01-14 17:10:16 +01:00
|
|
|
* Opens and returns a handle to an INF file to be used by
|
|
|
|
* TranslateInfStringEx to continuously translate the INF file.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pszInfFilename [I] Filename of the INF to open.
|
|
|
|
* pszInstallSection [I] Name of the Install section in the INF.
|
|
|
|
* dwFlags [I] See advpub.h.
|
|
|
|
* phInf [O] Handle to the loaded INF file.
|
|
|
|
* pvReserved [I] Reserved. Must be NULL.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: E_FAIL.
|
|
|
|
*/
|
2006-03-09 06:29:40 +01:00
|
|
|
HRESULT WINAPI OpenINFEngineW(LPCWSTR pszInfFilename, LPCWSTR pszInstallSection,
|
|
|
|
DWORD dwFlags, HINF *phInf, PVOID pvReserved)
|
2006-01-14 17:10:16 +01:00
|
|
|
{
|
2006-10-07 04:06:59 +02:00
|
|
|
TRACE("(%s, %s, %d, %p, %p)\n", debugstr_w(pszInfFilename),
|
2006-03-09 06:29:40 +01:00
|
|
|
debugstr_w(pszInstallSection), dwFlags, phInf, pvReserved);
|
2006-01-14 17:10:16 +01:00
|
|
|
|
2006-02-27 20:50:03 +01:00
|
|
|
if (!pszInfFilename || !phInf)
|
2006-02-21 04:42:25 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2006-03-09 06:29:40 +01:00
|
|
|
*phInf = SetupOpenInfFileW(pszInfFilename, NULL, INF_STYLE_WIN4, NULL);
|
2006-02-21 04:42:25 +01:00
|
|
|
if (*phInf == INVALID_HANDLE_VALUE)
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
|
|
|
|
|
2006-04-18 23:14:34 +02:00
|
|
|
set_ldids(*phInf, pszInstallSection, NULL);
|
2006-02-21 04:42:25 +01:00
|
|
|
|
|
|
|
return S_OK;
|
2006-01-14 17:10:16 +01:00
|
|
|
}
|
|
|
|
|
2006-01-21 19:22:17 +01:00
|
|
|
/***********************************************************************
|
2006-02-24 16:09:42 +01:00
|
|
|
* RebootCheckOnInstallA (ADVPACK.@)
|
2006-01-21 19:22:17 +01:00
|
|
|
*
|
2006-03-22 21:08:37 +01:00
|
|
|
* See RebootCheckOnInstallW.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI RebootCheckOnInstallA(HWND hWnd, LPCSTR pszINF,
|
2007-02-03 02:13:24 +01:00
|
|
|
LPCSTR pszSec, DWORD dwReserved)
|
2006-03-22 21:08:37 +01:00
|
|
|
{
|
|
|
|
UNICODE_STRING infW, secW;
|
|
|
|
HRESULT res;
|
|
|
|
|
2006-10-07 04:06:59 +02:00
|
|
|
TRACE("(%p, %s, %s, %d)\n", hWnd, debugstr_a(pszINF),
|
2006-03-22 21:08:37 +01:00
|
|
|
debugstr_a(pszSec), dwReserved);
|
|
|
|
|
|
|
|
if (!pszINF || !pszSec)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&infW, pszINF);
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&secW, pszSec);
|
|
|
|
|
|
|
|
res = RebootCheckOnInstallW(hWnd, infW.Buffer, secW.Buffer, dwReserved);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&infW);
|
|
|
|
RtlFreeUnicodeString(&secW);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RebootCheckOnInstallW (ADVPACK.@)
|
|
|
|
*
|
2006-01-21 19:22:17 +01:00
|
|
|
* Checks if a reboot is required for an installed INF section.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hWnd [I] Handle to the window used for messages.
|
|
|
|
* pszINF [I] Filename of the INF file.
|
|
|
|
* pszSec [I] INF section to check.
|
|
|
|
* dwReserved [I] Reserved. Must be 0.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK - Reboot is needed if the INF section is installed.
|
|
|
|
* S_FALSE - Reboot is not needed.
|
|
|
|
* Failure: HRESULT of GetLastError().
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* if pszSec is NULL, RebootCheckOnInstall checks the DefaultInstall
|
|
|
|
* or DefaultInstall.NT section.
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* Unimplemented.
|
|
|
|
*/
|
2006-03-22 21:08:37 +01:00
|
|
|
HRESULT WINAPI RebootCheckOnInstallW(HWND hWnd, LPCWSTR pszINF,
|
2007-02-03 02:13:24 +01:00
|
|
|
LPCWSTR pszSec, DWORD dwReserved)
|
2006-01-21 19:22:17 +01:00
|
|
|
{
|
2006-10-07 04:06:59 +02:00
|
|
|
FIXME("(%p, %s, %s, %d): stub\n", hWnd, debugstr_w(pszINF),
|
2006-03-22 21:08:37 +01:00
|
|
|
debugstr_w(pszSec), dwReserved);
|
2006-01-21 19:22:17 +01:00
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2006-04-17 08:51:37 +02:00
|
|
|
/* registers the OCX if do_reg is TRUE, unregisters it otherwise */
|
2011-11-07 11:45:18 +01:00
|
|
|
HRESULT do_ocx_reg(HMODULE hocx, BOOL do_reg, const WCHAR *flags, const WCHAR *param)
|
2006-04-17 08:51:37 +02:00
|
|
|
{
|
|
|
|
DLLREGISTER reg_func;
|
|
|
|
|
|
|
|
if (do_reg)
|
|
|
|
reg_func = (DLLREGISTER)GetProcAddress(hocx, "DllRegisterServer");
|
|
|
|
else
|
|
|
|
reg_func = (DLLREGISTER)GetProcAddress(hocx, "DllUnregisterServer");
|
|
|
|
|
|
|
|
if (!reg_func)
|
|
|
|
return E_FAIL;
|
|
|
|
|
2006-04-29 02:53:49 +02:00
|
|
|
reg_func();
|
|
|
|
return S_OK;
|
2006-04-17 08:51:37 +02:00
|
|
|
}
|
|
|
|
|
2005-03-14 18:16:03 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RegisterOCX (ADVPACK.@)
|
2006-04-14 05:32:23 +02:00
|
|
|
*
|
|
|
|
* Registers an OCX.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hWnd [I] Handle to the window used for the display.
|
|
|
|
* hInst [I] Instance of the process.
|
2006-04-17 08:48:52 +02:00
|
|
|
* cmdline [I] Contains parameters in the order OCX,flags,param.
|
2006-04-14 05:32:23 +02:00
|
|
|
* show [I] How the window should be shown.
|
|
|
|
*
|
|
|
|
* RETURNS
|
2006-04-17 08:48:34 +02:00
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: E_FAIL.
|
2006-04-14 05:32:23 +02:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* OCX - Filename of the OCX to register.
|
2006-04-17 08:48:52 +02:00
|
|
|
* flags - Controls the operation of RegisterOCX.
|
|
|
|
* 'I' Call DllRegisterServer and DllInstall.
|
|
|
|
* 'N' Only call DllInstall.
|
|
|
|
* param - Command line passed to DllInstall.
|
2005-03-14 18:16:03 +01:00
|
|
|
*/
|
2006-04-17 08:48:34 +02:00
|
|
|
HRESULT WINAPI RegisterOCX(HWND hWnd, HINSTANCE hInst, LPCSTR cmdline, INT show)
|
2005-03-14 18:16:03 +01:00
|
|
|
{
|
2006-04-17 08:50:46 +02:00
|
|
|
LPWSTR ocx_filename, str_flags, param;
|
|
|
|
LPWSTR cmdline_copy, cmdline_ptr;
|
|
|
|
UNICODE_STRING cmdlineW;
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
HMODULE hm = NULL;
|
|
|
|
DWORD size;
|
2005-03-14 18:16:03 +01:00
|
|
|
|
2006-04-11 07:17:13 +02:00
|
|
|
TRACE("(%s)\n", debugstr_a(cmdline));
|
2005-03-14 18:16:03 +01:00
|
|
|
|
2006-04-17 08:50:46 +02:00
|
|
|
RtlCreateUnicodeStringFromAsciiz(&cmdlineW, cmdline);
|
|
|
|
|
|
|
|
size = (lstrlenW(cmdlineW.Buffer) + 1) * sizeof(WCHAR);
|
|
|
|
cmdline_copy = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
cmdline_ptr = cmdline_copy;
|
|
|
|
lstrcpyW(cmdline_copy, cmdlineW.Buffer);
|
2005-03-14 18:16:03 +01:00
|
|
|
|
2013-07-22 23:48:19 +02:00
|
|
|
ocx_filename = get_parameter(&cmdline_ptr, ',', TRUE);
|
2006-04-17 08:50:46 +02:00
|
|
|
if (!ocx_filename || !*ocx_filename)
|
|
|
|
goto done;
|
2005-03-14 18:16:03 +01:00
|
|
|
|
2013-07-22 23:48:19 +02:00
|
|
|
str_flags = get_parameter(&cmdline_ptr, ',', TRUE);
|
|
|
|
param = get_parameter(&cmdline_ptr, ',', TRUE);
|
2006-04-17 08:50:46 +02:00
|
|
|
|
|
|
|
hm = LoadLibraryExW(ocx_filename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
2005-03-14 18:16:03 +01:00
|
|
|
if (!hm)
|
2006-04-17 08:50:46 +02:00
|
|
|
goto done;
|
2005-03-14 18:16:03 +01:00
|
|
|
|
2011-11-07 11:45:18 +01:00
|
|
|
hr = do_ocx_reg(hm, TRUE, str_flags, param);
|
2005-03-14 18:16:03 +01:00
|
|
|
|
2006-04-17 08:50:46 +02:00
|
|
|
done:
|
2005-03-14 18:16:03 +01:00
|
|
|
FreeLibrary(hm);
|
2006-04-17 08:50:46 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, cmdline_copy);
|
|
|
|
RtlFreeUnicodeString(&cmdlineW);
|
|
|
|
|
|
|
|
return hr;
|
2005-03-14 18:16:03 +01:00
|
|
|
}
|
|
|
|
|
2006-01-21 19:21:22 +01:00
|
|
|
/***********************************************************************
|
2006-02-24 16:09:42 +01:00
|
|
|
* SetPerUserSecValuesA (ADVPACK.@)
|
2006-01-21 19:21:22 +01:00
|
|
|
*
|
2006-03-24 06:10:04 +01:00
|
|
|
* See SetPerUserSecValuesW.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI SetPerUserSecValuesA(PERUSERSECTIONA* pPerUser)
|
|
|
|
{
|
|
|
|
PERUSERSECTIONW perUserW;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", pPerUser);
|
|
|
|
|
|
|
|
if (!pPerUser)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2018-06-11 21:22:35 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, pPerUser->szGUID, -1, perUserW.szGUID, ARRAY_SIZE(perUserW.szGUID));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pPerUser->szDispName, -1, perUserW.szDispName, ARRAY_SIZE(perUserW.szDispName));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pPerUser->szLocale, -1, perUserW.szLocale, ARRAY_SIZE(perUserW.szLocale));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pPerUser->szStub, -1, perUserW.szStub, ARRAY_SIZE(perUserW.szStub));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pPerUser->szVersion, -1, perUserW.szVersion, ARRAY_SIZE(perUserW.szVersion));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pPerUser->szCompID, -1, perUserW.szCompID, ARRAY_SIZE(perUserW.szCompID));
|
2006-03-24 06:10:04 +01:00
|
|
|
perUserW.dwIsInstalled = pPerUser->dwIsInstalled;
|
|
|
|
perUserW.bRollback = pPerUser->bRollback;
|
|
|
|
|
|
|
|
return SetPerUserSecValuesW(&perUserW);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetPerUserSecValuesW (ADVPACK.@)
|
|
|
|
*
|
2006-01-21 19:21:22 +01:00
|
|
|
* Prepares the per-user stub values under IsInstalled\{GUID} that
|
|
|
|
* control the per-user installation.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pPerUser [I] Per-user stub values.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: E_FAIL.
|
|
|
|
*/
|
2006-03-24 06:10:04 +01:00
|
|
|
HRESULT WINAPI SetPerUserSecValuesW(PERUSERSECTIONW* pPerUser)
|
2006-01-21 19:21:22 +01:00
|
|
|
{
|
2006-04-08 08:03:30 +02:00
|
|
|
HKEY setup, guid;
|
|
|
|
|
|
|
|
static const WCHAR stub_path[] = {'S','t','u','b','P','a','t','h',0};
|
|
|
|
static const WCHAR version[] = {'V','e','r','s','i','o','n',0};
|
|
|
|
static const WCHAR locale[] = {'L','o','c','a','l','e',0};
|
|
|
|
static const WCHAR compid[] = {'C','o','m','p','o','n','e','n','t','I','D',0};
|
|
|
|
static const WCHAR isinstalled[] = {'I','s','I','n','s','t','a','l','l','e','d',0};
|
|
|
|
|
|
|
|
TRACE("(%p)\n", pPerUser);
|
|
|
|
|
|
|
|
if (!pPerUser || !*pPerUser->szGUID)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, setup_key, 0, NULL, 0, KEY_WRITE,
|
|
|
|
NULL, &setup, NULL))
|
|
|
|
{
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RegCreateKeyExW(setup, pPerUser->szGUID, 0, NULL, 0, KEY_ALL_ACCESS,
|
|
|
|
NULL, &guid, NULL))
|
|
|
|
{
|
|
|
|
RegCloseKey(setup);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*pPerUser->szStub)
|
|
|
|
{
|
|
|
|
RegSetValueExW(guid, stub_path, 0, REG_SZ, (LPBYTE)pPerUser->szStub,
|
|
|
|
(lstrlenW(pPerUser->szStub) + 1) * sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*pPerUser->szVersion)
|
|
|
|
{
|
|
|
|
RegSetValueExW(guid, version, 0, REG_SZ, (LPBYTE)pPerUser->szVersion,
|
|
|
|
(lstrlenW(pPerUser->szVersion) + 1) * sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*pPerUser->szLocale)
|
|
|
|
{
|
|
|
|
RegSetValueExW(guid, locale, 0, REG_SZ, (LPBYTE)pPerUser->szLocale,
|
|
|
|
(lstrlenW(pPerUser->szLocale) + 1) * sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*pPerUser->szCompID)
|
|
|
|
{
|
|
|
|
RegSetValueExW(guid, compid, 0, REG_SZ, (LPBYTE)pPerUser->szCompID,
|
|
|
|
(lstrlenW(pPerUser->szCompID) + 1) * sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*pPerUser->szDispName)
|
|
|
|
{
|
|
|
|
RegSetValueExW(guid, NULL, 0, REG_SZ, (LPBYTE)pPerUser->szDispName,
|
|
|
|
(lstrlenW(pPerUser->szDispName) + 1) * sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
|
|
|
|
RegSetValueExW(guid, isinstalled, 0, REG_DWORD,
|
|
|
|
(LPBYTE)&pPerUser->dwIsInstalled, sizeof(DWORD));
|
|
|
|
|
|
|
|
RegCloseKey(guid);
|
|
|
|
RegCloseKey(setup);
|
|
|
|
|
|
|
|
return S_OK;
|
2006-01-21 19:21:22 +01:00
|
|
|
}
|
|
|
|
|
2005-07-11 20:01:48 +02:00
|
|
|
/***********************************************************************
|
2006-02-24 16:09:42 +01:00
|
|
|
* TranslateInfStringA (ADVPACK.@)
|
2005-07-11 20:01:48 +02:00
|
|
|
*
|
2006-03-09 06:29:40 +01:00
|
|
|
* See TranslateInfStringW.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI TranslateInfStringA(LPCSTR pszInfFilename, LPCSTR pszInstallSection,
|
|
|
|
LPCSTR pszTranslateSection, LPCSTR pszTranslateKey, LPSTR pszBuffer,
|
|
|
|
DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved)
|
|
|
|
{
|
|
|
|
UNICODE_STRING filenameW, installW;
|
|
|
|
UNICODE_STRING translateW, keyW;
|
|
|
|
LPWSTR bufferW;
|
|
|
|
HRESULT res;
|
|
|
|
DWORD len = 0;
|
|
|
|
|
2006-10-07 04:06:59 +02:00
|
|
|
TRACE("(%s, %s, %s, %s, %p, %d, %p, %p)\n",
|
2006-03-09 06:29:40 +01:00
|
|
|
debugstr_a(pszInfFilename), debugstr_a(pszInstallSection),
|
|
|
|
debugstr_a(pszTranslateSection), debugstr_a(pszTranslateKey),
|
|
|
|
pszBuffer, dwBufferSize,pdwRequiredSize, pvReserved);
|
|
|
|
|
|
|
|
if (!pszInfFilename || !pszTranslateSection ||
|
|
|
|
!pszTranslateKey || !pdwRequiredSize)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&filenameW, pszInfFilename);
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&installW, pszInstallSection);
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&translateW, pszTranslateSection);
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&keyW, pszTranslateKey);
|
|
|
|
|
|
|
|
res = TranslateInfStringW(filenameW.Buffer, installW.Buffer,
|
|
|
|
translateW.Buffer, keyW.Buffer, NULL,
|
|
|
|
dwBufferSize, &len, NULL);
|
|
|
|
|
|
|
|
if (res == S_OK)
|
|
|
|
{
|
|
|
|
bufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
|
|
|
|
res = TranslateInfStringW(filenameW.Buffer, installW.Buffer,
|
|
|
|
translateW.Buffer, keyW.Buffer, bufferW,
|
|
|
|
len, &len, NULL);
|
|
|
|
if (res == S_OK)
|
|
|
|
{
|
|
|
|
*pdwRequiredSize = WideCharToMultiByte(CP_ACP, 0, bufferW, -1,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
|
|
|
|
if (dwBufferSize >= *pdwRequiredSize)
|
|
|
|
{
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, bufferW, -1, pszBuffer,
|
|
|
|
dwBufferSize, NULL, NULL);
|
|
|
|
}
|
|
|
|
else
|
2014-10-07 07:34:33 +02:00
|
|
|
res = E_NOT_SUFFICIENT_BUFFER;
|
2006-03-09 06:29:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, bufferW);
|
|
|
|
}
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&filenameW);
|
|
|
|
RtlFreeUnicodeString(&installW);
|
|
|
|
RtlFreeUnicodeString(&translateW);
|
|
|
|
RtlFreeUnicodeString(&keyW);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* TranslateInfStringW (ADVPACK.@)
|
|
|
|
*
|
2005-11-08 13:43:35 +01:00
|
|
|
* Translates the value of a specified key in an inf file into the
|
|
|
|
* current locale by expanding string macros.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pszInfFilename [I] Filename of the inf file.
|
|
|
|
* pszInstallSection [I]
|
|
|
|
* pszTranslateSection [I] Inf section where the key exists.
|
|
|
|
* pszTranslateKey [I] Key to translate.
|
|
|
|
* pszBuffer [O] Contains the translated string on exit.
|
|
|
|
* dwBufferSize [I] Size on input of pszBuffer.
|
|
|
|
* pdwRequiredSize [O] Length of the translated key.
|
|
|
|
* pvReserved [I] Reserved, must be NULL.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: An hresult error code.
|
2005-07-11 20:01:48 +02:00
|
|
|
*/
|
2006-03-09 06:29:40 +01:00
|
|
|
HRESULT WINAPI TranslateInfStringW(LPCWSTR pszInfFilename, LPCWSTR pszInstallSection,
|
|
|
|
LPCWSTR pszTranslateSection, LPCWSTR pszTranslateKey, LPWSTR pszBuffer,
|
2005-07-11 20:01:48 +02:00
|
|
|
DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved)
|
|
|
|
{
|
2005-11-08 13:43:35 +01:00
|
|
|
HINF hInf;
|
2006-10-21 08:49:10 +02:00
|
|
|
HRESULT hret = S_OK;
|
2005-11-08 13:43:35 +01:00
|
|
|
|
2006-10-07 04:06:59 +02:00
|
|
|
TRACE("(%s, %s, %s, %s, %p, %d, %p, %p)\n",
|
2006-03-09 06:29:40 +01:00
|
|
|
debugstr_w(pszInfFilename), debugstr_w(pszInstallSection),
|
|
|
|
debugstr_w(pszTranslateSection), debugstr_w(pszTranslateKey),
|
2005-11-08 13:43:35 +01:00
|
|
|
pszBuffer, dwBufferSize,pdwRequiredSize, pvReserved);
|
|
|
|
|
|
|
|
if (!pszInfFilename || !pszTranslateSection ||
|
|
|
|
!pszTranslateKey || !pdwRequiredSize)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2006-03-09 06:29:40 +01:00
|
|
|
hInf = SetupOpenInfFileW(pszInfFilename, NULL, INF_STYLE_WIN4, NULL);
|
2005-11-08 13:43:35 +01:00
|
|
|
if (hInf == INVALID_HANDLE_VALUE)
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
|
|
|
|
|
2006-04-18 23:14:34 +02:00
|
|
|
set_ldids(hInf, pszInstallSection, NULL);
|
2006-02-21 04:40:59 +01:00
|
|
|
|
2006-03-09 06:29:40 +01:00
|
|
|
if (!SetupGetLineTextW(NULL, hInf, pszTranslateSection, pszTranslateKey,
|
2005-11-08 13:43:35 +01:00
|
|
|
pszBuffer, dwBufferSize, pdwRequiredSize))
|
|
|
|
{
|
|
|
|
if (dwBufferSize < *pdwRequiredSize)
|
2014-10-07 07:34:33 +02:00
|
|
|
hret = E_NOT_SUFFICIENT_BUFFER;
|
2006-10-21 08:49:10 +02:00
|
|
|
else
|
|
|
|
hret = SPAPI_E_LINE_NOT_FOUND;
|
2005-11-08 13:43:35 +01:00
|
|
|
}
|
|
|
|
|
2006-02-21 04:40:59 +01:00
|
|
|
SetupCloseInfFile(hInf);
|
2006-10-21 08:49:10 +02:00
|
|
|
return hret;
|
2005-07-11 20:01:48 +02:00
|
|
|
}
|
2006-01-14 17:10:16 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2006-02-24 16:09:42 +01:00
|
|
|
* TranslateInfStringExA (ADVPACK.@)
|
2006-01-14 17:10:16 +01:00
|
|
|
*
|
2006-03-21 20:32:37 +01:00
|
|
|
* See TranslateInfStringExW.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI TranslateInfStringExA(HINF hInf, LPCSTR pszInfFilename,
|
|
|
|
LPCSTR pszTranslateSection, LPCSTR pszTranslateKey,
|
|
|
|
LPSTR pszBuffer, DWORD dwBufferSize,
|
|
|
|
PDWORD pdwRequiredSize, PVOID pvReserved)
|
|
|
|
{
|
|
|
|
UNICODE_STRING filenameW, sectionW, keyW;
|
|
|
|
LPWSTR bufferW;
|
|
|
|
HRESULT res;
|
|
|
|
DWORD len = 0;
|
|
|
|
|
2017-03-24 15:49:21 +01:00
|
|
|
TRACE("(%p, %s, %s, %s, %p, %d, %p, %p)\n", hInf, debugstr_a(pszInfFilename),
|
2006-03-21 20:32:37 +01:00
|
|
|
debugstr_a(pszTranslateSection), debugstr_a(pszTranslateKey),
|
2017-03-24 15:49:21 +01:00
|
|
|
pszBuffer, dwBufferSize, pdwRequiredSize, pvReserved);
|
2006-03-21 20:32:37 +01:00
|
|
|
|
|
|
|
if (!pszInfFilename || !pszTranslateSection ||
|
|
|
|
!pszTranslateKey || !pdwRequiredSize)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&filenameW, pszInfFilename);
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(§ionW, pszTranslateSection);
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&keyW, pszTranslateKey);
|
|
|
|
|
|
|
|
res = TranslateInfStringExW(hInf, filenameW.Buffer, sectionW.Buffer,
|
|
|
|
keyW.Buffer, NULL, 0, &len, NULL);
|
|
|
|
|
|
|
|
if (res == S_OK)
|
|
|
|
{
|
|
|
|
bufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
|
|
|
|
res = TranslateInfStringExW(hInf, filenameW.Buffer, sectionW.Buffer,
|
|
|
|
keyW.Buffer, bufferW, len, &len, NULL);
|
|
|
|
|
|
|
|
if (res == S_OK)
|
|
|
|
{
|
|
|
|
*pdwRequiredSize = WideCharToMultiByte(CP_ACP, 0, bufferW, -1,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
|
|
|
|
if (dwBufferSize >= *pdwRequiredSize)
|
|
|
|
{
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, bufferW, -1, pszBuffer,
|
|
|
|
dwBufferSize, NULL, NULL);
|
|
|
|
}
|
|
|
|
else
|
2014-10-07 07:34:33 +02:00
|
|
|
res = E_NOT_SUFFICIENT_BUFFER;
|
2006-03-21 20:32:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, bufferW);
|
|
|
|
}
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&filenameW);
|
|
|
|
RtlFreeUnicodeString(§ionW);
|
|
|
|
RtlFreeUnicodeString(&keyW);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* TranslateInfStringExW (ADVPACK.@)
|
|
|
|
*
|
2006-01-14 17:10:16 +01:00
|
|
|
* Using a handle to an INF file opened with OpenINFEngine, translates
|
|
|
|
* the value of a specified key in an inf file into the current locale
|
|
|
|
* by expanding string macros.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hInf [I] Handle to the INF file.
|
|
|
|
* pszInfFilename [I] Filename of the INF file.
|
|
|
|
* pszTranslateSection [I] Inf section where the key exists.
|
|
|
|
* pszTranslateKey [I] Key to translate.
|
|
|
|
* pszBuffer [O] Contains the translated string on exit.
|
|
|
|
* dwBufferSize [I] Size on input of pszBuffer.
|
|
|
|
* pdwRequiredSize [O] Length of the translated key.
|
|
|
|
* pvReserved [I] Reserved. Must be NULL.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: E_FAIL.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* To use TranslateInfStringEx to translate an INF file continuously,
|
|
|
|
* open the INF file with OpenINFEngine, call TranslateInfStringEx as
|
|
|
|
* many times as needed, then release the handle with CloseINFEngine.
|
|
|
|
* When translating more than one keys, this method is more efficient
|
|
|
|
* than calling TranslateInfString, because the INF file is only
|
|
|
|
* opened once.
|
|
|
|
*/
|
2006-03-21 20:32:37 +01:00
|
|
|
HRESULT WINAPI TranslateInfStringExW(HINF hInf, LPCWSTR pszInfFilename,
|
|
|
|
LPCWSTR pszTranslateSection, LPCWSTR pszTranslateKey,
|
|
|
|
LPWSTR pszBuffer, DWORD dwBufferSize,
|
|
|
|
PDWORD pdwRequiredSize, PVOID pvReserved)
|
2006-01-14 17:10:16 +01:00
|
|
|
{
|
2017-03-24 15:49:21 +01:00
|
|
|
TRACE("(%p, %s, %s, %s, %p, %d, %p, %p)\n", hInf, debugstr_w(pszInfFilename),
|
2006-03-21 20:32:37 +01:00
|
|
|
debugstr_w(pszTranslateSection), debugstr_w(pszTranslateKey),
|
2017-03-24 15:49:21 +01:00
|
|
|
pszBuffer, dwBufferSize, pdwRequiredSize, pvReserved);
|
2006-01-14 17:10:16 +01:00
|
|
|
|
2006-02-27 20:50:03 +01:00
|
|
|
if (!hInf || !pszInfFilename || !pszTranslateSection || !pszTranslateKey)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2006-03-21 20:32:37 +01:00
|
|
|
if (!SetupGetLineTextW(NULL, hInf, pszTranslateSection, pszTranslateKey,
|
2006-02-21 04:42:25 +01:00
|
|
|
pszBuffer, dwBufferSize, pdwRequiredSize))
|
|
|
|
{
|
|
|
|
if (dwBufferSize < *pdwRequiredSize)
|
2014-10-07 07:34:33 +02:00
|
|
|
return E_NOT_SUFFICIENT_BUFFER;
|
2006-02-21 04:42:25 +01:00
|
|
|
|
|
|
|
return SPAPI_E_LINE_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2006-02-27 20:50:03 +01:00
|
|
|
return S_OK;
|
2006-01-14 17:10:16 +01:00
|
|
|
}
|
2006-01-21 19:19:31 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2006-02-24 16:09:42 +01:00
|
|
|
* UserInstStubWrapperA (ADVPACK.@)
|
2006-03-22 21:15:51 +01:00
|
|
|
*
|
|
|
|
* See UserInstStubWrapperW.
|
2006-01-21 19:19:31 +01:00
|
|
|
*/
|
2006-02-24 16:09:42 +01:00
|
|
|
HRESULT WINAPI UserInstStubWrapperA(HWND hWnd, HINSTANCE hInstance,
|
|
|
|
LPSTR pszParms, INT nShow)
|
2006-03-22 21:15:51 +01:00
|
|
|
{
|
|
|
|
UNICODE_STRING parmsW;
|
|
|
|
HRESULT res;
|
|
|
|
|
2006-04-11 07:17:13 +02:00
|
|
|
TRACE("(%p, %p, %s, %i)\n", hWnd, hInstance, debugstr_a(pszParms), nShow);
|
2006-03-22 21:15:51 +01:00
|
|
|
|
|
|
|
if (!pszParms)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&parmsW, pszParms);
|
|
|
|
|
|
|
|
res = UserInstStubWrapperW(hWnd, hInstance, parmsW.Buffer, nShow);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&parmsW);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* UserInstStubWrapperW (ADVPACK.@)
|
2006-04-11 08:26:44 +02:00
|
|
|
*
|
|
|
|
* Launches the user stub wrapper specified by the RealStubPath
|
|
|
|
* registry value under Installed Components\szParms.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hWnd [I] Handle to the window used for the display.
|
|
|
|
* hInstance [I] Instance of the process.
|
|
|
|
* szParms [I] The GUID of the installation.
|
|
|
|
* show [I] How the window should be shown.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: E_FAIL.
|
|
|
|
*
|
|
|
|
* TODO
|
|
|
|
* If the type of the StubRealPath value is REG_EXPAND_SZ, then
|
|
|
|
* we should call ExpandEnvironmentStrings on the value and
|
|
|
|
* launch the result.
|
2006-03-22 21:15:51 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI UserInstStubWrapperW(HWND hWnd, HINSTANCE hInstance,
|
|
|
|
LPWSTR pszParms, INT nShow)
|
2006-01-21 19:19:31 +01:00
|
|
|
{
|
2006-04-11 08:26:44 +02:00
|
|
|
HKEY setup, guid;
|
|
|
|
WCHAR stub[MAX_PATH];
|
2020-05-28 04:30:19 +02:00
|
|
|
DWORD size = sizeof(stub);
|
2006-04-11 08:26:44 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
BOOL res;
|
2006-01-21 19:19:31 +01:00
|
|
|
|
2006-04-11 08:26:44 +02:00
|
|
|
static const WCHAR real_stub_path[] = {
|
|
|
|
'R','e','a','l','S','t','u','b','P','a','t','h',0
|
|
|
|
};
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %s, %i)\n", hWnd, hInstance, debugstr_w(pszParms), nShow);
|
|
|
|
|
|
|
|
if (!pszParms || !*pszParms)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, setup_key, 0, KEY_READ, &setup))
|
|
|
|
{
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(setup, pszParms, 0, KEY_READ, &guid))
|
|
|
|
{
|
|
|
|
RegCloseKey(setup);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = RegQueryValueExW(guid, real_stub_path, NULL, NULL, (LPBYTE)stub, &size);
|
|
|
|
if (res || !*stub)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* launch the user stub wrapper */
|
|
|
|
hr = launch_exe(stub, NULL, NULL);
|
|
|
|
|
|
|
|
done:
|
|
|
|
RegCloseKey(setup);
|
|
|
|
RegCloseKey(guid);
|
|
|
|
|
|
|
|
return hr;
|
2006-01-21 19:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2006-02-24 16:09:42 +01:00
|
|
|
* UserUnInstStubWrapperA (ADVPACK.@)
|
2006-03-22 21:15:51 +01:00
|
|
|
*
|
|
|
|
* See UserUnInstStubWrapperW.
|
2006-01-21 19:19:31 +01:00
|
|
|
*/
|
2006-02-24 16:09:42 +01:00
|
|
|
HRESULT WINAPI UserUnInstStubWrapperA(HWND hWnd, HINSTANCE hInstance,
|
2006-03-22 21:15:51 +01:00
|
|
|
LPSTR pszParms, INT nShow)
|
|
|
|
{
|
|
|
|
UNICODE_STRING parmsW;
|
|
|
|
HRESULT res;
|
|
|
|
|
2006-04-11 07:17:13 +02:00
|
|
|
TRACE("(%p, %p, %s, %i)\n", hWnd, hInstance, debugstr_a(pszParms), nShow);
|
2006-03-22 21:15:51 +01:00
|
|
|
|
|
|
|
if (!pszParms)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&parmsW, pszParms);
|
|
|
|
|
|
|
|
res = UserUnInstStubWrapperW(hWnd, hInstance, parmsW.Buffer, nShow);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&parmsW);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* UserUnInstStubWrapperW (ADVPACK.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI UserUnInstStubWrapperW(HWND hWnd, HINSTANCE hInstance,
|
|
|
|
LPWSTR pszParms, INT nShow)
|
2006-01-21 19:19:31 +01:00
|
|
|
{
|
2006-04-11 07:17:13 +02:00
|
|
|
FIXME("(%p, %p, %s, %i): stub\n", hWnd, hInstance, debugstr_w(pszParms), nShow);
|
2006-01-21 19:19:31 +01:00
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|