#![allow(non_camel_case_types, non_snake_case)]
use crate::advapi::ffi;
use crate::co;
use crate::decl::*;
use crate::guard::*;
use crate::kernel::privs::*;
handle! { HEVENTLOG;
}
impl HEVENTLOG {
#[must_use]
pub fn RegisterEventSource(
unc_server_name: Option<&str>,
source_name: &str,
) -> SysResult<DeregisterEventSourceGuard> {
unsafe {
PtrRet(ffi::RegisterEventSourceW(
WString::from_opt_str(unc_server_name).as_ptr(),
WString::from_str(source_name).as_ptr(),
))
.to_sysresult_handle()
.map(|h| DeregisterEventSourceGuard::new(h))
}
}
pub fn ReportEvent(
&self,
event_type: co::EVENTLOG,
category: u16,
event_id: u32,
user_sid: Option<&SID>,
strings: &[impl AsRef<str>],
raw_data: &[u8],
) -> SysResult<()> {
let (_wstrs, pwstrs) = create_wstr_ptr_vecs(strings);
BoolRet(unsafe {
ffi::ReportEventW(
self.ptr(),
event_type.raw(),
category,
event_id,
pcvoid_or_null(user_sid),
pwstrs.len() as _,
raw_data.len() as _,
vec_ptr(&pwstrs),
vec_ptr(raw_data) as _,
)
})
.to_sysresult()
}
}