diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a27471..94f1c5d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,88 +7,58 @@ env: jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] + build_ubuntu_x86-64: + name: Build for ubuntu-latest (x86-64) + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - - name: Install libusb-1.0 + with: + submodules: 'true' + - name: install libusb-1.0 run: sudo apt-get install libusb-1.0-0-dev - if: runner.os != 'Windows' - - - name: Build - run: cargo build --workspace --verbose - - - name: Build examples - run: cargo build --workspace --examples --verbose + - name: build + run: cargo build --workspace --all-features --verbose + - name: run tests + run: cargo test --workspace --verbose + - name: build examples + run: cargo build --workspace --all-features --examples --verbose - build-arm: - runs-on: ubuntu-latest + build_windows_x86-64: + name: Build for windows-latest (x86-64) + runs-on: windows-latest steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 with: - toolchain: stable - target: aarch64-unknown-linux-gnu - override: true - - run: sudo apt-get install libusb-1.0-0-dev - - uses: actions-rs/cargo@v1 + submodules: 'true' + - name: install llvm and clang + uses: KyleMayes/install-llvm-action@v1 with: - use-cross: true - command: build - args: --target aarch64-unknown-linux-gnu --workspace --verbose - - test: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - steps: - - uses: actions/checkout@v2 - - - name: Install libusb-1.0 - run: sudo apt-get install libusb-1.0-0-dev - if: runner.os != 'Windows' - - - name: Run all tests + version: "10.0" + directory: ${{ runner.temp }}/llvm + - name: set LIBCLANG_PATH + run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV + - name: build + shell: bash + run: cargo build --workspace --all-features --verbose + - name: run tests + shell: bash run: cargo test --workspace --verbose - if: runner.os == 'Linux' - - - name: Run all tests - run: cargo test --workspace --exclude memflow-derive --verbose + - name: build examples + shell: bash + run: cargo build --workspace --all-features --examples --verbose lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + submodules: 'true' + - name: install libusb-1.0 + run: sudo apt-get install libusb-1.0-0-dev - run: rustup component add clippy - - name: Check formatting + - name: check formatting run: cargo fmt -- --check - uses: actions-rs/clippy-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} args: --all-targets - - build-coverage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Rust nightly - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - run: cargo install grcov - - name: Run tests with coverage - run: | - export CARGO_INCREMENTAL=0 - export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" - export RUSTDOCFLAGS="-Cpanic=abort" - cargo build --workspace --exclude memflow-derive - cargo test --workspace --exclude memflow-derive - grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o ./target/debug/coverage - bash <(curl -s https://codecov.io/bash) -f ./target/debug/coverage -t ${{ secrets.CODECOV_TOKEN }}; diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c7c8352 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,77 @@ +name: Release binaries + +on: + release: + types: [created] + +env: + CARGO_TERM_COLOR: always + +jobs: + + build_ubuntu_x86-64: + name: Build artifacts for ubuntu-latest (x86-64) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: 'true' + - name: install libusb-1.0 + run: sudo apt-get install libusb-1.0-0-dev + - name: build + run: cargo build --release --workspace --all-features --verbose + - uses: actions/upload-artifact@v2 + with: + name: library-ubuntu + path: target/release/*.so + + build_windows_x86-64: + name: Build artifacts for windows-latest (x86-64) + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: 'true' + - name: install llvm and clang + uses: KyleMayes/install-llvm-action@v1 + with: + version: "10.0" + directory: ${{ runner.temp }}/llvm + - name: set LIBCLANG_PATH + run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV + - name: build + shell: bash + run: cargo build --release --workspace --all-features --verbose + - uses: actions/upload-artifact@v2 + with: + name: library-windows + path: target/release/*.dll + + publish_artifacts: + name: Publish artifacts for x86-64/windows-latest + runs-on: ubuntu-latest + needs: [build_ubuntu_x86-64, build_windows_x86-64] + steps: + - uses: actions/download-artifact@v2 + with: + name: library-ubuntu + - name: Create archive for linux x86-64 + run: zip memflow_pcileech_linux_x86-64.zip *.so + - name: Upload artifacts for linux x86-64 + uses: skx/github-action-publish-binaries@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: 'memflow_pcileech_linux_x86-64.zip' + + - uses: actions/download-artifact@v2 + with: + name: library-windows + - name: Create archive for windows x86-64 + run: zip memflow_pcileech_windows_x86-64.zip *.dll + - name: Upload artifacts for windows x86-64 + uses: skx/github-action-publish-binaries@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: 'memflow_pcileech_windows_x86-64.zip' diff --git a/README.md b/README.md index 50a68a9..5dfa18e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -# This repository is currently work-in-progress and might not fully work. - # memflow-pcileech This connector implements a rust-native implementation of the pcileech interface. @@ -19,6 +17,8 @@ Install the following build tools: - clang - libusb-1.0 (only required on linux) +Make sure that libclang can be found by either adding it to your `PATH` or via the `LIBCLANG_PATH` environment variable. + On Windows you additionally need to supply the proprietary `FTD3XX.dll`. It can be downloaded from the [FTDI Website](https://www.ftdichip.com/Drivers/D3XX.htm) in the `Application Library (DLL)` column. On Linux you need to check-out and compile the `leechcore_ft601_driver_linux` project from the [LeechCore-Plugins](https://github.com/ufrisk/LeechCore-plugins) repository. @@ -105,6 +105,11 @@ real_base=0x3000 The `real_base` parameter is optional. If it is not set there will be no re-mapping. +On Windows systems the memory map can be obtained from the Registry under the following Key: +``` +HKEY_LOCAL_MACHINE\\HARDWARE\\RESOURCEMAP\\System Resources\\Physical Memory\\.Translated +``` + ## Troubleshooting Q: The plugin is not detected/found by memflow diff --git a/leechcore-sys/Cargo.toml b/leechcore-sys/Cargo.toml index 80449bf..da07684 100644 --- a/leechcore-sys/Cargo.toml +++ b/leechcore-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leechcore-sys" -version = "0.1.0" +version = "0.1.5" authors = ["ko1N "] edition = "2018" readme = "../README.md" @@ -12,6 +12,6 @@ links = "leechcore" ctor = "0.1" [build-dependencies] -cc = "1.0.62" -bindgen = "0.55" +cc = "1.0" +bindgen = "0.56" pkg-config = "0.3" diff --git a/leechcore-sys/build.rs b/leechcore-sys/build.rs index 8465fe2..8c8d32f 100644 --- a/leechcore-sys/build.rs +++ b/leechcore-sys/build.rs @@ -16,6 +16,11 @@ fn os_define() -> &'static str { "LINUX" } +#[cfg(target_os = "macos")] +fn os_define() -> &'static str { + "LINUX" +} + fn build_leechcore(target: &str) { let mut files = vec![ "oscompatibility.c", @@ -64,7 +69,7 @@ fn build_leechcore(target: &str) { for flag in String::from_utf8_lossy(&libusb_flags.stdout) .trim() - .split(" ") + .split(' ') { cfg.flag(flag); } @@ -91,7 +96,7 @@ fn build_leechcore(target: &str) { println!("cargo:rustc-link-lib=static=leechcore"); } -fn main() -> () { +fn main() { let target = env::var("TARGET").unwrap(); let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); diff --git a/leechcore-sys/src/leechcore b/leechcore-sys/src/leechcore index 9b859f1..e31a508 160000 --- a/leechcore-sys/src/leechcore +++ b/leechcore-sys/src/leechcore @@ -1 +1 @@ -Subproject commit 9b859f127784961882ab8ea8803043b37fd1ab61 +Subproject commit e31a5084e264b4ab3c21238a95f703e994ec3384 diff --git a/memflow-pcileech/Cargo.toml b/memflow-pcileech/Cargo.toml index 05604ca..82e34e2 100644 --- a/memflow-pcileech/Cargo.toml +++ b/memflow-pcileech/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "memflow-pcileech" -version = "0.1.0" +version = "0.1.5" authors = ["ko1N "] edition = "2018" description = "qemu procfs connector for leechcore/pcileech" diff --git a/memflow-pcileech/src/lib.rs b/memflow-pcileech/src/lib.rs index 5470626..30f9e3f 100644 --- a/memflow-pcileech/src/lib.rs +++ b/memflow-pcileech/src/lib.rs @@ -46,6 +46,7 @@ const fn calc_num_pages(start: u64, size: u64) -> u64 { ((start & (PAGE_SIZE as u64 - 1)) + size + (PAGE_SIZE as u64 - 1)) >> 12 } +#[allow(clippy::mutex_atomic)] #[derive(Debug)] pub struct PciLeech { handle: Arc>, @@ -82,6 +83,7 @@ impl PciLeech { Self::with_mapping(device, memmap) } + #[allow(clippy::mutex_atomic)] fn with_mapping(device: &str, mem_map: MemoryMap<(Address, usize)>) -> Result { // open device let mut conf = build_lc_config(device);