Add bcryptprimitives.dll shim for wine
This commit is contained in:
parent
e18201deca
commit
07633821ed
30
.github/workflows/main.yml
vendored
30
.github/workflows/main.yml
vendored
@ -44,10 +44,9 @@ jobs:
|
||||
env:
|
||||
TARGET_TRIPLE: x86_64-apple-darwin
|
||||
# cross-compile from Linux to Windows using mingw
|
||||
# FIXME The wine version in Ubuntu 22.04 is missing ProcessPrng
|
||||
#- os: ubuntu-latest
|
||||
# env:
|
||||
# TARGET_TRIPLE: x86_64-pc-windows-gnu
|
||||
- os: ubuntu-latest
|
||||
env:
|
||||
TARGET_TRIPLE: x86_64-pc-windows-gnu
|
||||
- os: ubuntu-latest
|
||||
env:
|
||||
TARGET_TRIPLE: aarch64-unknown-linux-gnu
|
||||
@ -81,11 +80,11 @@ jobs:
|
||||
if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
|
||||
run: rustup set default-host x86_64-pc-windows-gnu
|
||||
|
||||
#- name: Install MinGW toolchain and wine
|
||||
# if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
|
||||
# run: |
|
||||
# sudo apt-get update
|
||||
# sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
|
||||
- name: Install MinGW toolchain and wine
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
|
||||
|
||||
- name: Install AArch64 toolchain and qemu
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'aarch64-unknown-linux-gnu'
|
||||
@ -108,6 +107,15 @@ jobs:
|
||||
- name: Prepare dependencies
|
||||
run: ./y.sh prepare
|
||||
|
||||
# The Wine version shipped with Ubuntu 22.04 doesn't implement bcryptprimitives.dll
|
||||
- name: Build bcryptprimitives.dll shim for Wine
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
|
||||
run: |
|
||||
rustup target add x86_64-pc-windows-gnu
|
||||
mkdir wine_shims
|
||||
rustc patches/bcryptprimitives.rs -Copt-level=3 -Clto=fat --out-dir wine_shims --target x86_64-pc-windows-gnu
|
||||
echo "WINEPATH=$(pwd)/wine_shims" >> $GITHUB_ENV
|
||||
|
||||
- name: Build
|
||||
run: ./y.sh build --sysroot none
|
||||
|
||||
@ -234,11 +242,11 @@ jobs:
|
||||
if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
|
||||
run: rustup set default-host x86_64-pc-windows-gnu
|
||||
|
||||
- name: Install MinGW toolchain and wine
|
||||
- name: Install MinGW toolchain
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
|
||||
sudo apt-get install -y gcc-mingw-w64-x86-64
|
||||
|
||||
- name: Prepare dependencies
|
||||
run: ./y.sh prepare
|
||||
|
22
patches/bcryptprimitives.rs
Normal file
22
patches/bcryptprimitives.rs
Normal file
@ -0,0 +1,22 @@
|
||||
// Shim for bcryptprimitives.dll. The Wine version shipped with Ubuntu 22.04
|
||||
// doesn't support it yet. Authored by @ChrisDenton
|
||||
|
||||
#![crate_type = "cdylib"]
|
||||
#![allow(nonstandard_style)]
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "system" fn ProcessPrng(mut pbData: *mut u8, mut cbData: usize) -> i32 {
|
||||
while cbData > 0 {
|
||||
let size = core::cmp::min(cbData, u32::MAX as usize);
|
||||
RtlGenRandom(pbData, size as u32);
|
||||
cbData -= size;
|
||||
pbData = pbData.add(size);
|
||||
}
|
||||
1
|
||||
}
|
||||
|
||||
#[link(name = "advapi32")]
|
||||
extern "system" {
|
||||
#[link_name = "SystemFunction036"]
|
||||
pub fn RtlGenRandom(RandomBuffer: *mut u8, RandomBufferLength: u32) -> u8;
|
||||
}
|
Loading…
Reference in New Issue
Block a user