Fix bugs in process reading and module enumeration
This commit is contained in:
Родитель
222831abf4
Коммит
1efe1ebef8
|
@ -96,6 +96,7 @@ pub struct ReadProcessMemoryResponse {
|
||||||
|
|
||||||
impl CEResponse for ReadProcessMemoryResponse {
|
impl CEResponse for ReadProcessMemoryResponse {
|
||||||
fn serialize(self, writer: &mut dyn BufMut) {
|
fn serialize(self, writer: &mut dyn BufMut) {
|
||||||
|
writer.put_i32_le(self.data.len() as i32);
|
||||||
writer.put_slice(&self.data[..]);
|
writer.put_slice(&self.data[..]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ use winapi::{
|
||||||
memoryapi::VirtualQueryEx,
|
memoryapi::VirtualQueryEx,
|
||||||
memoryapi::WriteProcessMemory,
|
memoryapi::WriteProcessMemory,
|
||||||
processthreadsapi::OpenProcess,
|
processthreadsapi::OpenProcess,
|
||||||
|
tlhelp32::MODULEENTRY32,
|
||||||
tlhelp32::{
|
tlhelp32::{
|
||||||
CreateToolhelp32Snapshot, Module32First, Module32Next, Process32First, Process32Next,
|
CreateToolhelp32Snapshot, Module32First, Module32Next, Process32First, Process32Next,
|
||||||
LPMODULEENTRY32, LPPROCESSENTRY32,
|
LPMODULEENTRY32, LPPROCESSENTRY32,
|
||||||
|
@ -84,7 +85,8 @@ unsafe fn get_module_response<F>(handle: usize, func: F) -> Module32Response
|
||||||
where
|
where
|
||||||
F: FnOnce(HANDLE, LPMODULEENTRY32) -> i32,
|
F: FnOnce(HANDLE, LPMODULEENTRY32) -> i32,
|
||||||
{
|
{
|
||||||
let mut entry = std::mem::MaybeUninit::uninit().assume_init();
|
let mut entry: MODULEENTRY32 = std::mem::MaybeUninit::uninit().assume_init();
|
||||||
|
entry.dwSize = std::mem::size_of::<MODULEENTRY32>() as u32;
|
||||||
let response = func(handle as HANDLE, &mut entry);
|
let response = func(handle as HANDLE, &mut entry);
|
||||||
|
|
||||||
if response != 0 {
|
if response != 0 {
|
||||||
|
@ -105,6 +107,10 @@ impl Handler<CloseHandleRequest> for WindowsHandler {
|
||||||
unsafe {
|
unsafe {
|
||||||
let response = CloseHandle(req.handle as HANDLE);
|
let response = CloseHandle(req.handle as HANDLE);
|
||||||
|
|
||||||
|
if response != 1 {
|
||||||
|
warn!("CloseHandle returned {}", response);
|
||||||
|
}
|
||||||
|
|
||||||
I32Response { response }
|
I32Response { response }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,10 +71,9 @@ impl CheatEngineConnection {
|
||||||
};
|
};
|
||||||
|
|
||||||
let request = &buf[..n];
|
let request = &buf[..n];
|
||||||
debug!("incoming data({}): {:?}", request[0], request);
|
let response = Self::handle(request, &handler);
|
||||||
|
|
||||||
// Write the data back
|
// Write the data back
|
||||||
let response = Self::handle(request, &handler);
|
|
||||||
if let Err(e) = socket.write_all(&response[..]).await {
|
if let Err(e) = socket.write_all(&response[..]).await {
|
||||||
error!("failed to write to socket; err = {:?}", e);
|
error!("failed to write to socket; err = {:?}", e);
|
||||||
return;
|
return;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче