mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 12:23:31 +00:00
* lib/kernel32/k32.h: New file. * lib/kernel32/makefile (TARGET_CFLAGS): Add -I./. (TARGET_PCH): Set to k32.h. * lib/kernel32/except/except.c: Use <k32.h>. * lib/kernel32/file/backup.c: Ditto. * lib/kernel32/file/cnotify.c: Ditto. * lib/kernel32/file/copy.c: Ditto. * lib/kernel32/file/create.c: Ditto. * lib/kernel32/file/curdir.c: Ditto. * lib/kernel32/file/delete.c: Ditto. * lib/kernel32/file/deviceio.c: Ditto. * lib/kernel32/file/dir.c: Ditto. * lib/kernel32/file/dosdev.c: Ditto. * lib/kernel32/file/file.c: Ditto. * lib/kernel32/file/find.c: Ditto. * lib/kernel32/file/iocompl.c: Ditto. * lib/kernel32/file/lfile.c: Ditto. * lib/kernel32/file/lock.c: Ditto. * lib/kernel32/file/mailslot.c: Ditto. * lib/kernel32/file/move.c: Ditto. * lib/kernel32/file/npipe.c: Ditto. * lib/kernel32/file/pipe.c: Ditto. * lib/kernel32/file/rw.c: Ditto. * lib/kernel32/file/tape.c: Ditto. * lib/kernel32/file/volume.c: Ditto. * lib/kernel32/mem/global.c: Ditto. * lib/kernel32/mem/heap.c: Ditto. * lib/kernel32/mem/isbad.c: Ditto. * lib/kernel32/mem/local.c: Ditto. * lib/kernel32/mem/procmem.c: Ditto. * lib/kernel32/mem/section.c: Ditto. * lib/kernel32/mem/virtual.c: Ditto. * lib/kernel32/misc/atom.c: Ditto. * lib/kernel32/misc/comm.c: Ditto. * lib/kernel32/misc/console.c: Ditto. * lib/kernel32/misc/debug.c: Ditto. * lib/kernel32/misc/dllmain.c: Ditto. * lib/kernel32/misc/env.c: Ditto. * lib/kernel32/misc/error.c: Ditto. * lib/kernel32/misc/handle.c: Ditto. * lib/kernel32/misc/ldr.c: Ditto. * lib/kernel32/misc/profile.c: Ditto. * lib/kernel32/misc/res.c: Ditto. * lib/kernel32/misc/stubs.c: Ditto. * lib/kernel32/misc/sysinfo.c: Ditto. * lib/kernel32/misc/time.c: Ditto. * lib/kernel32/process/cmdline.c: Ditto. * lib/kernel32/process/create.c: Ditto. * lib/kernel32/process/proc.c: Ditto. * lib/kernel32/process/session.c: Ditto. * lib/kernel32/string/lstring.c: Ditto. * lib/kernel32/synch/critical.c: Ditto. * lib/kernel32/synch/event.c: Ditto. * lib/kernel32/synch/intrlck.c: Ditto. * lib/kernel32/synch/mutex.c: Ditto. * lib/kernel32/synch/sem.c: Ditto. * lib/kernel32/synch/timer.c: Ditto. * lib/kernel32/synch/wait.c: Ditto. * lib/kernel32/thread/fiber.c: Ditto. * lib/kernel32/thread/thread.c: Ditto. * lib/kernel32/thread/tls.c: Ditto. svn path=/trunk/; revision=4009
200 lines
3.7 KiB
C
200 lines
3.7 KiB
C
/* $Id: virtual.c,v 1.10 2003/01/15 21:24:34 chorns Exp $
|
|
*
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
* PROJECT: ReactOS kernel
|
|
* FILE: lib/kernel32/mem/virtual.c
|
|
* PURPOSE: Passing the Virtualxxx functions onto the kernel
|
|
* PROGRAMMER: David Welch ([email protected])
|
|
*/
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
#include <k32.h>
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
LPVOID STDCALL
|
|
VirtualAllocEx(HANDLE hProcess,
|
|
LPVOID lpAddress,
|
|
DWORD dwSize,
|
|
DWORD flAllocationType,
|
|
DWORD flProtect)
|
|
{
|
|
NTSTATUS Status;
|
|
|
|
Status = NtAllocateVirtualMemory(hProcess,
|
|
(PVOID *)&lpAddress,
|
|
0,
|
|
(PULONG)&dwSize,
|
|
flAllocationType,
|
|
flProtect);
|
|
if (!NT_SUCCESS(Status))
|
|
{
|
|
SetLastErrorByStatus(Status);
|
|
return(NULL);
|
|
}
|
|
return(lpAddress);
|
|
}
|
|
|
|
|
|
LPVOID STDCALL
|
|
VirtualAlloc(LPVOID lpAddress,
|
|
DWORD dwSize,
|
|
DWORD flAllocationType,
|
|
DWORD flProtect)
|
|
{
|
|
return(VirtualAllocEx(GetCurrentProcess(),
|
|
lpAddress,
|
|
dwSize,
|
|
flAllocationType,
|
|
flProtect));
|
|
}
|
|
|
|
|
|
WINBOOL STDCALL
|
|
VirtualFreeEx(HANDLE hProcess,
|
|
LPVOID lpAddress,
|
|
DWORD dwSize,
|
|
DWORD dwFreeType)
|
|
{
|
|
NTSTATUS Status;
|
|
|
|
Status = NtFreeVirtualMemory(hProcess,
|
|
(PVOID *)&lpAddress,
|
|
(PULONG)&dwSize,
|
|
dwFreeType);
|
|
if (!NT_SUCCESS(Status))
|
|
{
|
|
SetLastErrorByStatus(Status);
|
|
return(FALSE);
|
|
}
|
|
return(TRUE);
|
|
}
|
|
|
|
|
|
WINBOOL STDCALL
|
|
VirtualFree(LPVOID lpAddress,
|
|
DWORD dwSize,
|
|
DWORD dwFreeType)
|
|
{
|
|
return(VirtualFreeEx(GetCurrentProcess(),
|
|
lpAddress,
|
|
dwSize,
|
|
dwFreeType));
|
|
}
|
|
|
|
|
|
WINBOOL STDCALL
|
|
VirtualProtect(LPVOID lpAddress,
|
|
DWORD dwSize,
|
|
DWORD flNewProtect,
|
|
PDWORD lpflOldProtect)
|
|
{
|
|
return(VirtualProtectEx(GetCurrentProcess(),
|
|
lpAddress,
|
|
dwSize,
|
|
flNewProtect,
|
|
lpflOldProtect));
|
|
}
|
|
|
|
|
|
WINBOOL STDCALL
|
|
VirtualProtectEx(HANDLE hProcess,
|
|
LPVOID lpAddress,
|
|
DWORD dwSize,
|
|
DWORD flNewProtect,
|
|
PDWORD lpflOldProtect)
|
|
{
|
|
NTSTATUS Status;
|
|
|
|
Status = NtProtectVirtualMemory(hProcess,
|
|
(PVOID)lpAddress,
|
|
dwSize,
|
|
flNewProtect,
|
|
(PULONG)lpflOldProtect);
|
|
if (!NT_SUCCESS(Status))
|
|
{
|
|
SetLastErrorByStatus(Status);
|
|
return(FALSE);
|
|
}
|
|
return(TRUE);
|
|
}
|
|
|
|
|
|
WINBOOL STDCALL
|
|
VirtualLock(LPVOID lpAddress,
|
|
DWORD dwSize)
|
|
{
|
|
ULONG BytesLocked;
|
|
NTSTATUS Status;
|
|
|
|
Status = NtLockVirtualMemory(NtCurrentProcess(),
|
|
lpAddress,
|
|
dwSize,
|
|
&BytesLocked);
|
|
if (!NT_SUCCESS(Status))
|
|
{
|
|
SetLastErrorByStatus(Status);
|
|
return(FALSE);
|
|
}
|
|
return(TRUE);
|
|
}
|
|
|
|
|
|
DWORD STDCALL
|
|
VirtualQuery(LPCVOID lpAddress,
|
|
PMEMORY_BASIC_INFORMATION lpBuffer,
|
|
DWORD dwLength)
|
|
{
|
|
return(VirtualQueryEx(NtCurrentProcess(),
|
|
lpAddress,
|
|
lpBuffer,
|
|
dwLength));
|
|
}
|
|
|
|
|
|
DWORD STDCALL
|
|
VirtualQueryEx(HANDLE hProcess,
|
|
LPCVOID lpAddress,
|
|
PMEMORY_BASIC_INFORMATION lpBuffer,
|
|
DWORD dwLength)
|
|
{
|
|
NTSTATUS Status;
|
|
ULONG ResultLength;
|
|
|
|
Status = NtQueryVirtualMemory(hProcess,
|
|
(LPVOID)lpAddress,
|
|
MemoryBasicInformation,
|
|
lpBuffer,
|
|
sizeof(MEMORY_BASIC_INFORMATION),
|
|
&ResultLength );
|
|
if (!NT_SUCCESS(Status))
|
|
{
|
|
SetLastErrorByStatus(Status);
|
|
return(ResultLength);
|
|
}
|
|
return(ResultLength);
|
|
}
|
|
|
|
|
|
WINBOOL STDCALL
|
|
VirtualUnlock(LPVOID lpAddress,
|
|
DWORD dwSize)
|
|
{
|
|
ULONG BytesLocked;
|
|
NTSTATUS Status;
|
|
|
|
Status = NtUnlockVirtualMemory(NtCurrentProcess(),
|
|
lpAddress,
|
|
dwSize,
|
|
&BytesLocked);
|
|
if (!NT_SUCCESS(Status))
|
|
{
|
|
SetLastErrorByStatus(Status);
|
|
return(FALSE);
|
|
}
|
|
return(TRUE);
|
|
}
|
|
|
|
/* EOF */
|