diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bb33de1..7d836ce 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -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/github-release@2.0 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/* diff --git a/Cargo.toml b/Cargo.toml index b0fe674..568d906 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/lib.rs b/src/lib.rs index f22f27e..0ce47d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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)