Fix NtAllocateVirtualMemory declaration and fix users of the

function.
This commit is contained in:
Robert Shearman 2004-10-11 20:59:06 +00:00 committed by Alexandre Julliard
parent ace5f3c6ed
commit 2050591370
9 changed files with 40 additions and 28 deletions

View File

@ -379,6 +379,7 @@ static BOOL build_initial_environment( char **environ )
size *= sizeof(WCHAR);
/* Now allocate the environment */
ptr = NULL;
if (NtAllocateVirtualMemory(NtCurrentProcess(), &ptr, 0, &size,
MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE) != STATUS_SUCCESS)
return FALSE;
@ -719,7 +720,8 @@ static RTL_USER_PROCESS_PARAMETERS *init_user_process_params( size_t info_size )
RTL_USER_PROCESS_PARAMETERS *params;
size = info_size;
if (NtAllocateVirtualMemory( NtCurrentProcess(), &ptr, NULL, &size,
ptr = NULL;
if (NtAllocateVirtualMemory( NtCurrentProcess(), &ptr, 0, &size,
MEM_COMMIT, PAGE_READWRITE ) != STATUS_SUCCESS)
return NULL;
@ -748,7 +750,8 @@ static RTL_USER_PROCESS_PARAMETERS *init_user_process_params( size_t info_size )
/* environment needs to be a separate memory block */
env_size = info_size - params->Size;
if (!env_size) env_size = 1;
if (NtAllocateVirtualMemory( NtCurrentProcess(), &ptr, NULL, &env_size,
ptr = NULL;
if (NtAllocateVirtualMemory( NtCurrentProcess(), &ptr, 0, &env_size,
MEM_COMMIT, PAGE_READWRITE ) != STATUS_SUCCESS)
return NULL;
memcpy( ptr, (char *)params + params->Size, info_size - params->Size );

View File

@ -86,10 +86,10 @@ LPVOID WINAPI VirtualAllocEx(
DWORD type, /* [in] Type of allocation */
DWORD protect ) /* [in] Type of access protection */
{
LPVOID ret;
LPVOID ret = addr;
NTSTATUS status;
if ((status = NtAllocateVirtualMemory( hProcess, &ret, addr, &size, type, protect )))
if ((status = NtAllocateVirtualMemory( hProcess, &ret, 0, &size, type, protect )))
{
SetLastError( RtlNtStatusToDosError(status) );
ret = NULL;

View File

@ -65,10 +65,10 @@ NTSTATUS WINAPI RtlCreateEnvironment(BOOLEAN inherit, PWSTR* env)
else
{
ULONG size = 1;
nts = NtAllocateVirtualMemory(NtCurrentProcess(), (void**)env, 0, &size,
PVOID addr = NULL;
nts = NtAllocateVirtualMemory(NtCurrentProcess(), &addr, 0, &size,
MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if (nts == STATUS_SUCCESS)
memset(*env, 0, size);
if (nts == STATUS_SUCCESS) *env = addr;
}
return nts;
@ -446,7 +446,8 @@ NTSTATUS WINAPI RtlCreateProcessParameters( RTL_USER_PROCESS_PARAMETERS **result
+ RuntimeInfo->MaximumLength);
total_size = size;
if ((status = NtAllocateVirtualMemory( NtCurrentProcess(), &ptr, NULL, &total_size,
ptr = NULL;
if ((status = NtAllocateVirtualMemory( NtCurrentProcess(), &ptr, 0, &total_size,
MEM_COMMIT, PAGE_READWRITE )) == STATUS_SUCCESS)
{
RTL_USER_PROCESS_PARAMETERS *params = ptr;

View File

@ -343,12 +343,12 @@ static inline BOOL HEAP_Commit( SUBHEAP *subheap, void *ptr )
if (size > subheap->size) size = subheap->size;
if (size <= subheap->commitSize) return TRUE;
size -= subheap->commitSize;
if (NtAllocateVirtualMemory( GetCurrentProcess(), &ptr, (char *)subheap + subheap->commitSize,
ptr = (char *)subheap + subheap->commitSize;
if (NtAllocateVirtualMemory( GetCurrentProcess(), &ptr, 0,
&size, MEM_COMMIT, PAGE_EXECUTE_READWRITE))
{
WARN("Could not commit %08lx bytes at %08lx for heap %08lx\n",
size, (DWORD)((char *)subheap + subheap->commitSize),
(DWORD)subheap->heap );
WARN("Could not commit %08lx bytes at %p for heap %p\n",
size, ptr, subheap->heap );
return FALSE;
}
subheap->commitSize += size;
@ -530,7 +530,7 @@ static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags,
if (flags & HEAP_SHARED)
commitSize = totalSize; /* always commit everything in a shared heap */
if (NtAllocateVirtualMemory( GetCurrentProcess(), &address, address,
if (NtAllocateVirtualMemory( GetCurrentProcess(), &address, 0,
&commitSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE))
{
WARN("Could not commit %08lx bytes for sub-heap %p\n", commitSize, address );
@ -619,7 +619,7 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, void *base, DWORD flags,
if (!address)
{
/* allocate the memory block */
if (NtAllocateVirtualMemory( GetCurrentProcess(), &address, NULL, &totalSize,
if (NtAllocateVirtualMemory( GetCurrentProcess(), &address, 0, &totalSize,
MEM_RESERVE, PAGE_EXECUTE_READWRITE ))
{
WARN("Could not allocate %08lx bytes\n", totalSize );

View File

@ -1139,7 +1139,8 @@ static void load_builtin_callback( void *module, const char *filename )
return;
}
wm->ldr.Flags |= LDR_WINE_INTERNAL;
NtAllocateVirtualMemory( GetCurrentProcess(), &addr, module, &nt->OptionalHeader.SizeOfImage,
addr = module;
NtAllocateVirtualMemory( GetCurrentProcess(), &addr, 0, &nt->OptionalHeader.SizeOfImage,
MEM_SYSTEM | MEM_IMAGE, PAGE_EXECUTE_WRITECOPY );
/* fixup imports */

View File

@ -841,7 +841,8 @@ void SNOOP_SetupDLL(HMODULE hmod)
if (p > (*dll)->name && !strcasecmp( p, ".dll" )) *p = 0;
size = exports->NumberOfFunctions * sizeof(SNOOP_FUN);
NtAllocateVirtualMemory(GetCurrentProcess(), &addr, NULL, &size,
addr = NULL;
NtAllocateVirtualMemory(GetCurrentProcess(), &addr, 0, &size,
MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
if (!addr) {
RtlFreeHeap(GetProcessHeap(),0,*dll);
@ -1006,9 +1007,9 @@ void WINAPI SNOOP_DoEntry( CONTEXT86 *context )
}
if (!*rets) {
SIZE_T size = 4096;
VOID* addr;
VOID* addr = NULL;
NtAllocateVirtualMemory(GetCurrentProcess(), &addr, NULL, &size,
NtAllocateVirtualMemory(GetCurrentProcess(), &addr, 0, &size,
MEM_COMMIT | MEM_RESERVE,
PAGE_EXECUTE_READWRITE);
if (!addr) return;

View File

@ -142,7 +142,8 @@ void thread_init(void)
server_init_thread( thread_info.pid, thread_info.tid, NULL );
/* create a memory view for the TEB */
NtAllocateVirtualMemory( GetCurrentProcess(), &addr, teb, &size,
addr = teb;
NtAllocateVirtualMemory( GetCurrentProcess(), &addr, 0, &size,
MEM_SYSTEM, PAGE_EXECUTE_READWRITE );
/* create the process heap */
@ -179,7 +180,8 @@ static void start_thread( struct wine_pthread_thread_info *info )
/* allocate a memory view for the stack */
size = info->stack_size;
NtAllocateVirtualMemory( GetCurrentProcess(), &teb->DeallocationStack, info->stack_base,
teb->DeallocationStack = info->stack_base;
NtAllocateVirtualMemory( GetCurrentProcess(), &teb->DeallocationStack, 0,
&size, MEM_SYSTEM, PAGE_EXECUTE_READWRITE );
/* limit is lower than base since the stack grows down */
teb->Tib.StackBase = (char *)info->stack_base + info->stack_size;
@ -263,7 +265,8 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
teb->wait_fd[1] = -1;
teb->htask16 = NtCurrentTeb()->htask16;
NtAllocateVirtualMemory( GetCurrentProcess(), &info->pthread_info.teb_base, teb, &size,
info->pthread_info.teb_base = teb;
NtAllocateVirtualMemory( GetCurrentProcess(), &info->pthread_info.teb_base, 0, &size,
MEM_SYSTEM, PAGE_EXECUTE_READWRITE );
info->pthread_info.teb_size = size;
info->pthread_info.teb_sel = teb->teb_sel;

View File

@ -1153,7 +1153,7 @@ void VIRTUAL_UseLargeAddressSpace(void)
* NtAllocateVirtualMemory (NTDLL.@)
* ZwAllocateVirtualMemory (NTDLL.@)
*/
NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, PVOID addr,
NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_bits,
ULONG *size_ptr, ULONG type, ULONG protect )
{
void *base;
@ -1162,7 +1162,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, PVOID addr,
NTSTATUS status = STATUS_SUCCESS;
struct file_view *view;
TRACE("%p %p %08lx %lx %08lx\n", process, addr, size, type, protect );
TRACE("%p %p %08lx %lx %08lx\n", process, *ret, size, type, protect );
if (!size) return STATUS_INVALID_PARAMETER;
@ -1176,13 +1176,13 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, PVOID addr,
if (size > 0x7fc00000) return STATUS_WORKING_SET_LIMIT_RANGE; /* 2Gb - 4Mb */
if (addr)
if (*ret)
{
if (type & MEM_RESERVE) /* Round down to 64k boundary */
base = ROUND_ADDR( addr, granularity_mask );
base = ROUND_ADDR( *ret, granularity_mask );
else
base = ROUND_ADDR( addr, page_mask );
size = (((UINT_PTR)addr + size + page_mask) & ~page_mask) - (UINT_PTR)base;
base = ROUND_ADDR( *ret, page_mask );
size = (((UINT_PTR)*ret + size + page_mask) & ~page_mask) - (UINT_PTR)base;
/* disallow low 64k, wrap-around and kernel space */
if (((char *)base <= (char *)granularity_mask) ||
@ -1202,6 +1202,9 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, PVOID addr,
type &= ~MEM_TOP_DOWN;
}
if (zero_bits)
WARN("zero_bits %lu ignored\n", zero_bits);
/* Compute the alloc type flags */
if (!(type & MEM_SYSTEM))

View File

@ -1268,7 +1268,7 @@ NTSTATUS WINAPI NtAccessCheck(PSECURITY_DESCRIPTOR,HANDLE,ACCESS_MASK,PGENERIC_
NTSTATUS WINAPI NtAdjustGroupsToken(HANDLE,BOOLEAN,PTOKEN_GROUPS,ULONG,PTOKEN_GROUPS,PULONG);
NTSTATUS WINAPI NtAdjustPrivilegesToken(HANDLE,BOOLEAN,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
NTSTATUS WINAPI NtAlertThread(HANDLE ThreadHandle);
NTSTATUS WINAPI NtAllocateVirtualMemory(HANDLE,PVOID*,PVOID,ULONG*,ULONG,ULONG);
NTSTATUS WINAPI NtAllocateVirtualMemory(HANDLE,PVOID*,ULONG,ULONG*,ULONG,ULONG);
NTSTATUS WINAPI NtCancelIoFile(HANDLE,PIO_STATUS_BLOCK);
NTSTATUS WINAPI NtCancelTimer(HANDLE, BOOLEAN*);
NTSTATUS WINAPI NtClearEvent(HANDLE);