Correction to 36917: EPROFILE/KPROFILE.Segment is pointer sized, not a pointer.
[reactos.git] / reactos / ntoskrnl / ex / profile.c
index bec9a46..f931edf 100644 (file)
@@ -17,7 +17,7 @@
 #pragma alloc_text(INIT, ExpInitializeProfileImplementation)
 #endif
 
-#define TAG_PROFILE TAG('P', 'r', 'o', 'f')
+#define TAG_PROFILE 'forP'
 
 /* GLOBALS *******************************************************************/
 
@@ -102,9 +102,9 @@ NtCreateProfile(OUT PHANDLE ProfileHandle,
     PEPROCESS pProcess;
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
     OBJECT_ATTRIBUTES ObjectAttributes;
-    NTSTATUS Status = STATUS_SUCCESS;
+    NTSTATUS Status;
     ULONG Log2 = 0;
-    PVOID Segment = NULL;
+    ULONG_PTR Segment = 0;
     PAGED_CODE();
 
     /* Easy way out */
@@ -117,7 +117,7 @@ NtCreateProfile(OUT PHANDLE ProfileHandle,
         if (BufferSize < sizeof(ULONG)) return STATUS_INVALID_PARAMETER_7;
 
         /* This will become a segmented profile object */
-        Segment = RangeBase;
+        Segment = (ULONG_PTR)RangeBase;
         RangeBase = 0;
 
         /* Recalculate the bucket size */
@@ -154,7 +154,7 @@ NtCreateProfile(OUT PHANDLE ProfileHandle,
     if(PreviousMode != KernelMode)
     {
         /* Entry SEH */
-        _SEH_TRY
+        _SEH2_TRY
         {
             /* Make sure that the handle pointer is valid */
             ProbeForWriteHandle(ProfileHandle);
@@ -164,14 +164,12 @@ NtCreateProfile(OUT PHANDLE ProfileHandle,
                           BufferSize,
                           sizeof(ULONG));
         }
-        _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+        _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
         {
-            Status = _SEH_GetExceptionCode();
+            /* Return the exception code */
+            _SEH2_YIELD(return _SEH2_GetExceptionCode());
         }
-        _SEH_END;
-
-        /* Bail out if we failed */
-        if(!NT_SUCCESS(Status)) return Status;
+        _SEH2_END;
     }
 
     /* Check if a process was specified */
@@ -220,7 +218,7 @@ NtCreateProfile(OUT PHANDLE ProfileHandle,
     if (!NT_SUCCESS(Status))
     {
         /* Dereference the process object if it was specified */
-        if (Process) ObDereferenceObject(Process);
+        if (pProcess) ObDereferenceObject(pProcess);
 
         /* Return Status */
         return Status;
@@ -256,16 +254,16 @@ NtCreateProfile(OUT PHANDLE ProfileHandle,
     }
 
     /* Enter SEH */
-    _SEH_TRY
+    _SEH2_TRY
     {
         /* Copy the created handle back to the caller*/
         *ProfileHandle = hProfile;
     }
-    _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+    _SEH2_EXCEPT(ExSystemExceptionFilter())
     {
-        Status = _SEH_GetExceptionCode();
+        Status = _SEH2_GetExceptionCode();
     }
-    _SEH_END;
+    _SEH2_END;
 
     /* Return Status */
     return Status;
@@ -281,10 +279,10 @@ NtQueryPerformanceCounter(OUT PLARGE_INTEGER PerformanceCounter,
     NTSTATUS Status = STATUS_SUCCESS;
 
     /* Check if we were called from user-mode */
-    if(PreviousMode != KernelMode)
+    if (PreviousMode != KernelMode)
     {
         /* Entry SEH Block */
-        _SEH_TRY
+        _SEH2_TRY
         {
             /* Make sure the counter and frequency are valid */
             ProbeForWriteLargeInteger(PerformanceCounter);
@@ -293,30 +291,29 @@ NtQueryPerformanceCounter(OUT PLARGE_INTEGER PerformanceCounter,
                 ProbeForWriteLargeInteger(PerformanceFrequency);
             }
         }
-        _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+        _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
         {
-            Status = _SEH_GetExceptionCode();
+            /* Return the exception code */
+            _SEH2_YIELD(return _SEH2_GetExceptionCode());
         }
-        _SEH_END;
-
-        /* If the pointers are invalid, bail out */
-        if(!NT_SUCCESS(Status)) return Status;
+        _SEH2_END;
     }
 
     /* Enter a new SEH Block */
-    _SEH_TRY
+    _SEH2_TRY
     {
         /* Query the Kernel */
         *PerformanceCounter = KeQueryPerformanceCounter(&PerfFrequency);
 
         /* Return Frequency if requested */
-        if(PerformanceFrequency) *PerformanceFrequency = PerfFrequency;
+        if (PerformanceFrequency) *PerformanceFrequency = PerfFrequency;
     }
-    _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+    _SEH2_EXCEPT(ExSystemExceptionFilter())
     {
-        Status = _SEH_GetExceptionCode();
+        /* Get the exception code */
+        Status = _SEH2_GetExceptionCode();
     }
-    _SEH_END;
+    _SEH2_END;
 
     /* Return status to caller */
     return Status;
@@ -374,27 +371,20 @@ NtStartProfile(IN HANDLE ProfileHandle)
     Profile->Mdl = MmCreateMdl(NULL, Profile->Buffer, Profile->BufferSize);
 
     /* Protect this in SEH as we might raise an exception */
-    _SEH_TRY
+    _SEH2_TRY
     {
         /* Probe and Lock for Write Access */
         MmProbeAndLockPages(Profile->Mdl, PreviousMode, IoWriteAccess);
     }
-    _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
-    {
-        /* Get the exception code */
-        Status = _SEH_GetExceptionCode();
-    }
-    _SEH_END;
-
-    /* Fail if we raised an exception */
-    if (!NT_SUCCESS(Status))
+    _SEH2_EXCEPT(ExSystemExceptionFilter())
     {
         /* Release our lock, free the buffer, dereference and return */
         KeReleaseMutex(&ExpProfileMutex, FALSE);
         ObDereferenceObject(Profile);
         ExFreePool(ProfileObject);
-        return Status;
+        _SEH2_YIELD(return _SEH2_GetExceptionCode());
     }
+    _SEH2_END;
 
     /* Map the pages */
     TempLockedBufferAddress = MmMapLockedPages(Profile->Mdl, KernelMode);
@@ -482,41 +472,40 @@ NtQueryIntervalProfile(IN KPROFILE_SOURCE ProfileSource,
     PAGED_CODE();
 
     /* Check if we were called from user-mode */
-    if(PreviousMode != KernelMode)
+    if (PreviousMode != KernelMode)
     {
         /* Enter SEH Block */
-        _SEH_TRY
+        _SEH2_TRY
         {
             /* Validate interval */
             ProbeForWriteUlong(Interval);
         }
-        _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+        _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
         {
-            Status = _SEH_GetExceptionCode();
+            /* Return the exception code */
+            _SEH2_YIELD(return _SEH2_GetExceptionCode());
         }
-        _SEH_END;
-
-        /* If pointer was invalid, bail out */
-        if(!NT_SUCCESS(Status)) return Status;
+        _SEH2_END;
     }
 
     /* Query the Interval */
     ReturnInterval = KeQueryIntervalProfile(ProfileSource);
 
     /* Enter SEH block for return */
-    _SEH_TRY
+    _SEH2_TRY
     {
         /* Return the data */
         *Interval = ReturnInterval;
     }
-    _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
+    _SEH2_EXCEPT(ExSystemExceptionFilter())
     {
-        Status = _SEH_GetExceptionCode();
+        /* Get the exception code */
+        Status = _SEH2_GetExceptionCode();
     }
-    _SEH_END;
+    _SEH2_END;
 
     /* Return Success */
-    return STATUS_SUCCESS;
+    return Status;
 }
 
 NTSTATUS