I don't use Rust, but it appears that the posted code does not conform to the documented arguments that should be passed to the ReportEventW function. For example, the function takes nine arguments but the code passes only eight. The posted code should be passing a 16-bit value for the number of strings in the array but does not appear to be doing so. The related parameter is wNumStrings. In your example the dwDataSize parameter should be 0 but the code appears to be passing something else.
Rust ReportEventW returns The stub received bad data
Oliver
20
Reputation points
Hello!
Im currently experimenting with the Rust windows crate.
I have a problem with the ReportEventW function, its returning the message: "The stub received bad data." and i cant figure out what ive done wrong.
Maybe there are a helpful soul here that can give me some pointers?
Thanks!
fn write_event() -> ::windows_core::Result<()> {
let eventsource: PCWSTR = w!("Application");
let handle: HANDLE = unsafe { RegisterEventSourceW(None, eventsource)? };
let message = w!("Test log");
let message2 = w!("Test log2");
let strings = &[message, message2];
unsafe {
ReportEventW(
handle,
EVENTLOG_INFORMATION_TYPE,
0,
1,
None,
strings.len() as u32,
Some(strings),
None,
)?;
}
unsafe { DeregisterEventSource(handle)? };
Ok(())
}
Accepted answer
1 additional answer
Sort by: Most helpful
-
Oliver 20 Reputation points
2024-09-12T09:28:27.2933333+00:00 Im testing this on:
Microsoft Windows 11
Version 10.0.22621 Build 22621