[ntoskrnl]
[reactos.git] / reactos / ntoskrnl / ps / kill.c
index 351c5f8..b1ea95f 100644 (file)
@@ -177,7 +177,7 @@ PspReapRoutine(IN PVOID Context)
     do
     {
         /* Write magic value and return the next entry to process */
-        NextEntry = InterlockedExchangePointer((PVOID*)&PspReaperListHead.Flink,
+        NextEntry = InterlockedExchangePointer(&PspReaperListHead.Flink,
                                                (PVOID)1);
         ASSERT((NextEntry != NULL) && (NextEntry != (PVOID)1));
 
@@ -200,9 +200,9 @@ PspReapRoutine(IN PVOID Context)
         } while ((NextEntry != NULL) && (NextEntry != (PVOID)1));
 
         /* Remove magic value, keep looping if it got changed */
-    } while (InterlockedCompareExchangePointer((PVOID*)&PspReaperListHead.Flink,
-                                               (PVOID)0,
-                                               (PVOID)1) != (PVOID)1);
+    } while (InterlockedCompareExchangePointer(&PspReaperListHead.Flink,
+                                               0,
+                                               1) != (PVOID)1);
 }
 
 VOID
@@ -270,9 +270,11 @@ PspDeleteProcess(IN PVOID ObjectBody)
         Process->SectionObject = NULL;
     }
 
-    /* Clean LDT and VDM_OBJECTS */
+#if defined(_X86_)
+    /* Clean Ldt and Vdm objects */
     PspDeleteLdt(Process);
     PspDeleteVdmObjects(Process);
+#endif
 
     /* Delete the Object Table */
     if (Process->ObjectTable)
@@ -403,7 +405,7 @@ PspExitThread(IN NTSTATUS ExitStatus)
     PEPROCESS CurrentProcess;
     PETHREAD Thread, OtherThread, PreviousThread = NULL;
     PVOID DeallocationStack;
-    ULONG_PTR Dummy;
+    ULONG Dummy;
     BOOLEAN Last = FALSE;
     PTERMINATION_PORT TerminationPort, NextPort;
     PLIST_ENTRY FirstEntry, CurrentEntry;
@@ -594,6 +596,7 @@ PspExitThread(IN NTSTATUS ExitStatus)
     if (TerminationPort)
     {
         /* Setup the message header */
+        TerminationMsg.h.u2.ZeroInit = 0;
         TerminationMsg.h.u2.s2.Type = LPC_CLIENT_DIED;
         TerminationMsg.h.u1.s1.TotalLength = sizeof(TerminationMsg);
         TerminationMsg.h.u1.s1.DataLength = sizeof(TerminationMsg) -
@@ -880,7 +883,7 @@ PsExitSpecialApc(IN PKAPC Apc,
     if (Apc->SystemArgument2)
     {
         /* Free the APC */
-        Status = (NTSTATUS)(ULONG_PTR)Apc->NormalContext;
+        Status = (NTSTATUS)Apc->NormalContext;
         PspExitApcRundown(Apc);
 
         /* Terminate the Thread */
@@ -969,6 +972,7 @@ PspTerminateThreadByPointer(IN PETHREAD Thread,
 
     /* Allocate the APC */
     Apc = ExAllocatePoolWithTag(NonPagedPool, sizeof(KAPC), TAG_TERMINATE_APC);
+    if (!Apc) return STATUS_INSUFFICIENT_RESOURCES;
 
     /* Set the Terminated Flag */
     Flags = Thread->CrossThreadFlags | CT_TERMINATED_BIT;
@@ -985,13 +989,12 @@ PspTerminateThreadByPointer(IN PETHREAD Thread,
                         PspExitApcRundown,
                         PspExitNormalApc,
                         KernelMode,
-                        (PVOID)(ULONG_PTR)ExitStatus);
+                        (PVOID)ExitStatus);
 
         /* Insert it into the APC Queue */
         if (!KeInsertQueueApc(Apc, Apc, NULL, 2))
         {
             /* The APC was already in the queue, fail */
-            ExFreePool(Apc);
             Status = STATUS_UNSUCCESSFUL;
         }
         else
@@ -1299,7 +1302,7 @@ NtRegisterThreadTerminatePort(IN HANDLE PortHandle)
     /* Allocate the Port and make sure it suceeded */
     TerminationPort = ExAllocatePoolWithTag(NonPagedPool,
                                             sizeof(TERMINATION_PORT),
-                                            TAG('P', 's', 'T', '='));
+                                            '=TsP');
     if(TerminationPort)
     {
         /* Associate the Port */