ReactOS 0.4.16-dev-816-g135a9a9
netinstall.c File Reference
#include "precomp.h"
#include <rpc.h>
Include dependency graph for netinstall.c:

Go to the source code of this file.

Classes

struct  _COMPONENT_INFO
 

Typedefs

typedef struct _COMPONENT_INFO COMPONENT_INFO
 
typedef struct _COMPONENT_INFOPCOMPONENT_INFO
 

Functions

static BOOL InstallInfSections (_In_ HWND hWnd, _In_ HKEY hKey, _In_ LPCWSTR InfFile, _In_ LPCWSTR InfSection)
 
static BOOL CreateInstanceKey (_In_ PCOMPONENT_INFO pComponentInfo, _Out_ PHKEY pInstanceKey)
 
static BOOL CheckInfFile (_In_ PWSTR pszFullInfName, _In_ PCWSTR pszComponentId, _In_ PCOMPONENT_INFO pComponentInfo)
 
static BOOL ScanForInfFile (_In_ PCWSTR pszComponentId, _In_ PCOMPONENT_INFO pComponentInfo)
 
static VOID StartNetworkServices (_In_ PCOMPONENT_INFO pComponentInfo)
 
BOOL InstallNetworkComponent (_In_ PCWSTR pszComponentId)
 

Typedef Documentation

◆ COMPONENT_INFO

◆ PCOMPONENT_INFO

Function Documentation

◆ CheckInfFile()

static BOOL CheckInfFile ( _In_ PWSTR  pszFullInfName,
_In_ PCWSTR  pszComponentId,
_In_ PCOMPONENT_INFO  pComponentInfo 
)
static

Definition at line 244 of file netinstall.c.

248{
249 WCHAR szLineBuffer[MAX_PATH];
251 INFCONTEXT MfgContext, DevContext, MiscContext;
253
254 hInf = SetupOpenInfFileW(pszFullInfName,
255 NULL,
257 NULL);
258 if (hInf == INVALID_HANDLE_VALUE)
259 {
260 ERR("\n");
261 return FALSE;
262 }
263
264 if (!SetupFindFirstLineW(hInf,
265 L"Manufacturer",
266 NULL,
267 &MfgContext))
268 {
269 ERR("No Manufacurer section found!\n");
270 goto done;
271 }
272
273 for (;;)
274 {
275 if (!SetupGetStringFieldW(&MfgContext,
276 1,
277 szLineBuffer,
278 MAX_PATH,
279 NULL))
280 break;
281
282 TRACE("Manufacturer: %S\n", szLineBuffer);
283 if (!SetupFindFirstLineW(hInf,
284 szLineBuffer,
285 NULL,
286 &DevContext))
287 break;
288
289 for (;;)
290 {
291 if (!SetupGetStringFieldW(&DevContext,
292 2,
293 szLineBuffer,
294 MAX_PATH,
295 NULL))
296 break;
297
298 TRACE("Device: %S\n", szLineBuffer);
299 if (_wcsicmp(szLineBuffer, pszComponentId) == 0)
300 {
301 TRACE("Found it!\n");
302
303 /* Get the section name*/
304 SetupGetStringFieldW(&DevContext,
305 1,
306 NULL,
307 0,
308 &dwLength);
309
310 pComponentInfo->pszInfSection = HeapAlloc(GetProcessHeap(),
311 0,
312 dwLength * sizeof(WCHAR));
313 if (pComponentInfo->pszInfSection)
314 {
315 SetupGetStringFieldW(&DevContext,
316 1,
317 pComponentInfo->pszInfSection,
318 dwLength,
319 &dwLength);
320 }
321
322 /* Get the description*/
323 SetupGetStringFieldW(&DevContext,
324 0,
325 NULL,
326 0,
327 &dwLength);
328
329 pComponentInfo->pszDescription = HeapAlloc(GetProcessHeap(),
330 0,
331 dwLength * sizeof(WCHAR));
332 if (pComponentInfo->pszDescription)
333 {
334 SetupGetStringFieldW(&DevContext,
335 0,
336 pComponentInfo->pszDescription,
337 dwLength,
338 &dwLength);
339 }
340
341 /* Get the class GUID */
342 if (SetupFindFirstLineW(hInf,
343 L"Version",
344 L"ClassGuid",
345 &MiscContext))
346 {
347 SetupGetStringFieldW(&MiscContext,
348 1,
349 NULL,
350 0,
351 &dwLength);
352
353 pComponentInfo->pszClassGuid = HeapAlloc(GetProcessHeap(),
354 0,
355 dwLength * sizeof(WCHAR));
356 if (pComponentInfo->pszInfSection)
357 {
358 SetupGetStringFieldW(&MiscContext,
359 1,
360 pComponentInfo->pszClassGuid,
361 dwLength,
362 &dwLength);
363 }
364 }
365
366 /* Get the Characteristics value */
367 if (SetupFindFirstLineW(hInf,
368 pComponentInfo->pszInfSection,
369 L"Characteristics",
370 &MiscContext))
371 {
372 SetupGetIntField(&MiscContext,
373 1,
374 (PINT)&pComponentInfo->dwCharacteristics);
375 }
376
377 SetupCloseInfFile(hInf);
378 return TRUE;
379 }
380
381 if (!SetupFindNextLine(&DevContext, &DevContext))
382 break;
383 }
384
385 if (!SetupFindNextLine(&MfgContext, &MfgContext))
386 break;
387 }
388
389done:
390 if (hInf != INVALID_HANDLE_VALUE)
391 SetupCloseInfFile(hInf);
392
393 return FALSE;
394}
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
static DWORD DWORD * dwLength
Definition: fusion.c:86
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INF_STYLE_WIN4
Definition: infsupp.h:43
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:186
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:56
BOOL WINAPI SetupGetIntField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT INT *IntegerValue)
Definition: infsupp.c:148
BOOL WINAPI SetupFindNextLine(IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut)
Definition: infsupp.c:82
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:45
int * PINT
Definition: windef.h:177
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ScanForInfFile().

