diff --git a/reactos/subsys/win32k/eng/device.c b/reactos/subsys/win32k/eng/device.c index fdebed7fae1..15bec1a0cf2 100644 --- a/reactos/subsys/win32k/eng/device.c +++ b/reactos/subsys/win32k/eng/device.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: device.c,v 1.9 2003/07/11 15:59:37 royce Exp $ +/* $Id: device.c,v 1.10 2003/08/18 10:18:14 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -50,13 +50,18 @@ EngDeviceIoControl(HANDLE hDevice, KEVENT Event; IO_STATUS_BLOCK Iosb; PFILE_OBJECT FileObject; + PEPROCESS CurrentProcess; DPRINT("EngDeviceIoControl() called\n"); KeInitializeEvent(&Event, SynchronizationEvent, FALSE); - /* Switch to process context in which hDevice is valid */ - KeAttachProcess(W32kDeviceProcess); + CurrentProcess = PsGetCurrentProcess(); + if (CurrentProcess != W32kDeviceProcess) + { + /* Switch to process context in which hDevice is valid */ + KeAttachProcess(W32kDeviceProcess); + } Status = ObReferenceObjectByHandle(hDevice, FILE_READ_DATA | FILE_WRITE_DATA, @@ -64,7 +69,10 @@ EngDeviceIoControl(HANDLE hDevice, KernelMode, (PVOID *)&FileObject, NULL); - KeDetachProcess(); + if (CurrentProcess != W32kDeviceProcess) + { + KeDetachProcess(); + } if (!NT_SUCCESS(Status)) { diff --git a/reactos/subsys/win32k/misc/driver.c b/reactos/subsys/win32k/misc/driver.c index 8feecb194ad..4d09e53ee10 100644 --- a/reactos/subsys/win32k/misc/driver.c +++ b/reactos/subsys/win32k/misc/driver.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: driver.c,v 1.26 2003/08/13 20:24:05 chorns Exp $ +/* $Id: driver.c,v 1.27 2003/08/18 10:18:14 hbirr Exp $ * * GDI Driver support routines * (mostly swiped from Wine) @@ -244,9 +244,14 @@ HANDLE DRIVER_FindMPDriver(LPCWSTR Name) IO_STATUS_BLOCK Iosb; HANDLE DisplayHandle; NTSTATUS Status; + PEPROCESS CurrentProcess; - /* Switch to process context in which handle is to be valid */ - KeAttachProcess(W32kDeviceProcess); + CurrentProcess = PsGetCurrentProcess(); + if (CurrentProcess != W32kDeviceProcess) + { + /* Switch to process context in which handle is to be valid */ + KeAttachProcess(W32kDeviceProcess); + } RtlInitUnicodeStringFromLiteral(&DeviceName, L"\\??\\DISPLAY1"); InitializeObjectAttributes(&ObjectAttributes, @@ -261,7 +266,10 @@ HANDLE DRIVER_FindMPDriver(LPCWSTR Name) 0, FILE_SYNCHRONOUS_IO_ALERT); - KeDetachProcess(); + if (CurrentProcess != W32kDeviceProcess) + { + KeDetachProcess(); + } if (!NT_SUCCESS(Status)) { diff --git a/reactos/subsys/win32k/objects/dc.c b/reactos/subsys/win32k/objects/dc.c index 6e04aca2d94..11254681c30 100644 --- a/reactos/subsys/win32k/objects/dc.c +++ b/reactos/subsys/win32k/objects/dc.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: dc.c,v 1.70 2003/08/17 17:32:58 royce Exp $ +/* $Id: dc.c,v 1.71 2003/08/18 10:18:14 hbirr Exp $ * * DC.C - Device context functions * @@ -511,6 +511,7 @@ W32kDeleteDC(HDC DCHandle) { if (!DRIVER_UnreferenceDriver (DCToDelete->DriverName)) { + PEPROCESS CurrentProcess; DPRINT( "No more references to driver, reseting display\n" ); DCToDelete->DriverFunctions.AssertMode( DCToDelete->PDev, FALSE ); CHECKPOINT; @@ -518,9 +519,16 @@ W32kDeleteDC(HDC DCHandle) CHECKPOINT; DCToDelete->DriverFunctions.DisablePDev(DCToDelete->PDev); - KeAttachProcess(W32kDeviceProcess); + CurrentProcess = PsGetCurrentProcess(); + if (CurrentProcess != W32kDeviceProcess) + { + KeAttachProcess(W32kDeviceProcess); + } ZwClose(PrimarySurface.DisplayDevice); - KeDetachProcess(); + if (CurrentProcess != W32kDeviceProcess) + { + KeDetachProcess(); + } PrimarySurfaceCreated = FALSE; } diff --git a/reactos/subsys/win32k/objects/gdiobj.c b/reactos/subsys/win32k/objects/gdiobj.c index 2826f3edca4..709027b5bf7 100644 --- a/reactos/subsys/win32k/objects/gdiobj.c +++ b/reactos/subsys/win32k/objects/gdiobj.c @@ -19,7 +19,7 @@ /* * GDIOBJ.C - GDI object manipulation routines * - * $Id: gdiobj.c,v 1.35 2003/08/17 17:32:58 royce Exp $ + * $Id: gdiobj.c,v 1.36 2003/08/18 10:18:14 hbirr Exp $ * */ @@ -534,9 +534,14 @@ CleanupForProcess (struct _EPROCESS *Process, INT Pid) DWORD i; PGDI_HANDLE_ENTRY handleEntry; PGDIOBJHDR objectHeader; + PEPROCESS CurrentProcess; //NTSTATUS Status; - KeAttachProcess(Process); + CurrentProcess = PsGetCurrentProcess(); + if (CurrentProcess != Process) + { + KeAttachProcess(Process); + } for(i = 1; i < GDI_HANDLE_NUMBER; i++) { @@ -550,7 +555,10 @@ CleanupForProcess (struct _EPROCESS *Process, INT Pid) } } - KeDetachProcess(); + if (CurrentProcess != Process) + { + KeDetachProcess(); + } return TRUE; }