[SETUPAPI]

- Transform the cached OsVersionInfo structure into a OSVERSIONINFOEXW that is then reused in SetupDiGetActualSectionToInstallExW.
- Remove few unused hardcoded strings.
- Add two TRACEs in SetupDiGetActualSectionToInstallExW to debug diverse INF file installation problems.
- parser.c: enclose the contents of the for-loop inside braces.
- Implement pSetupSetGlobalFlags and pSetupModifyGlobalFlags, see https://msdn.microsoft.com/en-us/library/bb432397(v=vs.85).aspx
- Popup an error message box in InstallHinfSectionW if an error happened and if interactive setup is allowed (through the global setup flags).

svn path=/trunk/; revision=72008
This commit is contained in:
Hermès Bélusca-Maïto 2016-07-27 00:10:14 +00:00
parent 79ce70c1dd
commit 86ff038c51
7 changed files with 54 additions and 31 deletions

View file

@ -23,8 +23,6 @@
/* Unicode constants */
static const WCHAR BackSlash[] = {'\\',0};
static const WCHAR ClassGUID[] = {'C','l','a','s','s','G','U','I','D',0};
static const WCHAR Class[] = {'C','l','a','s','s',0};
static const WCHAR DateFormat[] = {'%','u','-','%','u','-','%','u',0};
static const WCHAR DotCoInstallers[] = {'.','C','o','I','n','s','t','a','l','l','e','r','s',0};
static const WCHAR DotHW[] = {'.','H','W',0};
@ -459,21 +457,16 @@ SetupDiGetActualSectionToInstallExW(
if (CurrentPlatform.cbSize != sizeof(SP_ALTPLATFORM_INFO))
{
/* That's the first time we go here. We need to fill in the structure */
OSVERSIONINFOEX VersionInfo;
SYSTEM_INFO SystemInfo;
VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
ret = GetVersionExW((OSVERSIONINFO*)&VersionInfo);
if (!ret)
goto done;
GetSystemInfo(&SystemInfo);
CurrentPlatform.cbSize = sizeof(SP_ALTPLATFORM_INFO);
CurrentPlatform.Platform = VersionInfo.dwPlatformId;
CurrentPlatform.MajorVersion = VersionInfo.dwMajorVersion;
CurrentPlatform.MinorVersion = VersionInfo.dwMinorVersion;
CurrentPlatform.Platform = OsVersionInfo.dwPlatformId;
CurrentPlatform.MajorVersion = OsVersionInfo.dwMajorVersion;
CurrentPlatform.MinorVersion = OsVersionInfo.dwMinorVersion;
CurrentPlatform.ProcessorArchitecture = SystemInfo.wProcessorArchitecture;
CurrentPlatform.Reserved = 0;
CurrentProductType = VersionInfo.wProductType;
CurrentSuiteMask = VersionInfo.wSuiteMask;
CurrentProductType = OsVersionInfo.wProductType;
CurrentSuiteMask = OsVersionInfo.wSuiteMask;
}
ProductType = CurrentProductType;
SuiteMask = CurrentSuiteMask;
@ -489,6 +482,7 @@ SetupDiGetActualSectionToInstallExW(
CallbackInfo.BestScore4 = ULONG_MAX;
CallbackInfo.BestScore5 = ULONG_MAX;
strcpyW(CallbackInfo.BestSection, InfSectionName);
TRACE("EnumerateSectionsStartingWith(InfSectionName = %S)\n", InfSectionName);
if (!EnumerateSectionsStartingWith(
InfHandle,
InfSectionName,
@ -498,6 +492,7 @@ SetupDiGetActualSectionToInstallExW(
SetLastError(ERROR_GEN_FAILURE);
goto done;
}
TRACE("CallbackInfo.BestSection = %S\n", CallbackInfo.BestSection);
dwFullLength = lstrlenW(CallbackInfo.BestSection);
if (RequiredSize != NULL)
@ -1011,7 +1006,7 @@ BOOL WINAPI SetupDiClassGuidsFromNameExW(
dwLength = MAX_CLASS_NAME_LEN * sizeof(WCHAR);
if (!RegQueryValueExW(hClassKey,
Class,
REGSTR_VAL_CLASS,
NULL,
NULL,
(LPBYTE)szClassName,
@ -1163,7 +1158,7 @@ BOOL WINAPI SetupDiClassNameFromGuidExW(
return FALSE;
/* Retrieve the class name data and close the key */
rc = QueryRegistryValue(hKey, Class, (LPBYTE *) &Buffer, &dwRegType, &dwLength);
rc = QueryRegistryValue(hKey, REGSTR_VAL_CLASS, (LPBYTE *) &Buffer, &dwRegType, &dwLength);
RegCloseKey(hKey);
/* Make sure we got the data */
@ -3613,7 +3608,7 @@ HKEY SETUP_CreateClassKey(HINF hInf)
if (!SetupGetLineTextW(NULL,
hInf,
Version,
ClassGUID,
REGSTR_VAL_CLASSGUID,
Buffer,
MAX_PATH,
&RequiredSize))
@ -3634,7 +3629,7 @@ HKEY SETUP_CreateClassKey(HINF hInf)
if (!SetupGetLineTextW(NULL,
hInf,
Version,
Class,
REGSTR_VAL_CLASS,
Buffer,
MAX_PATH,
&RequiredSize))
@ -3657,7 +3652,7 @@ HKEY SETUP_CreateClassKey(HINF hInf)
}
if (RegSetValueExW(hClassKey,
Class,
REGSTR_VAL_CLASS,
0,
REG_SZ,
(LPBYTE)Buffer,

View file

@ -1459,25 +1459,25 @@ BOOL WINAPI SetupInstallFromInfSectionW( HWND owner, HINF hinf, PCWSTR section,
*/
void WINAPI InstallHinfSectionW( HWND hwnd, HINSTANCE handle, LPCWSTR cmdline, INT show )
{
BOOL ret = FALSE;
WCHAR *s, *path, section[MAX_PATH];
void *callback_context = NULL;
DWORD SectionNameLength;
UINT mode;
HINF hinf = INVALID_HANDLE_VALUE;
BOOL bRebootRequired = FALSE;
BOOL ret;
TRACE("hwnd %p, handle %p, cmdline %s\n", hwnd, handle, debugstr_w(cmdline));
lstrcpynW( section, cmdline, MAX_PATH );
if (!(s = strchrW( section, ' ' ))) return;
if (!(s = strchrW( section, ' ' ))) goto cleanup;
*s++ = 0;
while (*s == ' ') s++;
mode = atoiW( s );
/* quoted paths are not allowed on native, the rest of the command line is taken as the path */
if (!(s = strchrW( s, ' ' ))) return;
if (!(s = strchrW( s, ' ' ))) goto cleanup;
while (*s == ' ') s++;
path = s;
@ -1576,6 +1576,12 @@ cleanup:
SetupTermDefaultQueueCallback( callback_context );
if ( hinf != INVALID_HANDLE_VALUE )
SetupCloseInfFile( hinf );
// TODO: Localize the error string.
if (!ret && !(GlobalSetupFlags & PSPGF_NONINTERACTIVE))
{
MessageBoxW(hwnd, section, L"setupapi.dll: An error happened...", MB_ICONERROR | MB_OK);
}
}

View file

@ -838,26 +838,38 @@ DWORD WINAPI RetreiveFileSecurity(LPCWSTR lpFileName,
}
static DWORD global_flags = 0; /* FIXME: what should be in here? */
/*
* See: https://msdn.microsoft.com/en-us/library/bb432397(v=vs.85).aspx
* for more information.
*/
DWORD GlobalSetupFlags = 0;
/***********************************************************************
* pSetupGetGlobalFlags (SETUPAPI.@)
*/
DWORD WINAPI pSetupGetGlobalFlags(void)
{
FIXME( "stub\n" );
return global_flags;
return GlobalSetupFlags;
}
/***********************************************************************
* pSetupModifyGlobalFlags (SETUPAPI.@)
*/
void WINAPI pSetupModifyGlobalFlags( DWORD mask, DWORD flags )
{
FIXME( "stub\n" );
GlobalSetupFlags = (GlobalSetupFlags & ~mask) | (flags & mask);
}
/***********************************************************************
* pSetupSetGlobalFlags (SETUPAPI.@)
*/
void WINAPI pSetupSetGlobalFlags( DWORD flags )
{
global_flags = flags;
pSetupModifyGlobalFlags(0xFFFFFFFF, flags);
}
/***********************************************************************
* AssertFail (SETUPAPI.@)
*

View file

@ -2383,10 +2383,12 @@ BOOL EnumerateSectionsStartingWith(
unsigned int i;
for (i = 0; i < file->nb_sections; i++)
{
if (strncmpiW(pStr, file->sections[i]->name, len) == 0)
{
if (!Callback(file->sections[i]->name, Context))
return FALSE;
}
}
return TRUE;
}

View file

@ -569,7 +569,7 @@
@ stdcall pSetupIsUserAdmin()
@ stub pSetupMakeSurePathExists
@ stub pSetupMalloc
@ stub pSetupModifyGlobalFlags
@ stdcall pSetupModifyGlobalFlags(long long)
@ stdcall pSetupMultiByteToUnicode(str long)
@ stdcall pSetupOpenAndMapFileForRead(wstr ptr ptr ptr ptr)
@ stub pSetupOutOfMemory

View file

@ -281,7 +281,15 @@ UINT CALLBACK QUEUE_callback_WtoA( void *context, UINT notification, UINT_PTR, U
#define _S_IREAD 0x0100
extern HINSTANCE hInstance;
extern OSVERSIONINFOW OsVersionInfo;
extern OSVERSIONINFOEXW OsVersionInfo;
/*
* See: https://msdn.microsoft.com/en-us/library/bb432397(v=vs.85).aspx
* for more information.
*/
extern DWORD GlobalSetupFlags;
#define PSPGF_NO_BACKUP 0x0002
#define PSPGF_NONINTERACTIVE 0x0004
/* devinst.c */

View file

@ -29,10 +29,10 @@
#include <share.h>
#include <fdi.h>
HINSTANCE hInstance = 0;
OSVERSIONINFOW OsVersionInfo;
HINSTANCE hInstance = NULL;
OSVERSIONINFOEXW OsVersionInfo;
static HINSTANCE CABINET_hInstance = 0;
static HINSTANCE CABINET_hInstance = NULL;
static HFDI (__cdecl *sc_FDICreate)(PFNALLOC, PFNFREE, PFNOPEN,
PFNREAD, PFNWRITE, PFNCLOSE, PFNSEEK, int, PERF);
@ -652,8 +652,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
OsVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
if (!GetVersionExW(&OsVersionInfo))
OsVersionInfo.dwOSVersionInfoSize = sizeof(OsVersionInfo);
if (!GetVersionExW((POSVERSIONINFOW)&OsVersionInfo))
return FALSE;
hInstance = (HINSTANCE)hinstDLL;
break;