Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support stable rust, bump versions of dependencies #16

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: CI

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

env:
Expand All @@ -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: |
Expand Down
11 changes: 2 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
13 changes: 7 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![no_std]
#![no_main]
#![feature(asm_const)]
#![windows_subsystem = "console"]

use core::arch::asm;
Expand All @@ -15,7 +14,7 @@ include!(concat!(env!("OUT_DIR"), "/syscall.rs"));

macro_rules! buf {
() => {
"Hello World!\n"
"Hello World!"
};
}

Expand Down Expand Up @@ -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]
Expand Down