mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
use tags for pool allocations, and reformat code
svn path=/trunk/; revision=14546
This commit is contained in:
parent
dac8f53fe5
commit
18cff7ccc9
1 changed files with 452 additions and 432 deletions
|
@ -27,6 +27,7 @@
|
|||
/* GLOBAL *******************************************************************/
|
||||
|
||||
#define MAX_THREAD_NOTIFY_ROUTINE_COUNT 8
|
||||
#define TAG_KAPC TAG('k','p','a','p') /* kpap - kernel ps apc */
|
||||
|
||||
static ULONG PiThreadNotifyRoutineCount = 0;
|
||||
static PCREATE_THREAD_NOTIFY_ROUTINE
|
||||
|
@ -44,11 +45,12 @@ PiBeforeBeginThread(CONTEXT c)
|
|||
}
|
||||
|
||||
NTSTATUS
|
||||
PsInitializeThread(PEPROCESS Process,
|
||||
PsInitializeThread (
|
||||
PEPROCESS Process,
|
||||
PETHREAD* ThreadPtr,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
KPROCESSOR_MODE AccessMode,
|
||||
BOOLEAN First)
|
||||
BOOLEAN First )
|
||||
{
|
||||
PETHREAD Thread;
|
||||
NTSTATUS Status;
|
||||
|
@ -127,10 +129,11 @@ PsInitializeThread(PEPROCESS Process,
|
|||
|
||||
|
||||
static NTSTATUS
|
||||
PsCreateTeb(HANDLE ProcessHandle,
|
||||
PsCreateTeb (
|
||||
HANDLE ProcessHandle,
|
||||
PTEB *TebPtr,
|
||||
PETHREAD Thread,
|
||||
PINITIAL_TEB InitialTeb)
|
||||
PINITIAL_TEB InitialTeb )
|
||||
{
|
||||
PEPROCESS Process;
|
||||
NTSTATUS Status;
|
||||
|
@ -276,14 +279,15 @@ PsCreateTeb(HANDLE ProcessHandle,
|
|||
|
||||
|
||||
VOID STDCALL
|
||||
LdrInitApcRundownRoutine(PKAPC Apc)
|
||||
LdrInitApcRundownRoutine ( PKAPC Apc )
|
||||
{
|
||||
ExFreePool(Apc);
|
||||
}
|
||||
|
||||
|
||||
VOID STDCALL
|
||||
LdrInitApcKernelRoutine(PKAPC Apc,
|
||||
LdrInitApcKernelRoutine (
|
||||
PKAPC Apc,
|
||||
PKNORMAL_ROUTINE* NormalRoutine,
|
||||
PVOID* NormalContext,
|
||||
PVOID* SystemArgument1,
|
||||
|
@ -294,14 +298,15 @@ LdrInitApcKernelRoutine(PKAPC Apc,
|
|||
|
||||
|
||||
NTSTATUS STDCALL
|
||||
NtCreateThread(OUT PHANDLE ThreadHandle,
|
||||
NtCreateThread (
|
||||
OUT PHANDLE ThreadHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
|
||||
IN HANDLE ProcessHandle,
|
||||
OUT PCLIENT_ID ClientId,
|
||||
IN PCONTEXT ThreadContext,
|
||||
IN PINITIAL_TEB InitialTeb,
|
||||
IN BOOLEAN CreateSuspended)
|
||||
IN BOOLEAN CreateSuspended )
|
||||
{
|
||||
HANDLE hThread;
|
||||
CONTEXT SafeContext;
|
||||
|
@ -362,7 +367,8 @@ NtCreateThread(OUT PHANDLE ThreadHandle,
|
|||
DPRINT("NtCreateThread(ThreadHandle %x, PCONTEXT %x)\n",
|
||||
ThreadHandle,ThreadContext);
|
||||
|
||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||
Status = ObReferenceObjectByHandle(
|
||||
ProcessHandle,
|
||||
PROCESS_CREATE_THREAD,
|
||||
PsProcessType,
|
||||
PreviousMode,
|
||||
|
@ -402,7 +408,8 @@ NtCreateThread(OUT PHANDLE ThreadHandle,
|
|||
}
|
||||
|
||||
/* create a client id handle */
|
||||
Status = PsCreateCidHandle(Thread, PsThreadType, &Thread->Cid.UniqueThread);
|
||||
Status = PsCreateCidHandle (
|
||||
Thread, PsThreadType, &Thread->Cid.UniqueThread);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ObDereferenceObject(Thread);
|
||||
|
@ -454,10 +461,17 @@ NtCreateThread(OUT PHANDLE ThreadHandle,
|
|||
* Queue an APC to the thread that will execute the ntdll startup
|
||||
* routine.
|
||||
*/
|
||||
LdrInitApc = ExAllocatePool(NonPagedPool, sizeof(KAPC));
|
||||
KeInitializeApc(LdrInitApc, &Thread->Tcb, OriginalApcEnvironment, LdrInitApcKernelRoutine,
|
||||
LdrInitApcRundownRoutine, LdrpGetSystemDllEntryPoint(),
|
||||
UserMode, NULL);
|
||||
LdrInitApc = ExAllocatePoolWithTag (
|
||||
NonPagedPool, sizeof(KAPC), TAG_KAPC );
|
||||
KeInitializeApc (
|
||||
LdrInitApc,
|
||||
&Thread->Tcb,
|
||||
OriginalApcEnvironment,
|
||||
LdrInitApcKernelRoutine,
|
||||
LdrInitApcRundownRoutine,
|
||||
LdrpGetSystemDllEntryPoint(),
|
||||
UserMode,
|
||||
NULL );
|
||||
KeInsertQueueApc(LdrInitApc, NULL, NULL, IO_NO_INCREMENT);
|
||||
|
||||
/*
|
||||
|
@ -503,13 +517,14 @@ NtCreateThread(OUT PHANDLE ThreadHandle,
|
|||
* @implemented
|
||||
*/
|
||||
NTSTATUS STDCALL
|
||||
PsCreateSystemThread(PHANDLE ThreadHandle,
|
||||
PsCreateSystemThread (
|
||||
PHANDLE ThreadHandle,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
HANDLE ProcessHandle,
|
||||
PCLIENT_ID ClientId,
|
||||
PKSTART_ROUTINE StartRoutine,
|
||||
PVOID StartContext)
|
||||
PVOID StartContext )
|
||||
/*
|
||||
* FUNCTION: Creates a thread which executes in kernel mode
|
||||
* ARGUMENTS:
|
||||
|
@ -536,7 +551,8 @@ PsCreateSystemThread(PHANDLE ThreadHandle,
|
|||
DPRINT("PsCreateSystemThread(ThreadHandle %x, ProcessHandle %x)\n",
|
||||
ThreadHandle,ProcessHandle);
|
||||
|
||||
Status = PsInitializeThread(NULL,
|
||||
Status = PsInitializeThread(
|
||||
NULL,
|
||||
&Thread,
|
||||
ObjectAttributes,
|
||||
KernelMode,
|
||||
|
@ -559,7 +575,8 @@ PsCreateSystemThread(PHANDLE ThreadHandle,
|
|||
}
|
||||
|
||||
Thread->StartAddress = StartRoutine;
|
||||
Status = KiArchInitThread(&Thread->Tcb, StartRoutine, StartContext);
|
||||
Status = KiArchInitThread (
|
||||
&Thread->Tcb, StartRoutine, StartContext);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ObDereferenceObject(Thread);
|
||||
|
@ -575,7 +592,8 @@ PsCreateSystemThread(PHANDLE ThreadHandle,
|
|||
KiUnblockThread(&Thread->Tcb, NULL, 0);
|
||||
KeReleaseDispatcherDatabaseLock(oldIrql);
|
||||
|
||||
Status = ObInsertObject((PVOID)Thread,
|
||||
Status = ObInsertObject(
|
||||
(PVOID)Thread,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
0,
|
||||
|
@ -590,8 +608,9 @@ PsCreateSystemThread(PHANDLE ThreadHandle,
|
|||
|
||||
|
||||
VOID STDCALL
|
||||
PspRunCreateThreadNotifyRoutines(PETHREAD CurrentThread,
|
||||
BOOLEAN Create)
|
||||
PspRunCreateThreadNotifyRoutines (
|
||||
PETHREAD CurrentThread,
|
||||
BOOLEAN Create )
|
||||
{
|
||||
ULONG i;
|
||||
CLIENT_ID Cid = CurrentThread->Cid;
|
||||
|
@ -607,7 +626,8 @@ PspRunCreateThreadNotifyRoutines(PETHREAD CurrentThread,
|
|||
* @implemented
|
||||
*/
|
||||
NTSTATUS STDCALL
|
||||
PsSetCreateThreadNotifyRoutine(IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine)
|
||||
PsSetCreateThreadNotifyRoutine (
|
||||
IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine )
|
||||
{
|
||||
if (PiThreadNotifyRoutineCount >= MAX_THREAD_NOTIFY_ROUTINE_COUNT)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue