ReactOS 0.4.17-dev-1183-g3b30a2a
installer.c File Reference
#include "precomp.h"
#include <strsafe.h>
Include dependency graph for installer.c:

Go to the source code of this file.

Functions

static LONG AppendStringToMultiSZ (IN HKEY hKey, IN PCWSTR ValueName, IN PCWSTR ValueToAppend)
 
static DWORD GetUniqueConnectionName (_In_ HKEY hNetworkKey, _Out_ PWSTR *ppszNameBuffer)
 
static DWORD InstallNetDevice (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData, LPCWSTR UuidString, DWORD Characteristics, LPCWSTR BusType)
 
static DWORD InstallNetClient (VOID)
 
static DWORD InstallNetService (VOID)
 
static DWORD InstallNetTransport (VOID)
 
DWORD WINAPI NetClassInstaller (IN DI_FUNCTION InstallFunction, IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
 

Function Documentation

◆ AppendStringToMultiSZ()

static LONG AppendStringToMultiSZ ( IN HKEY  hKey,
IN PCWSTR  ValueName,
IN PCWSTR  ValueToAppend 
)
static

Definition at line 20 of file installer.c.

24{
26 DWORD dwRegType;
27 DWORD dwRequired, dwLength;
28 DWORD dwTmp;
29 LONG rc;
30
33 NULL,
34 &dwRegType,
35 NULL,
36 &dwRequired);
37 if (rc != ERROR_FILE_NOT_FOUND)
38 {
39 if (rc != ERROR_SUCCESS)
40 goto cleanup;
41 if (dwRegType != REG_MULTI_SZ)
42 {
44 goto cleanup;
45 }
46
47 dwTmp = dwLength = dwRequired + wcslen(ValueToAppend) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
49 if (!Buffer)
50 {
52 goto cleanup;
53 }
54
57 NULL,
58 NULL,
59 (BYTE*)Buffer,
60 &dwTmp);
61 if (rc != ERROR_SUCCESS)
62 goto cleanup;
63 }
64 else
65 {
66 dwRequired = sizeof(WCHAR);
67 dwLength = wcslen(ValueToAppend) * sizeof(WCHAR) + 2 * sizeof(UNICODE_NULL);
69 if (!Buffer)
70 {
72 goto cleanup;
73 }
74 }
75
76 /* Append the value */
77 wcscpy(&Buffer[dwRequired / sizeof(WCHAR) - 1], ValueToAppend);
78 /* Terminate the REG_MULTI_SZ string */
79 Buffer[dwLength / sizeof(WCHAR) - 1] = UNICODE_NULL;
80
83 0,
85 (const BYTE*)Buffer,
86 dwLength);
87
90 return rc;
91}
Definition: bufpool.h:45
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
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
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
static DWORD DWORD * dwLength
Definition: fusion.c:86
static void cleanup(void)
Definition: main.c:1335
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define REG_MULTI_SZ
Definition: nt_native.h:1504
#define UNICODE_NULL
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
wcscpy
uint16_t * PWSTR
Definition: typedefs.h:56
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
#define ERROR_GEN_FAILURE
Definition: winerror.h:256
unsigned char BYTE
Definition: xxhash.c:193

Referenced by InstallNetDevice().

◆ GetUniqueConnectionName()

static DWORD GetUniqueConnectionName ( _In_ HKEY  hNetworkKey,
_Out_ PWSTR *  ppszNameBuffer 
)
static

Definition at line 95 of file installer.c.

