mirror of
https://github.com/reactos/reactos.git
synced 2025-06-06 18:00:41 +00:00
Implement SetupInstallServicesFromInfSectionExW
Process {DDInstall}.HW section in SetupDiInstallDevice svn path=/trunk/; revision=18119
This commit is contained in:
parent
322841976a
commit
6053e004ad
3 changed files with 168 additions and 17 deletions
|
@ -4389,9 +4389,12 @@ SetupDiInstallDevice(
|
||||||
DWORD RequiredSize;
|
DWORD RequiredSize;
|
||||||
HINF hInf = NULL;
|
HINF hInf = NULL;
|
||||||
LPCWSTR AssociatedService = NULL;
|
LPCWSTR AssociatedService = NULL;
|
||||||
|
LPWSTR pSectionName = NULL;
|
||||||
BOOL RebootRequired = FALSE;
|
BOOL RebootRequired = FALSE;
|
||||||
HKEY hEnumKey, hKey;
|
HKEY hEnumKey, hKey;
|
||||||
LONG rc;
|
LONG rc;
|
||||||
|
HWND hWnd;
|
||||||
|
PVOID callback_context;
|
||||||
|
|
||||||
TRACE("%p %p\n", DeviceInfoSet, DeviceInfoData);
|
TRACE("%p %p\n", DeviceInfoSet, DeviceInfoData);
|
||||||
|
|
||||||
|
@ -4419,9 +4422,15 @@ SetupDiInstallDevice(
|
||||||
/* FIXME: If DI_FLAGSEX_SETFAILEDINSTALL is set, set FAILEDINSTALL flag in ConfigFlags registry and exit */
|
/* FIXME: If DI_FLAGSEX_SETFAILEDINSTALL is set, set FAILEDINSTALL flag in ConfigFlags registry and exit */
|
||||||
|
|
||||||
if (DeviceInfoData)
|
if (DeviceInfoData)
|
||||||
|
{
|
||||||
DriverInfo = ((struct DeviceInfoElement *)DeviceInfoData->Reserved)->SelectedDriver;
|
DriverInfo = ((struct DeviceInfoElement *)DeviceInfoData->Reserved)->SelectedDriver;
|
||||||
|
hWnd = ((struct DeviceInfoElement *)DeviceInfoData->Reserved)->hwndParent;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
DriverInfo = ((struct DeviceInfoSet *)DeviceInfoSet)->SelectedDriver;
|
DriverInfo = ((struct DeviceInfoSet *)DeviceInfoSet)->SelectedDriver;
|
||||||
|
hWnd = ((struct DeviceInfoSet *)DeviceInfoSet)->hwndParent;
|
||||||
|
}
|
||||||
FileTimeToSystemTime(&DriverInfo->Info.DriverDate, &DriverDate);
|
FileTimeToSystemTime(&DriverInfo->Info.DriverDate, &DriverDate);
|
||||||
|
|
||||||
hInf = SetupOpenInfFileW(DriverInfo->InfPath, NULL, INF_STYLE_WIN4, NULL);
|
hInf = SetupOpenInfFileW(DriverInfo->InfPath, NULL, INF_STYLE_WIN4, NULL);
|
||||||
|
@ -4435,6 +4444,7 @@ SetupDiInstallDevice(
|
||||||
SetupCloseInfFile(hInf);
|
SetupCloseInfFile(hInf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
pSectionName = &SectionName[wcslen(SectionName)];
|
||||||
|
|
||||||
/* Create driver key information */
|
/* Create driver key information */
|
||||||
FIXME("FIXME: Create driver key information\n");
|
FIXME("FIXME: Create driver key information\n");
|
||||||
|
@ -4442,7 +4452,6 @@ SetupDiInstallDevice(
|
||||||
/* Write information to driver key */
|
/* Write information to driver key */
|
||||||
FIXME("FIXME: Write information to driver key\n");
|
FIXME("FIXME: Write information to driver key\n");
|
||||||
FIXME("DriverDate : '%u-%u-%u'\n", 0, DriverDate.wMonth, DriverDate.wDay, DriverDate.wYear);
|
FIXME("DriverDate : '%u-%u-%u'\n", 0, DriverDate.wMonth, DriverDate.wDay, DriverDate.wYear);
|
||||||
FIXME("DriverDateData :"); { ULONG i; for (i = 0; i < sizeof(DriverInfo->Info.DriverDate); i++) DbgPrint(" %02x", ((PCHAR)&DriverInfo->Info.DriverDate)[i] & 0xff); } DbgPrint("\n");
|
|
||||||
FIXME("DriverDesc : '%S'\n", DriverInfo->Info.Description);
|
FIXME("DriverDesc : '%S'\n", DriverInfo->Info.Description);
|
||||||
FIXME("DriverVersion : '%u.%u.%u.%u'\n", DriverInfo->Info.DriverVersion & 0xff, (DriverInfo->Info.DriverVersion >> 8) & 0xff, (DriverInfo->Info.DriverVersion >> 16) & 0xff, (DriverInfo->Info.DriverVersion >> 24) & 0xff);
|
FIXME("DriverVersion : '%u.%u.%u.%u'\n", DriverInfo->Info.DriverVersion & 0xff, (DriverInfo->Info.DriverVersion >> 8) & 0xff, (DriverInfo->Info.DriverVersion >> 16) & 0xff, (DriverInfo->Info.DriverVersion >> 24) & 0xff);
|
||||||
FIXME("InfPath : '%S'\n", DriverInfo->InfPath);
|
FIXME("InfPath : '%S'\n", DriverInfo->InfPath);
|
||||||
|
@ -4451,8 +4460,8 @@ SetupDiInstallDevice(
|
||||||
FIXME("MatchingDeviceId: '%S'\n", L"???"); /* FIXME */
|
FIXME("MatchingDeviceId: '%S'\n", L"???"); /* FIXME */
|
||||||
FIXME("ProviderName : '%S'\n", DriverInfo->Info.ProviderName);
|
FIXME("ProviderName : '%S'\n", DriverInfo->Info.ProviderName);
|
||||||
|
|
||||||
/* Install services */
|
/* Install .Services section */
|
||||||
wcscat(SectionName, L".Services");
|
wcscpy(pSectionName, L".Services");
|
||||||
Result = SetupFindFirstLineW(hInf, SectionName, NULL, &ContextService);
|
Result = SetupFindFirstLineW(hInf, SectionName, NULL, &ContextService);
|
||||||
while (Result)
|
while (Result)
|
||||||
{
|
{
|
||||||
|
@ -4517,7 +4526,7 @@ SetupDiInstallDevice(
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
Result = SetupInstallServicesFromInfSectionExW(hInf, ServiceSection, Flags, DeviceInfoSet, DeviceInfoData, NULL, NULL);
|
Result = SetupInstallServicesFromInfSectionExW(hInf, ServiceSection, Flags, DeviceInfoSet, DeviceInfoData, ServiceName, NULL);
|
||||||
if (Result && (Flags & SPSVCINST_ASSOCSERVICE))
|
if (Result && (Flags & SPSVCINST_ASSOCSERVICE))
|
||||||
{
|
{
|
||||||
AssociatedService = ServiceName;
|
AssociatedService = ServiceName;
|
||||||
|
@ -4540,7 +4549,7 @@ cleanup:
|
||||||
/* Copy .inf file to Inf\ directory */
|
/* Copy .inf file to Inf\ directory */
|
||||||
FIXME("FIXME: Copy .inf file to Inf\\ directory\n"); /* SetupCopyOEMInf */
|
FIXME("FIXME: Copy .inf file to Inf\\ directory\n"); /* SetupCopyOEMInf */
|
||||||
|
|
||||||
/* Write information to enum key */
|
/* Open enum key */
|
||||||
rc = RegOpenKeyExW(DevInfoSet->HKLM,
|
rc = RegOpenKeyExW(DevInfoSet->HKLM,
|
||||||
EnumKeyName,
|
EnumKeyName,
|
||||||
0,
|
0,
|
||||||
|
@ -4567,14 +4576,32 @@ cleanup:
|
||||||
SetupCloseInfFile(hInf);
|
SetupCloseInfFile(hInf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Install .HW section */
|
||||||
|
wcscpy(pSectionName, L".HW");
|
||||||
|
callback_context = SetupInitDefaultQueueCallback(hWnd);
|
||||||
|
Result = SetupInstallFromInfSectionW(hWnd, hInf, SectionName,
|
||||||
|
SPINST_REGISTRY, hKey, NULL, 0,
|
||||||
|
SetupDefaultQueueCallbackW, callback_context,
|
||||||
|
NULL, NULL);
|
||||||
|
SetupTermDefaultQueueCallback(callback_context);
|
||||||
|
if (!Result)
|
||||||
|
{
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
HeapFree(GetProcessHeap(), 0, (LPWSTR)AssociatedService);
|
||||||
|
SetupCloseInfFile(hInf);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write information to enum key */
|
||||||
FIXME("FIXME: Write information to enum key\n");
|
FIXME("FIXME: Write information to enum key\n");
|
||||||
FIXME("ParentIdPrefix : '%S'\n", L"0000"); /* FIXME */
|
FIXME("ParentIdPrefix : '%S'\n", L"0000"); /* FIXME */
|
||||||
//FIXME("Service : '%S'\n", AssociatedService);
|
TRACE("Service : '%S'\n", AssociatedService);
|
||||||
FIXME("Class : '%S'\n", L"???"); /* FIXME: SetupDiGetINFClass */
|
FIXME("Class : '%S'\n", L"???"); /* FIXME: SetupDiGetINFClass */
|
||||||
FIXME("ClassGUID : '%S'\n", L"???"); /* FIXME: SetupDiGetINFClass */
|
FIXME("ClassGUID : '%S'\n", L"???"); /* FIXME: SetupDiGetINFClass */
|
||||||
//FIXME("DeviceDesc : '%S'\n", DriverInfo->Info.Description);
|
TRACE("DeviceDesc : '%S'\n", DriverInfo->Info.Description);
|
||||||
FIXME("Driver : '%S'\n", L"???"); /* FIXME: autogenerated key */
|
FIXME("Driver : '%S'\n", L"???"); /* FIXME: autogenerated key */
|
||||||
//FIXME("Mfg : '%S'\n", DriverInfo->Info.MfgName);
|
TRACE("Mfg : '%S'\n", DriverInfo->Info.MfgName);
|
||||||
rc = RegSetValueEx(hKey, L"Service", 0, REG_SZ, (const BYTE *)AssociatedService, (wcslen(AssociatedService) + 1) * sizeof(WCHAR));
|
rc = RegSetValueEx(hKey, L"Service", 0, REG_SZ, (const BYTE *)AssociatedService, (wcslen(AssociatedService) + 1) * sizeof(WCHAR));
|
||||||
if (rc == ERROR_SUCCESS)
|
if (rc == ERROR_SUCCESS)
|
||||||
rc = RegSetValueEx(hKey, L"DeviceDesc", 0, REG_SZ, (const BYTE *)DriverInfo->Info.Description, (wcslen(DriverInfo->Info.Description) + 1) * sizeof(WCHAR));
|
rc = RegSetValueEx(hKey, L"DeviceDesc", 0, REG_SZ, (const BYTE *)DriverInfo->Info.Description, (wcslen(DriverInfo->Info.Description) + 1) * sizeof(WCHAR));
|
||||||
|
|
|
@ -993,3 +993,136 @@ BOOL WINAPI SetupInstallServicesFromInfSectionExA( HINF hinf, PCSTR sectionname,
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static BOOL GetLineText( HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR *value)
|
||||||
|
{
|
||||||
|
DWORD required;
|
||||||
|
PWSTR buf = NULL;
|
||||||
|
|
||||||
|
*value = NULL;
|
||||||
|
|
||||||
|
if (! SetupGetLineTextW( NULL, hinf, section_name, key_name, NULL, 0, &required )
|
||||||
|
&& GetLastError() != ERROR_INSUFFICIENT_BUFFER )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
buf = HeapAlloc( GetProcessHeap(), 0, required * sizeof(WCHAR) );
|
||||||
|
if ( ! buf )
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! SetupGetLineTextW( NULL, hinf, section_name, key_name, buf, required, &required ) )
|
||||||
|
{
|
||||||
|
HeapFree( GetProcessHeap(), 0, buf );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*value = buf;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static BOOL GetIntField( HINF hinf, PCWSTR section_name, PCWSTR key_name, INT *value)
|
||||||
|
{
|
||||||
|
LPWSTR buffer, end;
|
||||||
|
INT res;
|
||||||
|
|
||||||
|
if (! GetLineText( hinf, section_name, key_name, &buffer ) )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
res = wcstol( buffer, &end, 0 );
|
||||||
|
if (end != buffer && !*end)
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(), 0, buffer);
|
||||||
|
*value = res;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(), 0, buffer);
|
||||||
|
SetLastError( ERROR_INVALID_DATA );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* SetupInstallServicesFromInfSectionExW (SETUPAPI.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI SetupInstallServicesFromInfSectionExW( HINF hinf, PCWSTR sectionname, DWORD flags, HDEVINFO devinfo, PSP_DEVINFO_DATA devinfo_data, PVOID reserved1, PVOID reserved2 )
|
||||||
|
{
|
||||||
|
SC_HANDLE hSCManager, hService;
|
||||||
|
LPWSTR ServiceBinary, LoadOrderGroup;
|
||||||
|
LPWSTR DisplayName, Description, Dependencies;
|
||||||
|
INT ServiceType, StartType, ErrorControl;
|
||||||
|
|
||||||
|
TRACE("%p, %s, 0x%lx, %p, %p, %p, %p\n", hinf, debugstr_w(sectionname),
|
||||||
|
flags, devinfo, devinfo_data, reserved1, reserved2);
|
||||||
|
|
||||||
|
if (!reserved1)
|
||||||
|
{
|
||||||
|
/* FIXME: I don't know how to get the service name. ATM, just fail the call */
|
||||||
|
DPRINT1("Service name not specified!\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
/* FIXME: use the flags parameters */
|
||||||
|
/* FIXME: use DeviceInfoSet, DeviceInfoData parameters */
|
||||||
|
|
||||||
|
if (!GetIntField(hinf, sectionname, L"ServiceType", &ServiceType))
|
||||||
|
return FALSE;
|
||||||
|
if (!GetIntField(hinf, sectionname, L"StartType", &StartType))
|
||||||
|
return FALSE;
|
||||||
|
if (!GetIntField(hinf, sectionname, L"ErrorControl", &ErrorControl))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
hSCManager = OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_CREATE_SERVICE);
|
||||||
|
if (hSCManager == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (!GetLineText(hinf, sectionname, L"ServiceBinary", &ServiceBinary))
|
||||||
|
{
|
||||||
|
CloseServiceHandle(hSCManager);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!GetLineText(hinf, sectionname, L"LoadOrderGroup", &LoadOrderGroup))
|
||||||
|
{
|
||||||
|
CloseServiceHandle(hSCManager);
|
||||||
|
HeapFree(GetProcessHeap(), 0, ServiceBinary);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Don't check return value, as these fields are optional and
|
||||||
|
* GetLineText initialize output parameter even on failure */
|
||||||
|
GetLineText(hinf, sectionname, L"DisplayName", &DisplayName);
|
||||||
|
GetLineText(hinf, sectionname, L"Description", &Description);
|
||||||
|
GetLineText(hinf, sectionname, L"Dependencies", &Dependencies);
|
||||||
|
|
||||||
|
hService = CreateServiceW(
|
||||||
|
hSCManager,
|
||||||
|
reserved1,
|
||||||
|
Description,
|
||||||
|
0,
|
||||||
|
ServiceType,
|
||||||
|
StartType,
|
||||||
|
ErrorControl,
|
||||||
|
ServiceBinary,
|
||||||
|
LoadOrderGroup,
|
||||||
|
NULL,
|
||||||
|
Dependencies,
|
||||||
|
NULL, NULL);
|
||||||
|
HeapFree(GetProcessHeap(), 0, ServiceBinary);
|
||||||
|
HeapFree(GetProcessHeap(), 0, LoadOrderGroup);
|
||||||
|
HeapFree(GetProcessHeap(), 0, DisplayName);
|
||||||
|
HeapFree(GetProcessHeap(), 0, Description);
|
||||||
|
HeapFree(GetProcessHeap(), 0, Dependencies);
|
||||||
|
if (hService == NULL)
|
||||||
|
{
|
||||||
|
CloseServiceHandle(hSCManager);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
CloseServiceHandle(hService);
|
||||||
|
|
||||||
|
return CloseServiceHandle(hSCManager);
|
||||||
|
}
|
||||||
|
|
|
@ -124,15 +124,6 @@ HANDLE WINAPI SetupInitializeFileLogA(LPCSTR LogFileName, DWORD Flags)
|
||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* SetupInstallServicesFromInfSectionExW (SETUPAPI.@)
|
|
||||||
*/
|
|
||||||
BOOL WINAPI SetupInstallServicesFromInfSectionExW( HINF hinf, PCWSTR sectionname, DWORD flags, HDEVINFO devinfo, PSP_DEVINFO_DATA devinfo_data, PVOID reserved1, PVOID reserved2 )
|
|
||||||
{
|
|
||||||
FIXME("Stub %p, %s, 0x%lx, %p, %p, %p, %p\n", hinf, debugstr_w(sectionname), flags, devinfo, devinfo_data, reserved1, reserved2);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* SetupTerminateFileLog(SETUPAPI.@)
|
* SetupTerminateFileLog(SETUPAPI.@)
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue