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
;
19 static INTERFACE_TABLE InterfaceTable
[] =
33 DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
37 case DLL_PROCESS_ATTACH
:
38 netcfgx_hInstance
= hinstDLL
;
39 DisableThreadLibraryCalls(netcfgx_hInstance
);
56 DllRegisterServer(void)
60 WCHAR szName
[MAX_PATH
] = L
"CLSID\\";
62 if (FAILED(StringFromCLSID(&CLSID_CNetCfg
, &pStr
)))
63 return SELFREG_E_CLASS
;
65 wcscpy(&szName
[6], pStr
);
68 if (RegCreateKeyExW(HKEY_CLASSES_ROOT
, szName
, 0, NULL
, 0, KEY_WRITE
, NULL
, &hKey
, NULL
) != ERROR_SUCCESS
)
69 return SELFREG_E_CLASS
;
71 if (RegCreateKeyExW(hKey
, L
"InProcServer32", 0, NULL
, 0, KEY_WRITE
, NULL
, &hSubKey
, NULL
) == ERROR_SUCCESS
)
73 if (!GetModuleFileNameW(netcfgx_hInstance
, szName
, sizeof(szName
)/sizeof(WCHAR
)))
77 return SELFREG_E_CLASS
;
79 szName
[(sizeof(szName
)/sizeof(WCHAR
))-1] = L
'\0';
80 RegSetValueW(hSubKey
, NULL
, REG_SZ
, szName
, (wcslen(szName
)+1) * sizeof(WCHAR
));
81 RegSetValueExW(hSubKey
, L
"ThreadingModel", 0, REG_SZ
, (LPBYTE
)L
"Both", 10);
90 DllUnregisterServer(void)
93 // implement unregistering services
106 HRESULT hres
= E_OUTOFMEMORY
;
107 IClassFactory
* pcf
= NULL
;
114 for (i
= 0; InterfaceTable
[i
].riid
; i
++)
116 if (IsEqualIID(InterfaceTable
[i
].riid
, rclsid
))
118 pcf
= IClassFactory_fnConstructor(InterfaceTable
[i
].lpfnCI
, NULL
, NULL
);
125 return CLASS_E_CLASSNOTAVAILABLE
;
128 hres
= IClassFactory_QueryInterface(pcf
, riid
, ppv
);
129 IClassFactory_Release(pcf
);
135 /* Append a REG_SZ to an existing REG_MULTI_SZ string in the registry.
136 * If the value doesn't exist, create it.
137 * Returns ERROR_SUCCESS if success. Othewise, returns an error code
140 AppendStringToMultiSZ(
143 IN PCWSTR ValueToAppend
)
147 DWORD dwRequired
, dwLength
;
151 rc
= RegQueryValueExW(
158 if (rc
!= ERROR_FILE_NOT_FOUND
)
160 if (rc
!= ERROR_SUCCESS
)
162 if (dwRegType
!= REG_MULTI_SZ
)
164 rc
= ERROR_GEN_FAILURE
;
168 dwTmp
= dwLength
= dwRequired
+ wcslen(ValueToAppend
) * sizeof(WCHAR
) + sizeof(UNICODE_NULL
);
169 Buffer
= HeapAlloc(GetProcessHeap(), 0, dwLength
);
172 rc
= ERROR_NOT_ENOUGH_MEMORY
;
175 rc
= RegQueryValueExW(
182 if (rc
!= ERROR_SUCCESS
)
187 dwRequired
= sizeof(WCHAR
);
188 dwLength
= wcslen(ValueToAppend
) * sizeof(WCHAR
) + 2 * sizeof(UNICODE_NULL
);
189 Buffer
= HeapAlloc(GetProcessHeap(), 0, dwLength
);
192 rc
= ERROR_NOT_ENOUGH_MEMORY
;
197 /* Append the value */
198 wcscpy(&Buffer
[dwRequired
/ sizeof(WCHAR
) - 1], ValueToAppend
);
199 /* Terminate the REG_MULTI_SZ string */
200 Buffer
[dwLength
/ sizeof(WCHAR
) - 1] = UNICODE_NULL
;
211 HeapFree(GetProcessHeap(), 0, Buffer
);
215 /* Install a section of a .inf file
216 * Returns TRUE if success, FALSE if failure. Error code can
217 * be retrieved with GetLastError()
223 IN LPCWSTR InfSection OPTIONAL
,
224 IN LPCWSTR InfService OPTIONAL
)
226 WCHAR Buffer
[MAX_PATH
];
227 HINF hInf
= INVALID_HANDLE_VALUE
;
229 PVOID Context
= NULL
;
232 /* Get Windows directory */
233 BufferSize
= MAX_PATH
- 5 - wcslen(InfFile
);
234 if (GetWindowsDirectoryW(Buffer
, BufferSize
) > BufferSize
)
236 /* Function failed */
237 SetLastError(ERROR_GEN_FAILURE
);
240 /* We have enough space to add some information in the buffer */
241 if (Buffer
[wcslen(Buffer
) - 1] != '\\')
242 wcscat(Buffer
, L
"\\");
243 wcscat(Buffer
, L
"Inf\\");
244 wcscat(Buffer
, InfFile
);
246 /* Install specified section */
247 hInf
= SetupOpenInfFileW(Buffer
, NULL
, INF_STYLE_WIN4
, NULL
);
248 if (hInf
== INVALID_HANDLE_VALUE
)
251 Context
= SetupInitDefaultQueueCallback(hWnd
);
256 if (ret
&& InfSection
)
258 ret
= SetupInstallFromInfSectionW(
260 InfSection
, SPINST_ALL
,
261 NULL
, NULL
, SP_COPY_NEWER
,
262 SetupDefaultQueueCallbackW
, Context
,
265 if (ret
&& InfService
)
267 ret
= SetupInstallServicesFromInfSectionW(
268 hInf
, InfService
, 0);
273 SetupTermDefaultQueueCallback(Context
);
274 if (hInf
!= INVALID_HANDLE_VALUE
)
275 SetupCloseInfFile(hInf
);
279 /* Add default services for network cards */
281 InstallAdditionalServices(
286 /* Install TCP/IP protocol */
287 ret
= InstallInfSection(
290 L
"MS_TCPIP.PrimaryInstall",
291 L
"MS_TCPIP.PrimaryInstall.Services");
292 if (!ret
&& GetLastError() != ERROR_FILE_NOT_FOUND
)
294 DPRINT("InstallInfSection() failed with error 0x%lx\n", GetLastError());
295 return GetLastError();
298 /* You can add here more clients (SMB...) and services (DHCP server...) */
300 return ERROR_SUCCESS
;
305 IN HDEVINFO DeviceInfoSet
,
306 IN PSP_DEVINFO_DATA DeviceInfoData
,
308 DWORD Characteristics
,
311 LPWSTR InstanceId
= NULL
;
312 LPWSTR DeviceName
= NULL
;
313 LPWSTR ExportName
= NULL
;
316 HKEY hNetworkKey
= NULL
;
317 HKEY hLinkageKey
= NULL
;
318 HKEY hConnectionKey
= NULL
;
319 DWORD dwShowIcon
, dwLength
;
320 SP_DEVINSTALL_PARAMS_W installParams
;
322 /* Get Instance ID */
323 if (SetupDiGetDeviceInstanceIdW(DeviceInfoSet
, DeviceInfoData
, NULL
, 0, &dwLength
))
325 DPRINT("SetupDiGetDeviceInstanceIdW() returned TRUE. FALSE expected\n");
326 rc
= ERROR_GEN_FAILURE
;
329 InstanceId
= HeapAlloc(GetProcessHeap(), 0, dwLength
* sizeof(WCHAR
));
332 DPRINT("HeapAlloc() failed\n");
333 rc
= ERROR_NOT_ENOUGH_MEMORY
;
336 if (!SetupDiGetDeviceInstanceIdW(DeviceInfoSet
, DeviceInfoData
, InstanceId
, dwLength
, NULL
))
339 DPRINT("SetupDiGetDeviceInstanceIdW() failed with error 0x%lx\n", rc
);
343 /* Create device name */
344 DeviceName
= HeapAlloc(GetProcessHeap(), 0, (wcslen(L
"\\Device\\") + wcslen(UuidString
)) * sizeof(WCHAR
) + sizeof(UNICODE_NULL
));
347 DPRINT("HeapAlloc() failed\n");
348 rc
= ERROR_NOT_ENOUGH_MEMORY
;
351 wcscpy(DeviceName
, L
"\\Device\\");
352 wcscat(DeviceName
, UuidString
);
354 /* Create export name */
355 ExportName
= HeapAlloc(GetProcessHeap(), 0, (wcslen(L
"\\Device\\Tcpip_") + wcslen(UuidString
)) * sizeof(WCHAR
) + sizeof(UNICODE_NULL
));
358 DPRINT("HeapAlloc() failed\n");
359 rc
= ERROR_NOT_ENOUGH_MEMORY
;
362 wcscpy(ExportName
, L
"\\Device\\Tcpip_");
363 wcscat(ExportName
, UuidString
);
365 /* Write Tcpip parameters in new service Key */
366 rc
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
, L
"SYSTEM\\CurrentControlSet\\Services", 0, NULL
, REG_OPTION_NON_VOLATILE
, 0, NULL
, &hKey
, NULL
);
367 if (rc
!= ERROR_SUCCESS
)
369 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
372 rc
= RegCreateKeyExW(hKey
, UuidString
, 0, NULL
, REG_OPTION_NON_VOLATILE
, 0, NULL
, &hNetworkKey
, NULL
);
373 if (rc
!= ERROR_SUCCESS
)
375 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
380 rc
= RegCreateKeyExW(hNetworkKey
, L
"Parameters\\Tcpip", 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_SET_VALUE
, NULL
, &hKey
, NULL
);
381 if (rc
!= ERROR_SUCCESS
)
383 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
386 RegCloseKey(hNetworkKey
);
388 rc
= RegSetValueExW(hKey
, L
"DefaultGateway", 0, REG_SZ
, (const BYTE
*)L
"0.0.0.0", (wcslen(L
"0.0.0.0") + 1) * sizeof(WCHAR
));
389 if (rc
!= ERROR_SUCCESS
)
391 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
394 rc
= RegSetValueExW(hKey
, L
"IPAddress", 0, REG_SZ
, (const BYTE
*)L
"0.0.0.0", (wcslen(L
"0.0.0.0") + 1) * sizeof(WCHAR
));
395 if (rc
!= ERROR_SUCCESS
)
397 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
400 rc
= RegSetValueExW(hKey
, L
"SubnetMask", 0, REG_SZ
, (const BYTE
*)L
"0.0.0.0", (wcslen(L
"0.0.0.0") + 1) * sizeof(WCHAR
));
401 if (rc
!= ERROR_SUCCESS
)
403 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
409 /* Write 'Linkage' key in hardware key */
410 #if _WIN32_WINNT >= 0x502
411 hKey
= SetupDiOpenDevRegKey(DeviceInfoSet
, DeviceInfoData
, DICS_FLAG_GLOBAL
, 0, DIREG_DRV
, KEY_READ
| KEY_WRITE
);
413 hKey
= SetupDiOpenDevRegKey(DeviceInfoSet
, DeviceInfoData
, DICS_FLAG_GLOBAL
, 0, DIREG_DRV
, KEY_ALL_ACCESS
);
415 if (hKey
== INVALID_HANDLE_VALUE
&& GetLastError() == ERROR_FILE_NOT_FOUND
)
416 hKey
= SetupDiCreateDevRegKeyW(DeviceInfoSet
, DeviceInfoData
, DICS_FLAG_GLOBAL
, 0, DIREG_DRV
, NULL
, NULL
);
417 if (hKey
== INVALID_HANDLE_VALUE
)
421 DPRINT("SetupDiCreateDevRegKeyW() failed with error 0x%lx\n", rc
);
424 rc
= RegSetValueExW(hKey
, L
"NetCfgInstanceId", 0, REG_SZ
, (const BYTE
*)UuidString
, (wcslen(UuidString
) + 1) * sizeof(WCHAR
));
425 if (rc
!= ERROR_SUCCESS
)
427 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
430 rc
= RegSetValueExW(hKey
, L
"Characteristics", 0, REG_DWORD
, (const BYTE
*)&Characteristics
, sizeof(DWORD
));
431 if (rc
!= ERROR_SUCCESS
)
433 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
437 rc
= RegSetValueExW(hKey
, L
"BusType", 0, REG_SZ
, (const BYTE
*)BusType
, (wcslen(BusType
) + 1) * sizeof(WCHAR
));
438 if (rc
!= ERROR_SUCCESS
)
440 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
443 rc
= RegCreateKeyExW(hKey
, L
"Linkage", 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_SET_VALUE
, NULL
, &hLinkageKey
, NULL
);
444 if (rc
!= ERROR_SUCCESS
)
446 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
449 rc
= RegSetValueExW(hLinkageKey
, L
"Export", 0, REG_SZ
, (const BYTE
*)DeviceName
, (wcslen(DeviceName
) + 1) * sizeof(WCHAR
));
450 if (rc
!= ERROR_SUCCESS
)
452 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
455 rc
= RegSetValueExW(hLinkageKey
, L
"RootDevice", 0, REG_SZ
, (const BYTE
*)UuidString
, (wcslen(UuidString
) + 1) * sizeof(WCHAR
));
456 if (rc
!= ERROR_SUCCESS
)
458 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
461 rc
= RegSetValueExW(hLinkageKey
, L
"UpperBind", 0, REG_SZ
, (const BYTE
*)L
"Tcpip", (wcslen(L
"Tcpip") + 1) * sizeof(WCHAR
));
462 if (rc
!= ERROR_SUCCESS
)
464 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
470 /* Write connection information in network subkey */
471 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
);
472 if (rc
!= ERROR_SUCCESS
)
474 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
477 rc
= RegCreateKeyExW(hNetworkKey
, UuidString
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_CREATE_SUB_KEY
, NULL
, &hKey
, NULL
);
478 if (rc
!= ERROR_SUCCESS
)
480 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
483 rc
= RegCreateKeyExW(hKey
, L
"Connection", 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_SET_VALUE
, NULL
, &hConnectionKey
, NULL
);
486 if (rc
!= ERROR_SUCCESS
)
488 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
491 rc
= RegSetValueExW(hConnectionKey
, L
"Name", 0, REG_SZ
, (const BYTE
*)L
"Network connection", (wcslen(L
"Network connection") + 1) * sizeof(WCHAR
));
492 if (rc
!= ERROR_SUCCESS
)
494 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
497 rc
= RegSetValueExW(hConnectionKey
, L
"PnpInstanceId", 0, REG_SZ
, (const BYTE
*)InstanceId
, (wcslen(InstanceId
) + 1) * sizeof(WCHAR
));
498 if (rc
!= ERROR_SUCCESS
)
500 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
504 rc
= RegSetValueExW(hConnectionKey
, L
"ShowIcon", 0, REG_DWORD
, (const BYTE
*)&dwShowIcon
, sizeof(dwShowIcon
));
505 if (rc
!= ERROR_SUCCESS
)
507 DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc
);
511 /* Write linkage information in Tcpip service */
512 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
);
513 if (rc
!= ERROR_SUCCESS
)
515 DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc
);
518 rc
= AppendStringToMultiSZ(hKey
, L
"Bind", DeviceName
);
519 if (rc
!= ERROR_SUCCESS
)
521 DPRINT("AppendStringToMultiSZ() failed with error 0x%lx\n", rc
);
524 rc
= AppendStringToMultiSZ(hKey
, L
"Export", ExportName
);
525 if (rc
!= ERROR_SUCCESS
)
527 DPRINT("AppendStringToMultiSZ() failed with error 0x%lx\n", rc
);
530 rc
= AppendStringToMultiSZ(hKey
, L
"Route", UuidString
);
531 if (rc
!= ERROR_SUCCESS
)
533 DPRINT("AppendStringToMultiSZ() failed with error 0x%lx\n", rc
);
537 /* Install additionnal services */
538 rc
= InstallAdditionalServices(NULL
);
539 if (rc
!= ERROR_SUCCESS
)
541 DPRINT("InstallAdditionalServices() failed with error 0x%lx\n", rc
);
545 /* HACK: hpoussin, Dec 2005. TCP/IP driver is not able to manage devices
546 * which are installed after its startup. So, we have to reboot to take
547 * this new netcard into account.
549 /* Should we reboot? */
550 installParams
.cbSize
= sizeof(SP_DEVINSTALL_PARAMS_W
);
551 if (!SetupDiGetDeviceInstallParamsW(
557 DPRINT("SetupDiGetDeviceInstallParams() failed with error 0x%lx\n", rc
);
560 installParams
.Flags
|= DI_NEEDRESTART
;
561 if (!SetupDiSetDeviceInstallParamsW(
567 DPRINT("SetupDiSetDeviceInstallParams() failed with error 0x%lx\n", rc
);
573 HeapFree(GetProcessHeap(), 0, InstanceId
);
574 HeapFree(GetProcessHeap(), 0, DeviceName
);
575 HeapFree(GetProcessHeap(), 0, ExportName
);
578 if (hNetworkKey
!= NULL
)
579 RegCloseKey(hNetworkKey
);
580 if (hLinkageKey
!= NULL
)
581 RegCloseKey(hLinkageKey
);
582 if (hConnectionKey
!= NULL
)
583 RegCloseKey(hConnectionKey
);
588 InstallNetClient(VOID
)
590 DPRINT1("Installation of network clients is not yet supported\n");
591 return ERROR_GEN_FAILURE
;
595 InstallNetService(VOID
)
597 DPRINT1("Installation of network services is not yet supported\n");
598 return ERROR_GEN_FAILURE
;
602 InstallNetTransport(VOID
)
604 DPRINT1("Installation of network protocols is not yet supported\n");
605 return ERROR_GEN_FAILURE
;
610 IN DI_FUNCTION InstallFunction
,
611 IN HDEVINFO DeviceInfoSet
,
612 IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
)
614 SP_DRVINFO_DATA_W DriverInfoData
;
615 SP_DRVINFO_DETAIL_DATA_W DriverInfoDetail
;
616 WCHAR SectionName
[LINE_LEN
];
617 HINF hInf
= INVALID_HANDLE_VALUE
;
618 INFCONTEXT InfContext
;
620 INT CharacteristicsInt
;
621 DWORD Characteristics
;
622 LPWSTR BusType
= NULL
;
623 RPC_STATUS RpcStatus
;
625 LPWSTR UuidRpcString
= NULL
;
626 LPWSTR UuidString
= NULL
;
630 if (InstallFunction
!= DIF_INSTALLDEVICE
)
631 return ERROR_DI_DO_DEFAULT
;
633 DPRINT("%lu %p %p\n", InstallFunction
, DeviceInfoSet
, DeviceInfoData
);
635 /* Get driver info details */
636 DriverInfoData
.cbSize
= sizeof(SP_DRVINFO_DATA_W
);
637 if (!SetupDiGetSelectedDriverW(DeviceInfoSet
, DeviceInfoData
, &DriverInfoData
))
640 DPRINT("SetupDiGetSelectedDriverW() failed with error 0x%lx\n", rc
);
643 DriverInfoDetail
.cbSize
= sizeof(SP_DRVINFO_DETAIL_DATA_W
);
644 if (!SetupDiGetDriverInfoDetailW(DeviceInfoSet
, DeviceInfoData
, &DriverInfoData
, &DriverInfoDetail
, sizeof(DriverInfoDetail
), NULL
)
645 && GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
648 DPRINT("SetupDiGetDriverInfoDetailW() failed with error 0x%lx\n", rc
);
651 hInf
= SetupOpenInfFileW(DriverInfoDetail
.InfFileName
, NULL
, INF_STYLE_WIN4
, &ErrorLine
);
652 if (hInf
== INVALID_HANDLE_VALUE
)
655 DPRINT("SetupOpenInfFileW() failed with error 0x%lx\n", rc
);
658 if (!SetupDiGetActualSectionToInstallW(hInf
, DriverInfoDetail
.SectionName
, SectionName
, LINE_LEN
, NULL
, NULL
))
661 DPRINT("SetupDiGetActualSectionToInstallW() failed with error 0x%lx\n", rc
);
665 /* Get Characteristics and BusType (optional) from .inf file */
666 if (!SetupFindFirstLineW(hInf
, SectionName
, L
"Characteristics", &InfContext
))
669 DPRINT("Unable to find key %S in section %S of file %S (error 0x%lx)\n",
670 L
"Characteristics", SectionName
, DriverInfoDetail
.InfFileName
, rc
);
673 if (!SetupGetIntField(&InfContext
, 1, &CharacteristicsInt
))
676 DPRINT("SetupGetIntField() failed with error 0x%lx\n", rc
);
679 Characteristics
= (DWORD
)CharacteristicsInt
;
680 if (IsEqualIID(&DeviceInfoData
->ClassGuid
, &GUID_DEVCLASS_NET
))
682 if (SetupFindFirstLineW(hInf
, SectionName
, L
"BusType", &InfContext
))
684 if (!SetupGetStringFieldW(&InfContext
, 1, NULL
, 0, &dwLength
))
687 DPRINT("SetupGetStringFieldW() failed with error 0x%lx\n", rc
);
690 BusType
= HeapAlloc(GetProcessHeap(), 0, dwLength
* sizeof(WCHAR
));
693 DPRINT("HeapAlloc() failed\n");
694 rc
= ERROR_NOT_ENOUGH_MEMORY
;
697 if (!SetupGetStringFieldW(&InfContext
, 1, BusType
, dwLength
, NULL
))
700 DPRINT("SetupGetStringFieldW() failed with error 0x%lx\n", rc
);
706 /* Create a new UUID */
707 RpcStatus
= UuidCreate(&Uuid
);
708 if (RpcStatus
!= RPC_S_OK
&& RpcStatus
!= RPC_S_UUID_LOCAL_ONLY
)
710 DPRINT("UuidCreate() failed with RPC status 0x%lx\n", RpcStatus
);
711 rc
= ERROR_GEN_FAILURE
;
714 RpcStatus
= UuidToStringW(&Uuid
, &UuidRpcString
);
715 if (RpcStatus
!= RPC_S_OK
)
717 DPRINT("UuidToStringW() failed with RPC status 0x%lx\n", RpcStatus
);
718 rc
= ERROR_GEN_FAILURE
;
722 /* Add curly braces around Uuid */
723 UuidString
= HeapAlloc(GetProcessHeap(), 0, (2 + wcslen(UuidRpcString
)) * sizeof(WCHAR
) + sizeof(UNICODE_NULL
));
726 DPRINT("HeapAlloc() failed\n");
727 rc
= ERROR_NOT_ENOUGH_MEMORY
;
730 wcscpy(UuidString
, L
"{");
731 wcscat(UuidString
, UuidRpcString
);
732 wcscat(UuidString
, L
"}");
734 if (IsEqualIID(&DeviceInfoData
->ClassGuid
, &GUID_DEVCLASS_NET
))
735 rc
= InstallNetDevice(DeviceInfoSet
, DeviceInfoData
, UuidString
, Characteristics
, BusType
);
736 else if (IsEqualIID(&DeviceInfoData
->ClassGuid
, &GUID_DEVCLASS_NETCLIENT
))
737 rc
= InstallNetClient();
738 else if (IsEqualIID(&DeviceInfoData
->ClassGuid
, &GUID_DEVCLASS_NETSERVICE
))
739 rc
= InstallNetService();
740 else if (IsEqualIID(&DeviceInfoData
->ClassGuid
, &GUID_DEVCLASS_NETTRANS
))
741 rc
= InstallNetTransport();
744 DPRINT("Invalid class guid\n");
745 rc
= ERROR_GEN_FAILURE
;
749 if (hInf
!= INVALID_HANDLE_VALUE
)
750 SetupCloseInfFile(hInf
);
751 if (UuidRpcString
!= NULL
)
752 RpcStringFreeW(&UuidRpcString
);
753 HeapFree(GetProcessHeap(), 0, BusType
);
754 HeapFree(GetProcessHeap(), 0, UuidString
);
756 if (rc
== ERROR_SUCCESS
)
757 rc
= ERROR_DI_DO_DEFAULT
;
758 DPRINT("Returning 0x%lx\n", rc
);