Commit 9c57e23d authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Implement RtlExpandEnvironmentStrings().

parent 3624b7c6
...@@ -281,21 +281,14 @@ done: ...@@ -281,21 +281,14 @@ done:
return nts; return nts;
} }
/****************************************************************** /******************************************************************************
* RtlExpandEnvironmentStrings_U (NTDLL.@) * RtlExpandEnvironmentStrings (NTDLL.@)
*
*/ */
NTSTATUS WINAPI RtlExpandEnvironmentStrings_U(PCWSTR renv, const UNICODE_STRING* us_src, NTSTATUS WINAPI RtlExpandEnvironmentStrings( const WCHAR *renv, WCHAR *src, SIZE_T src_len,
PUNICODE_STRING us_dst, PULONG plen) WCHAR *dst, SIZE_T count, SIZE_T *plen )
{ {
DWORD src_len, len, count, total_size = 1; /* 1 for terminating '\0' */ SIZE_T len, total_size = 1; /* 1 for terminating '\0' */
LPCWSTR env, src, p, var; LPCWSTR env, p, var;
LPWSTR dst;
src = us_src->Buffer;
src_len = us_src->Length / sizeof(WCHAR);
count = us_dst->MaximumLength / sizeof(WCHAR);
dst = count ? us_dst->Buffer : NULL;
if (!renv) if (!renv)
{ {
...@@ -353,15 +346,28 @@ NTSTATUS WINAPI RtlExpandEnvironmentStrings_U(PCWSTR renv, const UNICODE_STRING* ...@@ -353,15 +346,28 @@ NTSTATUS WINAPI RtlExpandEnvironmentStrings_U(PCWSTR renv, const UNICODE_STRING*
if (!renv) RtlReleasePebLock(); if (!renv) RtlReleasePebLock();
/* Null-terminate the string */
if (dst && count) *dst = '\0'; if (dst && count) *dst = '\0';
if (plen) *plen = total_size;
us_dst->Length = (dst) ? (dst - us_dst->Buffer) * sizeof(WCHAR) : 0;
if (plen) *plen = total_size * sizeof(WCHAR);
return (count) ? STATUS_SUCCESS : STATUS_BUFFER_TOO_SMALL; return (count) ? STATUS_SUCCESS : STATUS_BUFFER_TOO_SMALL;
} }
/******************************************************************
* RtlExpandEnvironmentStrings_U (NTDLL.@)
*/
NTSTATUS WINAPI RtlExpandEnvironmentStrings_U( const WCHAR *env, const UNICODE_STRING *src,
UNICODE_STRING *dst, ULONG *plen )
{
SIZE_T len;
NTSTATUS ret;
ret = RtlExpandEnvironmentStrings( env, src->Buffer, src->Length / sizeof(WCHAR),
dst->Buffer, dst->MaximumLength / sizeof(WCHAR), &len );
if (plen) *plen = len * sizeof(WCHAR); /* FIXME: check for overflow? */
if (len > UNICODE_STRING_MAX_CHARS) ret = STATUS_BUFFER_TOO_SMALL;
if (!ret) dst->Length = (len - 1) * sizeof(WCHAR);
return ret;
}
static inline void normalize( void *base, WCHAR **ptr ) static inline void normalize( void *base, WCHAR **ptr )
{ {
......
...@@ -596,6 +596,7 @@ ...@@ -596,6 +596,7 @@
@ stdcall RtlEraseUnicodeString(ptr) @ stdcall RtlEraseUnicodeString(ptr)
@ stdcall RtlExitUserProcess(long) @ stdcall RtlExitUserProcess(long)
@ stdcall RtlExitUserThread(long) @ stdcall RtlExitUserThread(long)
@ stdcall RtlExpandEnvironmentStrings(ptr wstr long ptr long ptr)
@ stdcall RtlExpandEnvironmentStrings_U(ptr ptr ptr ptr) @ stdcall RtlExpandEnvironmentStrings_U(ptr ptr ptr ptr)
@ stub RtlExtendHeap @ stub RtlExtendHeap
@ stdcall -arch=win32 -ret64 RtlExtendedIntegerMultiply(int64 long) @ stdcall -arch=win32 -ret64 RtlExtendedIntegerMultiply(int64 long)
......
...@@ -2630,6 +2630,7 @@ NTSYSAPI BOOLEAN WINAPI RtlEqualString(const STRING*,const STRING*,BOOLEAN); ...@@ -2630,6 +2630,7 @@ NTSYSAPI BOOLEAN WINAPI RtlEqualString(const STRING*,const STRING*,BOOLEAN);
NTSYSAPI BOOLEAN WINAPI RtlEqualUnicodeString(const UNICODE_STRING*,const UNICODE_STRING*,BOOLEAN); NTSYSAPI BOOLEAN WINAPI RtlEqualUnicodeString(const UNICODE_STRING*,const UNICODE_STRING*,BOOLEAN);
NTSYSAPI void DECLSPEC_NORETURN WINAPI RtlExitUserProcess(ULONG); NTSYSAPI void DECLSPEC_NORETURN WINAPI RtlExitUserProcess(ULONG);
NTSYSAPI void DECLSPEC_NORETURN WINAPI RtlExitUserThread(ULONG); NTSYSAPI void DECLSPEC_NORETURN WINAPI RtlExitUserThread(ULONG);
NTSYSAPI NTSTATUS WINAPI RtlExpandEnvironmentStrings(const WCHAR*,WCHAR*,SIZE_T,WCHAR*,SIZE_T,SIZE_T*);
NTSYSAPI NTSTATUS WINAPI RtlExpandEnvironmentStrings_U(PCWSTR, const UNICODE_STRING*, UNICODE_STRING*, ULONG*); NTSYSAPI NTSTATUS WINAPI RtlExpandEnvironmentStrings_U(PCWSTR, const UNICODE_STRING*, UNICODE_STRING*, ULONG*);
NTSYSAPI NTSTATUS WINAPI RtlFindActivationContextSectionString(ULONG,const GUID*,ULONG,const UNICODE_STRING*,PVOID); NTSYSAPI NTSTATUS WINAPI RtlFindActivationContextSectionString(ULONG,const GUID*,ULONG,const UNICODE_STRING*,PVOID);
NTSYSAPI NTSTATUS WINAPI RtlFindActivationContextSectionGuid(ULONG,const GUID*,ULONG,const GUID*,PVOID); NTSYSAPI NTSTATUS WINAPI RtlFindActivationContextSectionGuid(ULONG,const GUID*,ULONG,const GUID*,PVOID);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment