Replace GetCurrentProcess() with NtCurrentProcess() in ntdll.
This commit is contained in:
parent
d8793bb776
commit
d3edafe1e2
|
@ -82,7 +82,7 @@ NTSTATUS WINAPI RtlDestroyHandleTable(RTL_HANDLE_TABLE * HandleTable)
|
||||||
|
|
||||||
/* native version only releases committed memory, but we also release reserved */
|
/* native version only releases committed memory, but we also release reserved */
|
||||||
return NtFreeVirtualMemory(
|
return NtFreeVirtualMemory(
|
||||||
GetCurrentProcess(),
|
NtCurrentProcess(),
|
||||||
&HandleTable->FirstHandle,
|
&HandleTable->FirstHandle,
|
||||||
&Size,
|
&Size,
|
||||||
MEM_RELEASE);
|
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
|
/* 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 */
|
* probably won't use most of it and it will use up physical memory */
|
||||||
status = NtAllocateVirtualMemory(
|
status = NtAllocateVirtualMemory(
|
||||||
GetCurrentProcess(),
|
NtCurrentProcess(),
|
||||||
&FirstHandleAddr,
|
&FirstHandleAddr,
|
||||||
0,
|
0,
|
||||||
&MaxSize,
|
&MaxSize,
|
||||||
|
@ -134,7 +134,7 @@ static NTSTATUS RtlpAllocateSomeHandles(RTL_HANDLE_TABLE * HandleTable)
|
||||||
return STATUS_NO_MEMORY; /* the handle table is completely full */
|
return STATUS_NO_MEMORY; /* the handle table is completely full */
|
||||||
|
|
||||||
status = NtAllocateVirtualMemory(
|
status = NtAllocateVirtualMemory(
|
||||||
GetCurrentProcess(),
|
NtCurrentProcess(),
|
||||||
&NextAvailAddr,
|
&NextAvailAddr,
|
||||||
0,
|
0,
|
||||||
&CommitSize,
|
&CommitSize,
|
||||||
|
|
|
@ -338,7 +338,7 @@ static inline BOOL HEAP_Commit( SUBHEAP *subheap, void *ptr )
|
||||||
if (size <= subheap->commitSize) return TRUE;
|
if (size <= subheap->commitSize) return TRUE;
|
||||||
size -= subheap->commitSize;
|
size -= subheap->commitSize;
|
||||||
ptr = (char *)subheap + subheap->commitSize;
|
ptr = (char *)subheap + subheap->commitSize;
|
||||||
if (NtAllocateVirtualMemory( GetCurrentProcess(), &ptr, 0,
|
if (NtAllocateVirtualMemory( NtCurrentProcess(), &ptr, 0,
|
||||||
&size, MEM_COMMIT, PAGE_EXECUTE_READWRITE))
|
&size, MEM_COMMIT, PAGE_EXECUTE_READWRITE))
|
||||||
{
|
{
|
||||||
WARN("Could not commit %08lx bytes at %p for heap %p\n",
|
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;
|
decommit_size = subheap->commitSize - size;
|
||||||
addr = (char *)subheap + 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",
|
WARN("Could not decommit %08lx bytes at %08lx for heap %p\n",
|
||||||
decommit_size, (DWORD)((char *)subheap + size), subheap->heap );
|
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;
|
if (pPrev) pPrev->next = subheap->next;
|
||||||
/* Free the memory */
|
/* Free the memory */
|
||||||
subheap->magic = 0;
|
subheap->magic = 0;
|
||||||
NtFreeVirtualMemory( GetCurrentProcess(), (void **)&subheap, &size, MEM_RELEASE );
|
NtFreeVirtualMemory( NtCurrentProcess(), (void **)&subheap, &size, MEM_RELEASE );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags,
|
||||||
|
|
||||||
if (flags & HEAP_SHARED)
|
if (flags & HEAP_SHARED)
|
||||||
commitSize = totalSize; /* always commit everything in a shared heap */
|
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))
|
&commitSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE))
|
||||||
{
|
{
|
||||||
WARN("Could not commit %08lx bytes for sub-heap %p\n", commitSize, address );
|
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;
|
HANDLE sem = heap->critSection.LockSemaphore;
|
||||||
if (!sem) NtCreateSemaphore( &sem, SEMAPHORE_ALL_ACCESS, NULL, 0, 1 );
|
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 );
|
DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
|
||||||
heap->critSection.LockSemaphore = sem;
|
heap->critSection.LockSemaphore = sem;
|
||||||
}
|
}
|
||||||
|
@ -613,7 +613,7 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, void *base, DWORD flags,
|
||||||
if (!address)
|
if (!address)
|
||||||
{
|
{
|
||||||
/* allocate the memory block */
|
/* allocate the memory block */
|
||||||
if (NtAllocateVirtualMemory( GetCurrentProcess(), &address, 0, &totalSize,
|
if (NtAllocateVirtualMemory( NtCurrentProcess(), &address, 0, &totalSize,
|
||||||
MEM_RESERVE, PAGE_EXECUTE_READWRITE ))
|
MEM_RESERVE, PAGE_EXECUTE_READWRITE ))
|
||||||
{
|
{
|
||||||
WARN("Could not allocate %08lx bytes\n", totalSize );
|
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 ))
|
address, flags, commitSize, totalSize ))
|
||||||
{
|
{
|
||||||
ULONG size = 0;
|
ULONG size = 0;
|
||||||
if (!base) NtFreeVirtualMemory( GetCurrentProcess(), &address, &size, MEM_RELEASE );
|
if (!base) NtFreeVirtualMemory( NtCurrentProcess(), &address, &size, MEM_RELEASE );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1066,7 +1066,7 @@ HANDLE WINAPI RtlDestroyHeap( HANDLE heap )
|
||||||
SUBHEAP *next = subheap->next;
|
SUBHEAP *next = subheap->next;
|
||||||
ULONG size = 0;
|
ULONG size = 0;
|
||||||
void *addr = subheap;
|
void *addr = subheap;
|
||||||
NtFreeVirtualMemory( GetCurrentProcess(), &addr, &size, MEM_RELEASE );
|
NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE );
|
||||||
subheap = next;
|
subheap = next;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -215,7 +215,7 @@ static void *allocate_stub( const char *dll, const char *name )
|
||||||
if (!stubs)
|
if (!stubs)
|
||||||
{
|
{
|
||||||
ULONG size = MAX_SIZE;
|
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)
|
MEM_COMMIT, PAGE_EXECUTE_WRITECOPY ) != STATUS_SUCCESS)
|
||||||
return (void *)0xdeadbeef;
|
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++;
|
while (import_list[protect_size].u1.Ordinal) protect_size++;
|
||||||
protect_base = thunk_list;
|
protect_base = thunk_list;
|
||||||
protect_size *= sizeof(*thunk_list);
|
protect_size *= sizeof(*thunk_list);
|
||||||
NtProtectVirtualMemory( GetCurrentProcess(), &protect_base,
|
NtProtectVirtualMemory( NtCurrentProcess(), &protect_base,
|
||||||
&protect_size, PAGE_WRITECOPY, &protect_old );
|
&protect_size, PAGE_WRITECOPY, &protect_old );
|
||||||
|
|
||||||
imp_mod = wmImp->ldr.BaseAddress;
|
imp_mod = wmImp->ldr.BaseAddress;
|
||||||
|
@ -561,7 +561,7 @@ static WINE_MODREF *import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *d
|
||||||
|
|
||||||
done:
|
done:
|
||||||
/* restore old protection of the import address table */
|
/* 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;
|
return wmImp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1229,7 +1229,7 @@ static void load_builtin_callback( void *module, const char *filename )
|
||||||
}
|
}
|
||||||
wm->ldr.Flags |= LDR_WINE_INTERNAL;
|
wm->ldr.Flags |= LDR_WINE_INTERNAL;
|
||||||
addr = module;
|
addr = module;
|
||||||
NtAllocateVirtualMemory( GetCurrentProcess(), &addr, 0, &nt->OptionalHeader.SizeOfImage,
|
NtAllocateVirtualMemory( NtCurrentProcess(), &addr, 0, &nt->OptionalHeader.SizeOfImage,
|
||||||
MEM_SYSTEM | MEM_IMAGE, PAGE_EXECUTE_WRITECOPY );
|
MEM_SYSTEM | MEM_IMAGE, PAGE_EXECUTE_WRITECOPY );
|
||||||
|
|
||||||
/* fixup imports */
|
/* fixup imports */
|
||||||
|
@ -1299,7 +1299,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
|
||||||
if (status != STATUS_SUCCESS) return status;
|
if (status != STATUS_SUCCESS) return status;
|
||||||
|
|
||||||
module = NULL;
|
module = NULL;
|
||||||
status = NtMapViewOfSection( mapping, GetCurrentProcess(),
|
status = NtMapViewOfSection( mapping, NtCurrentProcess(),
|
||||||
&module, 0, 0, &size, &len, ViewShare, 0, PAGE_READONLY );
|
&module, 0, 0, &size, &len, ViewShare, 0, PAGE_READONLY );
|
||||||
NtClose( mapping );
|
NtClose( mapping );
|
||||||
if (status != STATUS_SUCCESS) return status;
|
if (status != STATUS_SUCCESS) return status;
|
||||||
|
@ -1802,7 +1802,7 @@ static void MODULE_FlushModrefs(void)
|
||||||
}
|
}
|
||||||
SERVER_END_REQ;
|
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 (wm->ldr.Flags & LDR_WINE_INTERNAL) wine_dll_unload( wm->ldr.SectionHandle );
|
||||||
if (cached_modref == wm) cached_modref = NULL;
|
if (cached_modref == wm) cached_modref = NULL;
|
||||||
RtlFreeUnicodeString( &mod->FullDllName );
|
RtlFreeUnicodeString( &mod->FullDllName );
|
||||||
|
|
|
@ -820,7 +820,7 @@ void SNOOP_SetupDLL(HMODULE hmod)
|
||||||
/* another dll, loaded at the same address */
|
/* another dll, loaded at the same address */
|
||||||
addr = (*dll)->funs;
|
addr = (*dll)->funs;
|
||||||
size = (*dll)->nrofordinals * sizeof(SNOOP_FUN);
|
size = (*dll)->nrofordinals * sizeof(SNOOP_FUN);
|
||||||
NtFreeVirtualMemory(GetCurrentProcess(), &addr, &size, MEM_RELEASE);
|
NtFreeVirtualMemory(NtCurrentProcess(), &addr, &size, MEM_RELEASE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dll = &((*dll)->next);
|
dll = &((*dll)->next);
|
||||||
|
@ -842,7 +842,7 @@ void SNOOP_SetupDLL(HMODULE hmod)
|
||||||
|
|
||||||
size = exports->NumberOfFunctions * sizeof(SNOOP_FUN);
|
size = exports->NumberOfFunctions * sizeof(SNOOP_FUN);
|
||||||
addr = NULL;
|
addr = NULL;
|
||||||
NtAllocateVirtualMemory(GetCurrentProcess(), &addr, 0, &size,
|
NtAllocateVirtualMemory(NtCurrentProcess(), &addr, 0, &size,
|
||||||
MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||||
if (!addr) {
|
if (!addr) {
|
||||||
RtlFreeHeap(GetProcessHeap(),0,*dll);
|
RtlFreeHeap(GetProcessHeap(),0,*dll);
|
||||||
|
@ -1009,7 +1009,7 @@ void WINAPI SNOOP_DoEntry( CONTEXT86 *context )
|
||||||
SIZE_T size = 4096;
|
SIZE_T size = 4096;
|
||||||
VOID* addr = NULL;
|
VOID* addr = NULL;
|
||||||
|
|
||||||
NtAllocateVirtualMemory(GetCurrentProcess(), &addr, 0, &size,
|
NtAllocateVirtualMemory(NtCurrentProcess(), &addr, 0, &size,
|
||||||
MEM_COMMIT | MEM_RESERVE,
|
MEM_COMMIT | MEM_RESERVE,
|
||||||
PAGE_EXECUTE_READWRITE);
|
PAGE_EXECUTE_READWRITE);
|
||||||
if (!addr) return;
|
if (!addr) return;
|
||||||
|
|
|
@ -85,7 +85,7 @@ static inline void free_teb( TEB *teb )
|
||||||
ULONG size = 0;
|
ULONG size = 0;
|
||||||
void *addr = teb;
|
void *addr = teb;
|
||||||
|
|
||||||
NtFreeVirtualMemory( GetCurrentProcess(), &addr, &size, MEM_RELEASE );
|
NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE );
|
||||||
wine_ldt_free_fs( teb->teb_sel );
|
wine_ldt_free_fs( teb->teb_sel );
|
||||||
munmap( teb, SIGNAL_STACK_SIZE + sizeof(TEB) );
|
munmap( teb, SIGNAL_STACK_SIZE + sizeof(TEB) );
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ void thread_init(void)
|
||||||
|
|
||||||
/* create a memory view for the TEB */
|
/* create a memory view for the TEB */
|
||||||
addr = teb;
|
addr = teb;
|
||||||
NtAllocateVirtualMemory( GetCurrentProcess(), &addr, 0, &size,
|
NtAllocateVirtualMemory( NtCurrentProcess(), &addr, 0, &size,
|
||||||
MEM_SYSTEM, PAGE_EXECUTE_READWRITE );
|
MEM_SYSTEM, PAGE_EXECUTE_READWRITE );
|
||||||
|
|
||||||
/* create the process heap */
|
/* 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 */
|
/* allocate a memory view for the stack */
|
||||||
size = info->stack_size;
|
size = info->stack_size;
|
||||||
teb->DeallocationStack = info->stack_base;
|
teb->DeallocationStack = info->stack_base;
|
||||||
NtAllocateVirtualMemory( GetCurrentProcess(), &teb->DeallocationStack, 0,
|
NtAllocateVirtualMemory( NtCurrentProcess(), &teb->DeallocationStack, 0,
|
||||||
&size, MEM_SYSTEM, PAGE_EXECUTE_READWRITE );
|
&size, MEM_SYSTEM, PAGE_EXECUTE_READWRITE );
|
||||||
/* limit is lower than base since the stack grows down */
|
/* limit is lower than base since the stack grows down */
|
||||||
teb->Tib.StackBase = (char *)info->stack_base + info->stack_size;
|
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 */
|
/* setup the guard page */
|
||||||
size = 1;
|
size = 1;
|
||||||
NtProtectVirtualMemory( GetCurrentProcess(), &teb->DeallocationStack, &size,
|
NtProtectVirtualMemory( NtCurrentProcess(), &teb->DeallocationStack, &size,
|
||||||
PAGE_EXECUTE_READWRITE | PAGE_GUARD, NULL );
|
PAGE_EXECUTE_READWRITE | PAGE_GUARD, NULL );
|
||||||
RtlFreeHeap( GetProcessHeap(), 0, info );
|
RtlFreeHeap( GetProcessHeap(), 0, info );
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
|
||||||
teb->htask16 = NtCurrentTeb()->htask16;
|
teb->htask16 = NtCurrentTeb()->htask16;
|
||||||
|
|
||||||
info->pthread_info.teb_base = teb;
|
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 );
|
MEM_SYSTEM, PAGE_EXECUTE_READWRITE );
|
||||||
info->pthread_info.teb_size = size;
|
info->pthread_info.teb_size = size;
|
||||||
info->pthread_info.teb_sel = teb->teb_sel;
|
info->pthread_info.teb_sel = teb->teb_sel;
|
||||||
|
|
|
@ -1044,8 +1044,8 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, DWORD total_size
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (!removable) /* don't keep handle open on removable media */
|
if (!removable) /* don't keep handle open on removable media */
|
||||||
NtDuplicateObject( GetCurrentProcess(), hmapping,
|
NtDuplicateObject( NtCurrentProcess(), hmapping,
|
||||||
GetCurrentProcess(), &view->mapping,
|
NtCurrentProcess(), &view->mapping,
|
||||||
0, 0, DUPLICATE_SAME_ACCESS );
|
0, 0, DUPLICATE_SAME_ACCESS );
|
||||||
|
|
||||||
RtlLeaveCriticalSection( &csVirtual );
|
RtlLeaveCriticalSection( &csVirtual );
|
||||||
|
@ -1069,7 +1069,7 @@ BOOL is_current_process( HANDLE handle )
|
||||||
{
|
{
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
if (handle == GetCurrentProcess()) return TRUE;
|
if (handle == NtCurrentProcess()) return TRUE;
|
||||||
SERVER_START_REQ( get_process_info )
|
SERVER_START_REQ( get_process_info )
|
||||||
{
|
{
|
||||||
req->handle = handle;
|
req->handle = handle;
|
||||||
|
@ -1777,8 +1777,8 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
|
||||||
if (res == STATUS_SUCCESS)
|
if (res == STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
if (!removable) /* don't keep handle open on removable media */
|
if (!removable) /* don't keep handle open on removable media */
|
||||||
NtDuplicateObject( GetCurrentProcess(), handle,
|
NtDuplicateObject( NtCurrentProcess(), handle,
|
||||||
GetCurrentProcess(), &view->mapping,
|
NtCurrentProcess(), &view->mapping,
|
||||||
0, 0, DUPLICATE_SAME_ACCESS );
|
0, 0, DUPLICATE_SAME_ACCESS );
|
||||||
|
|
||||||
*addr_ptr = view->base;
|
*addr_ptr = view->base;
|
||||||
|
|
Loading…
Reference in New Issue