ReactOS 0.4.15-dev-5669-g09dde2c
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:4900
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4121
#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
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
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:134
__wchar_t WCHAR
Definition: xmlstorage.h:180
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: debug.h:110
#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:3690
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
HINSTANCE netcfgx_hInstance
Definition: netcfgx.c:15
#define IDS_NET_CONNECT
Definition: resource.h:98
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
#define TRACE(s)
Definition: solgame.cpp:4
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by InstallNetDevice().

◆ InstallNetClient()

static DWORD InstallNetClient ( VOID  )
static

Definition at line 509 of file installer.c.

510{
511 FIXME("Installation of network clients is not yet supported\n");
512 return ERROR_GEN_FAILURE;
513}
#define FIXME(fmt,...)
Definition: debug.h:111

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 hKey = NULL;
163 HKEY hNetworkKey = NULL;
164 HKEY hLinkageKey = NULL;
165 HKEY hConnectionKey = NULL;
166 DWORD dwShowIcon, dwLength, dwValue;
167 PWSTR pszNameBuffer = NULL;
168 PWSTR ptr;
169
174 {
175 rc = GetLastError();
176 ERR("SetupDiGetDeviceInstallParamsW() failed (Error %lu)\n", rc);
177 goto cleanup;
178 }
179
180 /* Do not start the adapter in the call to SetupDiInstallDevice */
182
186 {
187 rc = GetLastError();
188 ERR("SetupDiSetDeviceInstallParamsW() failed (Error %lu)\n", rc);
189 goto cleanup;
190 }
191
192 /* Install the adapter */
194 {
195 rc = GetLastError();
196 ERR("SetupDiInstallDevice() failed (Error %lu)\n", rc);
197 goto cleanup;
198 }
199
200 /* Get Instance ID */
202 {
203 ERR("SetupDiGetDeviceInstanceIdW() returned TRUE. FALSE expected\n");
205 goto cleanup;
206 }
207
209 if (!InstanceId)
210 {
211 ERR("HeapAlloc() failed\n");
213 goto cleanup;
214 }
215
217 {
218 rc = GetLastError();
219 ERR("SetupDiGetDeviceInstanceIdW() failed with error 0x%lx\n", rc);
220 goto cleanup;
221 }
222
224 if (!ComponentId)
225 {
226 ERR("HeapAlloc() failed\n");
228 goto cleanup;
229 }
230
232 ptr = wcsrchr(ComponentId, L'\\');
233 if (ptr != NULL)
234 *ptr = UNICODE_NULL;
235
236 /* Create device name */
237 DeviceName = HeapAlloc(GetProcessHeap(), 0, (wcslen(L"\\Device\\") + wcslen(UuidString)) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
238 if (!DeviceName)
239 {
240 ERR("HeapAlloc() failed\n");
242 goto cleanup;
243 }
244 wcscpy(DeviceName, L"\\Device\\");
245 wcscat(DeviceName, UuidString);
246
247 /* Create export name */
248 ExportName = HeapAlloc(GetProcessHeap(), 0, (wcslen(L"\\Device\\Tcpip_") + wcslen(UuidString)) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
249 if (!ExportName)
250 {
251 ERR("HeapAlloc() failed\n");
253 goto cleanup;
254 }
255 wcscpy(ExportName, L"\\Device\\Tcpip_");
256 wcscat(ExportName, UuidString);
257
258 /* Write Tcpip parameters in new service Key */
259 rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, NULL, &hKey, NULL);
260 if (rc != ERROR_SUCCESS)
261 {
262 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
263 goto cleanup;
264 }
265
266 rc = RegCreateKeyExW(hKey, UuidString, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, NULL, &hNetworkKey, NULL);
267 if (rc != ERROR_SUCCESS)
268 {
269 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
270 goto cleanup;
271 }
273 hKey = NULL;
274
275 rc = RegCreateKeyExW(hNetworkKey, L"Parameters\\Tcpip", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, NULL);
276 if (rc != ERROR_SUCCESS)
277 {
278 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
279 goto cleanup;
280 }
281 RegCloseKey(hNetworkKey);
282 hNetworkKey = NULL;
283
284 rc = RegSetValueExW(hKey, L"DefaultGateway", 0, REG_SZ, (const BYTE*)L"0.0.0.0", (wcslen(L"0.0.0.0") + 1) * sizeof(WCHAR));
285 if (rc != ERROR_SUCCESS)
286 {
287 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
288 goto cleanup;
289 }
290
291 rc = RegSetValueExW(hKey, L"IPAddress", 0, REG_SZ, (const BYTE*)L"0.0.0.0", (wcslen(L"0.0.0.0") + 1) * sizeof(WCHAR));
292 if (rc != ERROR_SUCCESS)
293 {
294 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
295 goto cleanup;
296 }
297
298 rc = RegSetValueExW(hKey, L"SubnetMask", 0, REG_SZ, (const BYTE*)L"0.0.0.0", (wcslen(L"0.0.0.0") + 1) * sizeof(WCHAR));
299 if (rc != ERROR_SUCCESS)
300 {
301 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
302 goto cleanup;
303 }
304
305 dwValue = 1;
306 rc = RegSetValueExW(hKey, L"EnableDHCP", 0, REG_DWORD, (const BYTE*)&dwValue, sizeof(DWORD));
307 if (rc != ERROR_SUCCESS)
308 {
309 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
310 goto cleanup;
311 }
313 hKey = NULL;
314
315 /* Write 'Linkage' key in hardware key */
316#if _WIN32_WINNT >= 0x502
318#else
320#endif
324 {
325 hKey = NULL;
326 rc = GetLastError();
327 ERR("SetupDiCreateDevRegKeyW() failed with error 0x%lx\n", rc);
328 goto cleanup;
329 }
330
331 rc = RegSetValueExW(hKey, L"NetCfgInstanceId", 0, REG_SZ, (const BYTE*)UuidString, (wcslen(UuidString) + 1) * sizeof(WCHAR));
332 if (rc != ERROR_SUCCESS)
333 {
334 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
335 goto cleanup;
336 }
337
338 rc = RegSetValueExW(hKey, L"Characteristics", 0, REG_DWORD, (const BYTE*)&Characteristics, sizeof(DWORD));
339 if (rc != ERROR_SUCCESS)
340 {
341 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
342 goto cleanup;
343 }
344
345 rc = RegSetValueExW(hKey, L"ComponentId", 0, REG_SZ, (const BYTE*)ComponentId, (wcslen(ComponentId) + 1) * sizeof(WCHAR));
346 if (rc != ERROR_SUCCESS)
347 {
348 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
349 goto cleanup;
350 }
351
352 if (BusType)
353 {
354 rc = RegSetValueExW(hKey, L"BusType", 0, REG_SZ, (const BYTE*)BusType, (wcslen(BusType) + 1) * sizeof(WCHAR));
355 if (rc != ERROR_SUCCESS)
356 {
357 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
358 goto cleanup;
359 }
360 }
361
362 rc = RegCreateKeyExW(hKey, L"Linkage", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hLinkageKey, NULL);
363 if (rc != ERROR_SUCCESS)
364 {
365 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
366 goto cleanup;
367 }
368
369 rc = RegSetValueExW(hLinkageKey, L"Export", 0, REG_SZ, (const BYTE*)DeviceName, (wcslen(DeviceName) + 1) * sizeof(WCHAR));
370 if (rc != ERROR_SUCCESS)
371 {
372 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
373 goto cleanup;
374 }
375
376 rc = RegSetValueExW(hLinkageKey, L"RootDevice", 0, REG_SZ, (const BYTE*)UuidString, (wcslen(UuidString) + 1) * sizeof(WCHAR));
377 if (rc != ERROR_SUCCESS)
378 {
379 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
380 goto cleanup;
381 }
382
383 rc = RegSetValueExW(hLinkageKey, L"UpperBind", 0, REG_SZ, (const BYTE*)L"Tcpip", (wcslen(L"Tcpip") + 1) * sizeof(WCHAR));
384 if (rc != ERROR_SUCCESS)
385 {
386 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
387 goto cleanup;
388 }
390 hKey = NULL;
391
392 /* Write connection information in network subkey */
394 L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}",
395 0,
396 NULL,
399 NULL,
400 &hNetworkKey,
401 NULL);
402 if (rc != ERROR_SUCCESS)
403 {
404 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
405 goto cleanup;
406 }
407
408 rc = GetUniqueConnectionName(hNetworkKey, &pszNameBuffer);
409 if (rc != ERROR_SUCCESS)
410 {
411 ERR("GetUniqueConnectionName() failed with error 0x%lx\n", rc);
412 goto cleanup;
413 }
414
415 rc = RegCreateKeyExW(hNetworkKey, UuidString, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, NULL, &hKey, NULL);
416 if (rc != ERROR_SUCCESS)
417 {
418 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
419 goto cleanup;
420 }
421
422 rc = RegCreateKeyExW(hKey, L"Connection", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hConnectionKey, NULL);
424 hKey = NULL;
425 if (rc != ERROR_SUCCESS)
426 {
427 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
428 goto cleanup;
429 }
430
431 rc = RegSetValueExW(hConnectionKey, L"Name", 0, REG_SZ, (const BYTE*)pszNameBuffer, (wcslen(pszNameBuffer) + 1) * sizeof(WCHAR));
432 if (rc != ERROR_SUCCESS)
433 {
434 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
435 goto cleanup;
436 }
437
438 rc = RegSetValueExW(hConnectionKey, L"PnpInstanceID", 0, REG_SZ, (const BYTE*)InstanceId, (wcslen(InstanceId) + 1) * sizeof(WCHAR));
439 if (rc != ERROR_SUCCESS)
440 {
441 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
442 goto cleanup;
443 }
444
445 dwShowIcon = 1;
446 rc = RegSetValueExW(hConnectionKey, L"ShowIcon", 0, REG_DWORD, (const BYTE*)&dwShowIcon, sizeof(dwShowIcon));
447 if (rc != ERROR_SUCCESS)
448 {
449 ERR("RegSetValueExW() failed with error 0x%lx\n", rc);
450 goto cleanup;
451 }
452
453 /* Write linkage information in Tcpip service */
454 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);
455 if (rc != ERROR_SUCCESS)
456 {
457 ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc);
458 goto cleanup;
459 }
461 if (rc != ERROR_SUCCESS)
462 {
463 ERR("AppendStringToMultiSZ() failed with error 0x%lx\n", rc);
464 goto cleanup;
465 }
466 rc = AppendStringToMultiSZ(hKey, L"Export", ExportName);
467 if (rc != ERROR_SUCCESS)
468 {
469 ERR("AppendStringToMultiSZ() failed with error 0x%lx\n", rc);
470 goto cleanup;
471 }
472 rc = AppendStringToMultiSZ(hKey, L"Route", UuidString);
473 if (rc != ERROR_SUCCESS)
474 {
475 ERR("AppendStringToMultiSZ() failed with error 0x%lx\n", rc);
476 goto cleanup;
477 }
478
479 /* Start the device */
481 {
482 rc = GetLastError();
483 ERR("SetupDiRestartDevices() failed with error 0x%lx\n", rc);
484 goto cleanup;
485 }
486
487 rc = ERROR_SUCCESS;
488
489cleanup:
490 HeapFree(GetProcessHeap(), 0, pszNameBuffer);
494 HeapFree(GetProcessHeap(), 0, ExportName);
495 if (hKey != NULL)
497 if (hNetworkKey != NULL)
498 RegCloseKey(hNetworkKey);
499 if (hLinkageKey != NULL)
500 RegCloseKey(hLinkageKey);
501 if (hConnectionKey != NULL)
502 RegCloseKey(hConnectionKey);
503
504 return rc;
505}
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 RegCloseKey(hKey)
Definition: registry.h:47
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:1091
#define wcsrchr
Definition: compat.h:16
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOL WINAPI SetupDiRestartDevices(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:6114
BOOL WINAPI SetupDiSetDeviceInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4558
HKEY WINAPI SetupDiCreateDevRegKeyW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, HINF InfHandle, PCWSTR InfSectionName)
Definition: devinst.c:1396
BOOL WINAPI SetupDiGetDeviceInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, OUT PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4451
BOOL WINAPI SetupDiInstallDevice(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5365
BOOL WINAPI SetupDiGetDeviceInstanceIdW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PWSTR DeviceInstanceId, DWORD DeviceInstanceIdSize, PDWORD RequiredSize)
Definition: devinst.c:1907
HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired)
Definition: devinst.c:5934
_Must_inspect_result_ _In_opt_ PVOID _In_opt_ PVOID InstanceId
Definition: fsrtlfuncs.h:908
#define REG_SZ
Definition: layer.c:22
static PVOID ptr
Definition: dispmode.c:27
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:1041
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define KEY_WRITE
Definition: nt_native.h:1031
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define REG_DWORD
Definition: sdbapi.c:596
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define DIREG_DRV
Definition: setupapi.h:182
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1528
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:113
#define DI_DONOTCALLCONFIGMG
Definition: setupapi.h:63
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
#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 517 of file installer.c.

