diff --git a/src/helpers.rs b/src/helpers.rs index 87d9c33..e7c1eaa 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -78,6 +78,20 @@ pub fn get_current_card_id() -> Option { guard.clone() } +pub fn is_current_card_id_whitelisted() -> bool { + if let Some(card) = get_current_card_id() { + if !CONFIGURATION.cards.whitelist.is_empty() + && !CONFIGURATION.cards.whitelist.contains(&card) + { + return false; + } + + return true; + } + + false +} + pub fn read_node_str(node: *const (), path: *const u8, length: usize) -> Option { let mut buffer = [0u8; 32]; let result = unsafe { diff --git a/src/mikado.rs b/src/mikado.rs index 2713275..aa15bff 100644 --- a/src/mikado.rs +++ b/src/mikado.rs @@ -8,6 +8,7 @@ use log::{debug, error, info, warn}; use crate::handlers::save::process_save; use crate::handlers::scores::process_scores; +use crate::helpers::is_current_card_id_whitelisted; use crate::sys::{ property_clear_error, property_mem_write, property_node_name, property_node_refer, property_query_size, property_search, property_set_flag, NodeType, @@ -200,10 +201,11 @@ pub unsafe fn property_mem_read_hook_wrapped( Ok(response) })()) - } else if load - .then(|| root.pointer(&["game", "code"])) - .flatten() - .is_some() + } else if is_current_card_id_whitelisted() + && load + .then(|| root.pointer(&["game", "code"])) + .flatten() + .is_some() { Some((|| { let game = root @@ -222,14 +224,18 @@ pub unsafe fn property_mem_read_hook_wrapped( Ok(response) })()) } else if let Some(music) = load_m.then(|| root.pointer(&["game", "music"])).flatten() { - Some((|| { - let user = USER.load(Ordering::SeqCst).to_string(); - let response = crate::cloudlink::process_pbs(user.as_str(), music)?; - let response = build_response(&original_signature, response, encoding)?; - LOAD_M.store(false, Ordering::Relaxed); + if is_current_card_id_whitelisted() { + Some((|| { + let user = USER.load(Ordering::SeqCst).to_string(); + let response = crate::cloudlink::process_pbs(user.as_str(), music)?; + let response = build_response(&original_signature, response, encoding)?; + LOAD_M.store(false, Ordering::Relaxed); - Ok(response) - })()) + Ok(response) + })()) + } else { + None + } } else { None }