Index: dll/win32/iphlpapi/iphlpapi_main.c =================================================================== --- dll/win32/iphlpapi/iphlpapi_main.c (revision 72796) +++ dll/win32/iphlpapi/iphlpapi_main.c (working copy) @@ -1404,7 +1404,7 @@ */ DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen) { - DWORD ret, size; + DWORD ret, size, type; LONG regReturn; HKEY hKey; PIPHLP_RES_INFO resInfo; @@ -1426,11 +1426,60 @@ } memset(pFixedInfo, 0, size); - size = sizeof(pFixedInfo->HostName); - GetComputerNameExA(ComputerNameDnsHostname, pFixedInfo->HostName, &size); - size = sizeof(pFixedInfo->DomainName); - GetComputerNameExA(ComputerNameDnsDomain, pFixedInfo->DomainName, &size); + /* Check for DhcpHostname and DhcpDomain first */ + regReturn = RegOpenKeyExA(HKEY_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", + 0, + KEY_READ, + &hKey); + if (regReturn == ERROR_SUCCESS) { + /* Windows doesn't honor DHCP option 12 even if RFC requires it if it is returned by DHCP server! */ +#if 0 + type = REG_SZ; + size = sizeof(pFixedInfo->HostName); + regReturn = RegQueryValueExA(hKey, + "DhcpHostname", + NULL, + &type, + (LPBYTE)pFixedInfo->HostName, + &size); + if (regReturn == ERROR_FILE_NOT_FOUND || (regReturn == ERROR_SUCCESS && size < 1)) + { +#endif + type = REG_SZ; + size = sizeof(pFixedInfo->HostName); + regReturn = RegQueryValueExA(hKey, + "Hostname", + NULL, + &type, + (LPBYTE)pFixedInfo->HostName, + &size); +#if 0 + } +#endif + type = REG_SZ; + size = sizeof(pFixedInfo->DomainName); + regReturn = RegQueryValueExA(hKey, + "DhcpDomain", + NULL, + &type, + (LPBYTE)pFixedInfo->DomainName, + &size); + if (regReturn == ERROR_FILE_NOT_FOUND || (regReturn == ERROR_SUCCESS && size < 1)) + { + type = REG_SZ; + size = sizeof(pFixedInfo->DomainName); + regReturn = RegQueryValueExA(hKey, + "Domain", + NULL, + &type, + (LPBYTE)pFixedInfo->DomainName, + &size); + } + RegCloseKey(hKey); + } + TRACE("GetComputerNameExA: %s\n", pFixedInfo->DomainName); if (resInfo->riCount > 0) Index: dll/win32/kernel32/client/compname.c =================================================================== --- dll/win32/kernel32/client/compname.c (revision 72796) +++ dll/win32/kernel32/client/compname.c (working copy) @@ -137,7 +137,6 @@ NTSTATUS Status; BOOL ret = TRUE; DWORD HostSize; - DWORD nBufferSize; if ((nSize == NULL) || (lpBuffer == NULL && *nSize > 0)) @@ -156,27 +155,11 @@ nSize); case ComputerNameDnsDomain: - /* Save original buffer size for the second call if neccessery */ - nBufferSize = *nSize; - if (!GetComputerNameFromRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet" - L"\\Services\\Tcpip\\Parameters", - L"DhcpDomain", - lpBuffer, - nSize)) - { - /* The value is there, just the buffer is insufficient in length */ - if (GetLastError() == ERROR_MORE_DATA) - return FALSE; - /* Restore original buffer size for the second call */ - *nSize = nBufferSize; - return GetComputerNameFromRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet" - L"\\Services\\Tcpip\\Parameters", - L"Domain", - lpBuffer, - nSize); - } - else - return TRUE; + return GetComputerNameFromRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet" + L"\\Services\\Tcpip\\Parameters", + L"Domain", + lpBuffer, + nSize); case ComputerNameDnsFullyQualified: ResultString.Length = 0; @@ -212,7 +195,7 @@ RtlFreeUnicodeString(&DomainPart); RtlInitUnicodeString(&DomainPart, NULL); - QueryTable[0].Name = L"DhcpDomain"; + QueryTable[0].Name = L"Domain"; QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; QueryTable[0].EntryContext = &DomainPart; @@ -224,9 +207,7 @@ NULL, NULL); - if ((NT_SUCCESS(Status)) && - (DomainPart.Buffer != NULL) && - (wcslen(DomainPart.Buffer) > 0)) + if (NT_SUCCESS(Status)) { Status = RtlAppendUnicodeStringToString(&ResultString, &DomainPart); if ((!NT_SUCCESS(Status)) || (!ret)) @@ -240,36 +221,6 @@ *nSize = ResultString.Length / sizeof(WCHAR) - 1; return TRUE; } - else - { - RtlInitUnicodeString(&DomainPart, NULL); - QueryTable[0].Name = L"Domain"; - QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; - QueryTable[0].EntryContext = &DomainPart; - - Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, - L"\\Registry\\Machine\\System" - L"\\CurrentControlSet\\Services\\Tcpip" - L"\\Parameters", - QueryTable, - NULL, - NULL); - - if (NT_SUCCESS(Status)) - { - Status = RtlAppendUnicodeStringToString(&ResultString, &DomainPart); - if ((!NT_SUCCESS(Status)) || (!ret)) - { - *nSize = HostSize + DomainPart.Length; - SetLastError(ERROR_MORE_DATA); - RtlFreeUnicodeString(&DomainPart); - return FALSE; - } - RtlFreeUnicodeString(&DomainPart); - *nSize = ResultString.Length / sizeof(WCHAR) - 1; - return TRUE; - } - } } return FALSE; @@ -281,9 +232,11 @@ nSize); case ComputerNamePhysicalDnsDomain: - return GetComputerNameExW(ComputerNameDnsDomain, - lpBuffer, - nSize); + return GetComputerNameFromRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet" + L"\\Services\\Tcpip\\Parameters", + L"Domain", + lpBuffer, + nSize); /* XXX Redo these */ case ComputerNamePhysicalDnsFullyQualified: