rosu_memory_lib/reader/user/stable/
memory.rs1use rosu_mem::process::{Process, ProcessTraits};
2use crate::reader::structs::State;
3use crate::reader::user::common::UserInfo;
4use crate::reader::user::stable::offset::USER_PROFILE_OFFSET;
5
6pub fn get_user_profile_base(p: &Process, state: &mut State) -> eyre::Result<i32>
7{
8 Ok(p.read_i32(p.read_i32(state.addresses.user_profile + USER_PROFILE_OFFSET.ptr)?)?)
9}
10
11pub fn get_user_id(p: &Process, state: &mut State) -> eyre::Result<i32> {
12 let user_profile_base = get_user_profile_base(p, state)?;
13 Ok(p.read_i32(user_profile_base + USER_PROFILE_OFFSET.id)?)
14}
15
16
17pub fn get_user_bancho_status(p: &Process, state: &mut State) -> eyre::Result<i32> {
18 let user_profile_base = get_user_profile_base(p, state)?;
19 Ok(p.read_i32(user_profile_base + USER_PROFILE_OFFSET.bancho_status)?)
20}
21
22pub fn get_user_country_code(p: &Process, state: &mut State) -> eyre::Result<i32> {
23 let user_profile_base = get_user_profile_base(p, state)?;
24 Ok(p.read_i32(user_profile_base + USER_PROFILE_OFFSET.country_code)?)
25}
26
27pub fn get_user_username(p: &Process, state: &mut State) -> eyre::Result<String> {
28 let user_profile_base = get_user_profile_base(p, state)?;
29 let username_ptr = p.read_i32(user_profile_base + USER_PROFILE_OFFSET.username)?;
30 Ok(p.read_string(username_ptr)?)
31}
32
33pub fn get_user_pp(p: &Process, state: &mut State) -> eyre::Result<i32> {
34 let user_profile_base = get_user_profile_base(p, state)?;
35 Ok(p.read_i32(user_profile_base + USER_PROFILE_OFFSET.pp)?)
36}
37
38pub fn get_user_rankedscore(p: &Process, state: &mut State) -> eyre::Result<i64> {
39 let user_profile_base = get_user_profile_base(p, state)?;
40 Ok(p.read_i64(user_profile_base + USER_PROFILE_OFFSET.rankedscore)?)
41}
42
43pub fn get_user_level(p: &Process, state: &mut State) -> eyre::Result<f32> {
44 let user_profile_base = get_user_profile_base(p, state)?;
45 Ok(p.read_f32(user_profile_base + USER_PROFILE_OFFSET.level)?)
46}
47
48pub fn get_user_playcount(p: &Process, state: &mut State) -> eyre::Result<i32> {
49 let user_profile_base = get_user_profile_base(p, state)?;
50 Ok(p.read_i32(user_profile_base + USER_PROFILE_OFFSET.playcount)?)
51}
52
53pub fn get_user_rank(p: &Process, state: &mut State) -> eyre::Result<i32> {
54 let user_profile_base = get_user_profile_base(p, state)?;
55 Ok(p.read_i32(user_profile_base + USER_PROFILE_OFFSET.rank)?)
56}
57
58pub fn get_user_playmode(p: &Process, state: &mut State) -> eyre::Result<i32> {
59 let user_profile_base = get_user_profile_base(p, state)?;
60 Ok(p.read_i32(user_profile_base + USER_PROFILE_OFFSET.playmode)?)
61}
62
63pub fn get_user_accuracy(p: &Process, state: &mut State) -> eyre::Result<f64> {
64 let user_profile_base = get_user_profile_base(p, state)?;
65 Ok(p.read_f64(user_profile_base + USER_PROFILE_OFFSET.accuracy)?)
66}
67
68pub fn get_user_info(p: &Process, state: &mut State) -> eyre::Result<UserInfo> {
69 let user_profile_base = get_user_profile_base(p, state)?;
70
71
72
73 let user_profile = UserInfo {
74 id: p.read_i32(user_profile_base + USER_PROFILE_OFFSET.id)?,
75 username: p.read_string(p.read_i32(user_profile_base + USER_PROFILE_OFFSET.username)?)?, pp: p.read_i32(user_profile_base + USER_PROFILE_OFFSET.pp)?,
77 rankedscore: p.read_i64(user_profile_base + USER_PROFILE_OFFSET.rankedscore)?,
78 level: p.read_f32(user_profile_base + USER_PROFILE_OFFSET.level)?,
79 playcount: p.read_i32(user_profile_base + USER_PROFILE_OFFSET.playcount)?,
80 rank: p.read_i32(user_profile_base + USER_PROFILE_OFFSET.rank)?,
81 playmode: p.read_i32(user_profile_base + USER_PROFILE_OFFSET.playmode)?,
82 accuracy: p.read_f64(user_profile_base + USER_PROFILE_OFFSET.accuracy)?,
83 country_code: p.read_i32(user_profile_base + USER_PROFILE_OFFSET.country_code)?,
84 bancho_status: p.read_i32(user_profile_base + USER_PROFILE_OFFSET.bancho_status)?,
85 };
86 Ok(user_profile)
87}