- Merge from trunk up to r45543
[reactos.git] / dll / win32 / kernel32 / except / except.c
index 9440984..75e9356 100644 (file)
@@ -170,7 +170,7 @@ BasepCheckForReadOnlyResource(IN PVOID Ptr)
            use SEH here because we don't know if it's actually a
            resource mapping */
 
-        _SEH_TRY
+        _SEH2_TRY
         {
             Data = RtlImageDirectoryEntryToData(mbi.AllocationBase,
                                                 TRUE,
@@ -195,19 +195,19 @@ BasepCheckForReadOnlyResource(IN PVOID Ptr)
                 }
             }
         }
-        _SEH_HANDLE
+        _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
         {
         }
-        _SEH_END;
+        _SEH2_END;
     }
 
     return Ret;
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
-LONG STDCALL
+LONG WINAPI
 UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
 {
    LONG RetValue;
@@ -216,7 +216,7 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
    ULONG ErrorParameters[4];
    ULONG ErrorResponse;
 
-   if (ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION &&
+   if ((NTSTATUS)ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION &&
        ExceptionInfo->ExceptionRecord->NumberParameters >= 2)
    {
       switch(ExceptionInfo->ExceptionRecord->ExceptionInformation[0])
@@ -269,18 +269,20 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
       /* Print a stack trace. */
       DbgPrint("Unhandled exception\n");
       DbgPrint("ExceptionCode:    %8x\n", ExceptionInfo->ExceptionRecord->ExceptionCode);
-      if (ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION &&
+      if ((NTSTATUS)ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION &&
           ExceptionInfo->ExceptionRecord->NumberParameters == 2)
       {
          DbgPrint("Faulting Address: %8x\n", ExceptionInfo->ExceptionRecord->ExceptionInformation[1]);
       }
-      DbgPrint("Address:          %8x   %s\n",
-         ExceptionInfo->ExceptionRecord->ExceptionAddress,
-         _module_name_from_addr(ExceptionInfo->ExceptionRecord->ExceptionAddress, &StartAddr, szMod, sizeof(szMod)));
       _dump_context ( ExceptionInfo->ContextRecord );
+      _module_name_from_addr(ExceptionInfo->ExceptionRecord->ExceptionAddress, &StartAddr, szMod, sizeof(szMod));
+      DbgPrint("Address:\n   %8x+%-8x   %s\n", 
+               (PVOID)StartAddr, (ULONG_PTR)ExceptionInfo->ExceptionRecord->ExceptionAddress - 
+               (ULONG_PTR)StartAddr, szMod);
+
 #ifdef _X86_
       DbgPrint("Frames:\n");
-      _SEH_TRY
+      _SEH2_TRY
       {
          Frame = (PULONG)ExceptionInfo->ContextRecord->Ebp;
          while (Frame[1] != 0 && Frame[1] != 0xdeadbeef)
@@ -300,11 +302,11 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
             Frame = (PULONG)Frame[0];
          }
       }
-      _SEH_HANDLE
+      _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
       {
-         DbgPrint("<error dumping stack trace: 0x%x>\n", _SEH_GetExceptionCode());
+         DbgPrint("<error dumping stack trace: 0x%x>\n", _SEH2_GetExceptionCode());
       }
-      _SEH_END;
+      _SEH2_END;
 #endif
    }
 
@@ -312,7 +314,7 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
    ErrorParameters[0] = (ULONG)ExceptionInfo->ExceptionRecord->ExceptionCode;
    ErrorParameters[1] = (ULONG)ExceptionInfo->ExceptionRecord->ExceptionAddress;
 
-   if (ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION)
+   if ((NTSTATUS)ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION)
    {
        /* get the type of operation that caused the access violation */
        ErrorParameters[2] = ExceptionInfo->ExceptionRecord->ExceptionInformation[0];
@@ -395,7 +397,18 @@ RaiseException(IN DWORD dwExceptionCode,
     {
         DPRINT1("Delphi Exception at address: %p\n", ExceptionRecord.ExceptionInformation[0]);
         DPRINT1("Exception-Object: %p\n", ExceptionRecord.ExceptionInformation[1]);
-        DPRINT1("Exception text: %s\n", ExceptionRecord.ExceptionInformation[2]);        
+        DPRINT1("Exception text: %s\n", ExceptionRecord.ExceptionInformation[2]);
+    }
+
+    /* Trace the wine special error and show the modulename and functionname */
+    if (dwExceptionCode == 0x80000100 /*EXCEPTION_WINE_STUB*/)
+    {
+       /* Numbers of parameter must be equal to two */
+       if (ExceptionRecord.NumberParameters == 2)
+       {
+          DPRINT1("Missing function in   : %s\n", ExceptionRecord.ExceptionInformation[0]);
+          DPRINT1("with the functionname : %s\n", ExceptionRecord.ExceptionInformation[1]);
+       }
     }
 
     /* Raise the exception */