Chuyu-Team / YY-Thunks

Fix DecodePointer, EncodePointer,RegDeleteKeyEx etc. APIs not found in Windows XP RTM.
MIT License
567 stars 103 forks source link

Tokio support (Rust) #60

Closed BlueGradientHorizon closed 1 year ago

BlueGradientHorizon commented 1 year ago

Hello. Tokio is an event-driven, non-blocking I/O platform for writing asynchronous applications with the Rust programming language.

I'm currently writing a small server-client application using the Tokio crate. I intended to write a very simple client with minimal dependencies, but it turns out that the core of my program - Tokio - already includes a few unresolved characters on Windows XP. When I try to run the given program's executable on Win XP:

Cargo.toml:

[package]
...

[dependencies]
tokio = { version = "1", features = ["full"] }

src/main.rs:

#[tokio::main]
async fn main() { }

i get two unresolved characters - GetQueuedCompletionStatusEx (MS docs) in kernel32.dll and NtCancelIoFileEx (MS docs) in ntdll.dll.

And this program (an example of a simple TCP server from https://crates.io/crates/tokio):

use tokio::net::TcpListener;
use tokio::io::{AsyncReadExt, AsyncWriteExt};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
     let listener = TcpListener::bind("127.0.0.1:8080").await?;

     loop {
         let (mut socket, _) = listener.accept().await?;

         tokio::spawn(async move {
             let mutbuf = [0; 1024];

             // In a loop, read data from the socket and write the data back.
             loop {
                 let n = match socket.read(&mut buf).await {
                     // socket closed
                     Ok(n) if n == 0 => return,
                     Ok(n) => n,
                     Err(e) => {
                         eprintln!("failed to read from socket; err = {:?}", e);
                         return;
                     }
                 };

                 // Write the data back
                 if let Err(e) = socket.write_all(&buf[0..n]).await {
                     eprintln!("failed to write to socket; err = {:?}", e);
                     return;
                 }
             }
         });
     }
}

adds one more unresolved symbol - SetFileCompletionNotificationModes (MS docs) in kernel32.dll

Is it possible to implement these functions?

Wine implementation of these functions:

I appreciate your work. Thanks.

mingkuang-Chuyu commented 1 year ago

I'm sorry. I don't know... SetFileCompletionNotificationModes.

mingkuang-Chuyu commented 1 year ago

https://github.com/Chuyu-Team/YY-Thunks/releases/tag/v1.0.9-Beta3

done!

zhuxiujia commented 7 months ago

https://github.com/Chuyu-Team/YY-Thunks/releases/tag/v1.0.9-Beta3

done!

yy-thunks version: v1.0.9 beta3

i try this code(tokio) on
windows server 2008( win vista) fail (PermissionDenied, this is run on administrator )

1708449346053