Skip to content
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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MingweiSamuel
Copy link

@MingweiSamuel MingweiSamuel commented Aug 21, 2024

#69

has a bug rn (I haven't tried unsafe rust before) :( happens once in a while only

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)
note: test exited abnormally; to see the full output pass --nocapture to the harness.
  process didn't exit successfully: `D:\Projects\blondie\target\debug\deps\multi-acb55ad735c22143.exe --nocapture` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)
Segmentation fault

- 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
Comment on lines 277 to 285
// 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,
Copy link
Author

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

src/lib.rs Show resolved Hide resolved
@@ -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
Copy link
Author

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...

Copy link
Author

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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant