-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-process proof-of-concept, fix #68 (WIP) #70
Conversation
- Moves bins into standard `src/bin` folder - Adds a basic test (TODO: doesn't work on gh-actions CI) - Reformat with new `rustfmt.toml`, rearrange some code, add some comments - Fix wrong error message for `GetVersionExA` - `cargo update`
yay unsoundness: thread '<unnamed>' panicked at core\src\panicking.rs:221:5: unsafe precondition(s) violated: slice::get_unchecked requires that the index is within the slice note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread caused non-unwinding panic. aborting. error: test failed, to rerun pass `--test basic` Caused by: process didn't exit successfully: `D:\Projects\blondie\target\debug\deps\basic-10e35b968cd5dbed.exe` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)
src/lib.rs
Outdated
// let kernel_logger_name_with_nul_pcstr = PCSTR(kernel_logger_name_with_nul.as_ptr()); | ||
// Stop an existing session with the kernel logger, if it exists | ||
// We use a copy of `event_trace_props` since ControlTrace overwrites it | ||
{ | ||
let mut event_trace_props_copy = event_trace_props.clone(); | ||
let control_stop_retcode = ControlTraceA( | ||
None, | ||
kernel_logger_name_with_nul_pcstr, | ||
addr_of_mut!(event_trace_props_copy) as *mut _, | ||
EVENT_TRACE_CONTROL_STOP, | ||
); | ||
let mut event_trace_props_copy = (*event_trace_props).clone(); | ||
// SAFETY: controlled input. | ||
// https://learn.microsoft.com/en-us/windows/win32/api/evntrace/nf-evntrace-controltracea | ||
let control_stop_retcode = unsafe { | ||
ControlTraceA( | ||
None, | ||
KERNEL_LOGGER_NAMEA, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering what the difference between kernel_logger_name_with_nul_pcstr
and KERNEL_LOGGER_NAMEA
is
@@ -195,17 +274,19 @@ unsafe fn trace_from_process_id( | |||
.s | |||
.copy_from_slice(&kernel_logger_name_with_nul[..]); | |||
|
|||
let kernel_logger_name_with_nul_pcstr = PCSTR(kernel_logger_name_with_nul.as_ptr()); | |||
// let kernel_logger_name_with_nul_pcstr = PCSTR(kernel_logger_name_with_nul.as_ptr()); | |||
// Stop an existing session with the kernel logger, if it exists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this can cause UB if blondie is running in multiple processes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now it seems to cause
value: Other(WIN32_ERROR(4201), "The instance name passed was not recognized as valid by a WMI data provider.\r\n", "TraceSetInformation stackwalk")
My knowledge of windows APIs and unsafe rust is insufficient to complete this PR |
#69
has a bug rn (I haven't tried unsafe rust before) :( happens once in a while only