1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-24 10:54:16 +00:00

Update to work with cargo-skyline

This commit is contained in:
jam1garner 2020-04-16 00:55:22 -04:00
parent b7aecf58f0
commit c405f4f76d
2 changed files with 22 additions and 42 deletions

View file

@ -1,5 +1,5 @@
[package]
name = "skyline-rs-template"
name = "skyline_rs_template"
version = "0.1.0"
authors = ["jam1garner <jam1.mcleod@hotmail.com>"]
edition = "2018"

View file

@ -1,50 +1,30 @@
#![feature(proc_macro_hygiene)]
use skyline::nn::account::{self, Uid, GetLastOpenedUser, GetNickname, Nickname};
use smash::hash40;
use skyline::{hook, install_hook};
#[skyline::main(name = "module_name_test")]
extern "C" fn test() -> u32 {
2
}
#[hook(replace = test)]
fn test_replacement() -> u32 {
let original_test = original!();
let val = original_test();
println!("[override] original value: {}", val); // 2
val + 1
}
#[skyline::main(name = "skyline_rs_template")]
pub fn main() {
println!("Hello from Skyline Rust Plugin!");
for i in 0..3 {
println!("{}", i);
}
install_hook!(test_replacement);
let nickname = unsafe { get_last_user_nickname() };
let x = test();
println!("Last nickname: {}", nickname);
println!("Contents of file: {:?}", std::fs::read_to_string("sd:/test.txt"));
println!("Compile-time hash40 of 'accel_x': {:010X}", hash40("accel_x"));
let string = "accel_x";
println!("Runtime hash40 of '{}': {:010X}", string, hash40(string));
println!("[main] test returned: {}", x); // 3
}
unsafe fn get_last_user_nickname() -> Nickname {
account::Initialize();
let uid = &mut Uid::new();
let mut nick = Nickname::new();
GetLastOpenedUser(uid);
GetNickname(&mut nick, uid);
nick
}
/*
use skyline::{
libc::{fopen, FileOpenMode, fwrite_slice, fclose},
c_str
};
fn write_to_file(file: &str, contents: &str) {
unsafe {
let file = fopen(c_str(file), FileOpenMode::Write);
fwrite_slice(contents.as_bytes(), file);
fclose(file);
}
}*/