98{
99 int Length = 0;
100 PWSTR pszDefaultName = NULL;
101 PWSTR pszNameBuffer = NULL;
102 DWORD dwSubKeys = 0;
103 DWORD dwError;
104
105 TRACE("GetNewConnectionName()\n");
106
108 if (Length == 0)
109 {
110 pszDefaultName = L"Network Connection";
111 Length = wcslen(pszDefaultName);
112 }
113
114 TRACE("Length %d\n", Length);
115
116 dwError = RegQueryInfoKeyW(hNetworkKey,
117 NULL, NULL, NULL, &dwSubKeys,
118 NULL, NULL, NULL, NULL, NULL, NULL, NULL);
119 if (dwError != ERROR_SUCCESS)
120 {
121 ERR("RegQueryInfoKeyW: Error %lu\n", dwError);
122 return dwError;
123 }
124
125 TRACE("Adapter Count: %lu\n", dwSubKeys);
126
127 pszNameBuffer = HeapAlloc(GetProcessHeap(),
129 (Length + ((dwSubKeys != 0) ? 6 : 1)) * sizeof(WCHAR));
130 if (pszNameBuffer == NULL)
131 {
132 return ERROR_OUTOFMEMORY;
133 }
134
135 if (dwSubKeys != 0)
136 StringCchPrintfW(pszNameBuffer, Length + 6, L"%.*s %lu", Length, pszDefaultName, dwSubKeys + 1);
137 else
138 StringCchPrintfW(pszNameBuffer, Length + 1, L"%.*s", Length, pszDefaultName);
139
140 TRACE("Adapter Name: %S\n", pszNameBuffer);
141
142 *ppszNameBuffer = pszNameBuffer;
143
144 return ERROR_SUCCESS;
145}
#define ERR(fmt,...)
Definition: precomp.h:57
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3662
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
HINSTANCE netcfgx_hInstance
Definition: netcfgx.c:15
#define IDS_NET_CONNECT
Definition: resource.h:107
#define L(x)
Definition: resources.c:13
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define LoadStringW
Definition: utils.h:64
#define TRACE(s)
Definition: solgame.cpp:4
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
uint16_t * LPWSTR
Definition: typedefs.h:56

Referenced by InstallNetDevice().

◆ InstallNetClient()

static DWORD InstallNetClient ( VOID  )
static

Definition at line 515 of file installer.c.

516{
517 FIXME("Installation of network clients is not yet supported\n");
518 return ERROR_GEN_FAILURE;
519}
#define FIXME(fmt,...)
Definition: precomp.h:53

Referenced by NetClassInstaller().

◆ InstallNetDevice()

static DWORD InstallNetDevice ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData,
LPCWSTR  UuidString,
DWORD  Characteristics,
LPCWSTR  BusType 
)
static

Definition at line 149 of file installer.c.

