33 PWSTR *OutEnvironment)
36 PVOID CurrentEnvironment, NewEnvironment =
NULL;
47 CurrentEnvironment =
NtCurrentPeb()->ProcessParameters->Environment;
48 if (CurrentEnvironment !=
NULL)
60 *OutEnvironment =
NULL;
75 *OutEnvironment =
NULL;
90 if (NewEnvironment ==
NULL)
105 *OutEnvironment = NewEnvironment;
149 DPRINT(
"RtlExpandEnvironmentStrings_U %p %wZ %p %p\n",
153 SourceBuffer =
Source->Buffer;
159 if (*SourceBuffer !=
L'%')
161 CopyBuffer = SourceBuffer;
163 while (SourceLength != 0 && *SourceBuffer !=
L'%')
174 VariableEnd = SourceBuffer + 1;
175 Tail = SourceLength - 1;
176 while (*VariableEnd !=
L'%' && Tail != 0)
186 Variable.
Buffer = SourceBuffer + 1;
190 Value.Buffer = DestBuffer;
196 SourceBuffer = VariableEnd + 1;
197 SourceLength = Tail - 1;
214 CopyBuffer = SourceBuffer;
215 CopyLength = SourceLength - Tail + 1;
216 SourceLength -= CopyLength;
217 SourceBuffer += CopyLength;
223 CopyBuffer = SourceBuffer;
224 CopyLength = SourceLength;
232 if (DestMax < CopyLength)
234 CopyLength = DestMax;
238 DestMax -= CopyLength;
239 DestBuffer += CopyLength;
264 PWSTR *OldEnvironment)
268 DPRINT(
"NewEnvironment 0x%p OldEnvironment 0x%p\n",
269 NewEnvironment, OldEnvironment);
273 EnvPtr =
NtCurrentPeb()->ProcessParameters->Environment;
274 NtCurrentPeb()->ProcessParameters->Environment = NewEnvironment;
276 if (OldEnvironment !=
NULL)
277 *OldEnvironment = EnvPtr;
293 size_t hole_len, new_len, env_len = 0;
300 DPRINT(
"RtlSetEnvironmentVariable(Environment %p Name %wZ Value %wZ)\n",
332 env_end +=
wcslen(env_end) + 1;
336 env_len = env_end -
env;
337 DPRINT(
"environment length %lu characters\n", env_len);
351 var.MaximumLength =
var.Length;
378 hole_len =
tail - hole;
383 new_size +=
Name->Length +
sizeof(
WCHAR);
384 new_len = new_size /
sizeof(
WCHAR);
385 if (hole_len < new_len)
389 new_size += (env_len - hole_len) *
sizeof(
WCHAR);
392 DPRINT(
"new_size %lu\n", new_size);
435 hole = new_env + (hole -
env);
440 tail = hole = new_env;
456 NtCurrentPeb()->ProcessParameters->Environment = new_env;
520 DPRINT(
"RtlQueryEnvironmentVariable_U Environment %p Variable %wZ Value %p\n",
568 DPRINT(
"Return STATUS_SUCCESS\n");
573 DPRINT(
"Return STATUS_BUFFER_TOO_SMALL\n");
589 DPRINT(
"Return STATUS_VARIABLE_NOT_FOUND: %wZ\n",
Name);
struct outqueuenode * tail
struct outqueuenode * head
static LPCWSTR LPCWSTR LPCWSTR env
#define NT_SUCCESS(StatCode)
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
#define ROUND_UP(n, align)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI void WINAPI RtlReleasePebLock(void)
NTSYSAPI void WINAPI RtlAcquirePebLock(void)
NTSYSAPI PEB *WINAPI RtlGetCurrentPeb(void)
#define memcpy(s1, s2, n)
#define memmove(s1, s2, n)
PVOID PVOID PWCHAR PVOID Environment
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
__kernel_entry _Inout_ _Inout_ PSIZE_T RegionSize
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define NtCurrentProcess()
_In_ ULONG _In_ ULONG _In_ ULONG Length
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
NTSTATUS NTAPI NtQueryVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, IN MEMORY_INFORMATION_CLASS MemoryInformationClass, OUT PVOID MemoryInformation, IN SIZE_T MemoryInformationLength, OUT PSIZE_T ReturnLength)
NTSTATUS NTAPI NtAllocateVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UBaseAddress, IN ULONG_PTR ZeroBits, IN OUT PSIZE_T URegionSize, IN ULONG AllocationType, IN ULONG Protect)
#define STATUS_NOT_IMPLEMENTED
#define STATUS_VARIABLE_NOT_FOUND
VOID NTAPI RtlSetCurrentEnvironment(PWSTR NewEnvironment, PWSTR *OldEnvironment)
NTSTATUS NTAPI RtlExpandEnvironmentStrings_U(PWSTR Environment, PUNICODE_STRING Source, PUNICODE_STRING Destination, PULONG Length)
NTSTATUS NTAPI RtlCreateEnvironment(BOOLEAN Inherit, PWSTR *OutEnvironment)
NTSTATUS NTAPI RtlSetEnvironmentStrings(IN PWCHAR NewEnvironment, IN ULONG NewEnvironmentSize)
VOID NTAPI RtlDestroyEnvironment(PWSTR Environment)
NTSTATUS NTAPI RtlSetEnvironmentVariable(PWSTR *Environment, PUNICODE_STRING Name, PUNICODE_STRING Value)
NTSTATUS NTAPI RtlQueryEnvironmentVariable_U(PWSTR Environment, PCUNICODE_STRING Name, PUNICODE_STRING Value)
#define STATUS_BUFFER_TOO_SMALL
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_INVALID_PARAMETER
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value