*/
DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
{
- DWORD ret, size;
+ DWORD ret, size, type;
LONG regReturn;
HKEY hKey;
PIPHLP_RES_INFO resInfo;
}
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);
NTSTATUS Status;
BOOL ret = TRUE;
DWORD HostSize;
- DWORD nBufferSize;
if ((nSize == NULL) ||
(lpBuffer == NULL && *nSize > 0))
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;
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;
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))
*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;
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: