kernel
Loading...
Searching...
No Matches
raise.c
Go to the documentation of this file.
1/*++
2
3Module Name:
4
5 raise.c
6
7Purpose:
8
9 This translation unit contains the implementation of raising status codes in the kernel.
10
11Author:
12
13 slep (Matanel) 2025.
14
15Revision History:
16
17--*/
18
20#include "../../includes/ps.h"
21
22void
24 IN MTSTATUS Status,
25 IN uint64_t Rip
26)
27
28{
29 // This is unused, or atleast should be changed.
30 // Since the try except macros are expected to work within interrupts (like a page fault), since RBP,RSP are saved (and General Purpose Registers)
31 // So simply jumping to there WILL NOT work, we must restore all general registers (which would require support handling in the try try_end; macros, and not only linker support
32 // So for now, this should stay unused.
33 // This will be used (probably) for user mode SEH.
34
35 PETHREAD CurrentThread = PsGetCurrentThread();
36 // Set status.
37 CurrentThread->LastStatus = Status;
38
39 // Dispatch exception. (RIP should be instruction that made the call, and not the retaddr)
40 uint64_t HandlerAddress = ExpFindKernelModeExceptionHandler(Rip - 1);
41 if (HandlerAddress != 0) {
42 // Jump to exception handler.
43 __asm__ volatile (
44 "jmp *%0"
45 :
46 : "r"(HandlerAddress)
47 );
48 }
49}
#define IN
Definition annotations.h:8
ETHREAD * PETHREAD
Definition core.h:44
uint64_t ExpFindKernelModeExceptionHandler(uint64_t Rip)
Definition exception.c:114
int32_t MTSTATUS
Definition mtstatus.h:12
void ExpRaiseStatus(IN MTSTATUS Status, IN uint64_t Rip)
Definition raise.c:23
MTSTATUS LastStatus
Definition ps.h:199
PETHREAD PsGetCurrentThread(void)
Definition thread.c:279