◆ CreateInstanceKey()

static BOOL CreateInstanceKey ( _In_ PCOMPONENT_INFO  pComponentInfo,
_Out_ PHKEY  pInstanceKey 
)
static

Definition at line 112 of file netinstall.c.

115{
116 WCHAR szKeyBuffer[128];
117 LPWSTR UuidString = NULL;
118 UUID Uuid;
119 RPC_STATUS RpcStatus;
120 HKEY hInstanceKey;
121 DWORD rc;
122 BOOL ret = FALSE;
123
124 TRACE("CreateInstanceKey()\n");
125
126 *pInstanceKey = NULL;
127
128 wcscpy(szKeyBuffer, L"SYSTEM\\CurrentControlSet\\Control\\Network\\");
129 wcscat(szKeyBuffer, pComponentInfo->pszClassGuid);
130 wcscat(szKeyBuffer, L"\\{");
131
132 /* Create a new UUID */
133 RpcStatus = UuidCreate(&Uuid);
134 if (RpcStatus != RPC_S_OK && RpcStatus != RPC_S_UUID_LOCAL_ONLY)
135 {
136 ERR("UuidCreate() failed with RPC status 0x%lx\n", RpcStatus);
137 goto done;
138 }
139
140 RpcStatus = UuidToStringW(&Uuid, &UuidString);
141 if (RpcStatus != RPC_S_OK)
142 {
143 ERR("UuidToStringW() failed with RPC status 0x%lx\n", RpcStatus);
144 goto done;
145 }
146
147 wcscat(szKeyBuffer, UuidString);
148 wcscat(szKeyBuffer, L"}");
149
150 RpcStringFreeW(&UuidString);
151
152 TRACE("szKeyBuffer %S\n", szKeyBuffer);
153
155 szKeyBuffer,
156 0,
157 NULL,
160 NULL,
161 &hInstanceKey,
162 NULL);
163 if (rc != ERROR_SUCCESS)
164 {
165 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
166 goto done;
167 }
168
169 rc = RegSetValueExW(hInstanceKey,
170 L"Characteristics",
171 0,
172 REG_DWORD,
173 (LPBYTE)&pComponentInfo->dwCharacteristics,
174 sizeof(DWORD));
175 if (rc != ERROR_SUCCESS)
176 {
177 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
178 goto done;
179 }
180
181 rc = RegSetValueExW(hInstanceKey,
182 L"ComponentId",
183 0,
184 REG_SZ,
185 (LPBYTE)pComponentInfo->pszComponentId,
186 (wcslen(pComponentInfo->pszComponentId) + 1) * sizeof(WCHAR));
187 if (rc != ERROR_SUCCESS)
188 {
189 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
190 goto done;
191 }
192
193 rc = RegSetValueExW(hInstanceKey,
194 L"Description",
195 0,
196 REG_SZ,
197 (LPBYTE)pComponentInfo->pszDescription,
198 (wcslen(pComponentInfo->pszDescription) + 1) * sizeof(WCHAR));
199 if (rc != ERROR_SUCCESS)
200 {
201 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
202 goto done;
203 }
204
205 rc = RegSetValueExW(hInstanceKey,
206 L"InfPath",
207 0,
208 REG_SZ,
209 (LPBYTE)pComponentInfo->pszInfPath,
210 (wcslen(pComponentInfo->pszInfPath) + 1) * sizeof(WCHAR));
211 if (rc != ERROR_SUCCESS)
212 {
213 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
214 goto done;
215 }
216
217 rc = RegSetValueExW(hInstanceKey,
218 L"InfSection",
219 0,
220 REG_SZ,
221 (LPBYTE)pComponentInfo->pszInfSection,
222 (wcslen(pComponentInfo->pszInfSection) + 1) * sizeof(WCHAR));
223 if (rc != ERROR_SUCCESS)
224 {
225 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
226 goto done;
227 }
228
229 *pInstanceKey = hInstanceKey;
230 ret = TRUE;
231
232done:
233 if (ret == FALSE)
234 RegCloseKey(hInstanceKey);
235
236 TRACE("CreateInstanceKey() done %u\n", ret);
237
238 return ret;
239}
#define RegCloseKey(hKey)
Definition: registry.h:49
wcscat
wcscpy
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
unsigned int BOOL
Definition: ntddk_ex.h:94
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define RPC_S_OK
Definition: rpcnterr.h:22
RPC_STATUS WINAPI UuidToStringW(UUID *Uuid, RPC_WSTR *StringUuid)
Definition: rpcrt4_main.c:540
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition: rpcrt4_main.c:175
RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
Definition: rpcrt4_main.c:305
#define REG_DWORD
Definition: sdbapi.c:596
long RPC_STATUS
Definition: rpc.h:48
unsigned char * LPBYTE
Definition: typedefs.h:53
int ret
#define RPC_S_UUID_LOCAL_ONLY
Definition: winerror.h:1131
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by InstallNetworkComponent().

