[KERNEL32] Improvements to Get/SetComputerNameExW

- The ComputerNamePhysicalDnsDomain name type gets or sets the 'NV Domain' registry value.
- The ComputerNamePhysicalDnsHostname name type gets or sets the 'NV Hostname' registry value.
- IsValidComputerName: Enforce name length restrictions according to the name type.
This commit is contained in:
Eric Kohl 2020-01-19 13:28:02 +01:00
parent 0f4827edde
commit c645660384

View file

@ -335,21 +335,24 @@ GetComputerNameExW(COMPUTER_NAME_FORMAT NameType,
case ComputerNamePhysicalDnsDomain:
return GetComputerNameFromRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
L"\\Services\\Tcpip\\Parameters",
L"Domain",
L"NV Domain",
lpBuffer,
nSize);
/* XXX Redo these */
/* XXX Redo this */
case ComputerNamePhysicalDnsFullyQualified:
return GetComputerNameExW(ComputerNameDnsFullyQualified,
lpBuffer,
nSize);
case ComputerNamePhysicalDnsHostname:
return GetComputerNameExW(ComputerNameDnsHostname,
lpBuffer,
nSize);
return GetComputerNameFromRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
L"\\Services\\Tcpip\\Parameters",
L"NV Hostname",
lpBuffer,
nSize);
/* XXX Redo this */
case ComputerNamePhysicalNetBIOS:
return GetComputerNameExW(ComputerNameNetBIOS,
lpBuffer,
@ -477,7 +480,14 @@ IsValidComputerName(COMPUTER_NAME_FORMAT NameType,
p++;
}
if (Length == 0 || Length > MAX_COMPUTERNAME_LENGTH)
if (NameType == ComputerNamePhysicalDnsDomain)
return TRUE;
if (Length == 0)
return FALSE;
if (NameType == ComputerNamePhysicalNetBIOS &&
Length > MAX_COMPUTERNAME_LENGTH)
return FALSE;
return TRUE;
@ -600,12 +610,12 @@ SetComputerNameExW(COMPUTER_NAME_FORMAT NameType,
return FALSE;
}
switch( NameType )
switch (NameType)
{
case ComputerNamePhysicalDnsDomain:
return SetComputerNameToRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
L"\\Services\\Tcpip\\Parameters",
L"Domain",
L"NV Domain",
lpBuffer);
case ComputerNamePhysicalDnsHostname: