Skip to content

Commit

Permalink
support stable rust, bump versions of dependencies
Browse files Browse the repository at this point in the history
StackOverflowExcept1on authored and mcountryman committed Oct 28, 2024
1 parent 864ffda commit b2563ed
Showing 5 changed files with 36 additions and 35 deletions.
43 changes: 25 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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: |
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
@@ -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
@@ -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.
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;
@@ -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]

0 comments on commit b2563ed

Please sign in to comment.