Skip to main content

luaur_code_gen/records/
unwind_builder_win.rs

1use crate::records::register_x_64::RegisterX64;
2use crate::records::unwind_builder::UnwindBuilder;
3use crate::records::unwind_code_win::UnwindCodeWin;
4use crate::records::unwind_function_win::UnwindFunctionWin;
5use alloc::vec::Vec;
6
7#[derive(Debug, Clone)]
8#[repr(C)]
9pub struct UnwindBuilderWin {
10    pub base: UnwindBuilder,
11    pub(crate) begin_offset: usize,
12    pub(crate) raw_data: [u8; 1024],
13    pub(crate) raw_data_pos: *mut u8,
14    pub(crate) unwind_functions: Vec<UnwindFunctionWin>,
15    pub(crate) unwind_codes: Vec<UnwindCodeWin>,
16    pub(crate) prolog_size: u8,
17    pub(crate) frame_reg: RegisterX64,
18    pub(crate) frame_reg_offset: u8,
19}
20
21impl UnwindBuilderWin {
22    pub(crate) const kRawDataLimit: u32 = 1024;
23}
24
25impl Default for UnwindBuilderWin {
26    fn default() -> Self {
27        unsafe {
28            let mut builder = Self {
29                base: core::mem::zeroed(),
30                begin_offset: 0,
31                raw_data: [0; 1024],
32                raw_data_pos: core::ptr::null_mut(),
33                unwind_functions: Vec::new(),
34                unwind_codes: Vec::new(),
35                prolog_size: 0,
36                frame_reg: core::mem::zeroed(), // X64::noreg
37                frame_reg_offset: 0,
38            };
39            builder.raw_data_pos = builder.raw_data.as_mut_ptr();
40            builder
41        }
42    }
43}