155{
160 LPWSTR ExportName = NULL;
161 LONG rc;
162 HKEY hInterfacesKey = NULL, hInterfaceKey = NULL;
163 HKEY hKey = NULL;
164 HKEY hNetworkKey = NULL;
165 HKEY hLinkageKey = NULL;
166 HKEY hConnectionKey = NULL;
167 DWORD dwShowIcon, dwLength, dwValue;
168 PWSTR pszNameBuffer = NULL;
169 DWORD dwRegType;
170
175 {
176 rc = GetLastError();
177 ERR("SetupDiGetDeviceInstallParamsW() failed (Error %lu)\n", rc);
178 goto cleanup;
179 }
180
181 /* Do not start the adapter in the call to SetupDiInstallDevice */
183
187 {
188 rc = GetLastError();
189 ERR("SetupDiSetDeviceInstallParamsW() failed (Error %lu)\n", rc);
190 goto cleanup;
191 }
192
193 /* Install the adapter */
195 {
196 rc = GetLastError();
197 ERR("SetupDiInstallDevice() failed (Error %lu)\n", rc);
198 goto cleanup;
199 }
200
201 /* Get Instance ID */
203 {
204 ERR("SetupDiGetDeviceInstanceIdW() returned TRUE. FALSE expected\n");
206 goto cleanup;
207 }
208
210 if (!InstanceId)
211 {
212 ERR("HeapAlloc() failed\n");
214 goto cleanup;
215 }
216
218 {
219 rc = GetLastError();
220 ERR("SetupDiGetDeviceInstanceIdW() failed with error 0x%lx\n", rc);
221 goto cleanup;
222 }
223
224 /* Create device name */
225 DeviceName = HeapAlloc(GetProcessHeap(), 0, (wcslen(L"\\Device\\") + wcslen(UuidString)) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
226 if (!DeviceName)
227 {
228 ERR("HeapAlloc() failed\n");
230 goto cleanup;
231 }
232 wcscpy(DeviceName, L"\\Device\\");
233 wcscat(DeviceName, UuidString);
234
235 /* Create export name */
236 ExportName = HeapAlloc(GetProcessHeap(), 0, (wcslen(L"\\Device\\Tcpip_") + wcslen(UuidString)) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
237 if (!ExportName)
238 {
239 ERR("HeapAlloc() failed\n");
241 goto cleanup;
242 }
243 wcscpy(ExportName, L"\\Device\\Tcpip_");
244 wcscat(ExportName, UuidString);
245
246 /* Write Tcpip parameters in new service Key */
247 rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hInterfacesKey, NULL);
248 if (rc != ERROR_SUCCESS)
249 {
250 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
251 goto cleanup;
252 }
253
254 rc = RegCreateKeyExW(hInterfacesKey, UuidString, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hInterfaceKey, NULL);
255 if (rc != ERROR_SUCCESS)
256 {
257 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
258 goto cleanup;
259 }
260
261 rc = RegSetValueExW(hInterfaceKey, L"DefaultGateway", 0, REG_MULTI_SZ, (const BYTE*)L"0.0.0.0\0", (wcslen(L"0.0.0.0") + 2) * sizeof(WCHAR));
262 if (rc != ERROR_SUCCESS)
263 {
264 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
265 goto cleanup;
266 }
267
268 rc = RegSetValueExW(hInterfaceKey, L"IPAddress", 0, REG_MULTI_SZ, (const BYTE*)L"0.0.0.0\0", (wcslen(L"0.0.0.0") + 2) * sizeof(WCHAR));
269 if (rc != ERROR_SUCCESS)
270 {
271 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
272 goto cleanup;
273 }
274
275 rc = RegSetValueExW(hInterfaceKey, L"SubnetMask", 0, REG_MULTI_SZ, (const BYTE*)L"0.0.0.0\0", (wcslen(L"0.0.0.0") + 2) * sizeof(WCHAR));
276 if (rc != ERROR_SUCCESS)
277 {
278 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
279 goto cleanup;
280 }
281
282 dwValue = 1;
283 rc = RegSetValueExW(hInterfaceKey, L"EnableDHCP", 0, REG_DWORD, (const BYTE*)&dwValue, sizeof(DWORD));
284 if (rc != ERROR_SUCCESS)
285 {
286 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
287 goto cleanup;
288 }
289
290 /* Write 'Linkage' key in hardware key */
291#if _WIN32_WINNT >= 0x502
293#else
295#endif
299 {
300 hKey = NULL;
301 rc = GetLastError();
302 ERR("SetupDiCreateDevRegKeyW() failed with error 0x%lx\n", rc);
303 goto cleanup;
304 }
305
306 rc = RegSetValueExW(hKey, L"NetCfgInstanceId", 0, REG_SZ, (const BYTE*)UuidString, (wcslen(UuidString) + 1) * sizeof(WCHAR));
307 if (rc != ERROR_SUCCESS)
308 {
309 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
310 goto cleanup;
311 }
312
313 rc = RegSetValueExW(hKey, L"Characteristics", 0, REG_DWORD, (const BYTE*)&Characteristics, sizeof(DWORD));
314 if (rc != ERROR_SUCCESS)
315 {
316 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
317 goto cleanup;
318 }
319
320 /* Get ComponentId (from MatchingDeviceId value) */
321 rc = RegQueryValueExW(hKey, L"MatchingDeviceId", 0, &dwRegType, NULL, &dwLength);
322 if (rc != ERROR_SUCCESS)
323 {
324 ERR("RegQueryValueExW() failed with error 0x%lx\n", rc);
325 goto cleanup;
326 }
327 if (dwRegType != REG_SZ)
328 {
329 ERR("Invalid registry type for 'MatchingDeviceId'\n");
331 goto cleanup;
332 }
334 if (!ComponentId)
335 {
336 ERR("HeapAlloc() failed\n");
338 goto cleanup;
339 }
340 rc = RegQueryValueExW(hKey, L"MatchingDeviceId", 0, &dwRegType, (BYTE*)ComponentId, &dwLength);
341 if (rc != ERROR_SUCCESS)
342 {
343 ERR("RegQueryValueExW() failed with error 0x%lx\n", rc);
344 goto cleanup;
345 }
346
347 rc = RegSetValueExW(hKey, L"ComponentId", 0, REG_SZ, (const BYTE*)ComponentId, dwLength);
348 if (rc != ERROR_SUCCESS)
349 {
350 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
351 goto cleanup;
352 }
353
354 if (BusType)
355 {
356 rc = RegSetValueExW(hKey, L"BusType", 0, REG_SZ, (const BYTE*)BusType, (wcslen(BusType) + 1) * sizeof(WCHAR));
357 if (rc != ERROR_SUCCESS)
358 {
359 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
360 goto cleanup;
361 }
362 }
363
364 rc = RegCreateKeyExW(hKey, L"Linkage", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hLinkageKey, NULL);
365 if (rc != ERROR_SUCCESS)
366 {
367 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
368 goto cleanup;
369 }
370
371 rc = RegSetValueExW(hLinkageKey, L"Export", 0, REG_SZ, (const BYTE*)DeviceName, (wcslen(DeviceName) + 1) * sizeof(WCHAR));
372 if (rc != ERROR_SUCCESS)
373 {
374 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
375 goto cleanup;
376 }
377
378 rc = RegSetValueExW(hLinkageKey, L"RootDevice", 0, REG_SZ, (const BYTE*)UuidString, (wcslen(UuidString) + 1) * sizeof(WCHAR));
379 if (rc != ERROR_SUCCESS)
380 {
381 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
382 goto cleanup;
383 }
384
385 rc = RegSetValueExW(hLinkageKey, L"UpperBind", 0, REG_SZ, (const BYTE*)L"Tcpip", (wcslen(L"Tcpip") + 1) * sizeof(WCHAR));
386 if (rc != ERROR_SUCCESS)
387 {
388 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
389 goto cleanup;
390 }
392 hKey = NULL;
393
394 /* Write connection information in network subkey */
396 L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}",
397 0,
398 NULL,
401 NULL,
402 &hNetworkKey,
403 NULL);
404 if (rc != ERROR_SUCCESS)
405 {
406 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
407 goto cleanup;
408 }
409
410 rc = GetUniqueConnectionName(hNetworkKey, &pszNameBuffer);
411 if (rc != ERROR_SUCCESS)
412 {
413 ERR("GetUniqueConnectionName() failed with error 0x%lx\n", rc);
414 goto cleanup;
415 }
416
417 rc = RegCreateKeyExW(hNetworkKey, UuidString, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, NULL, &hKey, NULL);
418 if (rc != ERROR_SUCCESS)
419 {
420 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
421 goto cleanup;
422 }
423
424 rc = RegCreateKeyExW(hKey, L"Connection", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hConnectionKey, NULL);
426 hKey = NULL;
427 if (rc != ERROR_SUCCESS)
428 {
429 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
430 goto cleanup;
431 }
432
433 rc = RegSetValueExW(hConnectionKey, L"Name", 0, REG_SZ, (const BYTE*)pszNameBuffer, (wcslen(pszNameBuffer) + 1) * sizeof(WCHAR));
434 if (rc != ERROR_SUCCESS)
435 {
436 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
437 goto cleanup;
438 }
439
440 rc = RegSetValueExW(hConnectionKey, L"PnpInstanceID", 0, REG_SZ, (const BYTE*)InstanceId, (wcslen(InstanceId) + 1) * sizeof(WCHAR));
441 if (rc != ERROR_SUCCESS)
442 {
443 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
444 goto cleanup;
445 }
446
447 dwShowIcon = 1;
448 rc = RegSetValueExW(hConnectionKey, L"ShowIcon", 0, REG_DWORD, (const BYTE*)&dwShowIcon, sizeof(dwShowIcon));
449 if (rc != ERROR_SUCCESS)
450 {
451 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
452 goto cleanup;
453 }
454
455 /* Write linkage information in Tcpip service */
456 rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Linkage", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE | KEY_SET_VALUE, NULL, &hKey, NULL);
457 if (rc != ERROR_SUCCESS)
458 {
459 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
460 goto cleanup;
461 }
463 if (rc != ERROR_SUCCESS)
464 {
465 ERR("AppendStringToMultiSZ() failed with error 0x%lx\n", rc);
466 goto cleanup;
467 }
468 rc = AppendStringToMultiSZ(hKey, L"Export", ExportName);
469 if (rc != ERROR_SUCCESS)
470 {
471 ERR("AppendStringToMultiSZ() failed with error 0x%lx\n", rc);
472 goto cleanup;
473 }
474 rc = AppendStringToMultiSZ(hKey, L"Route", UuidString);
475 if (rc != ERROR_SUCCESS)
476 {
477 ERR("AppendStringToMultiSZ() failed with error 0x%lx\n", rc);
478 goto cleanup;
479 }
480
481 /* Start the device */
483 {
484 rc = GetLastError();
485 ERR("SetupDiRestartDevices() failed with error 0x%lx\n", rc);
486 goto cleanup;
487 }
488
489 rc = ERROR_SUCCESS;
490
491cleanup:
492 HeapFree(GetProcessHeap(), 0, pszNameBuffer);
496 HeapFree(GetProcessHeap(), 0, ExportName);
497 if (hInterfaceKey != NULL)
498 RegCloseKey(hInterfaceKey);
499 if (hInterfacesKey != NULL)
500 RegCloseKey(hInterfacesKey);
501 if (hKey != NULL)
503 if (hNetworkKey != NULL)
504 RegCloseKey(hNetworkKey);
505 if (hLinkageKey != NULL)
506 RegCloseKey(hLinkageKey);
507 if (hConnectionKey != NULL)
508 RegCloseKey(hConnectionKey);
509
510 return rc;
511}
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 ComponentId
Definition: acpixf.h:1281
#define REG_SZ
Definition: layer.c:22
#define RegCloseKey(hKey)
Definition: registry.h:49
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
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOL WINAPI SetupDiRestartDevices(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:6403
BOOL WINAPI SetupDiSetDeviceInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4847
HKEY WINAPI SetupDiCreateDevRegKeyW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, HINF InfHandle, PCWSTR InfSectionName)
Definition: devinst.c:1639
BOOL WINAPI SetupDiGetDeviceInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, OUT PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4740
BOOL WINAPI SetupDiInstallDevice(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5654
BOOL WINAPI SetupDiGetDeviceInstanceIdW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PWSTR DeviceInstanceId, DWORD DeviceInstanceIdSize, PDWORD RequiredSize)
Definition: devinst.c:2150
HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired)
Definition: devinst.c:6223
_Must_inspect_result_ _In_opt_ PVOID _In_opt_ PVOID InstanceId
Definition: fsrtlfuncs.h:908
static DWORD GetUniqueConnectionName(_In_ HKEY hNetworkKey, _Out_ PWSTR *ppszNameBuffer)
Definition: installer.c:95
static LONG AppendStringToMultiSZ(IN HKEY hKey, IN PCWSTR ValueName, IN PCWSTR ValueToAppend)
Definition: installer.c:20
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
#define KEY_READ
Definition: nt_native.h:1026
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1021
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1060
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define KEY_WRITE
Definition: nt_native.h:1034
#define KEY_SET_VALUE
Definition: nt_native.h:1020
#define REG_DWORD
Definition: sdbapi.c:615
wcscat
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1559
#define DIREG_DRV
Definition: setupapi.h:185
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:115
#define DI_DONOTCALLCONFIGMG
Definition: setupapi.h:65
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3281
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE BusType
Definition: halfuncs.h:159

