Coder Social home page Coder Social logo

Comments (8)

kennykerr avatar kennykerr commented on June 9, 2024 1

I can transfer this issue to the Win32 metadata repo for discussion.

from win32metadata.

tim-weis avatar tim-weis commented on June 9, 2024 1

SEH is a system service that requires compiler (and language/language runtime) support. This should be filed against rustc for resolution.

@riverar This goes beyond (or underneath) API calls. MapViewOfFile(), for example, returns the equivalent of a region of memory. Dereferencing a pointer anywhere inside the reported valid range of the mapping can raise an SEH exception (e.g. when the file object backing the mapping becomes inaccessible).

The core issue here cannot be solved by annotating APIs alone, and a cursory search didn't uncover any hope for a resolution over the current workaround.

from win32metadata.

kennykerr avatar kennykerr commented on June 9, 2024

Adding some folks who may have some comments on SEH in Rust as well as some who are currently using a mix of Rust and C to make it work. @sivadeilra @dpaoliello @zadjii-msft

from win32metadata.

kennykerr avatar kennykerr commented on June 9, 2024

As for me, we don't have metadata at the moment that calls out which functions use SEH so I don't think this is very actionable at the moment.

https://kennykerr.ca/rust-getting-started/how-are-crates-built.html

from win32metadata.

RivenSkaye avatar RivenSkaye commented on June 9, 2024

I'm somewhat surprised that something like that isn't tracked through the metadata yet; I'd assume the information is relevant internally and the win32 C/C++ docs do make mention of using the __try handlers in some places. Should I open an issue there to ask for including it in the metadata output?

from win32metadata.

riverar avatar riverar commented on June 9, 2024

Do you have some example APIs in mind?

from win32metadata.

RivenSkaye avatar RivenSkaye commented on June 9, 2024

Not quite sure which end of the issue you'd want example API's for; the existing APIs where __try/__except are currently used, examples for the Rust end of things, or examples for the metadata definitions?

My initial request was aimed mostly at situations where the function call itself can reasonably cause these to be thrown, e.g. accessing networked locations can cause EXCEPTION_IN_PAGE_ERROR and in some situations, or for getting a generic function that allows users to register their own filter and handler functions; that said some of the SDK functions can also cause some of the recoverable ones to be thrown. The simple wrapper could look like

// Code may not be perfect, I'm not experienced in passing around functions in C++
void TryUserFn(DWORD[] handles, *void callable, *void handler, *void outvar) {
    __try {
        *outvar = callable();
    }
    __except(arr_contains(handles, GetExceptionCode())) {
        handler();
        *outvar = NULL;
    }
    return 0;
}

as a bare method of allowing people to attempt recovery or warning users

from win32metadata.

riverar avatar riverar commented on June 9, 2024

Not aware of any APIs using SEH so closing this for now. Feel free to keep the discussion going and let one of us know if we need to re-open this. Thanks!

from win32metadata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.