518{
519 FIXME("Installation of network services is not yet supported\n");
520 return ERROR_GEN_FAILURE;
521}

Referenced by NetClassInstaller().

◆ InstallNetTransport()

static DWORD InstallNetTransport ( VOID  )
static

Definition at line 525 of file installer.c.

526{
527 FIXME("Installation of network protocols is not yet supported\n");
528 return ERROR_GEN_FAILURE;
529}

Referenced by NetClassInstaller().

◆ NetClassInstaller()

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

Definition at line 533 of file installer.c.

537{
538 SP_DRVINFO_DATA_W DriverInfoData;
539 SP_DRVINFO_DETAIL_DATA_W DriverInfoDetail;
540 WCHAR SectionName[LINE_LEN];
542 INFCONTEXT InfContext;
543 UINT ErrorLine;
544 INT CharacteristicsInt;
545 DWORD Characteristics;
547 RPC_STATUS RpcStatus;
548 UUID Uuid;
549 LPWSTR UuidRpcString = NULL;
550 LPWSTR UuidString = NULL;
551 LONG rc;
553
554 if (InstallFunction != DIF_INSTALLDEVICE)
555 return ERROR_DI_DO_DEFAULT;
556
557 TRACE("%lu %p %p\n", InstallFunction, DeviceInfoSet, DeviceInfoData);
558
559 /* Get driver info details */
560 DriverInfoData.cbSize = sizeof(SP_DRVINFO_DATA_W);
562 {
563 rc = GetLastError();
564 ERR("SetupDiGetSelectedDriverW() failed with error 0x%lx\n", rc);
565 goto cleanup;
566 }
567
568 DriverInfoDetail.cbSize = sizeof(SP_DRVINFO_DETAIL_DATA_W);
569 if (!SetupDiGetDriverInfoDetailW(DeviceInfoSet, DeviceInfoData, &DriverInfoData, &DriverInfoDetail, sizeof(DriverInfoDetail), NULL)
571 {
572 rc = GetLastError();
573 ERR("SetupDiGetDriverInfoDetailW() failed with error 0x%lx\n", rc);
574 goto cleanup;
575 }
576
577 hInf = SetupOpenInfFileW(DriverInfoDetail.InfFileName, NULL, INF_STYLE_WIN4, &ErrorLine);
578 if (hInf == INVALID_HANDLE_VALUE)
579 {
580 rc = GetLastError();
581 ERR("SetupOpenInfFileW() failed with error 0x%lx\n", rc);
582 goto cleanup;
583 }
584
585 if (!SetupDiGetActualSectionToInstallW(hInf, DriverInfoDetail.SectionName, SectionName, LINE_LEN, NULL, NULL))
586 {
587 rc = GetLastError();
588 ERR("SetupDiGetActualSectionToInstallW() failed with error 0x%lx\n", rc);
589 goto cleanup;
590 }
591
592 /* Get Characteristics and BusType (optional) from .inf file */
593 if (!SetupFindFirstLineW(hInf, SectionName, L"Characteristics", &InfContext))
594 {
595 rc = GetLastError();
596 ERR("Unable to find key %S in section %S of file %S (error 0x%lx)\n",
597 L"Characteristics", SectionName, DriverInfoDetail.InfFileName, rc);
598 goto cleanup;
599 }
600
601 if (!SetupGetIntField(&InfContext, 1, &CharacteristicsInt))
602 {
603 rc = GetLastError();
604 ERR("SetupGetIntField() failed with error 0x%lx\n", rc);
605 goto cleanup;
606 }
607
608 Characteristics = (DWORD)CharacteristicsInt;
609 if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NET))
610 {
611 if (SetupFindFirstLineW(hInf, SectionName, L"BusType", &InfContext))
612 {
613 if (!SetupGetStringFieldW(&InfContext, 1, NULL, 0, &dwLength))
614 {
615 rc = GetLastError();
616 ERR("SetupGetStringFieldW() failed with error 0x%lx\n", rc);
617 goto cleanup;
618 }
619
620 BusType = HeapAlloc(GetProcessHeap(), 0, dwLength * sizeof(WCHAR));
621 if (!BusType)
622 {
623 ERR("HeapAlloc() failed\n");
625 goto cleanup;
626 }
627
628 if (!SetupGetStringFieldW(&InfContext, 1, BusType, dwLength, NULL))
629 {
630 rc = GetLastError();
631 ERR("SetupGetStringFieldW() failed with error 0x%lx\n", rc);
632 goto cleanup;
633 }
634 }
635 }
636
637 /* Create a new UUID */
638 RpcStatus = UuidCreate(&Uuid);
639 if (RpcStatus != RPC_S_OK && RpcStatus != RPC_S_UUID_LOCAL_ONLY)
640 {
641 ERR("UuidCreate() failed with RPC status 0x%lx\n", RpcStatus);
643 goto cleanup;
644 }
645
646 RpcStatus = UuidToStringW(&Uuid, &UuidRpcString);
647 if (RpcStatus != RPC_S_OK)
648 {
649 ERR("UuidToStringW() failed with RPC status 0x%lx\n", RpcStatus);
651 goto cleanup;
652 }
653
654 /* Add curly braces around Uuid */
655 UuidString = HeapAlloc(GetProcessHeap(), 0, (2 + wcslen(UuidRpcString)) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
656 if (!UuidString)
657 {
658 ERR("HeapAlloc() failed\n");
660 goto cleanup;
661 }
662
663 wcscpy(UuidString, L"{");
664 wcscat(UuidString, UuidRpcString);
665 wcscat(UuidString, L"}");
666
667 if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NET))
668 rc = InstallNetDevice(DeviceInfoSet, DeviceInfoData, UuidString, Characteristics, BusType);
669 else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETCLIENT))
670 rc = InstallNetClient();
671 else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETSERVICE))
672 rc = InstallNetService();
673 else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETTRANS))
674 rc = InstallNetTransport();
675 else
676 {
677 ERR("Invalid class guid\n");
679 }
680
681cleanup:
682 if (hInf != INVALID_HANDLE_VALUE)
683 SetupCloseInfFile(hInf);
684 if (UuidRpcString != NULL)
685 RpcStringFreeW(&UuidRpcString);
687 HeapFree(GetProcessHeap(), 0, UuidString);
688
689 TRACE("Returning 0x%lx\n", rc);
690 return rc;
691}
#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:1980
BOOL WINAPI SetupDiGetSelectedDriverW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, OUT PSP_DRVINFO_DATA_W DriverInfoData)
Definition: driver.c:1479
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:1878
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
#define INF_STYLE_WIN4
Definition: infsupp.h:41
unsigned int UINT
Definition: ndis.h:50
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:517
static DWORD InstallNetTransport(VOID)
Definition: installer.c:525
static DWORD InstallNetClient(VOID)
Definition: installer.c:509
#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:540
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition: rpcrt4_main.c:175
RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
Definition: rpcrt4_main.c:305
long RPC_STATUS
Definition: rpc.h:52
#define LINE_LEN
Definition: setupapi.h:20
struct _SP_DRVINFO_DETAIL_DATA_W SP_DRVINFO_DETAIL_DATA_W
SP_DRVINFO_DATA_V2_W SP_DRVINFO_DATA_W
Definition: setupapi.h:1053
#define ERROR_DI_DO_DEFAULT
Definition: setupapi.h:310
#define DIF_INSTALLDEVICE
Definition: setupapi.h:121
WCHAR SectionName[LINE_LEN]
Definition: setupapi.h:1076
WCHAR InfFileName[MAX_PATH]
Definition: setupapi.h:1077
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:184
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:54
BOOL WINAPI SetupGetIntField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT INT *IntegerValue)
Definition: infsupp.c:146
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43
#define RPC_S_UUID_LOCAL_ONLY
Definition: winerror.h:1131