Skip to content

Commit eccd642

Browse files
committed
Implement SetupDiGetDeviceInfoListClass
Parse 'Include' and 'Needs' directives in SetupInstallFromInfSectionW and when installing services svn path=/trunk/; revision=20271
1 parent eecd4bb commit eccd642

File tree

3 files changed

+153
-1
lines changed

3 files changed

+153
-1
lines changed

reactos/lib/setupapi/devinst.c

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,10 +3184,70 @@ InstallServicesSection(
31843184
OUT PBOOL pRebootRequired OPTIONAL)
31853185
{
31863186
INFCONTEXT ContextService;
3187+
INFCONTEXT ContextInclude;
31873188
DWORD RequiredSize;
31883189
INT Flags;
31893190
BOOL ret = FALSE;
31903191

3192+
/* Parse 'Include' line */
3193+
if (SetupFindFirstLineW(hInf, SectionName, L"Include", &ContextInclude))
3194+
{
3195+
DWORD Index = 1;
3196+
while (TRUE)
3197+
{
3198+
static WCHAR szBuffer[MAX_PATH];
3199+
PWSTR pBuffer = NULL;
3200+
DWORD required;
3201+
3202+
ret = SetupGetStringFieldW(&ContextInclude, Index, szBuffer, MAX_PATH, &required);
3203+
if (!ret && GetLastError() == ERROR_INVALID_PARAMETER)
3204+
break;
3205+
else if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
3206+
{
3207+
pBuffer = MyMalloc(required);
3208+
ret = SetupGetStringFieldW(&ContextInclude, Index, pBuffer, required, &required);
3209+
}
3210+
if (ret)
3211+
ret = SetupOpenAppendInfFileW(pBuffer ? pBuffer : szBuffer, hInf, NULL);
3212+
3213+
MyFree(pBuffer);
3214+
if (!ret)
3215+
goto done;
3216+
Index++;
3217+
}
3218+
}
3219+
3220+
/* Parse 'Needs' line */
3221+
if (SetupFindFirstLineW(hInf, SectionName, L"Needs", &ContextInclude))
3222+
{
3223+
DWORD Index = 1;
3224+
while (TRUE)
3225+
{
3226+
static WCHAR szBuffer[MAX_PATH];
3227+
PWSTR pBuffer = NULL;
3228+
DWORD required;
3229+
3230+
ret = SetupGetStringFieldW(&ContextInclude, Index, szBuffer, MAX_PATH, &required);
3231+
if (!ret && GetLastError() == ERROR_INVALID_PARAMETER)
3232+
break;
3233+
else if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
3234+
{
3235+
pBuffer = MyMalloc(required);
3236+
ret = SetupGetStringFieldW(&ContextInclude, Index, pBuffer, required, &required);
3237+
}
3238+
if (ret)
3239+
{
3240+
ret = InstallServicesSection(hInf, pBuffer ? pBuffer : szBuffer,
3241+
DeviceInfoSet, DeviceInfoData, pAssociatedService, pRebootRequired);
3242+
}
3243+
3244+
MyFree(pBuffer);
3245+
if (!ret)
3246+
goto done;
3247+
Index++;
3248+
}
3249+
}
3250+
31913251
ret = SetupFindFirstLineW(hInf, SectionName, NULL, &ContextService);
31923252
while (ret)
31933253
{
@@ -4132,6 +4192,35 @@ BOOL WINAPI SetupDiCallClassInstaller(
41324192
return ret;
41334193
}
41344194

4195+
/***********************************************************************
4196+
* SetupDiGetDeviceInfoListClass (SETUPAPI.@)
4197+
*/
4198+
BOOL WINAPI SetupDiGetDeviceInfoListClass(
4199+
IN HDEVINFO DeviceInfoSet,
4200+
OUT LPGUID ClassGuid)
4201+
{
4202+
struct DeviceInfoSet *list;
4203+
BOOL ret = FALSE;
4204+
4205+
TRACE("%p %p\n", DeviceInfoSet, ClassGuid);
4206+
4207+
if (!DeviceInfoSet)
4208+
SetLastError(ERROR_INVALID_HANDLE);
4209+
else if ((list = (struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEV_INFO_SET_MAGIC)
4210+
SetLastError(ERROR_INVALID_HANDLE);
4211+
else if (IsEqualIID(&list->ClassGuid, &GUID_NULL))
4212+
SetLastError(ERROR_NO_ASSOCIATED_CLASS);
4213+
else
4214+
{
4215+
memcpy(&ClassGuid, &list->ClassGuid, sizeof(GUID));
4216+
4217+
ret = TRUE;
4218+
}
4219+
4220+
TRACE("Returning %d\n", ret);
4221+
return ret;
4222+
}
4223+
41354224
/***********************************************************************
41364225
* SetupDiGetDeviceInfoListDetailW (SETUPAPI.@)
41374226
*/

reactos/lib/setupapi/install.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ static const WCHAR UpdateIniFields[] = {'U','p','d','a','t','e','I','n','i','F',
6464
static const WCHAR RegisterDlls[] = {'R','e','g','i','s','t','e','r','D','l','l','s',0};
6565
static const WCHAR UnregisterDlls[] = {'U','n','r','e','g','i','s','t','e','r','D','l','l','s',0};
6666
static const WCHAR ProfileItems[] = {'P','r','o','f','i','l','e','I','t','e','m','s',0};
67+
static const WCHAR Include[] = {'I','n','c','l','u','d','e',0};
68+
static const WCHAR Needs[] = {'N','e','e','d','s',0};
6769

6870

6971
/***********************************************************************
@@ -789,6 +791,67 @@ BOOL WINAPI SetupInstallFromInfSectionW( HWND owner, HINF hinf, PCWSTR section,
789791
PSP_FILE_CALLBACK_W callback, PVOID context,
790792
HDEVINFO devinfo, PSP_DEVINFO_DATA devinfo_data )
791793
{
794+
INFCONTEXT include_context;
795+
796+
/* Parse 'Include' line */
797+
if (SetupFindFirstLineW( hinf, section, Include, &include_context ))
798+
{
799+
DWORD index = 1;
800+
while (TRUE)
801+
{
802+
static WCHAR szBuffer[MAX_PATH];
803+
PWSTR pBuffer = NULL;
804+
DWORD required;
805+
BOOL ok;
806+
807+
ok = SetupGetStringFieldW( &include_context, index, szBuffer, MAX_PATH, &required );
808+
if (!ok && GetLastError() == ERROR_INVALID_PARAMETER)
809+
break;
810+
else if (!ok && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
811+
{
812+
pBuffer = MyMalloc(required);
813+
ok = SetupGetStringFieldW( &include_context, index, pBuffer, required, &required );
814+
}
815+
if (ok)
816+
ok = SetupOpenAppendInfFileW( pBuffer ? pBuffer : szBuffer, hinf, NULL );
817+
818+
MyFree(pBuffer);
819+
if (!ok) return FALSE;
820+
index++;
821+
}
822+
}
823+
824+
/* Parse 'Needs' line */
825+
if (SetupFindFirstLineW( hinf, section, Needs, &include_context ))
826+
{
827+
DWORD index = 1;
828+
while (TRUE)
829+
{
830+
static WCHAR szBuffer[MAX_PATH];
831+
PWSTR pBuffer = NULL;
832+
DWORD required;
833+
BOOL ok;
834+
835+
ok = SetupGetStringFieldW( &include_context, index, szBuffer, MAX_PATH, &required );
836+
if (!ok && GetLastError() == ERROR_INVALID_PARAMETER)
837+
break;
838+
else if (!ok && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
839+
{
840+
pBuffer = MyMalloc(required);
841+
ok = SetupGetStringFieldW( &include_context, index, pBuffer, required, &required );
842+
}
843+
if (ok)
844+
{
845+
ok = SetupInstallFromInfSectionW( owner, hinf, pBuffer ? pBuffer : szBuffer,
846+
flags, key_root, src_root, copy_flags, callback, context, devinfo, devinfo_data );
847+
}
848+
849+
MyFree(pBuffer);
850+
if (!ok) return FALSE;
851+
index++;
852+
}
853+
}
854+
792855
if (flags & SPINST_FILES)
793856
{
794857
struct files_callback_info info;

reactos/lib/setupapi/setupapi.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@
320320
@ stdcall SetupDiGetClassImageListExW(ptr wstr ptr)
321321
@ stub SetupDiGetClassInstallParamsA
322322
@ stub SetupDiGetClassInstallParamsW
323-
@ stub SetupDiGetDeviceInfoListClass
323+
@ stdcall SetupDiGetDeviceInfoListClass(ptr ptr)
324324
@ stdcall SetupDiGetDeviceInfoListDetailA(ptr ptr)
325325
@ stdcall SetupDiGetDeviceInfoListDetailW(ptr ptr)
326326
@ stdcall SetupDiGetDeviceInstallParamsA(ptr ptr ptr)

0 commit comments

Comments
 (0)