From d3edafe1e226ef7818c209f38ae7e41179008a64 Mon Sep 17 00:00:00 2001 From: Ivan Leo Puoti Date: Tue, 22 Feb 2005 19:33:50 +0000 Subject: [PATCH] Replace GetCurrentProcess() with NtCurrentProcess() in ntdll. --- dlls/ntdll/handletable.c | 6 +++--- dlls/ntdll/heap.c | 16 ++++++++-------- dlls/ntdll/loader.c | 12 ++++++------ dlls/ntdll/relay.c | 6 +++--- dlls/ntdll/thread.c | 10 +++++----- dlls/ntdll/virtual.c | 10 +++++----- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/dlls/ntdll/handletable.c b/dlls/ntdll/handletable.c index 2baa749dd85..3c23705a525 100644 --- a/dlls/ntdll/handletable.c +++ b/dlls/ntdll/handletable.c @@ -82,7 +82,7 @@ NTSTATUS WINAPI RtlDestroyHandleTable(RTL_HANDLE_TABLE * HandleTable) /* native version only releases committed memory, but we also release reserved */ return NtFreeVirtualMemory( - GetCurrentProcess(), + NtCurrentProcess(), &HandleTable->FirstHandle, &Size, MEM_RELEASE); @@ -111,7 +111,7 @@ static NTSTATUS RtlpAllocateSomeHandles(RTL_HANDLE_TABLE * HandleTable) /* reserve memory for the handles, but don't commit it yet because we * probably won't use most of it and it will use up physical memory */ status = NtAllocateVirtualMemory( - GetCurrentProcess(), + NtCurrentProcess(), &FirstHandleAddr, 0, &MaxSize, @@ -134,7 +134,7 @@ static NTSTATUS RtlpAllocateSomeHandles(RTL_HANDLE_TABLE * HandleTable) return STATUS_NO_MEMORY; /* the handle table is completely full */ status = NtAllocateVirtualMemory( - GetCurrentProcess(), + NtCurrentProcess(), &NextAvailAddr, 0, &CommitSize, diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index e7c76356046..01ce36b02fa 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -338,7 +338,7 @@ static inline BOOL HEAP_Commit( SUBHEAP *subheap, void *ptr ) if (size <= subheap->commitSize) return TRUE; size -= subheap->commitSize; ptr = (char *)subheap + subheap->commitSize; - if (NtAllocateVirtualMemory( GetCurrentProcess(), &ptr, 0, + if (NtAllocateVirtualMemory( NtCurrentProcess(), &ptr, 0, &size, MEM_COMMIT, PAGE_EXECUTE_READWRITE)) { WARN("Could not commit %08lx bytes at %p for heap %p\n", @@ -367,7 +367,7 @@ static inline BOOL HEAP_Decommit( SUBHEAP *subheap, void *ptr ) decommit_size = subheap->commitSize - size; addr = (char *)subheap + size; - if (NtFreeVirtualMemory( GetCurrentProcess(), &addr, &decommit_size, MEM_DECOMMIT )) + if (NtFreeVirtualMemory( NtCurrentProcess(), &addr, &decommit_size, MEM_DECOMMIT )) { WARN("Could not decommit %08lx bytes at %08lx for heap %p\n", decommit_size, (DWORD)((char *)subheap + size), subheap->heap ); @@ -477,7 +477,7 @@ static void HEAP_MakeInUseBlockFree( SUBHEAP *subheap, ARENA_INUSE *pArena ) if (pPrev) pPrev->next = subheap->next; /* Free the memory */ subheap->magic = 0; - NtFreeVirtualMemory( GetCurrentProcess(), (void **)&subheap, &size, MEM_RELEASE ); + NtFreeVirtualMemory( NtCurrentProcess(), (void **)&subheap, &size, MEM_RELEASE ); return; } @@ -524,7 +524,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, 0, + if (NtAllocateVirtualMemory( NtCurrentProcess(), &address, 0, &commitSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE)) { WARN("Could not commit %08lx bytes for sub-heap %p\n", commitSize, address ); @@ -579,7 +579,7 @@ static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags, HANDLE sem = heap->critSection.LockSemaphore; if (!sem) NtCreateSemaphore( &sem, SEMAPHORE_ALL_ACCESS, NULL, 0, 1 ); - NtDuplicateObject( GetCurrentProcess(), sem, GetCurrentProcess(), &sem, 0, 0, + NtDuplicateObject( NtCurrentProcess(), sem, NtCurrentProcess(), &sem, 0, 0, DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE ); heap->critSection.LockSemaphore = sem; } @@ -613,7 +613,7 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, void *base, DWORD flags, if (!address) { /* allocate the memory block */ - if (NtAllocateVirtualMemory( GetCurrentProcess(), &address, 0, &totalSize, + if (NtAllocateVirtualMemory( NtCurrentProcess(), &address, 0, &totalSize, MEM_RESERVE, PAGE_EXECUTE_READWRITE )) { WARN("Could not allocate %08lx bytes\n", totalSize ); @@ -627,7 +627,7 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, void *base, DWORD flags, address, flags, commitSize, totalSize )) { ULONG size = 0; - if (!base) NtFreeVirtualMemory( GetCurrentProcess(), &address, &size, MEM_RELEASE ); + if (!base) NtFreeVirtualMemory( NtCurrentProcess(), &address, &size, MEM_RELEASE ); return NULL; } @@ -1066,7 +1066,7 @@ HANDLE WINAPI RtlDestroyHeap( HANDLE heap ) SUBHEAP *next = subheap->next; ULONG size = 0; void *addr = subheap; - NtFreeVirtualMemory( GetCurrentProcess(), &addr, &size, MEM_RELEASE ); + NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE ); subheap = next; } return 0; diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 0c481a692cc..884f10b5877 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -215,7 +215,7 @@ static void *allocate_stub( const char *dll, const char *name ) if (!stubs) { ULONG size = MAX_SIZE; - if (NtAllocateVirtualMemory( GetCurrentProcess(), (void **)&stubs, 0, &size, + if (NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&stubs, 0, &size, MEM_COMMIT, PAGE_EXECUTE_WRITECOPY ) != STATUS_SUCCESS) return (void *)0xdeadbeef; } @@ -491,7 +491,7 @@ static WINE_MODREF *import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *d while (import_list[protect_size].u1.Ordinal) protect_size++; protect_base = thunk_list; protect_size *= sizeof(*thunk_list); - NtProtectVirtualMemory( GetCurrentProcess(), &protect_base, + NtProtectVirtualMemory( NtCurrentProcess(), &protect_base, &protect_size, PAGE_WRITECOPY, &protect_old ); imp_mod = wmImp->ldr.BaseAddress; @@ -561,7 +561,7 @@ static WINE_MODREF *import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *d done: /* restore old protection of the import address table */ - NtProtectVirtualMemory( GetCurrentProcess(), &protect_base, &protect_size, protect_old, NULL ); + NtProtectVirtualMemory( NtCurrentProcess(), &protect_base, &protect_size, protect_old, NULL ); return wmImp; } @@ -1229,7 +1229,7 @@ static void load_builtin_callback( void *module, const char *filename ) } wm->ldr.Flags |= LDR_WINE_INTERNAL; addr = module; - NtAllocateVirtualMemory( GetCurrentProcess(), &addr, 0, &nt->OptionalHeader.SizeOfImage, + NtAllocateVirtualMemory( NtCurrentProcess(), &addr, 0, &nt->OptionalHeader.SizeOfImage, MEM_SYSTEM | MEM_IMAGE, PAGE_EXECUTE_WRITECOPY ); /* fixup imports */ @@ -1299,7 +1299,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file, if (status != STATUS_SUCCESS) return status; module = NULL; - status = NtMapViewOfSection( mapping, GetCurrentProcess(), + status = NtMapViewOfSection( mapping, NtCurrentProcess(), &module, 0, 0, &size, &len, ViewShare, 0, PAGE_READONLY ); NtClose( mapping ); if (status != STATUS_SUCCESS) return status; @@ -1802,7 +1802,7 @@ static void MODULE_FlushModrefs(void) } SERVER_END_REQ; - NtUnmapViewOfSection( GetCurrentProcess(), mod->BaseAddress ); + NtUnmapViewOfSection( NtCurrentProcess(), mod->BaseAddress ); if (wm->ldr.Flags & LDR_WINE_INTERNAL) wine_dll_unload( wm->ldr.SectionHandle ); if (cached_modref == wm) cached_modref = NULL; RtlFreeUnicodeString( &mod->FullDllName ); diff --git a/dlls/ntdll/relay.c b/dlls/ntdll/relay.c index 27edbc42fdc..7bfafa2ed0d 100644 --- a/dlls/ntdll/relay.c +++ b/dlls/ntdll/relay.c @@ -820,7 +820,7 @@ void SNOOP_SetupDLL(HMODULE hmod) /* another dll, loaded at the same address */ addr = (*dll)->funs; size = (*dll)->nrofordinals * sizeof(SNOOP_FUN); - NtFreeVirtualMemory(GetCurrentProcess(), &addr, &size, MEM_RELEASE); + NtFreeVirtualMemory(NtCurrentProcess(), &addr, &size, MEM_RELEASE); break; } dll = &((*dll)->next); @@ -842,7 +842,7 @@ void SNOOP_SetupDLL(HMODULE hmod) size = exports->NumberOfFunctions * sizeof(SNOOP_FUN); addr = NULL; - NtAllocateVirtualMemory(GetCurrentProcess(), &addr, 0, &size, + NtAllocateVirtualMemory(NtCurrentProcess(), &addr, 0, &size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); if (!addr) { RtlFreeHeap(GetProcessHeap(),0,*dll); @@ -1009,7 +1009,7 @@ void WINAPI SNOOP_DoEntry( CONTEXT86 *context ) SIZE_T size = 4096; VOID* addr = NULL; - NtAllocateVirtualMemory(GetCurrentProcess(), &addr, 0, &size, + NtAllocateVirtualMemory(NtCurrentProcess(), &addr, 0, &size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); if (!addr) return; diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index 4fb14785e75..94dd0c0728b 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -85,7 +85,7 @@ static inline void free_teb( TEB *teb ) ULONG size = 0; void *addr = teb; - NtFreeVirtualMemory( GetCurrentProcess(), &addr, &size, MEM_RELEASE ); + NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE ); wine_ldt_free_fs( teb->teb_sel ); munmap( teb, SIGNAL_STACK_SIZE + sizeof(TEB) ); } @@ -143,7 +143,7 @@ void thread_init(void) /* create a memory view for the TEB */ addr = teb; - NtAllocateVirtualMemory( GetCurrentProcess(), &addr, 0, &size, + NtAllocateVirtualMemory( NtCurrentProcess(), &addr, 0, &size, MEM_SYSTEM, PAGE_EXECUTE_READWRITE ); /* create the process heap */ @@ -181,7 +181,7 @@ static void start_thread( struct wine_pthread_thread_info *info ) /* allocate a memory view for the stack */ size = info->stack_size; teb->DeallocationStack = info->stack_base; - NtAllocateVirtualMemory( GetCurrentProcess(), &teb->DeallocationStack, 0, + NtAllocateVirtualMemory( NtCurrentProcess(), &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; @@ -189,7 +189,7 @@ static void start_thread( struct wine_pthread_thread_info *info ) /* setup the guard page */ size = 1; - NtProtectVirtualMemory( GetCurrentProcess(), &teb->DeallocationStack, &size, + NtProtectVirtualMemory( NtCurrentProcess(), &teb->DeallocationStack, &size, PAGE_EXECUTE_READWRITE | PAGE_GUARD, NULL ); RtlFreeHeap( GetProcessHeap(), 0, info ); @@ -266,7 +266,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR * teb->htask16 = NtCurrentTeb()->htask16; info->pthread_info.teb_base = teb; - NtAllocateVirtualMemory( GetCurrentProcess(), &info->pthread_info.teb_base, 0, &size, + NtAllocateVirtualMemory( NtCurrentProcess(), &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; diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index ff95a6148ca..22166b037b2 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -1044,8 +1044,8 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, DWORD total_size done: if (!removable) /* don't keep handle open on removable media */ - NtDuplicateObject( GetCurrentProcess(), hmapping, - GetCurrentProcess(), &view->mapping, + NtDuplicateObject( NtCurrentProcess(), hmapping, + NtCurrentProcess(), &view->mapping, 0, 0, DUPLICATE_SAME_ACCESS ); RtlLeaveCriticalSection( &csVirtual ); @@ -1069,7 +1069,7 @@ BOOL is_current_process( HANDLE handle ) { BOOL ret = FALSE; - if (handle == GetCurrentProcess()) return TRUE; + if (handle == NtCurrentProcess()) return TRUE; SERVER_START_REQ( get_process_info ) { req->handle = handle; @@ -1777,8 +1777,8 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p if (res == STATUS_SUCCESS) { if (!removable) /* don't keep handle open on removable media */ - NtDuplicateObject( GetCurrentProcess(), handle, - GetCurrentProcess(), &view->mapping, + NtDuplicateObject( NtCurrentProcess(), handle, + NtCurrentProcess(), &view->mapping, 0, 0, DUPLICATE_SAME_ACCESS ); *addr_ptr = view->base;