mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
- Fix KeEnterCriticalRegion/KeLeaveCriticalRegion by moving to ke_x and adding ASSERTs, and change the code in apc.c to call these inlined versions instead. Also fix comment headers for these functions in apc.c to match the official standard.
svn path=/trunk/; revision=24049
This commit is contained in:
parent
38759195cb
commit
4d94e0557f
5 changed files with 83 additions and 81 deletions
|
@ -146,25 +146,6 @@ extern VOID KiTrap2(VOID);
|
||||||
InitializeListHead(&((Header)->WaitListHead)); \
|
InitializeListHead(&((Header)->WaitListHead)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define KeEnterCriticalRegion() \
|
|
||||||
{ \
|
|
||||||
PKTHREAD _Thread = KeGetCurrentThread(); \
|
|
||||||
if (_Thread) _Thread->KernelApcDisable--; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define KeLeaveCriticalRegion() \
|
|
||||||
{ \
|
|
||||||
PKTHREAD _Thread = KeGetCurrentThread(); \
|
|
||||||
if((_Thread) && (++_Thread->KernelApcDisable == 0)) \
|
|
||||||
{ \
|
|
||||||
if (!IsListEmpty(&_Thread->ApcState.ApcListHead[KernelMode]) && \
|
|
||||||
(_Thread->SpecialApcDisable == 0)) \
|
|
||||||
{ \
|
|
||||||
KiCheckForKernelApcDelivery(); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define KEBUGCHECKWITHTF(a,b,c,d,e,f) \
|
#define KEBUGCHECKWITHTF(a,b,c,d,e,f) \
|
||||||
DbgPrint("KeBugCheckWithTf at %s:%i\n",__FILE__,__LINE__), \
|
DbgPrint("KeBugCheckWithTf at %s:%i\n",__FILE__,__LINE__), \
|
||||||
KeBugCheckWithTf(a,b,c,d,e,f)
|
KeBugCheckWithTf(a,b,c,d,e,f)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//
|
//
|
||||||
// Enters a Critical Region
|
// Enters a Guarded Region
|
||||||
//
|
//
|
||||||
#define KeEnterGuardedRegion() \
|
#define KeEnterGuardedRegion() \
|
||||||
{ \
|
{ \
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Leaves a Critical Region
|
// Leaves a Guarded Region
|
||||||
//
|
//
|
||||||
#define KeLeaveGuardedRegion() \
|
#define KeLeaveGuardedRegion() \
|
||||||
{ \
|
{ \
|
||||||
|
@ -53,8 +53,51 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// TODO: Critical Region Routines
|
// Enters a Critical Region
|
||||||
//
|
//
|
||||||
|
#define KeEnterCriticalRegion() \
|
||||||
|
{ \
|
||||||
|
PKTHREAD Thread = KeGetCurrentThread(); \
|
||||||
|
if (Thread) \
|
||||||
|
{ \
|
||||||
|
/* Sanity checks */ \
|
||||||
|
ASSERT(Thread == KeGetCurrentThread()); \
|
||||||
|
ASSERT((Thread->KernelApcDisable <= 0) && \
|
||||||
|
(Thread->KernelApcDisable != -32768)); \
|
||||||
|
\
|
||||||
|
/* Disable Kernel APCs */ \
|
||||||
|
Thread->KernelApcDisable--; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Leaves a Critical Region
|
||||||
|
//
|
||||||
|
#define KeLeaveCriticalRegion() \
|
||||||
|
{ \
|
||||||
|
PKTHREAD Thread = KeGetCurrentThread(); \
|
||||||
|
if (Thread) \
|
||||||
|
{ \
|
||||||
|
/* Sanity checks */ \
|
||||||
|
ASSERT(Thread == KeGetCurrentThread()); \
|
||||||
|
ASSERT(Thread->KernelApcDisable < 0); \
|
||||||
|
\
|
||||||
|
/* Enable Kernel APCs */ \
|
||||||
|
Thread->KernelApcDisable++; \
|
||||||
|
\
|
||||||
|
/* Check if Kernel APCs are now enabled */ \
|
||||||
|
if (!(Thread->KernelApcDisable)) \
|
||||||
|
{ \
|
||||||
|
/* Check if we need to request an APC Delivery */ \
|
||||||
|
if (!(IsListEmpty(&Thread->ApcState.ApcListHead[KernelMode])) && \
|
||||||
|
!(Thread->KernelApcDisable)) \
|
||||||
|
{ \
|
||||||
|
/* Check for the right environment */ \
|
||||||
|
KiCheckForKernelApcDelivery(); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Satisfies the wait of any dispatcher object
|
// Satisfies the wait of any dispatcher object
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* PROJECT: ReactOS Kernel
|
||||||
* PROJECT: ReactOS kernel
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* FILE: ntoskrnl/ke/apc.c
|
* FILE: ntoskrnl/ke/apc.c
|
||||||
* PURPOSE: NT Implementation of APCs
|
* PURPOSE: Implements the Asyncronous Procedure Call mechanism
|
||||||
*
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||||
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
|
||||||
* Phillip Susi
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
@ -17,27 +15,24 @@
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
* KiCheckForKernelApcDelivery
|
* @name KiCheckForKernelApcDelivery
|
||||||
* @implemented NT 5.2
|
* @implemented NT 5.2
|
||||||
*
|
*
|
||||||
* The KiCheckForKernelApcDelivery routine is called whenever APCs have just
|
* The KiCheckForKernelApcDelivery routine is called whenever APCs have just
|
||||||
* been re-enabled in Kernel Mode, such as after leaving a Critical or
|
* been re-enabled in Kernel Mode, such as after leaving a Critical or
|
||||||
* Guarded Region. It delivers APCs if the environment is right.
|
* Guarded Region. It delivers APCs if the environment is right.
|
||||||
*
|
*
|
||||||
* Params:
|
* @param None.
|
||||||
* None.
|
|
||||||
*
|
*
|
||||||
* Returns:
|
* @return None.
|
||||||
* None.
|
|
||||||
*
|
*
|
||||||
* Remarks:
|
* @remarks This routine allows KeLeave/EnterCritical/GuardedRegion to be used
|
||||||
* This routine allows KeLeave/EnterCritical/GuardedRegion to be used as a
|
* as macro from inside WIN32K or other Drivers, which will then only
|
||||||
* macro from inside WIN32K or other Drivers, which will then only have to
|
* have do an Import API call in the case where APCs are enabled again.
|
||||||
* do an Import API call in the case where APCs are enabled again.
|
|
||||||
*
|
*
|
||||||
*--*/
|
*--*/
|
||||||
VOID
|
VOID
|
||||||
STDCALL
|
NTAPI
|
||||||
KiCheckForKernelApcDelivery(VOID)
|
KiCheckForKernelApcDelivery(VOID)
|
||||||
{
|
{
|
||||||
/* We should only deliver at passive */
|
/* We should only deliver at passive */
|
||||||
|
@ -63,34 +58,31 @@ KiCheckForKernelApcDelivery(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
* KeEnterCriticalRegion
|
* @name KeEnterCriticalRegion
|
||||||
* @implemented NT4
|
* @implemented NT4
|
||||||
*
|
*
|
||||||
* The KeEnterCriticalRegion routine temporarily disables the delivery of
|
* The KeEnterCriticalRegion routine temporarily disables the delivery of
|
||||||
* normal kernel APCs; special kernel-mode APCs are still delivered.
|
* normal kernel APCs; special kernel-mode APCs are still delivered.
|
||||||
*
|
*
|
||||||
* Params:
|
* @param None.
|
||||||
* None.
|
|
||||||
*
|
*
|
||||||
* Returns:
|
* @return None.
|
||||||
* None.
|
|
||||||
*
|
*
|
||||||
* Remarks:
|
* @remarks Highest-level drivers can call this routine while running in the
|
||||||
* Highest-level drivers can call this routine while running in the context
|
* context of the thread that requested the current I/O operation.
|
||||||
* of the thread that requested the current I/O operation. Any caller of
|
* Any caller of this routine should call KeLeaveCriticalRegion as
|
||||||
* this routine should call KeLeaveCriticalRegion as quickly as possible.
|
* quickly as possible.
|
||||||
*
|
*
|
||||||
* Callers of KeEnterCriticalRegion must be running at IRQL <= APC_LEVEL.
|
* Callers of KeEnterCriticalRegion must be running at IRQL <=
|
||||||
|
* APC_LEVEL.
|
||||||
*
|
*
|
||||||
*--*/
|
*--*/
|
||||||
#undef KeEnterCriticalRegion
|
|
||||||
VOID
|
VOID
|
||||||
STDCALL
|
NTAPI
|
||||||
KeEnterCriticalRegion(VOID)
|
_KeEnterCriticalRegion(VOID)
|
||||||
{
|
{
|
||||||
/* Disable Kernel APCs */
|
/* Use inlined function */
|
||||||
PKTHREAD Thread = KeGetCurrentThread();
|
KeEnterCriticalRegion();
|
||||||
if (Thread) Thread->KernelApcDisable--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
|
@ -100,37 +92,23 @@ KeEnterCriticalRegion(VOID)
|
||||||
* The KeLeaveCriticalRegion routine reenables the delivery of normal
|
* The KeLeaveCriticalRegion routine reenables the delivery of normal
|
||||||
* kernel-mode APCs that were disabled by a call to KeEnterCriticalRegion.
|
* kernel-mode APCs that were disabled by a call to KeEnterCriticalRegion.
|
||||||
*
|
*
|
||||||
* Params:
|
* @param None.
|
||||||
* None.
|
|
||||||
*
|
*
|
||||||
* Returns:
|
* @return None.
|
||||||
* None.
|
|
||||||
*
|
*
|
||||||
* Remarks:
|
* @remarks Highest-level drivers can call this routine while running in the
|
||||||
* Highest-level drivers can call this routine while running in the context
|
* context of the thread that requested the current I/O operation.
|
||||||
* of the thread that requested the current I/O operation.
|
|
||||||
*
|
*
|
||||||
* Callers of KeLeaveCriticalRegion must be running at IRQL <= DISPATCH_LEVEL.
|
* Callers of KeLeaveCriticalRegion must be running at IRQL <=
|
||||||
|
* DISPATCH_LEVEL.
|
||||||
*
|
*
|
||||||
*--*/
|
*--*/
|
||||||
#undef KeLeaveCriticalRegion
|
|
||||||
VOID
|
VOID
|
||||||
STDCALL
|
NTAPI
|
||||||
KeLeaveCriticalRegion (VOID)
|
_KeLeaveCriticalRegion(VOID)
|
||||||
{
|
{
|
||||||
PKTHREAD Thread = KeGetCurrentThread();
|
/* Use inlined version */
|
||||||
|
KeLeaveCriticalRegion();
|
||||||
/* Check if Kernel APCs are now enabled */
|
|
||||||
if((Thread) && (++Thread->KernelApcDisable == 0))
|
|
||||||
{
|
|
||||||
/* Check if we need to request an APC Delivery */
|
|
||||||
if ((!IsListEmpty(&Thread->ApcState.ApcListHead[KernelMode])) &&
|
|
||||||
(Thread->SpecialApcDisable == 0))
|
|
||||||
{
|
|
||||||
/* Check for the right environment */
|
|
||||||
KiCheckForKernelApcDelivery();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
|
|
|
@ -534,7 +534,7 @@ KeDeregisterBugCheckCallback@4
|
||||||
KeDeregisterBugCheckReasonCallback@4
|
KeDeregisterBugCheckReasonCallback@4
|
||||||
KeDetachProcess@0
|
KeDetachProcess@0
|
||||||
KeDisconnectInterrupt@4
|
KeDisconnectInterrupt@4
|
||||||
KeEnterCriticalRegion@0
|
KeEnterCriticalRegion@=_KeEnterCriticalRegion@0
|
||||||
KeEnterGuardedRegion@0
|
KeEnterGuardedRegion@0
|
||||||
KeEnterKernelDebugger@0
|
KeEnterKernelDebugger@0
|
||||||
KeFindConfigurationEntry@16
|
KeFindConfigurationEntry@16
|
||||||
|
@ -576,7 +576,7 @@ KeInsertQueueApc@16
|
||||||
KeInsertQueueDpc@12
|
KeInsertQueueDpc@12
|
||||||
KeIsAttachedProcess@0
|
KeIsAttachedProcess@0
|
||||||
KeIsExecutingDpc@0
|
KeIsExecutingDpc@0
|
||||||
KeLeaveCriticalRegion@0
|
KeLeaveCriticalRegion@0=_KeLeaveCriticalRegion@0
|
||||||
KeLeaveGuardedRegion@0
|
KeLeaveGuardedRegion@0
|
||||||
KeLoaderBlock DATA
|
KeLoaderBlock DATA
|
||||||
KeNumberProcessors DATA
|
KeNumberProcessors DATA
|
||||||
|
|
|
@ -583,7 +583,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
|
||||||
PROCESS_PRIORITY_NORMAL,
|
PROCESS_PRIORITY_NORMAL,
|
||||||
Affinity,
|
Affinity,
|
||||||
&DirectoryTableBase,
|
&DirectoryTableBase,
|
||||||
Process->DefaultHardErrorProcessing & 4);
|
(BOOLEAN)(Process->DefaultHardErrorProcessing & 4));
|
||||||
|
|
||||||
/* Duplicate Parent Token */
|
/* Duplicate Parent Token */
|
||||||
Status = PspInitializeProcessSecurity(Process, Parent);
|
Status = PspInitializeProcessSecurity(Process, Parent);
|
||||||
|
|
Loading…
Reference in a new issue