Referenced by NetClassInstaller().

◆ InstallNetService()

static DWORD InstallNetService ( VOID  )
static

Definition at line 523 of file installer.c.

524{
525 FIXME("Installation of network services is not yet supported\n");
526 return ERROR_GEN_FAILURE;
527}

Referenced by NetClassInstaller().

◆ InstallNetTransport()

static DWORD InstallNetTransport ( VOID  )
static

Definition at line 531 of file installer.c.

532{
533 FIXME("Installation of network protocols is not yet supported\n");
534 return ERROR_GEN_FAILURE;
535}

Referenced by NetClassInstaller().

◆ NetClassInstaller()

DWORD WINAPI NetClassInstaller ( IN DI_FUNCTION  InstallFunction,
IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData  OPTIONAL 
)

Definition at line 539 of file installer.c.

543{
544 SP_DRVINFO_DATA_W DriverInfoData;
545 SP_DRVINFO_DETAIL_DATA_W DriverInfoDetail;
546 WCHAR SectionName[LINE_LEN];
548 INFCONTEXT InfContext;
549 UINT ErrorLine;
550 INT CharacteristicsInt;
551 DWORD Characteristics;
553 RPC_STATUS RpcStatus;
554 UUID Uuid;
555 LPWSTR UuidRpcString = NULL;
556 LPWSTR UuidString = NULL;
557 LONG rc;
559
560 if (InstallFunction != DIF_INSTALLDEVICE)
561 return ERROR_DI_DO_DEFAULT;
562
563 TRACE("%lu %p %p\n", InstallFunction, DeviceInfoSet, DeviceInfoData);
564
565 /* Get driver info details */
566 DriverInfoData.cbSize = sizeof(SP_DRVINFO_DATA_W);
568 {
569 rc = GetLastError();
570 ERR("SetupDiGetSelectedDriverW() failed with error 0x%lx\n", rc);
571 goto cleanup;
572 }
573
574 DriverInfoDetail.cbSize = sizeof(SP_DRVINFO_DETAIL_DATA_W);
575 if (!SetupDiGetDriverInfoDetailW(DeviceInfoSet, DeviceInfoData, &DriverInfoData, &DriverInfoDetail, sizeof(DriverInfoDetail), NULL)
577 {
578 rc = GetLastError();
579 ERR("SetupDiGetDriverInfoDetailW() failed with error 0x%lx\n", rc);
580 goto cleanup;
581 }
582
583 hInf = SetupOpenInfFileW(DriverInfoDetail.InfFileName, NULL, INF_STYLE_WIN4, &ErrorLine);
584 if (hInf == INVALID_HANDLE_VALUE)
585 {
586 rc = GetLastError();
587 ERR("SetupOpenInfFileW() failed with error 0x%lx\n", rc);
588 goto cleanup;
589 }
590
591 if (!SetupDiGetActualSectionToInstallW(hInf, DriverInfoDetail.SectionName, SectionName, LINE_LEN, NULL, NULL))
592 {
593 rc = GetLastError();
594 ERR("SetupDiGetActualSectionToInstallW() failed with error 0x%lx\n", rc);
595 goto cleanup;
596 }
597
598 /* Get Characteristics and BusType (optional) from .inf file */
599 if (!SetupFindFirstLineW(hInf, SectionName, L"Characteristics", &InfContext))
600 {
601 rc = GetLastError();
602 ERR("Unable to find key %S in section %S of file %S (error 0x%lx)\n",
603 L"Characteristics", SectionName, DriverInfoDetail.InfFileName, rc);
604 goto cleanup;
605 }
606
607 if (!SetupGetIntField(&InfContext, 1, &CharacteristicsInt))
608 {
609 rc = GetLastError();
610 ERR("SetupGetIntField() failed with error 0x%lx\n", rc);
611 goto cleanup;
612 }
613
614 Characteristics = (DWORD)CharacteristicsInt;
615 if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NET))
616 {
617 if (SetupFindFirstLineW(hInf, SectionName, L"BusType", &InfContext))
618 {
619 if (!SetupGetStringFieldW(&InfContext, 1, NULL, 0, &dwLength))
620 {
621 rc = GetLastError();
622 ERR("SetupGetStringFieldW() failed with error 0x%lx\n", rc);
623 goto cleanup;
624 }
625
626 BusType = HeapAlloc(GetProcessHeap(), 0, dwLength * sizeof(WCHAR));
627 if (!BusType)
628 {
629 ERR("HeapAlloc() failed\n");
631 goto cleanup;
632 }
633
634 if (!SetupGetStringFieldW(&InfContext, 1, BusType, dwLength, NULL))
635 {
636 rc = GetLastError();
637 ERR("SetupGetStringFieldW() failed with error 0x%lx\n", rc);
638 goto cleanup;
639 }
640 }
641 }
642
643 /* Create a new UUID */
644 RpcStatus = UuidCreate(&Uuid);
645 if (RpcStatus != RPC_S_OK && RpcStatus != RPC_S_UUID_LOCAL_ONLY)
646 {
647 ERR("UuidCreate() failed with RPC status 0x%lx\n", RpcStatus);
649 goto cleanup;
650 }
651
652 RpcStatus = UuidToStringW(&Uuid, &UuidRpcString);
653 if (RpcStatus != RPC_S_OK)
654 {
655 ERR("UuidToStringW() failed with RPC status 0x%lx\n", RpcStatus);
657 goto cleanup;
658 }
659
660 /* Add curly braces around Uuid */
661 UuidString = HeapAlloc(GetProcessHeap(), 0, (2 + wcslen(UuidRpcString)) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
662 if (!UuidString)
663 {
664 ERR("HeapAlloc() failed\n");
666 goto cleanup;
667 }
668
669 wcscpy(UuidString, L"{");
670 wcscat(UuidString, UuidRpcString);
671 wcscat(UuidString, L"}");
672
673 if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NET))
674 rc = InstallNetDevice(DeviceInfoSet, DeviceInfoData, UuidString, Characteristics, BusType);
675 else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETCLIENT))
676 rc = InstallNetClient();
677 else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETSERVICE))
678 rc = InstallNetService();
679 else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETTRANS))
680 rc = InstallNetTransport();
681 else
682 {
683 ERR("Invalid class guid\n");
685 }
686
687cleanup:
688 if (hInf != INVALID_HANDLE_VALUE)
689 SetupCloseInfFile(hInf);
690 if (UuidRpcString != NULL)
691 RpcStringFreeW(&UuidRpcString);
693 HeapFree(GetProcessHeap(), 0, UuidString);
694
695 TRACE("Returning 0x%lx\n", rc);
696 return rc;
697}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI SetupDiGetActualSectionToInstallW(HINF InfHandle, PCWSTR InfSectionName, PWSTR InfSectionWithExt, DWORD InfSectionWithExtSize, PDWORD RequiredSize, PWSTR *Extension)
Definition: devinst.c:2223
BOOL WINAPI SetupDiGetSelectedDriverW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, OUT PSP_DRVINFO_DATA_W DriverInfoData)
Definition: driver.c:1333
BOOL WINAPI SetupDiGetDriverInfoDetailW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN PSP_DRVINFO_DATA_W DriverInfoData, IN OUT PSP_DRVINFO_DETAIL_DATA_W DriverInfoDetailData OPTIONAL, IN DWORD DriverInfoDetailDataSize, OUT PDWORD RequiredSize OPTIONAL)
Definition: driver.c:1732
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
unsigned int UINT
Definition: sysinfo.c:13
#define INF_STYLE_WIN4
Definition: infsupp.h:43
static DWORD InstallNetDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData, LPCWSTR UuidString, DWORD Characteristics, LPCWSTR BusType)
Definition: installer.c:149
static DWORD InstallNetService(VOID)
Definition: installer.c:523
static DWORD InstallNetTransport(VOID)
Definition: installer.c:531
static DWORD InstallNetClient(VOID)
Definition: installer.c:515
#define DWORD
Definition: nt_native.h:44
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define RPC_S_OK
Definition: rpcnterr.h:22
RPC_STATUS WINAPI UuidToStringW(UUID *Uuid, RPC_WSTR *StringUuid)
Definition: rpcrt4_main.c:573
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition: rpcrt4_main.c:181
RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
Definition: rpcrt4_main.c:330
long RPC_STATUS
Definition: rpc.h:48
#define LINE_LEN
Definition: setupapi.h:22
struct _SP_DRVINFO_DETAIL_DATA_W SP_DRVINFO_DETAIL_DATA_W
SP_DRVINFO_DATA_V2_W SP_DRVINFO_DATA_W
Definition: setupapi.h:1056
#define ERROR_DI_DO_DEFAULT
Definition: setupapi.h:313
#define DIF_INSTALLDEVICE
Definition: setupapi.h:124
WCHAR SectionName[LINE_LEN]
Definition: setupapi.h:1079
WCHAR InfFileName[MAX_PATH]
Definition: setupapi.h:1080
int32_t INT
Definition: typedefs.h:58
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
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:45
#define RPC_S_UUID_LOCAL_ONLY
Definition: winerror.h:1488