Hello, I would like to implement my own Windows Exception Handlers (more precisely, something like the __try/ __except C++ language extension).
Context
From what I understood, it can be done by updating the pointer in the first element of the TIB (std.os.windows.teb().NtTib.ExceptionList) to a custom EXCEPTION_REGISTRATION_RECORD, which should contain a pointer to my new exception handler and to the previous one.
My issue
When creating a new EXCEPTION_REGISTRATION_RECORD (see type definition below), the type of the .Handler property is defined as an optional pointer to EXCEPTION_DISPOSITION (i32).
pub const EXCEPTION_REGISTRATION_RECORD = extern struct {
Next: ?*EXCEPTION_REGISTRATION_RECORD,
Handler: ?*EXCEPTION_DISPOSITION,
};
But I thought it had to be a function pointer to the new exception handler, something like the type EXCEPTION_ROUTINE, which is defined as
pub const EXCEPTION_ROUTINE = *const fn (
ExceptionRecord: ?*EXCEPTION_RECORD,
EstablisherFrame: PVOID,
ContextRecord: *(Self.CONTEXT),
DispatcherContext: PVOID,
) callconv(WINAPI) EXCEPTION_DISPOSITION;
Did I miss some critical information ?
Should I attempt to constCast/ptrCast/allignCast a function pointer to a *i32 ? Or could it be the windows bindings are somewhat incomplete in this regard ?