Alexandre Julliard : ntdll: Allocate process parameters on the heap in RtlCreateProcessParametersEx() .
Alexandre Julliard
julliard at winehq.org
Tue Oct 16 15:53:07 CDT 2018
Module: wine
Branch: master
Commit: b5d4484cd2993e0b7d9ecb15ca756d4b2ce983c0
URL: https://source.winehq.org/git/wine.git/?a=commit;h=b5d4484cd2993e0b7d9ecb15ca756d4b2ce983c0
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Oct 16 20:45:31 2018 +0200
ntdll: Allocate process parameters on the heap in RtlCreateProcessParametersEx().
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/env.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c
index 1d34e62..37224a4 100644
--- a/dlls/ntdll/env.c
+++ b/dlls/ntdll/env.c
@@ -460,10 +460,10 @@ NTSTATUS WINAPI RtlCreateProcessParametersEx( RTL_USER_PROCESS_PARAMETERS **resu
UNICODE_STRING curdir;
const RTL_USER_PROCESS_PARAMETERS *cur_params;
- SIZE_T size, env_size, total_size;
+ SIZE_T size, env_size;
void *ptr;
const WCHAR *env;
- NTSTATUS status;
+ NTSTATUS status = STATUS_SUCCESS;
RtlAcquirePebLock();
cur_params = NtCurrentTeb()->Peb->ProcessParameters;
@@ -500,13 +500,10 @@ NTSTATUS WINAPI RtlCreateProcessParametersEx( RTL_USER_PROCESS_PARAMETERS **resu
+ ROUND_SIZE( ShellInfo->MaximumLength )
+ ROUND_SIZE( RuntimeInfo->MaximumLength ));
- total_size = size + env_size;
- ptr = NULL;
- if ((status = NtAllocateVirtualMemory( NtCurrentProcess(), &ptr, 0, &total_size,
- MEM_COMMIT, PAGE_READWRITE )) == STATUS_SUCCESS)
+ if ((ptr = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, size + env_size )))
{
RTL_USER_PROCESS_PARAMETERS *params = ptr;
- params->AllocationSize = total_size;
+ params->AllocationSize = size;
params->Size = size;
params->Flags = PROCESS_PARAMS_FLAG_NORMALIZED;
params->ConsoleFlags = cur_params->ConsoleFlags;
@@ -526,6 +523,8 @@ NTSTATUS WINAPI RtlCreateProcessParametersEx( RTL_USER_PROCESS_PARAMETERS **resu
*result = params;
if (!(flags & PROCESS_PARAMS_FLAG_NORMALIZED)) RtlDeNormalizeProcessParams( params );
}
+ else status = STATUS_NO_MEMORY;
+
RtlReleasePebLock();
return status;
}
@@ -555,7 +554,5 @@ NTSTATUS WINAPI RtlCreateProcessParameters( RTL_USER_PROCESS_PARAMETERS **result
*/
void WINAPI RtlDestroyProcessParameters( RTL_USER_PROCESS_PARAMETERS *params )
{
- void *ptr = params;
- SIZE_T size = 0;
- NtFreeVirtualMemory( NtCurrentProcess(), &ptr, &size, MEM_RELEASE );
+ RtlFreeHeap( GetProcessHeap(), 0, params );
}
More information about the wine-cvs
mailing list