◆ InstallInfSections()

static BOOL InstallInfSections ( _In_ HWND  hWnd,
_In_ HKEY  hKey,
_In_ LPCWSTR  InfFile,
_In_ LPCWSTR  InfSection 
)
static

Definition at line 34 of file netinstall.c.

39{
44 BOOL ret = FALSE;
45
46 TRACE("InstallInfSections()\n");
47
48 if (InfSection == NULL)
49 return FALSE;
50
51 /* Get Windows directory */
52 BufferSize = ARRAYSIZE(Buffer) - 5 - wcslen(InfFile);
54 {
55 /* Function failed */
57 goto cleanup;
58 }
59
60 /* We have enough space to add some information in the buffer */
61 if (Buffer[wcslen(Buffer) - 1] != '\\')
62 wcscat(Buffer, L"\\");
63 wcscat(Buffer, L"Inf\\");
64 wcscat(Buffer, InfFile);
65
66 /* Install specified section */
68 if (hInf == INVALID_HANDLE_VALUE)
69 goto cleanup;
70
72 if (Context == NULL)
73 goto cleanup;
74
76 hWnd, hInf,
77 InfSection, SPINST_ALL,
80 NULL, NULL);
81 if (ret == FALSE)
82 {
83 ERR("SetupInstallFromInfSectionW(%S) failed (Error %lx)\n", InfSection, GetLastError());
84 goto cleanup;
85 }
86
87 wcscpy(Buffer, InfSection);
88 wcscat(Buffer, L".Services");
89
91 if (ret == FALSE)
92 {
93 ERR("SetupInstallServicesFromInfSectionW(%S) failed (Error %lx)\n", Buffer, GetLastError());
94 goto cleanup;
95 }
96
98 if (Context)
100
101 if (hInf != INVALID_HANDLE_VALUE)
102 SetupCloseInfFile(hInf);
103
104 TRACE("InstallInfSections() done %u\n", ret);
105
106 return ret;
107}
HWND hWnd
Definition: settings.c:17
Definition: bufpool.h:45
#define BufferSize
Definition: mmc.h:75
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define SetLastError(x)
Definition: compat.h:752
static void cleanup(void)
Definition: main.c:1335
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
BOOL WINAPI SetupInstallServicesFromInfSectionW(HINF Inf, PCWSTR SectionName, DWORD Flags)
Definition: install.c:1615
BOOL WINAPI SetupInstallFromInfSectionW(HWND owner, HINF hinf, PCWSTR section, UINT flags, HKEY key_root, PCWSTR src_root, UINT copy_flags, PSP_FILE_CALLBACK_W callback, PVOID context, HDEVINFO devinfo, PSP_DEVINFO_DATA devinfo_data)
Definition: install.c:1330
UINT WINAPI SetupDefaultQueueCallbackW(PVOID context, UINT notification, UINT_PTR param1, UINT_PTR param2)
Definition: queue.c:1729
void WINAPI SetupTermDefaultQueueCallback(PVOID context)
Definition: queue.c:1656
PVOID WINAPI SetupInitDefaultQueueCallback(HWND owner)
Definition: queue.c:1629
FxAutoRegKey hKey
unsigned int UINT
Definition: ndis.h:50
#define SPINST_ALL
Definition: setupapi.h:602
#define SP_COPY_NEWER
Definition: setupapi.h:479
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_GEN_FAILURE
Definition: winerror.h:134

