diff --git a/reactos/dll/win32/setupapi/devinst.c b/reactos/dll/win32/setupapi/devinst.c index 0057ef88419..ac40dbd0344 100644 --- a/reactos/dll/win32/setupapi/devinst.c +++ b/reactos/dll/win32/setupapi/devinst.c @@ -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, diff --git a/reactos/dll/win32/setupapi/install.c b/reactos/dll/win32/setupapi/install.c index 8408cb6a84e..34c22daf94f 100644 --- a/reactos/dll/win32/setupapi/install.c +++ b/reactos/dll/win32/setupapi/install.c @@ -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); + } } diff --git a/reactos/dll/win32/setupapi/misc.c b/reactos/dll/win32/setupapi/misc.c index 626dc1305ae..701af294924 100644 --- a/reactos/dll/win32/setupapi/misc.c +++ b/reactos/dll/win32/setupapi/misc.c @@ -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.@) * diff --git a/reactos/dll/win32/setupapi/parser.c b/reactos/dll/win32/setupapi/parser.c index 6d5b23ca7d7..fbb459f8838 100644 --- a/reactos/dll/win32/setupapi/parser.c +++ b/reactos/dll/win32/setupapi/parser.c @@ -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; } diff --git a/reactos/dll/win32/setupapi/setupapi.spec b/reactos/dll/win32/setupapi/setupapi.spec index 13e6eb35b2b..7de1d290d75 100644 --- a/reactos/dll/win32/setupapi/setupapi.spec +++ b/reactos/dll/win32/setupapi/setupapi.spec @@ -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 diff --git a/reactos/dll/win32/setupapi/setupapi_private.h b/reactos/dll/win32/setupapi/setupapi_private.h index cf86101583e..29594eb169e 100644 --- a/reactos/dll/win32/setupapi/setupapi_private.h +++ b/reactos/dll/win32/setupapi/setupapi_private.h @@ -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 */ diff --git a/reactos/dll/win32/setupapi/setupcab.c b/reactos/dll/win32/setupapi/setupcab.c index e2f03039185..42f6192c224 100644 --- a/reactos/dll/win32/setupapi/setupcab.c +++ b/reactos/dll/win32/setupapi/setupcab.c @@ -29,10 +29,10 @@ #include #include -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;