Fix UB and other clippy lints
This commit is contained in:
Родитель
bb97b4997d
Коммит
eafa9cc96d
|
@ -13,6 +13,7 @@ miniz_oxide = "0.4.3"
|
|||
simplelog = "0.7.6"
|
||||
tokio = { version = "1.33.0", features = ["net", "rt-multi-thread", "io-util"] }
|
||||
winapi = { version = "0.3.9", features = [
|
||||
"impl-default",
|
||||
"memoryapi",
|
||||
"processthreadsapi",
|
||||
"tlhelp32",
|
||||
|
|
|
@ -123,6 +123,5 @@ pub fn compress_data(data: Vec<u8>, level: u8) -> Vec<u8> {
|
|||
// let blocks = vec![[0u8; BLOCK_SIZE]; max_blocks];
|
||||
|
||||
// deflate to first block
|
||||
let compressed = miniz_oxide::deflate::compress_to_vec_zlib(&data[..], level);
|
||||
compressed
|
||||
miniz_oxide::deflate::compress_to_vec_zlib(&data[..], level)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use winapi::{
|
|||
tlhelp32::MODULEENTRY32,
|
||||
tlhelp32::{
|
||||
CreateToolhelp32Snapshot, Module32First, Module32Next, Process32First, Process32Next,
|
||||
LPMODULEENTRY32, LPPROCESSENTRY32,
|
||||
LPMODULEENTRY32, LPPROCESSENTRY32, PROCESSENTRY32,
|
||||
},
|
||||
winnt::MEMORY_BASIC_INFORMATION,
|
||||
winnt::{HANDLE, PROCESS_ALL_ACCESS},
|
||||
|
@ -54,7 +54,7 @@ unsafe fn get_process_response<F>(handle: usize, func: F) -> Process32Response
|
|||
where
|
||||
F: FnOnce(HANDLE, LPPROCESSENTRY32) -> i32,
|
||||
{
|
||||
let mut entry = std::mem::MaybeUninit::uninit().assume_init();
|
||||
let mut entry = PROCESSENTRY32::default();
|
||||
let response = func(handle as HANDLE, &mut entry);
|
||||
|
||||
if response != 0 {
|
||||
|
@ -85,8 +85,10 @@ unsafe fn get_module_response<F>(handle: usize, func: F) -> Module32Response
|
|||
where
|
||||
F: FnOnce(HANDLE, LPMODULEENTRY32) -> i32,
|
||||
{
|
||||
let mut entry: MODULEENTRY32 = std::mem::MaybeUninit::uninit().assume_init();
|
||||
entry.dwSize = std::mem::size_of::<MODULEENTRY32>() as u32;
|
||||
let mut entry = MODULEENTRY32 {
|
||||
dwSize: std::mem::size_of::<MODULEENTRY32>() as u32,
|
||||
..Default::default()
|
||||
};
|
||||
let response = func(handle as HANDLE, &mut entry);
|
||||
|
||||
if response != 0 {
|
||||
|
@ -216,7 +218,7 @@ impl Handler<VirtualQueryExFullRequest> for WindowsHandler {
|
|||
let mut items = vec![];
|
||||
|
||||
let (_paged_only, _dirty_only, _no_shared) =
|
||||
(req.flags | 1 != 0, req.flags | 2 != 0, req.flags | 4 != 0);
|
||||
(req.flags & 1 != 0, req.flags & 2 != 0, req.flags & 4 != 0);
|
||||
// TODO: use these flags?
|
||||
// https://github.com/cheat-engine/cheat-engine/blob/master/Cheat%20Engine/ceserver/api.c#L2822
|
||||
|
||||
|
@ -238,7 +240,7 @@ impl Handler<VirtualQueryExFullRequest> for WindowsHandler {
|
|||
}
|
||||
|
||||
unsafe fn virtual_query_ex(handle: i32, address: usize) -> Option<RegionInfo> {
|
||||
let mut data = std::mem::MaybeUninit::<MEMORY_BASIC_INFORMATION>::uninit().assume_init();
|
||||
let mut data = MEMORY_BASIC_INFORMATION::default();
|
||||
let size = VirtualQueryEx(
|
||||
handle as HANDLE,
|
||||
address as LPCVOID,
|
||||
|
|
|
@ -4,6 +4,8 @@ mod commands_request;
|
|||
mod commands_response;
|
||||
mod handler;
|
||||
mod handlers;
|
||||
|
||||
#[allow(clippy::module_inception)] // FIXME
|
||||
mod server;
|
||||
|
||||
pub use handlers::WindowsHandler;
|
||||
|
|
|
@ -64,7 +64,7 @@ impl CheatEngineConnection {
|
|||
loop {
|
||||
let n = match socket.read(&mut buf).await {
|
||||
// socket closed
|
||||
Ok(n) if n == 0 => return,
|
||||
Ok(0) => return,
|
||||
Ok(n) => n,
|
||||
Err(e) => {
|
||||
error!("failed to read from socket; err = {:?}", e);
|
||||
|
|
Загрузка…
Ссылка в новой задаче