From 9a02e2c18be85a37116109268cce3aad58259124 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Sun, 17 Mar 2002 17:56:57 +0000 Subject: [PATCH] Fixed the return value in GetEnvironmentVariable(). svn path=/trunk/; revision=2728 --- reactos/lib/kernel32/misc/env.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/reactos/lib/kernel32/misc/env.c b/reactos/lib/kernel32/misc/env.c index 3d5831be639..bce42337196 100644 --- a/reactos/lib/kernel32/misc/env.c +++ b/reactos/lib/kernel32/misc/env.c @@ -1,4 +1,4 @@ -/* $Id: env.c,v 1.11 2000/07/01 17:07:00 ea Exp $ +/* $Id: env.c,v 1.12 2002/03/17 17:56:57 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -70,7 +70,14 @@ GetEnvironmentVariableA ( RtlFreeUnicodeString (&VarNameU); SetLastErrorByStatus (Status); - return 0; + if (Status == STATUS_BUFFER_TOO_SMALL) + { + return VarNameU.Length / sizeof(WCHAR) + 1; + } + else + { + return 0; + } } /* convert unicode value string to ansi */ @@ -115,7 +122,14 @@ GetEnvironmentVariableW ( if (!NT_SUCCESS(Status)) { SetLastErrorByStatus (Status); - return 0; + if (Status == STATUS_BUFFER_TOO_SMALL) + { + return (VarValue.Length / sizeof(WCHAR)) + 1; + } + else + { + return 0; + } } return (VarValue.Length / sizeof(WCHAR)); @@ -135,6 +149,8 @@ SetEnvironmentVariableA ( UNICODE_STRING VarValueU; NTSTATUS Status; + DPRINT("SetEnvironmentVariableA(Name '%s', Value '%s')\n", lpName, lpValue); + RtlInitAnsiString (&VarName, (LPSTR)lpName); RtlAnsiStringToUnicodeString (&VarNameU, @@ -175,6 +191,8 @@ SetEnvironmentVariableW ( UNICODE_STRING VarValue; NTSTATUS Status; + DPRINT("SetEnvironmentVariableW(Name '%S', Value '%S')\n", lpName, lpValue); + RtlInitUnicodeString (&VarName, lpName);