add log and use error! in Drop of Handle to let users choose if they want to care about failed CloseHandle
This commit is contained in:
@@ -10,6 +10,7 @@ keywords = ["memory", "game", "hacking", "process"]
|
||||
|
||||
[dependencies]
|
||||
derive_more = { version = "1.0.0", features = ["display"] }
|
||||
log = "0.4.22"
|
||||
thiserror = "2.0.9"
|
||||
|
||||
[dependencies.windows]
|
||||
|
||||
@@ -21,12 +21,10 @@ impl Deref for Handle {
|
||||
|
||||
impl Drop for Handle {
|
||||
fn drop(&mut self) {
|
||||
if self.0 != INVALID_HANDLE_VALUE {
|
||||
unsafe {
|
||||
if let Err(why) = CloseHandle(**self) {
|
||||
eprintln!("failed to close handle: {why}");
|
||||
};
|
||||
}
|
||||
unsafe {
|
||||
if let Err(why) = CloseHandle(**self) {
|
||||
log::error!("failed to close handle: {why}");
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user