From 66a7d8a22a1dc165386b9e24c32ff6451cb423f1 Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Fri, 18 Oct 2024 17:33:01 +0300 Subject: [PATCH] support stable rust, bump versions of dependencies --- .github/workflows/ci.yml | 43 +++++++++++++++++++++++----------------- Cargo.lock | 11 ++-------- Cargo.toml | 2 +- build.rs | 2 +- src/main.rs | 13 ++++++------ 5 files changed, 36 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b75bf8..bdd6da4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,9 @@ name: CI on: push: + branches: [ master ] pull_request: + branches: [ master ] workflow_dispatch: env: @@ -12,37 +14,42 @@ jobs: build: name: Build project runs-on: ${{ matrix.os }} + strategy: matrix: - os: [windows-2022, windows-2019] - if: "!contains(github.event.head_commit.message, '[ci skip]')" + os: + - windows-2022 + - windows-2019 + toolchain: + - stable + - nightly steps: - - name: Checkout - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v4 - - name: Cache cargo - uses: actions/cache@v3 - with: - path: ~/.cargo - key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }} + - name: Cargo cache + uses: Swatinem/rust-cache@v2 - - name: Setup cargo toolchain - uses: actions-rs/toolchain@v1 + - name: Setup ${{ matrix.toolchain }} toolchain + uses: dtolnay/rust-toolchain@master with: - toolchain: nightly - override: true + toolchain: ${{ matrix.toolchain }} + components: clippy, rustfmt - name: Patch MSVC linker run: | cargo install anonlink anonlink - - name: Build cargo - uses: actions-rs/cargo@v1 - with: - command: build - args: --verbose --release + - name: Cargo build + run: cargo build --release + + - name: Cargo clippy + run: cargo clippy --release -- -D warnings + + - name: Cargo fmt + run: cargo fmt -- --check - name: Test execution run: | diff --git a/Cargo.lock b/Cargo.lock index c2bfa7a..6014680 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,12 +4,11 @@ version = 3 [[package]] name = "iced-x86" -version = "1.17.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "158f5204401d08f91d19176112146d75e99b3cf745092e268fa7be33e09adcec" +checksum = "7c447cff8c7f384a7d4f741cfcff32f75f3ad02b406432e8d6c878d56b1edf6b" dependencies = [ "lazy_static", - "static_assertions", ] [[package]] @@ -24,9 +23,3 @@ version = "0.1.0" dependencies = [ "iced-x86", ] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" diff --git a/Cargo.toml b/Cargo.toml index 6904dd0..2e5e48f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,4 +16,4 @@ opt-level = "z" codegen-units = 1 [build-dependencies] -iced-x86 = { version = "1.17", default-features = false, features = ["std", "decoder"] } +iced-x86 = { version = "1.21", default-features = false, features = ["std", "decoder"] } diff --git a/build.rs b/build.rs index a208a3b..e819559 100644 --- a/build.rs +++ b/build.rs @@ -3,7 +3,7 @@ //! Provides two functions. //! //! 1. Resolves syscall id of `NtWriteFile` of local system and creates a rust file at -//! `$OUT_DIR/syscall.rs` containing a single constant `NT_WRITE_FILE_SYSCALL_ID`. +//! `$OUT_DIR/syscall.rs` containing a single constant `NT_WRITE_FILE_SYSCALL_ID`. //! //! 2. Writes link.exe flags to optimize size. diff --git a/src/main.rs b/src/main.rs index 943ecab..2a81f4a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(asm_const)] #![windows_subsystem = "console"] use core::arch::asm; @@ -15,7 +14,7 @@ include!(concat!(env!("OUT_DIR"), "/syscall.rs")); macro_rules! buf { () => { - "Hello World!\n" + "Hello World!" }; } @@ -80,12 +79,14 @@ extern "C" fn mainCRTStartup() { //arg 6, [rsp + 0x30] //this is dirty hack to save bytes and push string to register rax - //call instruction will push address of hello world string to the stack and jumps to label 1 + //call instruction will push address of hello world string to the stack and jumps to label 2 //so, we can store address of string using pop instruction - //label "1", f - forward (see https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels) - "call 1f", + //label "2", f - forward (see https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels) + "call 2f", concat!(".ascii \"", buf!(), "\""), - "1: pop rax", + //new line + ".byte 0x0a", + "2: pop rax", "mov [rsp + 0x30], rax", //arg 7, [rsp + 0x38]