From a988e5ab0e9761cc27e60239dad2b54c7393c7db Mon Sep 17 00:00:00 2001 From: Gunnar Dalsnes Date: Thu, 5 Jun 2003 23:38:37 +0000 Subject: [PATCH] -corrected protoype svn path=/trunk/; revision=4848 --- reactos/include/ddk/kefuncs.h | 6 +++--- reactos/include/ddk/ketypes.h | 6 ++++++ reactos/ntoskrnl/io/cleanup.c | 4 ++-- reactos/ntoskrnl/io/irp.c | 6 +++--- reactos/ntoskrnl/ke/apc.c | 29 +++++++++++++++++++---------- reactos/ntoskrnl/ke/kthread.c | 4 ++-- reactos/ntoskrnl/nt/nttimer.c | 6 +++--- reactos/ntoskrnl/ps/create.c | 6 +++--- reactos/ntoskrnl/ps/debug.c | 6 +++--- reactos/ntoskrnl/ps/kill.c | 6 +++--- reactos/ntoskrnl/ps/suspend.c | 4 ++-- 11 files changed, 49 insertions(+), 34 deletions(-) diff --git a/reactos/include/ddk/kefuncs.h b/reactos/include/ddk/kefuncs.h index bb479335592..4f169d052ac 100644 --- a/reactos/include/ddk/kefuncs.h +++ b/reactos/include/ddk/kefuncs.h @@ -87,11 +87,11 @@ ULONG STDCALL KeGetPreviousMode (VOID); VOID STDCALL KeInitializeApc (PKAPC Apc, struct _KTHREAD* Thread, - UCHAR StateIndex, + KAPC_ENVIRONMENT Environment, PKKERNEL_ROUTINE KernelRoutine, PKRUNDOWN_ROUTINE RundownRoutine, PKNORMAL_ROUTINE NormalRoutine, - UCHAR Mode, + KPROCESSOR_MODE Mode, PVOID Context); /* @@ -172,7 +172,7 @@ KeInsertQueue(IN PKQUEUE Queue, BOOLEAN STDCALL KeInsertQueueApc (PKAPC Apc, PVOID SystemArgument1, PVOID SystemArgument2, - UCHAR Mode); + KPRIORITY PriorityBoost); BOOLEAN STDCALL KeInsertQueueDpc (PKDPC Dpc, PVOID SystemArgument1, diff --git a/reactos/include/ddk/ketypes.h b/reactos/include/ddk/ketypes.h index 4b5921d1fc1..72be56b8c51 100644 --- a/reactos/include/ddk/ketypes.h +++ b/reactos/include/ddk/ketypes.h @@ -44,6 +44,12 @@ typedef VOID STDCALL_FUNC typedef VOID STDCALL_FUNC (*PKRUNDOWN_ROUTINE)(struct _KAPC* Apc); +typedef enum _KAPC_ENVIRONMENT { + OriginalApcEnvironment, + AttachedApcEnvironment, + CurrentApcEnvironment +} KAPC_ENVIRONMENT; + struct _DISPATCHER_HEADER; typedef struct _KWAIT_BLOCK diff --git a/reactos/ntoskrnl/io/cleanup.c b/reactos/ntoskrnl/io/cleanup.c index 860fa5f32bd..064f2d7b712 100644 --- a/reactos/ntoskrnl/io/cleanup.c +++ b/reactos/ntoskrnl/io/cleanup.c @@ -256,7 +256,7 @@ IoSecondStageCompletion( KeInitializeApc( &Irp->Tail.Apc, KeGetCurrentThread(), - 0, + OriginalApcEnvironment, IoSecondStageCompletion_KernelApcRoutine, IoSecondStageCompletion_RundownApcRoutine, UserApcRoutine, @@ -266,7 +266,7 @@ IoSecondStageCompletion( KeInsertQueueApc( &Irp->Tail.Apc, Irp, NULL, - KernelMode); + PriorityBoost); //NOTE: kernel (or rundown) routine frees the IRP diff --git a/reactos/ntoskrnl/io/irp.c b/reactos/ntoskrnl/io/irp.c index ba5daa0f7da..9af39ca8f11 100644 --- a/reactos/ntoskrnl/io/irp.c +++ b/reactos/ntoskrnl/io/irp.c @@ -1,4 +1,4 @@ -/* $Id: irp.c,v 1.50 2003/05/22 00:47:04 gdalsnes Exp $ +/* $Id: irp.c,v 1.51 2003/06/05 23:37:10 gdalsnes Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -270,7 +270,7 @@ IofCompleteRequest(PIRP Irp, DPRINT("Dispatching APC\n"); KeInitializeApc( &Irp->Tail.Apc, &Irp->Tail.Overlay.Thread->Tcb, - 0, + OriginalApcEnvironment, IoSecondStageCompletion, NULL, (PKNORMAL_ROUTINE) NULL, @@ -280,7 +280,7 @@ IofCompleteRequest(PIRP Irp, bStatus = KeInsertQueueApc(&Irp->Tail.Apc, (PVOID)Irp, (PVOID)(ULONG)PriorityBoost, - KernelMode); + PriorityBoost); if (bStatus == FALSE) { diff --git a/reactos/ntoskrnl/ke/apc.c b/reactos/ntoskrnl/ke/apc.c index b8e30c0f270..f6d01da659c 100644 --- a/reactos/ntoskrnl/ke/apc.c +++ b/reactos/ntoskrnl/ke/apc.c @@ -291,7 +291,7 @@ BOOLEAN STDCALL KeInsertQueueApc (PKAPC Apc, PVOID SystemArgument1, PVOID SystemArgument2, - UCHAR Mode) + KPRIORITY PriorityBoost) /* * FUNCTION: Queues an APC for execution * ARGUMENTS: @@ -305,8 +305,8 @@ KeInsertQueueApc (PKAPC Apc, PKTHREAD TargetThread; DPRINT("KeInsertQueueApc(Apc %x, SystemArgument1 %x, " - "SystemArgument2 %x, Mode %d)\n",Apc,SystemArgument1, - SystemArgument2,Mode); + "SystemArgument2 %x)\n",Apc,SystemArgument1, + SystemArgument2); KeAcquireSpinLock(&PiApcLock, &oldlvl); @@ -443,11 +443,11 @@ KeRemoveQueueApc (PKAPC Apc) VOID STDCALL KeInitializeApc(PKAPC Apc, PKTHREAD Thread, - UCHAR StateIndex, + KAPC_ENVIRONMENT Environment, PKKERNEL_ROUTINE KernelRoutine, PKRUNDOWN_ROUTINE RundownRoutine, PKNORMAL_ROUTINE NormalRoutine, - UCHAR Mode, + KPROCESSOR_MODE Mode, PVOID Context) /* * FUNCTION: Initialize an APC object @@ -463,9 +463,9 @@ KeInitializeApc(PKAPC Apc, * Context = Parameter to be passed to the APC routine */ { - DPRINT("KeInitializeApc(Apc %x, Thread %x, StateIndex %d, " + DPRINT("KeInitializeApc(Apc %x, Thread %x, Environment %d, " "KernelRoutine %x, RundownRoutine %x, NormalRoutine %x, Mode %d, " - "Context %x)\n",Apc,Thread,StateIndex,KernelRoutine,RundownRoutine, + "Context %x)\n",Apc,Thread,Environment,KernelRoutine,RundownRoutine, NormalRoutine,Mode,Context); memset(Apc, 0, sizeof(KAPC)); @@ -477,7 +477,16 @@ KeInitializeApc(PKAPC Apc, Apc->NormalRoutine = NormalRoutine; Apc->NormalContext = Context; Apc->Inserted = FALSE; - Apc->ApcStateIndex = StateIndex; + + if (Environment == CurrentApcEnvironment) + { + Apc->ApcStateIndex = Thread->ApcStateIndex; + } + else + { + Apc->ApcStateIndex = Environment; + } + if (Apc->NormalRoutine != NULL) { Apc->ApcMode = Mode; @@ -535,7 +544,7 @@ NtQueueApcThread(HANDLE ThreadHandle, KeInitializeApc(Apc, &Thread->Tcb, - 0, + OriginalApcEnvironment, NtQueueApcKernelRoutine, NtQueueApcRundownRoutine, ApcRoutine, @@ -544,7 +553,7 @@ NtQueueApcThread(HANDLE ThreadHandle, KeInsertQueueApc(Apc, SystemArgument1, SystemArgument2, - UserMode); + IO_NO_INCREMENT); ObDereferenceObject(Thread); return(STATUS_SUCCESS); diff --git a/reactos/ntoskrnl/ke/kthread.c b/reactos/ntoskrnl/ke/kthread.c index a4806771f35..769e2cd5348 100644 --- a/reactos/ntoskrnl/ke/kthread.c +++ b/reactos/ntoskrnl/ke/kthread.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: kthread.c,v 1.37 2003/05/17 15:28:06 ekohl Exp $ +/* $Id: kthread.c,v 1.38 2003/06/05 23:37:00 gdalsnes Exp $ * * FILE: ntoskrnl/ke/kthread.c * PURPOSE: Microkernel thread support @@ -214,7 +214,7 @@ KeInitializeThread(PKPROCESS Process, PKTHREAD Thread, BOOLEAN First) Thread->AutoAlignment = 0; KeInitializeApc(&Thread->SuspendApc, Thread, - 0, + OriginalApcEnvironment, PiSuspendThreadKernelRoutine, PiSuspendThreadRundownRoutine, PiSuspendThreadNormalRoutine, diff --git a/reactos/ntoskrnl/nt/nttimer.c b/reactos/ntoskrnl/nt/nttimer.c index bcc77e340db..d9ffa5ba405 100644 --- a/reactos/ntoskrnl/nt/nttimer.c +++ b/reactos/ntoskrnl/nt/nttimer.c @@ -1,4 +1,4 @@ -/* $Id: nttimer.c,v 1.17 2003/02/27 15:41:54 gdalsnes Exp $ +/* $Id: nttimer.c,v 1.18 2003/06/05 23:36:48 gdalsnes Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -99,7 +99,7 @@ NtpTimerDpcRoutine(PKDPC Dpc, KeInsertQueueApc(&Timer->Apc, SystemArgument1, SystemArgument2, - KernelMode); + IO_NO_INCREMENT); } } @@ -335,7 +335,7 @@ NtSetTimer(IN HANDLE TimerHandle, if( TimerApcRoutine ) KeInitializeApc(&Timer->Apc, KeGetCurrentThread(), - 0, + OriginalApcEnvironment, (PKKERNEL_ROUTINE)NtpTimerApcKernelRoutine, (PKRUNDOWN_ROUTINE)NULL, (PKNORMAL_ROUTINE)TimerApcRoutine, diff --git a/reactos/ntoskrnl/ps/create.c b/reactos/ntoskrnl/ps/create.c index 991fff2f879..629f054aeaf 100644 --- a/reactos/ntoskrnl/ps/create.c +++ b/reactos/ntoskrnl/ps/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.59 2003/06/05 22:45:38 gdalsnes Exp $ +/* $Id: create.c,v 1.60 2003/06/05 23:36:35 gdalsnes Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -626,10 +626,10 @@ NtCreateThread(PHANDLE ThreadHandle, * routine. */ LdrInitApc = ExAllocatePool(NonPagedPool, sizeof(KAPC)); - KeInitializeApc(LdrInitApc, &Thread->Tcb, 0, LdrInitApcKernelRoutine, + KeInitializeApc(LdrInitApc, &Thread->Tcb, OriginalApcEnvironment, LdrInitApcKernelRoutine, LdrInitApcRundownRoutine, LdrpGetSystemDllEntryPoint(), UserMode, NULL); - KeInsertQueueApc(LdrInitApc, NULL, NULL, UserMode); + KeInsertQueueApc(LdrInitApc, NULL, NULL, IO_NO_INCREMENT); /* * Start the thread running and force it to execute the APC(s) we just diff --git a/reactos/ntoskrnl/ps/debug.c b/reactos/ntoskrnl/ps/debug.c index 286c31bd5e5..d1746f8fa20 100644 --- a/reactos/ntoskrnl/ps/debug.c +++ b/reactos/ntoskrnl/ps/debug.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: debug.c,v 1.7 2002/12/22 11:35:15 gvg Exp $ +/* $Id: debug.c,v 1.8 2003/06/05 23:36:35 gdalsnes Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/ps/debug.c @@ -236,7 +236,7 @@ NtGetContextThread(IN HANDLE ThreadHandle, KeInitializeApc(&Apc, &Thread->Tcb, - 0, + OriginalApcEnvironment, KeGetContextKernelRoutine, KeGetContextRundownRoutine, NULL, @@ -245,7 +245,7 @@ NtGetContextThread(IN HANDLE ThreadHandle, KeInsertQueueApc(&Apc, (PVOID)&Event, (PVOID)&AStatus, - 0); + IO_NO_INCREMENT); Status = KeWaitForSingleObject(&Event, 0, UserMode, diff --git a/reactos/ntoskrnl/ps/kill.c b/reactos/ntoskrnl/ps/kill.c index 0d5c8e696a5..ac2af198c25 100644 --- a/reactos/ntoskrnl/ps/kill.c +++ b/reactos/ntoskrnl/ps/kill.c @@ -1,4 +1,4 @@ -/* $Id: kill.c,v 1.59 2003/05/01 22:00:31 gvg Exp $ +/* $Id: kill.c,v 1.60 2003/06/05 23:36:35 gdalsnes Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -235,7 +235,7 @@ PsTerminateOtherThread(PETHREAD Thread, Apc = ExAllocatePoolWithTag(NonPagedPool, sizeof(KAPC), TAG_TERMINATE_APC); KeInitializeApc(Apc, &Thread->Tcb, - 0, + OriginalApcEnvironment, PiTerminateThreadKernelRoutine, PiTerminateThreadRundownRoutine, PiTerminateThreadNormalRoutine, @@ -244,7 +244,7 @@ PsTerminateOtherThread(PETHREAD Thread, KeInsertQueueApc(Apc, NULL, NULL, - KernelMode); + IO_NO_INCREMENT); if (THREAD_STATE_BLOCKED == Thread->Tcb.State && UserMode == Thread->Tcb.WaitMode) { DPRINT("Unblocking thread\n"); diff --git a/reactos/ntoskrnl/ps/suspend.c b/reactos/ntoskrnl/ps/suspend.c index ab6c843f090..878a15d4ae1 100644 --- a/reactos/ntoskrnl/ps/suspend.c +++ b/reactos/ntoskrnl/ps/suspend.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: suspend.c,v 1.10 2002/09/08 10:23:40 chorns Exp $ +/* $Id: suspend.c,v 1.11 2003/06/05 23:36:35 gdalsnes Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/ps/suspend.c @@ -113,7 +113,7 @@ PsSuspendThread(PETHREAD Thread, PULONG PreviousSuspendCount) KeInsertQueueApc(&Thread->Tcb.SuspendApc, NULL, NULL, - 0); + IO_NO_INCREMENT); } ExReleaseFastMutex(&SuspendMutex); if (PreviousSuspendCount != NULL)