From 9ad6e7c184fcf6bd72721ccdf66efa9271ad0163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Thu, 19 Jun 2003 17:13:28 +0000 Subject: [PATCH] Implement EngQueryPerformanceFrequency, EngQueryPerformanceCounter and partly Eng(Un)SecureMem svn path=/trunk/; revision=4928 --- reactos/include/ddk/mmfuncs.h | 12 +++---- reactos/ntoskrnl/mm/virtual.c | 24 ++++++++++---- reactos/subsys/win32k/eng/mem.c | 19 ++++++++++- reactos/subsys/win32k/eng/perfcnt.c | 51 +++++++++++++++++++++++++++++ reactos/subsys/win32k/makefile | 6 ++-- reactos/subsys/win32k/stubs/stubs.c | 4 --- reactos/subsys/win32k/win32k.edf | 10 +++--- 7 files changed, 101 insertions(+), 25 deletions(-) create mode 100644 reactos/subsys/win32k/eng/perfcnt.c diff --git a/reactos/include/ddk/mmfuncs.h b/reactos/include/ddk/mmfuncs.h index 0cd9959fc91..f78096bd503 100644 --- a/reactos/include/ddk/mmfuncs.h +++ b/reactos/include/ddk/mmfuncs.h @@ -1,6 +1,6 @@ #ifndef _INCLUDE_DDK_MMFUNCS_H #define _INCLUDE_DDK_MMFUNCS_H -/* $Id: mmfuncs.h,v 1.15 2003/05/14 10:51:26 ekohl Exp $ */ +/* $Id: mmfuncs.h,v 1.16 2003/06/19 17:13:27 gvg Exp $ */ /* MEMORY MANAGMENT ******************************************************/ @@ -455,12 +455,12 @@ MmResetDriverPaging ( PVOID AddressWithinSection ); -DWORD +PVOID STDCALL MmSecureVirtualMemory ( - DWORD Unknown0, - DWORD Unknown1, - DWORD Unknown2 + PVOID Address, + SIZE_T Length, + ULONG Mode ); BOOLEAN STDCALL @@ -548,6 +548,6 @@ MmUnmapViewOfSection ( VOID STDCALL MmUnsecureVirtualMemory ( - DWORD Unknown0 + PVOID SecureMem ); #endif diff --git a/reactos/ntoskrnl/mm/virtual.c b/reactos/ntoskrnl/mm/virtual.c index d717ff3ca82..e3901cca9ea 100644 --- a/reactos/ntoskrnl/mm/virtual.c +++ b/reactos/ntoskrnl/mm/virtual.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: virtual.c,v 1.65 2003/04/28 10:37:40 gvg Exp $ +/* $Id: virtual.c,v 1.66 2003/06/19 17:13:28 gvg Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/virtual.c @@ -344,19 +344,31 @@ NtWriteVirtualMemory(IN HANDLE ProcessHandle, return(STATUS_SUCCESS); } -DWORD STDCALL -MmSecureVirtualMemory (DWORD Unknown0, - DWORD Unknown1, - DWORD Unknown2) +PVOID STDCALL +MmSecureVirtualMemory (PVOID Address, + SIZE_T Length, + ULONG Mode) { + /* Only works for user space */ + if (MmHighestUserAddress < Address) + { + return NULL; + } + UNIMPLEMENTED; + return 0; } VOID STDCALL -MmUnsecureVirtualMemory (DWORD Unknown0) +MmUnsecureVirtualMemory(PVOID SecureMem) { + if (NULL == SecureMem) + { + return; + } + UNIMPLEMENTED; } diff --git a/reactos/subsys/win32k/eng/mem.c b/reactos/subsys/win32k/eng/mem.c index 993930bc6f1..24042bc6bae 100644 --- a/reactos/subsys/win32k/eng/mem.c +++ b/reactos/subsys/win32k/eng/mem.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: mem.c,v 1.9 2003/06/06 10:17:44 gvg Exp $ +/* $Id: mem.c,v 1.10 2003/06/19 17:13:28 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -30,6 +30,10 @@ #include #include +#define NDEBUG +#include +#include + typedef struct _USERMEMHEADER { ULONG Tag; @@ -90,4 +94,17 @@ EngFreeUserMem(PVOID pv) ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *) &Header, &MemSize, MEM_DECOMMIT); } + +HANDLE STDCALL +EngSecureMem(PVOID Address, ULONG Length) +{ + return MmSecureVirtualMemory(Address, Length, PAGE_READWRITE); +} + +VOID STDCALL +EngUnsecureMem(HANDLE Mem) +{ + return MmUnsecureVirtualMemory((PVOID) Mem); +} + /* EOF */ diff --git a/reactos/subsys/win32k/eng/perfcnt.c b/reactos/subsys/win32k/eng/perfcnt.c new file mode 100644 index 00000000000..330aeeaf488 --- /dev/null +++ b/reactos/subsys/win32k/eng/perfcnt.c @@ -0,0 +1,51 @@ +/* + * ReactOS W32 Subsystem + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: perfcnt.c,v 1.1 2003/06/19 17:13:28 gvg Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: GDI Driver Performance Counter Functions + * FILE: subsys/win32k/eng/perfcnt.c + * PROGRAMER: Ge van Geldorp + */ + +#include + +#define NDEBUG +#include +#include + +VOID STDCALL +EngQueryPerformanceFrequency(LONGLONG *Frequency) +{ + LARGE_INTEGER Freq; + +__asm__("int $3\n"); + KeQueryPerformanceCounter(&Freq); + *Frequency = Freq.QuadPart; +} + +VOID STDCALL +EngQueryPerformanceCounter(LONGLONG *Count) +{ + LARGE_INTEGER PerfCount; + + PerfCount = KeQueryPerformanceCounter(NULL); + *Count = PerfCount.QuadPart; +} diff --git a/reactos/subsys/win32k/makefile b/reactos/subsys/win32k/makefile index 07f8b335ddf..0e548e86113 100644 --- a/reactos/subsys/win32k/makefile +++ b/reactos/subsys/win32k/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.65 2003/06/05 22:47:47 gdalsnes Exp $ +# $Id: makefile,v 1.66 2003/06/19 17:13:28 gvg Exp $ PATH_TO_TOP = ../.. @@ -35,8 +35,8 @@ TARGET_LFLAGS =\ ENG_OBJECTS= eng/debug.o eng/mem.o eng/brush.o eng/bitblt.o eng/clip.o \ eng/copybits.o eng/device.o eng/handle.o eng/lineto.o eng/paint.o \ - eng/palette.o eng/surface.o eng/xlate.o eng/transblt.o eng/mouse.o \ - eng/misc.o + eng/palette.o eng/perfcnt.o eng/surface.o eng/xlate.o eng/transblt.o \ + eng/mouse.o eng/misc.o MAIN_OBJECTS = main/dllmain.o main/svctabm.o diff --git a/reactos/subsys/win32k/stubs/stubs.c b/reactos/subsys/win32k/stubs/stubs.c index 8e381d71b03..70a8b8e17d4 100644 --- a/reactos/subsys/win32k/stubs/stubs.c +++ b/reactos/subsys/win32k/stubs/stubs.c @@ -52,12 +52,9 @@ STUB(EngProbeForRead) STUB(EngProbeForReadAndWrite) STUB(EngQueryLocalTime) STUB(EngQueryPalette) -STUB(EngQueryPerformanceCounter) -STUB(EngQueryPerformanceFrequency) STUB(EngReleaseSemaphore) STUB(EngRestoreFloatingPointState) STUB(EngSaveFloatingPointState) -STUB(EngSecureMem) STUB(EngSetEvent) STUB(EngSetLastError) STUB(EngSetPointerShape) @@ -73,7 +70,6 @@ STUB(EngUnloadImage) STUB(EngUnlockDriverObj) STUB(EngUnmapEvent) STUB(EngUnmapFontFile) -STUB(EngUnsecureMem) STUB(EngWaitForSingleObject) STUB(EngWideCharToMultiByte) STUB(EngWritePrinter) diff --git a/reactos/subsys/win32k/win32k.edf b/reactos/subsys/win32k/win32k.edf index 7f7cfecffe3..f9152ff20c1 100644 --- a/reactos/subsys/win32k/win32k.edf +++ b/reactos/subsys/win32k/win32k.edf @@ -1,4 +1,4 @@ -; $Id: win32k.edf,v 1.8 2003/02/15 19:16:33 gvg Exp $ +; $Id: win32k.edf,v 1.9 2003/06/19 17:13:28 gvg Exp $ ; ; win32k.def ; @@ -81,12 +81,12 @@ EngProbeForRead EngProbeForReadAndWrite EngQueryLocalTime EngQueryPalette -EngQueryPerformanceCounter -EngQueryPerformanceFrequency +EngQueryPerformanceCounter=EngQueryPerformanceCounter@4 +EngQueryPerformanceFrequency=EngQueryPerformanceFrequency@4 EngReleaseSemaphore EngRestoreFloatingPointState EngSaveFloatingPointState -EngSecureMem +EngSecureMem=EngSecureMem@8 EngSetEvent EngSetLastError EngSetPointerShape @@ -105,7 +105,7 @@ EngUnlockSurface=EngUnlockSurface@4 EngUnmapEvent EngUnmapFontFile ; EngUnsecureMem = NTOSKRNL.MmUnsecureVirtualMemory -EngUnsecureMem +EngUnsecureMem=EngUnsecureMem@4 EngWaitForSingleObject EngWideCharToMultiByte EngWritePrinter