最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

windows - The easiest way to allow SEH of an ASM code calling C - Stack Overflow

programmeradmin1浏览0评论

I wrote a function in pure ASM and compiled it with my project with MinGW-w64 GCC. I want to implement a custom structured exception handling to this code and trap any potential exceptions raised (this can be achieved with WinAPI's AddVectoredExceptionHandler as well as setjmp / longjmp).

The problem is that SEH would not work for a naked asm function. If I compile a really small C sample with --save-temps I can see a lot of compiler unwinding metadata and it's just way too complicated for me to even begin understanding what is going on.

Is there any trick that would let me take advantage of the custom exception handling in my ASM function that is called from a C application? All my hopes were destroyed when I tried this:

uint64_t call_asm_func_from_c (int param) {
    __asm__ __volatile__ (
        "call my_asm_function\n"  // Call the external assembly function (it calls a C function by address)
    );
}

hoping that this may work, but here me are.

发布评论

评论列表(0)

  1. 暂无评论