Second and third patch are just small cleanups to align excpt.h with
MS SDK excpt.h.

First patch is probably more controversal, so I will write more
information what I found.

My understanding of i386 SEH exception callback is that it has cdecl
calling convention. All i386 SEH exception callbacks in crtdll, msvcrt
and UCRT libraries are cdecl. Also older MS SEH exception documentation
shows it in examples:

https://web.archive.org/web/20001214001500/http://www.microsoft.com/msj/0197/exception/exception.htm
https://web.archive.org/web/20010212091437/http://www.microsoft.com/msj/0197/exception/exceptiontextfigs.htm#fig14

Based on the Figure 14 and flow diagram I tried to locate that code in
32-bit x86 ntdll.dll library (version 10.0.18362.387) to confirm what
is recent Windows system doing. I think that I located the relevant
code in objdump -d output which is calling the SEH handler and it
should be this one (AT&T notation):

4b308d7c:       55                      push   %ebp
4b308d7d:       8b ec                   mov    %esp,%ebp
4b308d7f:       ff 75 0c                pushl  0xc(%ebp)
4b308d82:       52                      push   %edx
4b308d83:       64 ff 35 00 00 00 00    pushl  %fs:0x0
4b308d8a:       64 89 25 00 00 00 00    mov    %esp,%fs:0x0
4b308d91:       ff 75 14                pushl  0x14(%ebp)
4b308d94:       ff 75 10                pushl  0x10(%ebp)
4b308d97:       ff 75 0c                pushl  0xc(%ebp)
4b308d9a:       ff 75 08                pushl  0x8(%ebp)
4b308d9d:       8b 4d 18                mov    0x18(%ebp),%ecx
4b308da0:       ff d1                   call   *%ecx
4b308da2:       64 8b 25 00 00 00 00    mov    %fs:0x0,%esp
4b308da9:       64 8f 05 00 00 00 00    popl   %fs:0x0
4b308db0:       8b e5                   mov    %ebp,%esp
4b308db2:       5d                      pop    %ebp

In %ecx is the SEH handler. And from this it looks like that ntdll.dll
library resets stack pointer %esp back to the state before the arguments
for SEH handler were put on the stack which confirm the __cdecl calling
convention. But as it is written, it would work also SEH handler which
pops input arguments itself.

Pali Rohár (3):
  headers: Fix PEXCEPTION_ROUTINE type definition
  headers: Remove ExceptionExecuteHandler
  headers: Convert EXCEPTION_DISPOSITION from define to enum

 mingw-w64-headers/crt/excpt.h     | 14 ++++++--------
 mingw-w64-headers/include/ntdef.h |  2 +-
 mingw-w64-headers/include/winnt.h |  2 +-
 3 files changed, 8 insertions(+), 10 deletions(-)

-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to