Skip to content
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.

Doesn't work since Rust 1.51.0 #4

Open
BlueGradientHorizon opened this issue Jul 12, 2022 · 3 comments
Open

Doesn't work since Rust 1.51.0 #4

BlueGradientHorizon opened this issue Jul 12, 2022 · 3 comments

Comments

@BlueGradientHorizon
Copy link

In total, in my tests, I used these toolchains:

  • 1.50.0-i686-pc-windows-gnu
  • 1.50.0-i686-pc-windows-msvc
  • 1.51.0-i686-pc-windows-gnu
  • 1.51.0-i686-pc-windows-msvc

To build the program in gnu toolchains, I used the MinGW toolchain: i686-8.1.0-release-win32-dwarf. If I use Rust toolchains version 1.50.0, the program runs successfully on Windows XP (for msvc builds, of course, I installed MS Visual C++ 2015 Redist. x86 on my Windows XP virtual machine).

But if I try to run the same program built in any version of Rust since 1.51.0, I get an error [translated to English]: The procedure entry point AcquireSRWLockExclusive could not be located in the dynamic link library KERNEL32.dll.
Capture

It looks like the xpsupport initialization doesn't happen until the Rust standard library is run.

Contents of the program source file src\main.rs:

extern crate xpsupport;
fn main() {
    xpsupport::init();
    println!("Hello, World!");
}

Cargo.toml:

[package]
name = "xp_test"
version = "0.1.0"
authors = ["lenovo-pc <***@gmail.com>"]
edition = "2018"

[dependencies]
xpsupport = "0.2"

RUSTFLAGS:

  • for gnu Rust toolchain build
set RUSTFLAGS=-Ctarget-feature=+crt-static
  • for msvc Rust toolchain build
set RUSTFLAGS=-Ctarget-feature=+crt-static -Clink-args=/subsystem:console,5.01

Build command:

cargo build --target i686-pc-windows-XXX --release
@BlueGradientHorizon
Copy link
Author

BlueGradientHorizon commented Jul 12, 2022

Hm, I've made some progress. It turns out that the YY_Thunks_for_WinXP.obj file is required and must be included in the linker parameters. But also i need to pass user32.lib library as parameter for successfull linking. But now I have another missing function error: SetThreadStackGuarantee. I'm investigating it.

@BlueGradientHorizon
Copy link
Author

BlueGradientHorizon commented Jul 12, 2022

Also, if I understand correctly, the SetThreadStackGuarantee function is the only one missing to run my Rust test program. I checked it with Dependency walker program.

@lynnux
Copy link
Owner

lynnux commented Jul 13, 2022

Sadly, the commit rust-lang/rust@59855e0 make this crate not work anymore, but the YY_Thunks_for_WinXP.obj trick should work, I'v noticed your comment on Chuyu-Team/YY-Thunks#37. Link YY_Thunks maybe the only solution to support XP right now.

You can write a obj file like YY-Thunks and link it to your rust code, and implement SetThreadStackGuarantee like this: rust-lang/rust@59855e0#diff-96f5abd15201d718909ac0227541d568d9985ac9b075a34ae7eb9f5f66a562f9L1042-L1044

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants