Skip to content

Commit 920b97e

Browse files
committed
Add offset search for 1.0.0
1 parent 9813e19 commit 920b97e

4 files changed

Lines changed: 70 additions & 15 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "arcropolis"
3-
version = "1.0.0-beta"
3+
version = "1.0.0-beta2"
44
authors = ["Raytwo <raytwost@gmail.com>, jam1garner <jam1.mcleod@hotmail.com>"]
55
edition = "2018"
66

src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::io::prelude::*;
77
use std::ffi::CStr;
88
use std::net::IpAddr;
99

10-
use skyline::{hook, hooks::InlineCtx, install_hooks, logging::{hex_dump_ptr, hex_dump_str}, nn};
10+
use skyline::{hook, hooks::InlineCtx, install_hooks, nn};
1111

1212
mod config;
1313
use config::CONFIG;
@@ -18,7 +18,7 @@ mod replacement_files;
1818
use replacement_files::{ FileCtx, ARC_FILES, INCOMING };
1919

2020
mod offsets;
21-
use offsets::TITLE_SCREEN_VERSION_OFFSET;
21+
use offsets::{ TITLE_SCREEN_VERSION_OFFSET, INFLATE_OFFSET, MEMCPY_1_OFFSET, MEMCPY_2_OFFSET, MEMCPY_3_OFFSET, INFLATE_DIR_FILE_OFFSET, MANUAL_OPEN_OFFSET, INITIAL_LOADING_OFFSET };
2222

2323
use owo_colors::OwoColorize;
2424

@@ -98,7 +98,7 @@ fn replace_textures_by_index(file_ctx: &FileCtx, table2entry: &mut Table2Entry)
9898
}
9999
}
100100

101-
#[hook(offset = 0x33b71e8, inline)]
101+
#[hook(offset = INFLATE_OFFSET, inline)]
102102
fn inflate_incoming(ctx: &InlineCtx) {
103103
unsafe {
104104
let arc = LoadedTables::get_instance().get_arc();
@@ -139,7 +139,7 @@ fn loading_incoming(ctx: &InlineCtx) {
139139
}
140140

141141
/// For small uncompressed files
142-
#[hook(offset = 0x33b7d08, inline)]
142+
#[hook(offset = MEMCPY_1_OFFSET, inline)]
143143
fn memcpy_uncompressed(_ctx: &InlineCtx) {
144144
trace!("[ResInflateThread | Memcpy1] Entering function");
145145

@@ -151,7 +151,7 @@ fn memcpy_uncompressed(_ctx: &InlineCtx) {
151151
}
152152

153153
/// For uncompressed files a bit larger
154-
#[hook(offset = 0x33b78f8, inline)]
154+
#[hook(offset = MEMCPY_2_OFFSET, inline)]
155155
fn memcpy_uncompressed_2(_ctx: &InlineCtx) {
156156
trace!("[ResInflateThread | Memcpy2] Entering function");
157157

@@ -163,7 +163,7 @@ fn memcpy_uncompressed_2(_ctx: &InlineCtx) {
163163
}
164164

165165
/// For uncompressed files being read in multiple chunks
166-
#[hook(offset = 0x33b7988, inline)]
166+
#[hook(offset = MEMCPY_3_OFFSET, inline)]
167167
fn memcpy_uncompressed_3(_ctx: &InlineCtx) {
168168
trace!("[ResInflateThread | Memcpy3] Entering function");
169169

@@ -180,7 +180,7 @@ pub struct InflateFile {
180180
pub size: u64,
181181
}
182182

183-
#[hook(offset = 0x3816230)]
183+
#[hook(offset = INFLATE_DIR_FILE_OFFSET)]
184184
fn load_directory_hook(unk1: *const u64, out_data: &InflateFile, comp_data: &InflateFile) -> u64 {
185185
trace!("[LoadFileFromDirectory] Incoming filesize: {:x}", out_data.size);
186186

@@ -217,7 +217,7 @@ fn change_version_string(arg1: u64, string: *const u8) {
217217
}
218218
}
219219

220-
#[hook(offset = 0x35c93b0)]
220+
#[hook(offset = MANUAL_OPEN_OFFSET)]
221221
unsafe fn manual_hook(page_path: *const u8, unk2: *const u8, unk3: *const u64, unk4: u64) {
222222
let original_page = CStr::from_ptr(page_path as _).to_str().unwrap();
223223

@@ -237,7 +237,7 @@ unsafe fn manual_hook(page_path: *const u8, unk2: *const u8, unk3: *const u64, u
237237
}
238238
}
239239

240-
#[hook(offset = 0x35c6470, inline)]
240+
#[hook(offset = INITIAL_LOADING_OFFSET, inline)]
241241
fn initial_loading(_ctx: &InlineCtx) {
242242
logging::init(CONFIG.logger.as_ref().unwrap().logger_level.into()).unwrap();
243243

src/offsets.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ pub static mut RES_SERVICE_ADRP_OFFSET: usize = 0x335a860;
77
pub static mut LOOKUP_STREAM_HASH_OFFSET: usize = 0x335A7F0;
88
pub static mut TITLE_SCREEN_VERSION_OFFSET:usize = 0x35BAE00;
99

10+
pub static mut INFLATE_OFFSET:usize = 0x33b71e8;
11+
pub static mut MEMCPY_1_OFFSET:usize = 0x33b7d08;
12+
pub static mut MEMCPY_2_OFFSET:usize = 0x33b78f8;
13+
pub static mut MEMCPY_3_OFFSET:usize = 0x33b7988;
14+
pub static mut INFLATE_DIR_FILE_OFFSET:usize = 0x3816230;
15+
pub static mut MANUAL_OPEN_OFFSET:usize = 0x35c93b0;
16+
pub static mut INITIAL_LOADING_OFFSET:usize = 0x35c6474;
17+
1018
static LOADED_TABLES_ADRP_SEARCH_CODE: &[u8] = &[
1119
0xf3, 0x03, 0x00, 0xaa, 0x1f, 0x01, 0x09, 0x6b, 0xe0, 0x04, 0x00, 0x54,
1220
];
@@ -25,6 +33,41 @@ static TITLE_SCREEN_VERSION_SEARCH_CODE: &[u8] = &[
2533
0xff, 0x07, 0x40, 0xd1, 0xf4, 0x03, 0x01, 0xaa, 0xf3, 0x03, 0x00, 0xaa,
2634
];
2735

36+
static INFLATE_SEARCH_CODE: &[u8] = &[
37+
0x4b, 0x00, 0x1b, 0x0b, 0x00, 0x01, 0x1f, 0xd6, 0x68, 0x6a, 0x40, 0xf9, 0x09, 0x3d, 0x40, 0xf9,
38+
0x2c, 0x01, 0x40, 0xf9,
39+
];
40+
41+
static MEMCPY_1_SEARCH_CODE: &[u8] = &[
42+
0xf5, 0x1f, 0x40, 0xb9, 0xa7, 0x00, 0x00, 0x14, 0xe2, 0xa3, 0x00, 0x91, 0xe4, 0xc3, 0x00, 0x91,
43+
];
44+
45+
static MEMCPY_2_SEARCH_CODE: &[u8] = &[
46+
0xf8, 0x1b, 0x40, 0xf9, 0x1f, 0x03, 0x15, 0xeb, 0xa2, 0x2a, 0x00, 0x54, 0x96, 0x03, 0x18, 0x8b,
47+
0x68, 0x1a, 0x40, 0xf9,
48+
];
49+
50+
static MEMCPY_3_SEARCH_CODE: &[u8] = &[
51+
0xe8, 0x03, 0x18, 0xaa, 0xf8, 0x1b, 0x40, 0xf9, 0xd6, 0x02, 0x18, 0x8b, 0xbf, 0x02, 0x18, 0xeb,
52+
0x88, 0xfb, 0xff, 0x54,
53+
];
54+
55+
static INFLATE_DIR_FILE_SEARCH_CODE: &[u8] = &[
56+
0xfc, 0x6f, 0xba, 0xa9, 0xfa, 0x67, 0x01, 0xa9, 0xf8, 0x5f, 0x02, 0xa9, 0xf6, 0x57, 0x03, 0xa9,
57+
0xf4, 0x4f, 0x04, 0xa9, 0xfd, 0x7b, 0x05, 0xa9, 0xfd, 0x43, 0x01, 0x91, 0xff, 0x03, 0x07, 0xd1,
58+
0x4c, 0xb4, 0x40, 0xa9,
59+
];
60+
61+
static MANUAL_OPEN_SEARCH_CODE: &[u8] = &[
62+
0xfc, 0x4f, 0xbe, 0xa9, 0xfd, 0x7b, 0x01, 0xa9, 0xfd, 0x43, 0x00, 0x91, 0xff, 0x0f, 0x40, 0xd1,
63+
];
64+
65+
static INITIAL_LOADING_SEARCH_CODE: &[u8] = &[
66+
0x08, 0x3f, 0x40, 0xf9, 0x08, 0x01, 0x40, 0xf9, 0x08, 0x21, 0x40, 0xf9, 0x08, 0x3d, 0x40, 0xb9,
67+
0x08, 0x5d, 0x00, 0x12,
68+
];
69+
70+
2871
fn find_subsequence(haystack: &[u8], needle: &[u8]) -> Option<usize> {
2972
haystack
3073
.windows(needle.len())
@@ -109,6 +152,13 @@ pub fn search_offsets() {
109152
find_offsets!(
110153
(LOOKUP_STREAM_HASH_OFFSET, LOOKUP_STREAM_HASH_SEARCH_CODE),
111154
(TITLE_SCREEN_VERSION_OFFSET, TITLE_SCREEN_VERSION_SEARCH_CODE),
155+
(INFLATE_OFFSET, INFLATE_SEARCH_CODE),
156+
(MEMCPY_1_OFFSET, MEMCPY_1_SEARCH_CODE),
157+
(MEMCPY_2_OFFSET, MEMCPY_2_SEARCH_CODE),
158+
(MEMCPY_3_OFFSET, MEMCPY_3_SEARCH_CODE),
159+
(INFLATE_DIR_FILE_OFFSET, INFLATE_DIR_FILE_SEARCH_CODE),
160+
(MANUAL_OPEN_OFFSET, MANUAL_OPEN_SEARCH_CODE),
161+
(INITIAL_LOADING_OFFSET, INITIAL_LOADING_SEARCH_CODE),
112162
);
113163
}
114164
}

src/selector.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
use std::{fs::{File, create_dir_all, read_dir}, path::Path};
1+
use std::{
2+
fs::{
3+
create_dir_all,
4+
read_dir
5+
},
6+
path::Path
7+
};
8+
29
use std::io::prelude::*;
310

411
use log::info;
@@ -8,8 +15,6 @@ use skyline_web::PageResult;
815

916
use crate::config::Config;
1017

11-
use crate::config::CONFIG;
12-
1318
// Thanks jugeeya :^)
1419
pub fn get_arguments_from_url(s: &str) -> String{
1520
let base_url_len = "http://localhost/".len();
@@ -54,7 +59,7 @@ fn get_workspaces() -> Vec<Workspace> {
5459
fn show_selector(workspaces: &Workspaces) -> PageResult {
5560
let mut file = std::fs::File::open("sd:/atmosphere/contents/01006A800016E000/manual_html/html-document/contents.htdocs/arcropolis/selector/templates/index.html").unwrap();
5661
let mut page_content: String = String::new();
57-
file.read_to_string(&mut page_content);
62+
file.read_to_string(&mut page_content).unwrap();
5863

5964
let tpl = ramhorns::Template::new(page_content).unwrap();
6065

@@ -110,7 +115,7 @@ pub fn workspace_selector() {
110115
}
111116

112117
if config_changed {
113-
config.save();
118+
config.save().unwrap();
114119
skyline_web::DialogOk::ok(
115120
"Your changes have been applied.
116121
Consider rebooting the game to apply your changes.");

0 commit comments

Comments
 (0)