System calls, FFI, and cross-platform abstractions 59 h Console Output: i32, lp Buffer: *const u16, number Of Chars To Write: u32, lp Number Of Chars Written: *mut u32, lp Reserved: *const std::ffi::c_void, )-> i32; } The first thing you notice is that we no longer link to the "C" library. Instead, we link to the kernel32 library. The next change is the use of the system calling convention. This calling convention is a bit peculiar. Y ou see, Windows uses different calling conventions depending on whether you write for a 32-bit x86 Windows version or a 64-bit x86_64 Windows version. Newer Windows versions running on x86_64 use the "C" calling convention, so if you have a newer system you can try changing that out and see that it still works. “Specifying system” lets the compiler figure out the right one to use based on the system. We link to two different syscalls in Windows: Get Std Handle : This retrieves a reference to a standard device like stdout Write Console W : Write Console comes in two types. Write Console W takes Unicode text and Write Console A takes ANSI-encoded text. We're using the one that takes Unicode text in our program. Now, ANSI-encoded text works fine if you only write English text, but as soon as you write text in other languages, you might need to use special characters that are not possible to represent in ANSI but possible in Unicode. If you mix them up, your program will not work as you expect. Next is our new syscall function: ch03/b-normal-syscall fn syscall(message: String)-> io::Result<()> { let msg: Vec<u16> = message. encode_utf16(). collect(); let msg_ptr = msg. as_ptr(); let len = msg. len() as u32; let mut output: u32 = 0; let handle = unsafe { Get Std Handle(-11) }; if handle ==-1 { return Err(io::Error::last_os_error()) } let res = unsafe { Write Console W( handle,