mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
Part of patch contributed by Gunnar Andr� Dalsnes.
svn path=/trunk/; revision=3641
This commit is contained in:
parent
db067a2011
commit
bab254e373
2 changed files with 48 additions and 25 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: curdir.c,v 1.31 2002/09/08 10:22:41 chorns Exp $
|
||||
/* $Id: curdir.c,v 1.32 2002/10/20 03:33:34 robd Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -250,29 +250,35 @@ GetSystemDirectoryA (
|
|||
{
|
||||
ANSI_STRING String;
|
||||
ULONG Length;
|
||||
NTSTATUS Status;
|
||||
|
||||
if (lpBuffer == NULL)
|
||||
return 0;
|
||||
|
||||
Length = RtlUnicodeStringToAnsiSize (&SystemDirectory);
|
||||
if (uSize > Length)
|
||||
{
|
||||
Length = RtlUnicodeStringToAnsiSize (&SystemDirectory); //len of ansi str incl. nullchar
|
||||
|
||||
if (uSize >= Length){
|
||||
String.Length = 0;
|
||||
String.MaximumLength = uSize;
|
||||
String.Buffer = lpBuffer;
|
||||
|
||||
/* convert unicode string to ansi (or oem) */
|
||||
if (bIsFileApiAnsi)
|
||||
RtlUnicodeStringToAnsiString (&String,
|
||||
Status = RtlUnicodeStringToAnsiString (&String,
|
||||
&SystemDirectory,
|
||||
FALSE);
|
||||
else
|
||||
RtlUnicodeStringToOemString (&String,
|
||||
Status = RtlUnicodeStringToOemString (&String,
|
||||
&SystemDirectory,
|
||||
FALSE);
|
||||
if (!NT_SUCCESS(Status) )
|
||||
return 0;
|
||||
|
||||
return Length-1; //good: ret chars excl. nullchar
|
||||
|
||||
}
|
||||
|
||||
return Length;
|
||||
return Length; //bad: ret space needed incl. nullchar
|
||||
}
|
||||
|
||||
|
||||
|
@ -289,15 +295,16 @@ GetSystemDirectoryW (
|
|||
return 0;
|
||||
|
||||
Length = SystemDirectory.Length / sizeof (WCHAR);
|
||||
if (uSize > Length)
|
||||
{
|
||||
if (uSize > Length) {
|
||||
memmove (lpBuffer,
|
||||
SystemDirectory.Buffer,
|
||||
SystemDirectory.Length);
|
||||
lpBuffer[Length] = 0;
|
||||
|
||||
return Length; //good: ret chars excl. nullchar
|
||||
}
|
||||
|
||||
return Length;
|
||||
return Length+1; //bad: ret space needed incl. nullchar
|
||||
}
|
||||
|
||||
|
||||
|
@ -310,29 +317,43 @@ GetWindowsDirectoryA (
|
|||
{
|
||||
ANSI_STRING String;
|
||||
ULONG Length;
|
||||
NTSTATUS Status;
|
||||
|
||||
if (lpBuffer == NULL)
|
||||
return 0;
|
||||
|
||||
Length = RtlUnicodeStringToAnsiSize (&WindowsDirectory);
|
||||
if (uSize > Length)
|
||||
{
|
||||
Length = RtlUnicodeStringToAnsiSize (&WindowsDirectory); //len of ansi str incl. nullchar
|
||||
|
||||
printf("windirlen incl term %i\n", Length);
|
||||
|
||||
if (uSize >= Length){
|
||||
|
||||
printf("ok: enoug space\n");
|
||||
|
||||
String.Length = 0;
|
||||
String.MaximumLength = uSize;
|
||||
String.Buffer = lpBuffer;
|
||||
|
||||
/* convert unicode string to ansi (or oem) */
|
||||
if (bIsFileApiAnsi)
|
||||
RtlUnicodeStringToAnsiString (&String,
|
||||
Status = RtlUnicodeStringToAnsiString (&String,
|
||||
&WindowsDirectory,
|
||||
FALSE);
|
||||
else
|
||||
RtlUnicodeStringToOemString (&String,
|
||||
Status = RtlUnicodeStringToOemString (&String,
|
||||
&WindowsDirectory,
|
||||
FALSE);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
return 0;
|
||||
|
||||
printf("good: ret chars %i\n",Length-1);
|
||||
printf("dir: %s\n",lpBuffer);
|
||||
return Length-1; //good: ret chars excl. nullchar
|
||||
}
|
||||
|
||||
return Length;
|
||||
printf("bad: ret chars needed %i\n",Length);
|
||||
return Length; //bad: ret space needed incl. nullchar
|
||||
}
|
||||
|
||||
|
||||
|
@ -355,9 +376,11 @@ GetWindowsDirectoryW (
|
|||
WindowsDirectory.Buffer,
|
||||
WindowsDirectory.Length);
|
||||
lpBuffer[Length] = 0;
|
||||
|
||||
return Length; //good: ret chars excl. nullchar
|
||||
}
|
||||
|
||||
return Length;
|
||||
return Length+1; //bad: ret space needed incl. nullchar
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: unicode.c,v 1.23 2002/09/17 23:41:44 dwelch Exp $
|
||||
/* $Id: unicode.c,v 1.24 2002/10/20 03:34:00 robd Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -1122,7 +1122,7 @@ RtlUnicodeStringToAnsiSize (
|
|||
UnicodeString->Buffer,
|
||||
UnicodeString->Length);
|
||||
|
||||
return Size;
|
||||
return Size+1; //NB: incl. nullterm
|
||||
}
|
||||
|
||||
|
||||
|
@ -1286,7 +1286,7 @@ RtlUnicodeStringToOemSize (
|
|||
UnicodeString->Buffer,
|
||||
UnicodeString->Length);
|
||||
|
||||
return Size;
|
||||
return Size+1; //NB: incl. nullterm
|
||||
}
|
||||
|
||||
|
||||
|
@ -1303,7 +1303,7 @@ RtlUnicodeStringToCountedOemString (
|
|||
ULONG Size;
|
||||
|
||||
if (NlsMbOemCodePageTag == TRUE)
|
||||
Length = RtlUnicodeStringToAnsiSize (SourceString) + 1;
|
||||
Length = RtlUnicodeStringToAnsiSize (SourceString)/* + 1*/;
|
||||
else
|
||||
Length = SourceString->Length / sizeof(WCHAR) + 1;
|
||||
|
||||
|
@ -1370,7 +1370,7 @@ RtlUnicodeStringToOemString (
|
|||
ULONG Size;
|
||||
|
||||
if (NlsMbOemCodePageTag == TRUE)
|
||||
Length = RtlUnicodeStringToAnsiSize (SourceString) + 1;
|
||||
Length = RtlUnicodeStringToAnsiSize (SourceString)/* + 1*/;
|
||||
else
|
||||
Length = SourceString->Length / sizeof(WCHAR) + 1;
|
||||
|
||||
|
@ -1496,7 +1496,7 @@ RtlUpcaseUnicodeStringToAnsiString (
|
|||
ULONG Size;
|
||||
|
||||
if (NlsMbCodePageTag == TRUE)
|
||||
Length = RtlUnicodeStringToAnsiSize (SourceString) + 1;
|
||||
Length = RtlUnicodeStringToAnsiSize (SourceString)/* + 1*/;
|
||||
else
|
||||
Length = SourceString->Length / sizeof(WCHAR) + 1;
|
||||
|
||||
|
@ -1563,7 +1563,7 @@ RtlUpcaseUnicodeStringToCountedOemString (
|
|||
ULONG Size;
|
||||
|
||||
if (NlsMbCodePageTag == TRUE)
|
||||
Length = RtlUnicodeStringToAnsiSize (SourceString) + 1;
|
||||
Length = RtlUnicodeStringToAnsiSize (SourceString)/* + 1*/;
|
||||
else
|
||||
Length = SourceString->Length / sizeof(WCHAR) + 1;
|
||||
|
||||
|
@ -1630,7 +1630,7 @@ RtlUpcaseUnicodeStringToOemString (
|
|||
ULONG Size;
|
||||
|
||||
if (NlsMbOemCodePageTag == TRUE)
|
||||
Length = RtlUnicodeStringToAnsiSize (SourceString) + 1;
|
||||
Length = RtlUnicodeStringToAnsiSize (SourceString)/* + 1*/;
|
||||
else
|
||||
Length = SourceString->Length / sizeof(WCHAR) + 1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue