fix some kernel32 environ winetests

svn path=/trunk/; revision=36020
This commit is contained in:
Christoph von Wittich 2008-09-07 09:19:49 +00:00
parent 714e5fdc39
commit 26fef2b1c8

View file

@ -88,6 +88,7 @@ static BOOL GetComputerNameFromRegistry( LPWSTR RegistryKey,
0, 0,
KeyInfo); KeyInfo);
ZwClose (KeyHandle); ZwClose (KeyHandle);
*nSize = ReturnSize;
SetLastErrorByStatus (Status); SetLastErrorByStatus (Status);
return FALSE; return FALSE;
} }
@ -95,6 +96,7 @@ static BOOL GetComputerNameFromRegistry( LPWSTR RegistryKey,
if( *nSize > (KeyInfo->DataLength / sizeof(WCHAR)) ) { if( *nSize > (KeyInfo->DataLength / sizeof(WCHAR)) ) {
*nSize = KeyInfo->DataLength / sizeof(WCHAR); *nSize = KeyInfo->DataLength / sizeof(WCHAR);
lpBuffer[*nSize] = 0; lpBuffer[*nSize] = 0;
(*nSize)--;
} }
RtlCopyMemory (lpBuffer, RtlCopyMemory (lpBuffer,
@ -103,8 +105,7 @@ static BOOL GetComputerNameFromRegistry( LPWSTR RegistryKey,
RtlFreeHeap (RtlGetProcessHeap (), RtlFreeHeap (RtlGetProcessHeap (),
0, 0,
KeyInfo) KeyInfo);
;
ZwClose (KeyHandle); ZwClose (KeyHandle);
return TRUE; return TRUE;
@ -124,6 +125,8 @@ GetComputerNameExW (
UNICODE_STRING DomainPart; UNICODE_STRING DomainPart;
RTL_QUERY_REGISTRY_TABLE QueryTable[2]; RTL_QUERY_REGISTRY_TABLE QueryTable[2];
NTSTATUS Status; NTSTATUS Status;
BOOL ret = TRUE;
DWORD HostSize;
switch( NameType ) { switch( NameType ) {
case ComputerNameNetBIOS: case ComputerNameNetBIOS:
@ -160,7 +163,11 @@ GetComputerNameExW (
QueryTable, NULL, NULL); QueryTable, NULL, NULL);
if( NT_SUCCESS(Status) ) { if( NT_SUCCESS(Status) ) {
RtlAppendUnicodeStringToString(&ResultString, &DomainPart); Status = RtlAppendUnicodeStringToString(&ResultString, &DomainPart);
HostSize = DomainPart.Length;
if (!NT_SUCCESS(Status)) {
ret = FALSE;
}
RtlAppendUnicodeToString(&ResultString, L"."); RtlAppendUnicodeToString(&ResultString, L".");
RtlFreeUnicodeString(&DomainPart); RtlFreeUnicodeString(&DomainPart);
@ -176,9 +183,15 @@ GetComputerNameExW (
QueryTable, NULL, NULL); QueryTable, NULL, NULL);
if( NT_SUCCESS(Status) ) { if( NT_SUCCESS(Status) ) {
RtlAppendUnicodeStringToString(&ResultString, &DomainPart); Status = RtlAppendUnicodeStringToString(&ResultString, &DomainPart);
if ( (!NT_SUCCESS(Status)) || (!ret)) {
*nSize = HostSize + DomainPart.Length;
SetLastError(ERROR_MORE_DATA);
RtlFreeUnicodeString(&DomainPart); RtlFreeUnicodeString(&DomainPart);
*nSize = ResultString.Length / sizeof(WCHAR); return FALSE;
}
RtlFreeUnicodeString(&DomainPart);
*nSize = ResultString.Length / sizeof(WCHAR) - 1;
return TRUE; return TRUE;
} }
} }
@ -245,8 +258,8 @@ GetComputerNameExA (
Result = GetComputerNameExW( NameType, TempBuffer, nSize ); Result = GetComputerNameExW( NameType, TempBuffer, nSize );
if( Result ) { if( Result ) {
UnicodeString.MaximumLength = (USHORT)*nSize * sizeof(WCHAR); UnicodeString.MaximumLength = (USHORT)*nSize * sizeof(WCHAR) + sizeof(WCHAR);
UnicodeString.Length = (USHORT)*nSize * sizeof(WCHAR); UnicodeString.Length = (USHORT)*nSize * sizeof(WCHAR) + sizeof(WCHAR);
UnicodeString.Buffer = TempBuffer; UnicodeString.Buffer = TempBuffer;
RtlUnicodeStringToAnsiString (&AnsiString, RtlUnicodeStringToAnsiString (&AnsiString,