Skip to content

Commit

Permalink
Merge pull request #2 from ultimate-research/no-force-eager
Browse files Browse the repository at this point in the history
Do not force eager loading of NROs, as it causes crashes
  • Loading branch information
jugeeya authored Sep 7, 2021
2 parents 7b2462b + e89c888 commit d3124bf
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 22 deletions.
49 changes: 33 additions & 16 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,49 @@
name: Rust Build
name: Rust

on:
push:
branches: [ master ]
jobs:
build:
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
plugin:
env:
PLUGIN_NAME: nro_hook
runs-on: ubuntu-latest

container:
image: jugeeya/cargo-skyline:2.1.0
steps:
- uses: actions/checkout@v2
- name: Install cargo-skyline
run: cargo install --git https://github.com/jam1garner/cargo-skyline
- name: Install rust-std-skyline-squashed
run: cd .. && git clone https://github.com/jam1garner/rust-std-skyline-squashed && cd -
- name: Attempt to build
run: PATH=$PATH:/usr/share/rust/.rustup/toolchains/nightly-2020-04-10-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin cargo skyline build --release
- name: Update Release
- name: Build release NRO
run: |
PATH=$PATH:/root/.cargo/bin /root/.cargo/bin/cargo-skyline skyline build --release
env:
PLUGIN_NAME: 'libnro_hook.nro' # change this to the name of your plugin
HOME: /root
- name: Upload plugin artifact
uses: actions/upload-artifact@v2
with:
name: plugin
path: target/aarch64-skyline-switch/release/lib${{env.PLUGIN_NAME}}.nro
upload:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs:
- plugin
steps:
- name: Download all artifacts
uses: actions/download-artifact@v2
- name: Update Release
uses: meeDamian/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
allow_override: true
gzip: false
tag: master
name: master
body: Build of ${{env.PLUGIN_NAME}} from master.
tag: beta
name: beta
body: >
Beta built off of the latest code in the repository.
files: >
./target/aarch64-skyline-switch/release/${{env.PLUGIN_NAME}}
plugin/*
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ crate-type = ["cdylib"]
[dependencies]
skyline = { git = "https://github.com/ultimate-research/skyline-rs.git", features = ["nro_internal"] }
skyline_smash = { git = "https://github.com/ultimate-research/skyline-smash.git" }
parking_lot = { version = "0.10", features = ["nightly"] }
parking_lot = { version = "0.11.1", features = ["nightly"] }

[profile.dev]
panic = "abort"
Expand Down
12 changes: 7 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ pub fn handle_load_module(
image: *const c_void,
buffer: *mut c_void,
buffer_size: size_t,
_flag: c_int
flag: c_int
) -> c_int {
// use Flag_Now to ensure we aren't lazy loading NROs
// causes slower load times but is necessary for hooking
let ret = original!()(out_module, image, buffer, buffer_size, ro::BindFlag_BindFlag_Now as i32);
let ret = original!()(out_module, image, buffer, buffer_size, flag);

let name = unsafe { from_c_str(&(*out_module).Name as *const u8) };
println!("[NRO hook] Loaded {}.", name);
println!("[NRO hook] Loaded {}. BindFlag: {}", name, match flag {
1 => "Now",
2 => "Lazy",
_ => "Unknown"
});
let nro_info = NroInfo::new(&name, unsafe { &mut *out_module });
for hook in LOAD_HOOKS.lock().iter() {
hook(&nro_info)
Expand Down

0 comments on commit d3124bf

Please sign in to comment.