在 2026-5-31 01:43, Pali Rohár 写道:
wine's msvcrt exception handler for both i386 and amd64 is checking also EXCEPTION_EXIT_UNWIND:
To perform an exit unwind, call `RtlUnwind()` with a null target pointer:
#include <windows.h>
#include <stdio.h>
EXCEPTION_DISPOSITION
unwind_done(EXCEPTION_RECORD* rec, PVOID frm, CONTEXT* ctx, PVOID disp)
{
fprintf(stderr, "code = 0x%lx\n", rec->ExceptionCode);
fprintf(stderr, "flags = 0x%lx\n", rec->ExceptionFlags);
if(rec->ExceptionFlags & EXCEPTION_EXIT_UNWIND)
ExitProcess(0);
return ExceptionContinueSearch;
}
#if defined _M_IX86 && defined _MSC_VER
__asm__ (".safeseh _unwind_done");
#endif
void
test_exit_unwind(void)
{
#if defined __i386__
DWORD record[] = { __readfsdword(0), (DWORD) unwind_done };
__writefsdword(0, (DWORD) &record);
#else
__asm__ (".seh_handler %c0, @except, @unwind" : : "i"(unwind_done));
#endif
fprintf(stderr, "doing exit unwind\n");
RtlUnwind(NULL, NULL, NULL, NULL);
}
int
main(void)
{
test_exit_unwind();
fprintf(stderr, "aborting\n");
abort();
}
This gives
doing exit unwind
code = 0xc0000027 // STATUS_UNWIND
flags = 0x6 // EXCEPTION_UNWINDING + EXCEPTION_EXIT_UNWIND
--
Best regards,
LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
