[NETCFGX]

Formatting. No code changes!

svn path=/trunk/; revision=61273
This commit is contained in:
Eric Kohl 2013-12-14 20:27:45 +00:00
parent d0d5cf63bb
commit 5a9dd2eb87

View file

@ -102,8 +102,7 @@ STDAPI
DllGetClassObject(
REFCLSID rclsid,
REFIID riid,
LPVOID* ppv
)
LPVOID* ppv)
{
UINT i;
HRESULT hres = E_OUTOFMEMORY;
@ -139,7 +138,8 @@ DllGetClassObject(
* If the value doesn't exist, create it.
* Returns ERROR_SUCCESS if success. Othewise, returns an error code
*/
static LONG
static
LONG
AppendStringToMultiSZ(
IN HKEY hKey,
IN PCWSTR ValueName,
@ -151,8 +151,7 @@ AppendStringToMultiSZ(
DWORD dwTmp;
LONG rc;
rc = RegQueryValueExW(
hKey,
rc = RegQueryValueExW(hKey,
ValueName,
NULL,
&dwRegType,
@ -175,8 +174,8 @@ AppendStringToMultiSZ(
rc = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup;
}
rc = RegQueryValueExW(
hKey,
rc = RegQueryValueExW(hKey,
ValueName,
NULL,
NULL,
@ -202,8 +201,7 @@ AppendStringToMultiSZ(
/* Terminate the REG_MULTI_SZ string */
Buffer[dwLength / sizeof(WCHAR) - 1] = UNICODE_NULL;
rc = RegSetValueExW(
hKey,
rc = RegSetValueExW(hKey,
ValueName,
0,
REG_MULTI_SZ,
@ -219,7 +217,8 @@ cleanup:
* Returns TRUE if success, FALSE if failure. Error code can
* be retrieved with GetLastError()
*/
static BOOL
static
BOOL
InstallInfSection(
IN HWND hWnd,
IN LPCWSTR InfFile,
@ -280,7 +279,8 @@ cleanup:
}
/* Add default services for network cards */
static DWORD
static
DWORD
InstallAdditionalServices(
IN HWND hWnd)
{
@ -288,8 +288,7 @@ InstallAdditionalServices(
UNICODE_STRING TcpipServicePath = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\Tcpip");
/* Install TCP/IP protocol */
ret = InstallInfSection(
hWnd,
ret = InstallInfSection(hWnd,
L"nettcpip.inf",
L"MS_TCPIP.PrimaryInstall",
L"MS_TCPIP.PrimaryInstall.Services");
@ -315,7 +314,8 @@ InstallAdditionalServices(
return ERROR_SUCCESS;
}
static DWORD
static
DWORD
InstallNetDevice(
IN HDEVINFO DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData,
@ -341,6 +341,7 @@ InstallNetDevice(
rc = ERROR_GEN_FAILURE;
goto cleanup;
}
InstanceId = HeapAlloc(GetProcessHeap(), 0, dwLength * sizeof(WCHAR));
if (!InstanceId)
{
@ -348,6 +349,7 @@ InstallNetDevice(
rc = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup;
}
if (!SetupDiGetDeviceInstanceIdW(DeviceInfoSet, DeviceInfoData, InstanceId, dwLength, NULL))
{
rc = GetLastError();
@ -384,6 +386,7 @@ InstallNetDevice(
DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
rc = RegCreateKeyExW(hKey, UuidString, 0, NULL, REG_OPTION_NON_VOLATILE, 0, NULL, &hNetworkKey, NULL);
if (rc != ERROR_SUCCESS)
{
@ -392,6 +395,7 @@ InstallNetDevice(
}
RegCloseKey(hKey);
hKey = NULL;
rc = RegCreateKeyExW(hNetworkKey, L"Parameters\\Tcpip", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, NULL);
if (rc != ERROR_SUCCESS)
{
@ -400,24 +404,28 @@ InstallNetDevice(
}
RegCloseKey(hNetworkKey);
hNetworkKey = NULL;
rc = RegSetValueExW(hKey, L"DefaultGateway", 0, REG_SZ, (const BYTE*)L"0.0.0.0", (wcslen(L"0.0.0.0") + 1) * sizeof(WCHAR));
if (rc != ERROR_SUCCESS)
{
DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
rc = RegSetValueExW(hKey, L"IPAddress", 0, REG_SZ, (const BYTE*)L"0.0.0.0", (wcslen(L"0.0.0.0") + 1) * sizeof(WCHAR));
if (rc != ERROR_SUCCESS)
{
DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
rc = RegSetValueExW(hKey, L"SubnetMask", 0, REG_SZ, (const BYTE*)L"0.0.0.0", (wcslen(L"0.0.0.0") + 1) * sizeof(WCHAR));
if (rc != ERROR_SUCCESS)
{
DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
dwValue = 1;
rc = RegSetValueExW(hKey, L"EnableDHCP", 0, REG_DWORD, (const BYTE*)&dwValue, sizeof(DWORD));
if (rc != ERROR_SUCCESS)
@ -443,43 +451,52 @@ InstallNetDevice(
DPRINT("SetupDiCreateDevRegKeyW() failed with error 0x%lx\n", rc);
goto cleanup;
}
rc = RegSetValueExW(hKey, L"NetCfgInstanceId", 0, REG_SZ, (const BYTE*)UuidString, (wcslen(UuidString) + 1) * sizeof(WCHAR));
if (rc != ERROR_SUCCESS)
{
DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
rc = RegSetValueExW(hKey, L"Characteristics", 0, REG_DWORD, (const BYTE*)&Characteristics, sizeof(DWORD));
if (rc != ERROR_SUCCESS)
{
DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
if (BusType)
{
rc = RegSetValueExW(hKey, L"BusType", 0, REG_SZ, (const BYTE*)BusType, (wcslen(BusType) + 1) * sizeof(WCHAR));
if (rc != ERROR_SUCCESS)
{
DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
}
rc = RegCreateKeyExW(hKey, L"Linkage", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hLinkageKey, NULL);
if (rc != ERROR_SUCCESS)
{
DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
rc = RegSetValueExW(hLinkageKey, L"Export", 0, REG_SZ, (const BYTE*)DeviceName, (wcslen(DeviceName) + 1) * sizeof(WCHAR));
if (rc != ERROR_SUCCESS)
{
DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
rc = RegSetValueExW(hLinkageKey, L"RootDevice", 0, REG_SZ, (const BYTE*)UuidString, (wcslen(UuidString) + 1) * sizeof(WCHAR));
if (rc != ERROR_SUCCESS)
{
DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
rc = RegSetValueExW(hLinkageKey, L"UpperBind", 0, REG_SZ, (const BYTE*)L"Tcpip", (wcslen(L"Tcpip") + 1) * sizeof(WCHAR));
if (rc != ERROR_SUCCESS)
{
@ -496,12 +513,14 @@ InstallNetDevice(
DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
rc = RegCreateKeyExW(hNetworkKey, UuidString, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, NULL, &hKey, NULL);
if (rc != ERROR_SUCCESS)
{
DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
rc = RegCreateKeyExW(hKey, L"Connection", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hConnectionKey, NULL);
RegCloseKey(hKey);
hKey = NULL;
@ -510,22 +529,26 @@ InstallNetDevice(
DPRINT("RegCreateKeyExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
if (!LoadStringW(netcfgx_hInstance, IDS_NET_CONNECT, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
{
wcscpy(szBuffer,L"Network connection");
}
rc = RegSetValueExW(hConnectionKey, L"Name", 0, REG_SZ, (const BYTE*)szBuffer, (wcslen(szBuffer) + 1) * sizeof(WCHAR));
if (rc != ERROR_SUCCESS)
{
DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
rc = RegSetValueExW(hConnectionKey, L"PnpInstanceId", 0, REG_SZ, (const BYTE*)InstanceId, (wcslen(InstanceId) + 1) * sizeof(WCHAR));
if (rc != ERROR_SUCCESS)
{
DPRINT("RegSetValueExW() failed with error 0x%lx\n", rc);
goto cleanup;
}
dwShowIcon = 1;
rc = RegSetValueExW(hConnectionKey, L"ShowIcon", 0, REG_DWORD, (const BYTE*)&dwShowIcon, sizeof(dwShowIcon));
if (rc != ERROR_SUCCESS)
@ -585,28 +608,32 @@ cleanup:
return rc;
}
static DWORD
static
DWORD
InstallNetClient(VOID)
{
DPRINT1("Installation of network clients is not yet supported\n");
return ERROR_GEN_FAILURE;
}
static DWORD
static
DWORD
InstallNetService(VOID)
{
DPRINT1("Installation of network services is not yet supported\n");
return ERROR_GEN_FAILURE;
}
static DWORD
static
DWORD
InstallNetTransport(VOID)
{
DPRINT1("Installation of network protocols is not yet supported\n");
return ERROR_GEN_FAILURE;
}
DWORD WINAPI
DWORD
WINAPI
NetClassInstaller(
IN DI_FUNCTION InstallFunction,
IN HDEVINFO DeviceInfoSet,
@ -641,6 +668,7 @@ NetClassInstaller(
DPRINT("SetupDiGetSelectedDriverW() failed with error 0x%lx\n", rc);
goto cleanup;
}
DriverInfoDetail.cbSize = sizeof(SP_DRVINFO_DETAIL_DATA_W);
if (!SetupDiGetDriverInfoDetailW(DeviceInfoSet, DeviceInfoData, &DriverInfoData, &DriverInfoDetail, sizeof(DriverInfoDetail), NULL)
&& GetLastError() != ERROR_INSUFFICIENT_BUFFER)
@ -649,6 +677,7 @@ NetClassInstaller(
DPRINT("SetupDiGetDriverInfoDetailW() failed with error 0x%lx\n", rc);
goto cleanup;
}
hInf = SetupOpenInfFileW(DriverInfoDetail.InfFileName, NULL, INF_STYLE_WIN4, &ErrorLine);
if (hInf == INVALID_HANDLE_VALUE)
{
@ -656,6 +685,7 @@ NetClassInstaller(
DPRINT("SetupOpenInfFileW() failed with error 0x%lx\n", rc);
goto cleanup;
}
if (!SetupDiGetActualSectionToInstallW(hInf, DriverInfoDetail.SectionName, SectionName, LINE_LEN, NULL, NULL))
{
rc = GetLastError();
@ -671,12 +701,14 @@ NetClassInstaller(
L"Characteristics", SectionName, DriverInfoDetail.InfFileName, rc);
goto cleanup;
}
if (!SetupGetIntField(&InfContext, 1, &CharacteristicsInt))
{
rc = GetLastError();
DPRINT("SetupGetIntField() failed with error 0x%lx\n", rc);
goto cleanup;
}
Characteristics = (DWORD)CharacteristicsInt;
if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NET))
{
@ -688,6 +720,7 @@ NetClassInstaller(
DPRINT("SetupGetStringFieldW() failed with error 0x%lx\n", rc);
goto cleanup;
}
BusType = HeapAlloc(GetProcessHeap(), 0, dwLength * sizeof(WCHAR));
if (!BusType)
{
@ -695,6 +728,7 @@ NetClassInstaller(
rc = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup;
}
if (!SetupGetStringFieldW(&InfContext, 1, BusType, dwLength, NULL))
{
rc = GetLastError();
@ -712,6 +746,7 @@ NetClassInstaller(
rc = ERROR_GEN_FAILURE;
goto cleanup;
}
RpcStatus = UuidToStringW(&Uuid, &UuidRpcString);
if (RpcStatus != RPC_S_OK)
{
@ -728,6 +763,7 @@ NetClassInstaller(
rc = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup;
}
wcscpy(UuidString, L"{");
wcscat(UuidString, UuidRpcString);
wcscat(UuidString, L"}");