fix: use card whitelist for cloudlink scores injection

This commit is contained in:
Adamaq01 2023-09-07 01:20:08 +02:00
parent f750adc485
commit 8418d47080
2 changed files with 31 additions and 11 deletions

View File

@ -78,6 +78,20 @@ pub fn get_current_card_id() -> Option<String> {
guard.clone() 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<String> { pub fn read_node_str(node: *const (), path: *const u8, length: usize) -> Option<String> {
let mut buffer = [0u8; 32]; let mut buffer = [0u8; 32];
let result = unsafe { let result = unsafe {

View File

@ -8,6 +8,7 @@ use log::{debug, error, info, warn};
use crate::handlers::save::process_save; use crate::handlers::save::process_save;
use crate::handlers::scores::process_scores; use crate::handlers::scores::process_scores;
use crate::helpers::is_current_card_id_whitelisted;
use crate::sys::{ use crate::sys::{
property_clear_error, property_mem_write, property_node_name, property_node_refer, property_clear_error, property_mem_write, property_node_name, property_node_refer,
property_query_size, property_search, property_set_flag, NodeType, property_query_size, property_search, property_set_flag, NodeType,
@ -200,7 +201,8 @@ pub unsafe fn property_mem_read_hook_wrapped(
Ok(response) Ok(response)
})()) })())
} else if load } else if is_current_card_id_whitelisted()
&& load
.then(|| root.pointer(&["game", "code"])) .then(|| root.pointer(&["game", "code"]))
.flatten() .flatten()
.is_some() .is_some()
@ -222,6 +224,7 @@ pub unsafe fn property_mem_read_hook_wrapped(
Ok(response) Ok(response)
})()) })())
} else if let Some(music) = load_m.then(|| root.pointer(&["game", "music"])).flatten() { } else if let Some(music) = load_m.then(|| root.pointer(&["game", "music"])).flatten() {
if is_current_card_id_whitelisted() {
Some((|| { Some((|| {
let user = USER.load(Ordering::SeqCst).to_string(); let user = USER.load(Ordering::SeqCst).to_string();
let response = crate::cloudlink::process_pbs(user.as_str(), music)?; let response = crate::cloudlink::process_pbs(user.as_str(), music)?;
@ -233,6 +236,9 @@ pub unsafe fn property_mem_read_hook_wrapped(
} else { } else {
None None
} }
} else {
None
}
} }
#[crochet::hook("avs2-core.dll", "XCgsqzn0000091")] #[crochet::hook("avs2-core.dll", "XCgsqzn0000091")]