Referenced by InstallNetworkComponent().

◆ InstallNetworkComponent()

BOOL InstallNetworkComponent ( _In_ PCWSTR  pszComponentId)

Definition at line 561 of file netinstall.c.

563{
565 HKEY hInstanceKey = NULL;
566 BOOL bResult = FALSE;
567
568 TRACE("InstallNetworkComponent(%S)\n", pszComponentId);
569
571
572 if (!ScanForInfFile(pszComponentId, &ComponentInfo))
573 goto done;
574
575 TRACE("Characteristics: 0x%lx\n", ComponentInfo.dwCharacteristics);
576 TRACE("ComponentId: %S\n", ComponentInfo.pszComponentId);
577 TRACE("Description: %S\n", ComponentInfo.pszDescription);
578 TRACE("InfPath: %S\n", ComponentInfo.pszInfPath);
579 TRACE("InfSection: %S\n", ComponentInfo.pszInfSection);
580 TRACE("ClassGuid: %S\n", ComponentInfo.pszClassGuid);
581
583 &hInstanceKey))
584 {
585 ERR("CreateInstanceKey() failed (Error %lx)\n", GetLastError());
586 goto done;
587 }
588
590 hInstanceKey,
591 ComponentInfo.pszInfPath,
592 ComponentInfo.pszInfSection))
593 {
594 ERR("InstallInfSections() failed (Error %lx)\n", GetLastError());
595 goto done;
596 }
597
598 bResult = TRUE;
599
601
602done:
603 if (hInstanceKey != NULL)
604 RegCloseKey(hInstanceKey);
605
606 if (ComponentInfo.pszFullInfPath)
607 HeapFree(GetProcessHeap(), 0, ComponentInfo.pszFullInfPath);
608
609 if (ComponentInfo.pszInfPath)
610 HeapFree(GetProcessHeap(), 0, ComponentInfo.pszInfPath);
611
612 if (ComponentInfo.pszInfSection)
613 HeapFree(GetProcessHeap(), 0, ComponentInfo.pszInfSection);
614
615 if (ComponentInfo.pszComponentId)
616 HeapFree(GetProcessHeap(), 0, ComponentInfo.pszComponentId);
617
618 if (ComponentInfo.pszDescription)
619 HeapFree(GetProcessHeap(), 0, ComponentInfo.pszDescription);
620
621 if (ComponentInfo.pszClassGuid)
622 HeapFree(GetProcessHeap(), 0, ComponentInfo.pszClassGuid);
623
624 return bResult;
625}
#define HeapFree(x, y, z)
Definition: compat.h:735
static BOOL ScanForInfFile(_In_ PCWSTR pszComponentId, _In_ PCOMPONENT_INFO pComponentInfo)
Definition: netinstall.c:399
static BOOL InstallInfSections(_In_ HWND hWnd, _In_ HKEY hKey, _In_ LPCWSTR InfFile, _In_ LPCWSTR InfSection)
Definition: netinstall.c:34
static BOOL CreateInstanceKey(_In_ PCOMPONENT_INFO pComponentInfo, _Out_ PHKEY pInstanceKey)
Definition: netinstall.c:112
static VOID StartNetworkServices(_In_ PCOMPONENT_INFO pComponentInfo)
Definition: netinstall.c:471
#define ZeroMemory
Definition: winbase.h:1737

◆ ScanForInfFile()

static BOOL ScanForInfFile ( _In_ PCWSTR  pszComponentId,
_In_ PCOMPONENT_INFO  pComponentInfo 
)
static

Definition at line 399 of file netinstall.c.

402{
403 WCHAR szInfPath[MAX_PATH];
404 WCHAR szFullInfName[MAX_PATH];
405 WCHAR szPathBuffer[MAX_PATH];
407 HANDLE hFindFile = INVALID_HANDLE_VALUE;
408 BOOL bFound = FALSE;
409
410 GetWindowsDirectoryW(szInfPath, MAX_PATH);
411 wcscat(szInfPath, L"\\inf");
412
413 wcscpy(szPathBuffer, szInfPath);
414 wcscat(szPathBuffer, L"\\*.inf");
415
416 hFindFile = FindFirstFileW(szPathBuffer, &fdw);
417 if (hFindFile == INVALID_HANDLE_VALUE)
418 return FALSE;
419
420 for (;;)
421 {
422 if (wcscmp(fdw.cFileName, L".") == 0 ||
423 wcscmp(fdw.cFileName, L"..") == 0)
424 continue;
425
426 TRACE("FileName: %S\n", fdw.cFileName);
427
428 wcscpy(szFullInfName, szInfPath);
429 wcscat(szFullInfName, L"\\");
430 wcscat(szFullInfName, fdw.cFileName);
431
432 TRACE("Full Inf Name: %S\n", szFullInfName);
433 if (CheckInfFile(szFullInfName,
434 pszComponentId,
435 pComponentInfo))
436 {
437 pComponentInfo->pszFullInfPath = HeapAlloc(GetProcessHeap(),
438 0,
439 (wcslen(szFullInfName) + 1) * sizeof(WCHAR));
440 if (pComponentInfo->pszFullInfPath)
441 wcscpy(pComponentInfo->pszFullInfPath, szFullInfName);
442
443 pComponentInfo->pszInfPath = HeapAlloc(GetProcessHeap(),
444 0,
445 (wcslen(fdw.cFileName) + 1) * sizeof(WCHAR));
446 if (pComponentInfo->pszInfPath)
447 wcscpy(pComponentInfo->pszInfPath, fdw.cFileName);
448
449 pComponentInfo->pszComponentId = HeapAlloc(GetProcessHeap(),
450 0,
451 (wcslen(pszComponentId) + 1) * sizeof(WCHAR));
452 if (pComponentInfo->pszComponentId)
453 wcscpy(pComponentInfo->pszComponentId, pszComponentId);
454
455 bFound = TRUE;
456 break;
457 }
458
459 if (!FindNextFileW(hFindFile, &fdw))
460 break;
461 }
462
463 if (hFindFile != INVALID_HANDLE_VALUE)
464 FindClose(hFindFile);
465
466 return bFound;
467}
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
static BOOL CheckInfFile(_In_ PWSTR pszFullInfName, _In_ PCWSTR pszComponentId, _In_ PCOMPONENT_INFO pComponentInfo)
Definition: netinstall.c:244
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by InstallNetworkComponent().

◆ StartNetworkServices()

static VOID StartNetworkServices ( _In_ PCOMPONENT_INFO  pComponentInfo)
static

Definition at line 471 of file netinstall.c.

473{
474 WCHAR szServiceName[64];
477 PWSTR pServiceSection = NULL;
478
479 SC_HANDLE hManager = NULL;
480 SC_HANDLE hService = NULL;
481
482 hManager = OpenSCManagerW(NULL,
483 NULL,
485 if (hManager == NULL)
486 {
487 ERR("\n");
488 goto done;
489 }
490
491 hInf = SetupOpenInfFileW(pComponentInfo->pszFullInfPath,
492 NULL,
494 NULL);
495 if (hInf == INVALID_HANDLE_VALUE)
496 {
497 ERR("\n");
498 goto done;
499 }
500
501 pServiceSection = HeapAlloc(GetProcessHeap(), 0,
502 (wcslen(pComponentInfo->pszInfSection) + wcslen(L".Service") + 1) * sizeof(WCHAR));
503 if (pServiceSection == NULL)
504 {
505 ERR("\n");
506 goto done;
507 }
508
509 wcscpy(pServiceSection, pComponentInfo->pszInfSection);
510 wcscat(pServiceSection, L".Service");
511
512 TRACE("ServiceSection: %S\n", pServiceSection);
513
514 if (!SetupFindFirstLineW(hInf,
515 pServiceSection,
516 L"AddService",
517 &Context))
518 {
519 ERR("\n");
520 goto done;
521 }
522
523 for (;;)
524 {
526 1,
527 szServiceName,
528 64,
529 NULL);
530
531 hService = OpenServiceW(hManager,
532 szServiceName,
534 if (hService)
535 {
536 if (!StartService(hService, 0, NULL))
537 {
538 ERR("StartService() %S failed %lu\n", szServiceName, GetLastError());
539 }
540
541 CloseServiceHandle(hService);
542 }
543
545 break;
546 }
547
548done:
549 if (pServiceSection)
550 HeapFree(GetProcessHeap(), 0, pServiceSection);
551
552 if (hInf != INVALID_HANDLE_VALUE)
553 SetupCloseInfFile(hInf);
554
555 if (hManager != NULL)
556 CloseServiceHandle(hManager);
557}
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2068
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2160
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
uint16_t * PWSTR
Definition: typedefs.h:56
#define SERVICE_START
Definition: winsvc.h:57
#define StartService
Definition: winsvc.h:585
#define SC_MANAGER_ALL_ACCESS
Definition: winsvc.h:13

Referenced by InstallNetworkComponent().