2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Configuration of network devices
4 * FILE: dll/win32/netcfgx/netcfgx.c
5 * PURPOSE: Network devices installer
7 * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
17 HINSTANCE netcfgx_hInstance
;
18 const GUID CLSID_TcpipConfigNotifyObject
= {0xA907657F, 0x6FDF, 0x11D0, {0x8E, 0xFB, 0x00, 0xC0, 0x4F, 0xD9, 0x12, 0xB2}};
23 static INTERFACE_TABLE InterfaceTable
[] =
30 &CLSID_TcpipConfigNotifyObject
,
31 TcpipConfigNotify_Constructor
41 DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
45 case DLL_PROCESS_ATTACH
:
46 netcfgx_hInstance
= hinstDLL
;
47 DisableThreadLibraryCalls(netcfgx_hInstance
);
64 DllRegisterServer(void)
68 WCHAR szName
[MAX_PATH
] = L
"CLSID\\";
70 if (FAILED(StringFromCLSID(&CLSID_CNetCfg
, &pStr
)))
71 return SELFREG_E_CLASS
;
73 wcscpy(&szName
[6], pStr
);
76 if (RegCreateKeyExW(HKEY_CLASSES_ROOT
, szName
, 0, NULL
, 0, KEY_WRITE
, NULL
, &hKey
, NULL
) != ERROR_SUCCESS
)
77 return SELFREG_E_CLASS
;
79 if (RegCreateKeyExW(hKey
, L
"InProcServer32", 0, NULL
, 0, KEY_WRITE
, NULL
, &hSubKey
, NULL
) == ERROR_SUCCESS
)
81 if (!GetModuleFileNameW(netcfgx_hInstance
, szName
, sizeof(szName
)/sizeof(WCHAR
)))
85 return SELFREG_E_CLASS
;
87 szName
[(sizeof(szName
)/sizeof(WCHAR
))-1] = L
'\0';
88 RegSetValueW(hSubKey
, NULL
, REG_SZ
, szName
, (wcslen(szName
)+1) * sizeof(WCHAR
));
89 RegSetValueExW(hSubKey
, L
"ThreadingModel", 0, REG_SZ
, (LPBYTE
)L
"Both", 10);
98 DllUnregisterServer(void)
101 // implement unregistering services
114 HRESULT hres
= E_OUTOFMEMORY
;
115 IClassFactory
* pcf
= NULL
;
122 for (i
= 0; InterfaceTable
[i
].riid
; i
++)
124 if (IsEqualIID(InterfaceTable
[i
].riid
, rclsid
))
126 pcf
= IClassFactory_fnConstructor(InterfaceTable
[i
].lpfnCI
, NULL
, NULL
);
133 return CLASS_E_CLASSNOTAVAILABLE
;
136 hres
= IClassFactory_QueryInterface(pcf
, riid
, ppv
);
137 IClassFactory_Release(pcf
);
143 /* Append a REG_SZ to an existing REG_MULTI_SZ string in the registry.
144 * If the value doesn't exist, create it.
145 * Returns ERROR_SUCCESS if success. Othewise, returns an error code
148 AppendStringToMultiSZ(
151 IN PCWSTR ValueToAppend
)
155 DWORD dwRequired
, dwLength
;
159 rc
= RegQueryValueExW(
166 if (rc
!= ERROR_FILE_NOT_FOUND
)
168 if (rc
!= ERROR_SUCCESS
)
170 if (dwRegType
!= REG_MULTI_SZ
)
172 rc
= ERROR_GEN_FAILURE
;
176 dwTmp
= dwLength
= dwRequired
+ wcslen(ValueToAppend
) * sizeof(WCHAR
) + sizeof(UNICODE_NULL
);
177 Buffer
= HeapAlloc(GetProcessHeap(), 0, dwLength
);
180 rc
= ERROR_NOT_ENOUGH_MEMORY
;
183 rc
= RegQueryValueExW(
190 if (rc
!= ERROR_SUCCESS
)
195 dwRequired
= sizeof(WCHAR
);
196 dwLength
= wcslen(ValueToAppend
) * sizeof(WCHAR
) + 2 * sizeof(UNICODE_NULL
);
197 Buffer
= HeapAlloc(GetProcessHeap(), 0, dwLength
);
200 rc
= ERROR_NOT_ENOUGH_MEMORY
;
205 /* Append the value */
206 wcscpy(&Buffer
[dwRequired
/ sizeof(WCHAR
) - 1], ValueToAppend
);
207 /* Terminate the REG_MULTI_SZ string */
208 Buffer
[dwLength
/ sizeof(WCHAR
) - 1] = UNICODE_NULL
;
219 HeapFree(GetProcessHeap(), 0, Buffer
);
223 /* Install a section of a .inf file
224 * Returns TRUE if success, FALSE if failure. Error code can
225 * be retrieved with GetLastError()
231 IN LPCWSTR InfSection OPTIONAL
,
232 IN LPCWSTR InfService OPTIONAL
)
234 WCHAR Buffer
[MAX_PATH
];
235 HINF hInf
= INVALID_HANDLE_VALUE
;
237 PVOID Context
= NULL
;
240 /* Get Windows directory */
241 BufferSize
= MAX_PATH
- 5 - wcslen(InfFile
);
242 if (GetWindowsDirectoryW(Buffer
, BufferSize
) > BufferSize
)
244 /* Function failed */
245 SetLastError(ERROR_GEN_FAILURE
);
248 /* We have enough space to add some information in the buffer */
249 if (Buffer
[wcslen(Buffer
) - 1] != '\\')
250 wcscat(Buffer
, L
"\\");
251 wcscat(Buffer
, L
"Inf\\");
252 wcscat(Buffer
, InfFile
);
254 /* Install specified section */
255 hInf
= SetupOpenInfFileW(Buffer
, NULL
, INF_STYLE_WIN4
, NULL
);
256 if (hInf
== INVALID_HANDLE_VALUE
)
259 Context
= SetupInitDefaultQueueCallback(hWnd
);
264 if (ret
&& InfSection
)
266 ret
= SetupInstallFromInfSectionW(
268 InfSection
, SPINST_ALL
,
269 NULL
, NULL
, SP_COPY_NEWER
,
270 SetupDefaultQueueCallbackW
, Context
,
273 if (ret
&& InfService
)
275 ret
= SetupInstallServicesFromInfSectionW(
276 hInf
, InfService
, 0);
281 SetupTermDefaultQueueCallback(Context
);
282 if (hInf
!= INVALID_HANDLE_VALUE
)
283 SetupCloseInfFile(hInf
);
287 /* Add default services for network cards */
289 InstallAdditionalServices(
294 /* Install TCP/IP protocol */
295 ret
= InstallInfSection(
298 L
"MS_TCPIP.PrimaryInstall",
299 L
"MS_TCPIP.PrimaryInstall.Services");
300 if (!ret
&& GetLastError() != ERROR_FILE_NOT_FOUND
)
302 DPRINT("InstallInfSection() failed with error 0x%lx\n", GetLastError());
303 return GetLastError();
306 /* You can add here more clients (SMB...) and services (DHCP server...) */
308 return ERROR_SUCCESS
;
313 IN HDEVINFO DeviceInfoSet
,
314 IN PSP_DEVINFO_DATA DeviceInfoData
,
316 DWORD Characteristics
,
319 LPWSTR InstanceId
= NULL
;
320 LPWSTR DeviceName
= NULL
;
321 LPWSTR ExportName
= NULL
;
324 HKEY hNetworkKey
= NULL
;
325 HKEY hLinkageKey
= NULL
;
326 HKEY hConnectionKey
= NULL
;
327 DWORD dwShowIcon
, dwLength
;
328 SP_DEVINSTALL_PARAMS_W installParams
;
330 /* Get Instance ID */
331 if (SetupDiGetDeviceInstanceIdW(DeviceInfoSet
, DeviceInfoData
, NULL
, 0, &dwLength
))
333 DPRINT("SetupDiGetDeviceInstanceIdW() returned TRUE. FALSE expected\n");
334 rc
= ERROR_GEN_FAILURE
;
337 InstanceId
= HeapAlloc(GetProcessHeap(), 0, dwLength
* sizeof(WCHAR
));
340 DPRINT("HeapAlloc() failed\n");
341 rc
= ERROR_NOT_ENOUGH_MEMORY
;
344 if (!SetupDiGetDeviceInstanceIdW(DeviceInfoSet
, DeviceInfoData
, InstanceId
, dwLength
, NULL
))
347 DPRINT("SetupDiGetDeviceInstanceIdW() failed with error 0x%lx\n", rc
);
351 /* Create device name */
352 DeviceName
= HeapAlloc(GetProcessHeap(), 0, (wcslen(L
"\\Device\\") + wcslen(UuidString
)) * sizeof(WCHAR
) + sizeof(UNICODE_NULL
));
355 DPRINT("HeapAlloc() failed\n");
356 rc
= ERROR_NOT_ENOUGH_MEMORY
;
359 wcscpy(DeviceName
, L
"\\Device\\");
360 wcscat(DeviceName
, UuidString
);
362 /* Create export name */
363 ExportName
= HeapAlloc(GetProcessHeap(), 0, (wcslen(L
"\\Device\\Tcpip_") + wcslen(UuidString
)) * sizeof(WCHAR
) + sizeof(UNICODE_NULL
));
366 DPRINT("HeapAlloc() failed\n");
367 rc
= ERROR_NOT_ENOUGH_MEMORY
;
370 wcscpy(ExportName
, L
"\\Device\\Tcpip_");
371 wcscat(ExportName
, UuidString
);
373 /* Write Tcpip parameters in new service Key */
374 rc
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
, L
"SYSTEM\\CurrentControlSet\\Services", 0, NULL
, REG_OPTION_NON_VOLATILE
, 0, NULL
, &hKey
, NULL
);
375 if (rc
!= ERROR_SUCCESS
)
377 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
380 rc
= RegCreateKeyExW(hKey
, UuidString
, 0, NULL
, REG_OPTION_NON_VOLATILE
, 0, NULL
, &hNetworkKey
, NULL
);
381 if (rc
!= ERROR_SUCCESS
)
383 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
388 rc
= RegCreateKeyExW(hNetworkKey
, L
"Parameters\\Tcpip", 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_SET_VALUE
, NULL
, &hKey
, NULL
);
389 if (rc
!= ERROR_SUCCESS
)
391 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
394 RegCloseKey(hNetworkKey
);
396 rc
= RegSetValueExW(hKey
, L
"DefaultGateway", 0, REG_SZ
, (const BYTE
*)L
"0.0.0.0", (wcslen(L
"0.0.0.0") + 1) * sizeof(WCHAR
));
397 if (rc
!= ERROR_SUCCESS
)
399 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
402 rc
= RegSetValueExW(hKey
, L
"IPAddress", 0, REG_SZ
, (const BYTE
*)L
"0.0.0.0", (wcslen(L
"0.0.0.0") + 1) * sizeof(WCHAR
));
403 if (rc
!= ERROR_SUCCESS
)
405 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
408 rc
= RegSetValueExW(hKey
, L
"SubnetMask", 0, REG_SZ
, (const BYTE
*)L
"0.0.0.0", (wcslen(L
"0.0.0.0") + 1) * sizeof(WCHAR
));
409 if (rc
!= ERROR_SUCCESS
)
411 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
417 /* Write 'Linkage' key in hardware key */
418 #if _WIN32_WINNT >= 0x502
419 hKey
= SetupDiOpenDevRegKey(DeviceInfoSet
, DeviceInfoData
, DICS_FLAG_GLOBAL
, 0, DIREG_DRV
, KEY_READ
| KEY_WRITE
);
421 hKey
= SetupDiOpenDevRegKey(DeviceInfoSet
, DeviceInfoData
, DICS_FLAG_GLOBAL
, 0, DIREG_DRV
, KEY_ALL_ACCESS
);
423 if (hKey
== INVALID_HANDLE_VALUE
&& GetLastError() == ERROR_FILE_NOT_FOUND
)
424 hKey
= SetupDiCreateDevRegKeyW(DeviceInfoSet
, DeviceInfoData
, DICS_FLAG_GLOBAL
, 0, DIREG_DRV
, NULL
, NULL
);
425 if (hKey
== INVALID_HANDLE_VALUE
)
429 DPRINT("SetupDiCreateDevRegKeyW() failed with error 0x%lx\n", rc
);
432 rc
= RegSetValueExW(hKey
, L
"NetCfgInstanceId", 0, REG_SZ
, (const BYTE
*)UuidString
, (wcslen(UuidString
) + 1) * sizeof(WCHAR
));
433 if (rc
!= ERROR_SUCCESS
)
435 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
438 rc
= RegSetValueExW(hKey
, L
"Characteristics", 0, REG_DWORD
, (const BYTE
*)&Characteristics
, sizeof(DWORD
));
439 if (rc
!= ERROR_SUCCESS
)
441 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
445 rc
= RegSetValueExW(hKey
, L
"BusType", 0, REG_SZ
, (const BYTE
*)BusType
, (wcslen(BusType
) + 1) * sizeof(WCHAR
));
446 if (rc
!= ERROR_SUCCESS
)
448 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
451 rc
= RegCreateKeyExW(hKey
, L
"Linkage", 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_SET_VALUE
, NULL
, &hLinkageKey
, NULL
);
452 if (rc
!= ERROR_SUCCESS
)
454 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
457 rc
= RegSetValueExW(hLinkageKey
, L
"Export", 0, REG_SZ
, (const BYTE
*)DeviceName
, (wcslen(DeviceName
) + 1) * sizeof(WCHAR
));
458 if (rc
!= ERROR_SUCCESS
)
460 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
463 rc
= RegSetValueExW(hLinkageKey
, L
"RootDevice", 0, REG_SZ
, (const BYTE
*)UuidString
, (wcslen(UuidString
) + 1) * sizeof(WCHAR
));
464 if (rc
!= ERROR_SUCCESS
)
466 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
469 rc
= RegSetValueExW(hLinkageKey
, L
"UpperBind", 0, REG_SZ
, (const BYTE
*)L
"Tcpip", (wcslen(L
"Tcpip") + 1) * sizeof(WCHAR
));
470 if (rc
!= ERROR_SUCCESS
)
472 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
478 /* Write connection information in network subkey */
479 rc
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
, L
"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}", 0, NULL
, REG_OPTION_NON_VOLATILE
, 0, NULL
, &hNetworkKey
, NULL
);
480 if (rc
!= ERROR_SUCCESS
)
482 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
485 rc
= RegCreateKeyExW(hNetworkKey
, UuidString
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_CREATE_SUB_KEY
, NULL
, &hKey
, NULL
);
486 if (rc
!= ERROR_SUCCESS
)
488 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
491 rc
= RegCreateKeyExW(hKey
, L
"Connection", 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_SET_VALUE
, NULL
, &hConnectionKey
, NULL
);
494 if (rc
!= ERROR_SUCCESS
)
496 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
499 rc
= RegSetValueExW(hConnectionKey
, L
"Name", 0, REG_SZ
, (const BYTE
*)L
"Network connection", (wcslen(L
"Network connection") + 1) * sizeof(WCHAR
));
500 if (rc
!= ERROR_SUCCESS
)
502 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
505 rc
= RegSetValueExW(hConnectionKey
, L
"PnpInstanceId", 0, REG_SZ
, (const BYTE
*)InstanceId
, (wcslen(InstanceId
) + 1) * sizeof(WCHAR
));
506 if (rc
!= ERROR_SUCCESS
)
508 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
512 rc
= RegSetValueExW(hConnectionKey
, L
"ShowIcon", 0, REG_DWORD
, (const BYTE
*)&dwShowIcon
, sizeof(dwShowIcon
));
513 if (rc
!= ERROR_SUCCESS
)
515 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
519 /* Write linkage information in Tcpip service */
520 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
);
521 if (rc
!= ERROR_SUCCESS
)
523 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
526 rc
= AppendStringToMultiSZ(hKey
, L
"Bind", DeviceName
);
527 if (rc
!= ERROR_SUCCESS
)
529 DPRINT("AppendStringToMultiSZ() failed with error 0x%lx\n", rc
);
532 rc
= AppendStringToMultiSZ(hKey
, L
"Export", ExportName
);
533 if (rc
!= ERROR_SUCCESS
)
535 DPRINT("AppendStringToMultiSZ() failed with error 0x%lx\n", rc
);
538 rc
= AppendStringToMultiSZ(hKey
, L
"Route", UuidString
);
539 if (rc
!= ERROR_SUCCESS
)
541 DPRINT("AppendStringToMultiSZ() failed with error 0x%lx\n", rc
);
545 /* Install additionnal services */
546 rc
= InstallAdditionalServices(NULL
);
547 if (rc
!= ERROR_SUCCESS
)
549 DPRINT("InstallAdditionalServices() failed with error 0x%lx\n", rc
);
553 /* HACK: hpoussin, Dec 2005. TCP/IP driver is not able to manage devices
554 * which are installed after its startup. So, we have to reboot to take
555 * this new netcard into account.
557 /* Should we reboot? */
558 installParams
.cbSize
= sizeof(SP_DEVINSTALL_PARAMS_W
);
559 if (!SetupDiGetDeviceInstallParamsW(
565 DPRINT("SetupDiGetDeviceInstallParams() failed with error 0x%lx\n", rc
);
568 installParams
.Flags
|= DI_NEEDRESTART
;
569 if (!SetupDiSetDeviceInstallParamsW(
575 DPRINT("SetupDiSetDeviceInstallParams() failed with error 0x%lx\n", rc
);
581 HeapFree(GetProcessHeap(), 0, InstanceId
);
582 HeapFree(GetProcessHeap(), 0, DeviceName
);
583 HeapFree(GetProcessHeap(), 0, ExportName
);
586 if (hNetworkKey
!= NULL
)
587 RegCloseKey(hNetworkKey
);
588 if (hLinkageKey
!= NULL
)
589 RegCloseKey(hLinkageKey
);
590 if (hConnectionKey
!= NULL
)
591 RegCloseKey(hConnectionKey
);
596 InstallNetClient(VOID
)
598 DPRINT1("Installation of network clients is not yet supported\n");
599 return ERROR_GEN_FAILURE
;
603 InstallNetService(VOID
)
605 DPRINT1("Installation of network services is not yet supported\n");
606 return ERROR_GEN_FAILURE
;
610 InstallNetTransport(VOID
)
612 DPRINT1("Installation of network protocols is not yet supported\n");
613 return ERROR_GEN_FAILURE
;
618 IN DI_FUNCTION InstallFunction
,
619 IN HDEVINFO DeviceInfoSet
,
620 IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
)
622 SP_DRVINFO_DATA_W DriverInfoData
;
623 SP_DRVINFO_DETAIL_DATA_W DriverInfoDetail
;
624 WCHAR SectionName
[LINE_LEN
];
625 HINF hInf
= INVALID_HANDLE_VALUE
;
626 INFCONTEXT InfContext
;
628 INT CharacteristicsInt
;
629 DWORD Characteristics
;
630 LPWSTR BusType
= NULL
;
631 RPC_STATUS RpcStatus
;
633 LPWSTR UuidRpcString
= NULL
;
634 LPWSTR UuidString
= NULL
;
638 if (InstallFunction
!= DIF_INSTALLDEVICE
)
639 return ERROR_DI_DO_DEFAULT
;
641 DPRINT("%lu %p %p\n", InstallFunction
, DeviceInfoSet
, DeviceInfoData
);
643 /* Get driver info details */
644 DriverInfoData
.cbSize
= sizeof(SP_DRVINFO_DATA_W
);
645 if (!SetupDiGetSelectedDriverW(DeviceInfoSet
, DeviceInfoData
, &DriverInfoData
))
648 DPRINT("SetupDiGetSelectedDriverW() failed with error 0x%lx\n", rc
);
651 DriverInfoDetail
.cbSize
= sizeof(SP_DRVINFO_DETAIL_DATA_W
);
652 if (!SetupDiGetDriverInfoDetailW(DeviceInfoSet
, DeviceInfoData
, &DriverInfoData
, &DriverInfoDetail
, sizeof(DriverInfoDetail
), NULL
)
653 && GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
656 DPRINT("SetupDiGetDriverInfoDetailW() failed with error 0x%lx\n", rc
);
659 hInf
= SetupOpenInfFileW(DriverInfoDetail
.InfFileName
, NULL
, INF_STYLE_WIN4
, &ErrorLine
);
660 if (hInf
== INVALID_HANDLE_VALUE
)
663 DPRINT("SetupOpenInfFileW() failed with error 0x%lx\n", rc
);
666 if (!SetupDiGetActualSectionToInstallW(hInf
, DriverInfoDetail
.SectionName
, SectionName
, LINE_LEN
, NULL
, NULL
))
669 DPRINT("SetupDiGetActualSectionToInstallW() failed with error 0x%lx\n", rc
);
673 /* Get Characteristics and BusType (optional) from .inf file */
674 if (!SetupFindFirstLineW(hInf
, SectionName
, L
"Characteristics", &InfContext
))
677 DPRINT("Unable to find key %S in section %S of file %S (error 0x%lx)\n",
678 L
"Characteristics", SectionName
, DriverInfoDetail
.InfFileName
, rc
);
681 if (!SetupGetIntField(&InfContext
, 1, &CharacteristicsInt
))
684 DPRINT("SetupGetIntField() failed with error 0x%lx\n", rc
);
687 Characteristics
= (DWORD
)CharacteristicsInt
;
688 if (IsEqualIID(&DeviceInfoData
->ClassGuid
, &GUID_DEVCLASS_NET
))
690 if (SetupFindFirstLineW(hInf
, SectionName
, L
"BusType", &InfContext
))
692 if (!SetupGetStringFieldW(&InfContext
, 1, NULL
, 0, &dwLength
))
695 DPRINT("SetupGetStringFieldW() failed with error 0x%lx\n", rc
);
698 BusType
= HeapAlloc(GetProcessHeap(), 0, dwLength
* sizeof(WCHAR
));
701 DPRINT("HeapAlloc() failed\n");
702 rc
= ERROR_NOT_ENOUGH_MEMORY
;
705 if (!SetupGetStringFieldW(&InfContext
, 1, BusType
, dwLength
, NULL
))
708 DPRINT("SetupGetStringFieldW() failed with error 0x%lx\n", rc
);
714 /* Create a new UUID */
715 RpcStatus
= UuidCreate(&Uuid
);
716 if (RpcStatus
!= RPC_S_OK
&& RpcStatus
!= RPC_S_UUID_LOCAL_ONLY
)
718 DPRINT("UuidCreate() failed with RPC status 0x%lx\n", RpcStatus
);
719 rc
= ERROR_GEN_FAILURE
;
722 RpcStatus
= UuidToStringW(&Uuid
, &UuidRpcString
);
723 if (RpcStatus
!= RPC_S_OK
)
725 DPRINT("UuidToStringW() failed with RPC status 0x%lx\n", RpcStatus
);
726 rc
= ERROR_GEN_FAILURE
;
730 /* Add curly braces around Uuid */
731 UuidString
= HeapAlloc(GetProcessHeap(), 0, (2 + wcslen(UuidRpcString
)) * sizeof(WCHAR
) + sizeof(UNICODE_NULL
));
734 DPRINT("HeapAlloc() failed\n");
735 rc
= ERROR_NOT_ENOUGH_MEMORY
;
738 wcscpy(UuidString
, L
"{");
739 wcscat(UuidString
, UuidRpcString
);
740 wcscat(UuidString
, L
"}");
742 if (IsEqualIID(&DeviceInfoData
->ClassGuid
, &GUID_DEVCLASS_NET
))
743 rc
= InstallNetDevice(DeviceInfoSet
, DeviceInfoData
, UuidString
, Characteristics
, BusType
);
744 else if (IsEqualIID(&DeviceInfoData
->ClassGuid
, &GUID_DEVCLASS_NETCLIENT
))
745 rc
= InstallNetClient();
746 else if (IsEqualIID(&DeviceInfoData
->ClassGuid
, &GUID_DEVCLASS_NETSERVICE
))
747 rc
= InstallNetService();
748 else if (IsEqualIID(&DeviceInfoData
->ClassGuid
, &GUID_DEVCLASS_NETTRANS
))
749 rc
= InstallNetTransport();
752 DPRINT("Invalid class guid\n");
753 rc
= ERROR_GEN_FAILURE
;
757 if (hInf
!= INVALID_HANDLE_VALUE
)
758 SetupCloseInfFile(hInf
);
759 if (UuidRpcString
!= NULL
)
760 RpcStringFreeW(&UuidRpcString
);
761 HeapFree(GetProcessHeap(), 0, BusType
);
762 HeapFree(GetProcessHeap(), 0, UuidString
);
764 if (rc
== ERROR_SUCCESS
)
765 rc
= ERROR_DI_DO_DEFAULT
;
766 DPRINT("Returning 0x%lx\n", rc
);