- Do not call KeAttachProcess/keDetachProcess if the current process is the necessary process.

svn path=/trunk/; revision=5638
This commit is contained in:
Hartmut Birr 2003-08-18 10:18:14 +00:00
parent e7eff667e5
commit 8ab6fed82c
4 changed files with 46 additions and 14 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -50,13 +50,18 @@ EngDeviceIoControl(HANDLE hDevice,
KEVENT Event; KEVENT Event;
IO_STATUS_BLOCK Iosb; IO_STATUS_BLOCK Iosb;
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
PEPROCESS CurrentProcess;
DPRINT("EngDeviceIoControl() called\n"); DPRINT("EngDeviceIoControl() called\n");
KeInitializeEvent(&Event, SynchronizationEvent, FALSE); KeInitializeEvent(&Event, SynchronizationEvent, FALSE);
/* Switch to process context in which hDevice is valid */ CurrentProcess = PsGetCurrentProcess();
KeAttachProcess(W32kDeviceProcess); if (CurrentProcess != W32kDeviceProcess)
{
/* Switch to process context in which hDevice is valid */
KeAttachProcess(W32kDeviceProcess);
}
Status = ObReferenceObjectByHandle(hDevice, Status = ObReferenceObjectByHandle(hDevice,
FILE_READ_DATA | FILE_WRITE_DATA, FILE_READ_DATA | FILE_WRITE_DATA,
@ -64,7 +69,10 @@ EngDeviceIoControl(HANDLE hDevice,
KernelMode, KernelMode,
(PVOID *)&FileObject, (PVOID *)&FileObject,
NULL); NULL);
KeDetachProcess(); if (CurrentProcess != W32kDeviceProcess)
{
KeDetachProcess();
}
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * GDI Driver support routines
* (mostly swiped from Wine) * (mostly swiped from Wine)
@ -244,9 +244,14 @@ HANDLE DRIVER_FindMPDriver(LPCWSTR Name)
IO_STATUS_BLOCK Iosb; IO_STATUS_BLOCK Iosb;
HANDLE DisplayHandle; HANDLE DisplayHandle;
NTSTATUS Status; NTSTATUS Status;
PEPROCESS CurrentProcess;
/* Switch to process context in which handle is to be valid */ CurrentProcess = PsGetCurrentProcess();
KeAttachProcess(W32kDeviceProcess); if (CurrentProcess != W32kDeviceProcess)
{
/* Switch to process context in which handle is to be valid */
KeAttachProcess(W32kDeviceProcess);
}
RtlInitUnicodeStringFromLiteral(&DeviceName, L"\\??\\DISPLAY1"); RtlInitUnicodeStringFromLiteral(&DeviceName, L"\\??\\DISPLAY1");
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
@ -261,7 +266,10 @@ HANDLE DRIVER_FindMPDriver(LPCWSTR Name)
0, 0,
FILE_SYNCHRONOUS_IO_ALERT); FILE_SYNCHRONOUS_IO_ALERT);
KeDetachProcess(); if (CurrentProcess != W32kDeviceProcess)
{
KeDetachProcess();
}
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * DC.C - Device context functions
* *
@ -511,6 +511,7 @@ W32kDeleteDC(HDC DCHandle)
{ {
if (!DRIVER_UnreferenceDriver (DCToDelete->DriverName)) if (!DRIVER_UnreferenceDriver (DCToDelete->DriverName))
{ {
PEPROCESS CurrentProcess;
DPRINT( "No more references to driver, reseting display\n" ); DPRINT( "No more references to driver, reseting display\n" );
DCToDelete->DriverFunctions.AssertMode( DCToDelete->PDev, FALSE ); DCToDelete->DriverFunctions.AssertMode( DCToDelete->PDev, FALSE );
CHECKPOINT; CHECKPOINT;
@ -518,9 +519,16 @@ W32kDeleteDC(HDC DCHandle)
CHECKPOINT; CHECKPOINT;
DCToDelete->DriverFunctions.DisablePDev(DCToDelete->PDev); DCToDelete->DriverFunctions.DisablePDev(DCToDelete->PDev);
KeAttachProcess(W32kDeviceProcess); CurrentProcess = PsGetCurrentProcess();
if (CurrentProcess != W32kDeviceProcess)
{
KeAttachProcess(W32kDeviceProcess);
}
ZwClose(PrimarySurface.DisplayDevice); ZwClose(PrimarySurface.DisplayDevice);
KeDetachProcess(); if (CurrentProcess != W32kDeviceProcess)
{
KeDetachProcess();
}
PrimarySurfaceCreated = FALSE; PrimarySurfaceCreated = FALSE;
} }

View file

@ -19,7 +19,7 @@
/* /*
* GDIOBJ.C - GDI object manipulation routines * 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; DWORD i;
PGDI_HANDLE_ENTRY handleEntry; PGDI_HANDLE_ENTRY handleEntry;
PGDIOBJHDR objectHeader; PGDIOBJHDR objectHeader;
PEPROCESS CurrentProcess;
//NTSTATUS Status; //NTSTATUS Status;
KeAttachProcess(Process); CurrentProcess = PsGetCurrentProcess();
if (CurrentProcess != Process)
{
KeAttachProcess(Process);
}
for(i = 1; i < GDI_HANDLE_NUMBER; i++) 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; return TRUE;
} }