n4r1b / ferrisetw

Basically a KrabsETW rip-off written in Rust
Other
65 stars 24 forks source link

Fix the build and initialize `EventFilterDescriptor` by slice instead of pointer arithmetic #115

Closed DrChat closed 1 year ago

DrChat commented 1 year ago

Fresh checkout was throwing these errors (somehow despite CI not doing so):

error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
  --> src\provider\event_filter.rs:96:17
   |
91 |             &((*p).Events[0]) as *const u16 as *mut u16
   |             ------------------------------------------- casting happend here
...
96 |                 *p_evt = 0;
   |                 ^^^^^^^^^^
   |
   = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
   = note: `#[deny(invalid_reference_casting)]` on by default

error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
   --> src\provider\event_filter.rs:103:17
    |
91  |             &((*p).Events[0]) as *const u16 as *mut u16
    |             ------------------------------------------- casting happend here
...
103 |                 *p_evt = *event_id;
    |                 ^^^^^^^^^^^^^^^^^^
    |
    = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>

I went ahead and just redid the logic so that this constructs a slice and initializes it using copy_from_slice instead.