by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
FXTi
@FXTi
Hey guys, I'm new to rust on Windows. I wonder how to use NtDeviceIoControlFile in nt.dll in rust way.
I see it in ntdll.def. But seems there's no rust source code about it in winapi-rs crate. And I think it may concerns bindgen.
anyway, is there a way to call that function? It's quite complicated for me...
Peter Atashian
@retep998
@FXTi that function is in the Windows SDK, so it's just a matter of someone submitting a pull request to winapi adding the bindings for it correctly.
FXTi
@FXTi
@retep998 Like this? retep998/winapi-rs#775
FXTi
@FXTi
Sorry to bother you, another solution found.
Ryan Levick
@rylev
Hello! I was wondering if anyone had a good idea of how complete the winapi crate is in terms of API coverage. Just having some conversations at work about the likelihood of running into unimplemented bindings
Peter Atashian
@retep998
rylev: yes
Ryan Levick
@rylev
@retep998 would you be able to give a rough estimate of API coverage (and I do realize how hard that might be...)
Peter Atashian
@retep998
@rylev maybe 20%?
plus or minus 20%
Ryan Levick
@rylev
Meaning 20% is covered right?
Peter Atashian
@retep998
roughly yeah
the windows sdk is huge
Peter Atashian
@retep998
and unfortunately tools like bindgen don't work very well
Brian Merchant
@bzm3r
what's the preferred way to pass a path to a winapi wrapper?
i'm finding that there's no easy way to go from OsStr to a const * _?
Peter Atashian
@retep998
@bzm3r OsStrExt::encode_wide().chain(once(0)).collect() to get you a Vec<u16>. You can then call .as_ptr() on it to get a pointer to pass to winapi.
@bzm3r As for your ID3D10Blob question, you would call the GetBufferPointer and GetBufferSize methods to get the pointer and size, and pass them to std::slice::from_raw_parts to get a &[T].
If the blob is a unicode string you would get a &[u16] and pass it to OsStringExt::from_wide()
Barret Rennie
@brennie
Howdy. Is there an expected release date for the 0.38? I'd like to use the DISK_PERFORMANCE struct that was added recently.
Peter Atashian
@retep998
@brennie I am currently in the process of verifying I did not break backwards compatibility before I publish a new version.
Barret Rennie
@brennie
👍
MarkAnthonyM
@MarkAnthonyM
How exactly do I go about using the struct CHAR_INFO_Char? I'm trying to use it in conjunction with the struct CHAR_INFO but I'm not sure how to go about populating its private field.
MarkAnthonyM
@MarkAnthonyM
actually, scratch that. I think I found an example I can work off of
Peter Atashian
@retep998
@MarkAnthonyM Initialize CHAR_INFO with zeroed() or Default and then use the methods to access the union variant and assign the value you want
it'll be better in winapi 0.4 which will use actual unions
MarkAnthonyM
@MarkAnthonyM
Ah, I was just looking over the function of zeroed() in the rust docs when you sent this message. Many thanks!
Hilmar Gústafsson
@LiHRaM
Can anyone tell me why this code is failing on CoCreateInstance with a class not found error? https://github.com/LiHRaM/egpu-rs/blob/master/src/main.rs
the HRESULT specifically is: 0x80040154
Dan Kyung
@dank
How do I use ReadFile? More specifically, I'm wondering what types to pass into lpBuffer. let mut buffer_read: LPVOID = std::ptr::null_mut(); is the closest I got and that remains null.
Dan Kyung
@dank
let mut buffer_read = vec![0; 5]; worked ^
Mathieu Tarral
@Wenzel
hi !
small issue here, I can't figure out how to import tlhelp32
error[E0432]: unresolved import `winapi::um::tlhelp32`
import winapi::um works though
ok, i have to enable a feature to gain access to tlhelp32
matrixbot
@matrixbot
lihram Hey, does anyone know if winapi-rs has support for toast notifications, or how I might access them?
lihram This is the relevant windows documentation for C++
Lazy-256
@Lazy-256
Hi,
I am trying to use UIAutomation in my project.
I've found out only https://lib.rs/install/uiautomationcore-sys
But there is no documentation how to use it. Maybe anybody knows or there is better way? Thanks!
Michael
@rucoder_gitlab

Hello, I'm struggling with following problem:
I have a BITMAP declared like this

            let mut bmp: BITMAP = mem::uninitialized();

then I'm trying to call a GetObject

            GetObjectW(
                bitmap as HANDLE,
                mem::size_of::<BITMAP>() as i32,
                &mut bmp as * LPVOID,
            );

And I'm getting

error[E0606]: casting `&mut winapi::um::wingdi::BITMAP` as `*mut std::ffi::c_void` is invalid
   --> src\main.rs:118:17
    |
118 |                 &mut bmp as LPVOID,
    |                 ^^^^^^^^^^^^^^^^^^
I've tried different combinations of types in cast expression but still cannot find a correct one
Peter Atashian
@retep998
@rucoder_gitlab &mut bmp as *mut BITMAP as LPVOID
@rucoder_gitlab Alternatively <*mut _>::cast(&mut bmp)
Michael
@rucoder_gitlab
Thanks. I've figured out it already but the second alternative is unknown to me. I'm still learning Rust :)
as I understand the rule here is : "cast reference to the pointer of the same type and then reinterpret pointer with second 'as'"
Adriano Grieb
@griebd
hi there! it was probably asked a zillion times, but how do I get data back? I'm trying to get the returned value pvData and pcbData from a call to winapi::um::winreg::RegGetValueA... the function returns ERROR_SUCCESS if I set those both to std::ptr::null_mut(), so all other parameters are OK! I'm just stuck on how do declare those variables and converting then to and from... I'm new to rust!!!
Adriano Grieb
@griebd
ok, did it! the solution is always simpler than we think....
let mut pvData = vec![0; 2];
let lstatus = unsafe { RegGetValueA(HKEY_CURRENT_USER,
                                        hkey.as_ptr(),
                                        lpSubKey.as_ptr(),
                                        RRF_RT_REG_DWORD,
                                        std::ptr::null_mut(),
                                        pvData.as_mut_ptr() as *mut c_void,
                                        std::ptr::null_mut()
)};
println!("SUCCESS {:?}", pvData[0]);
this key always has value 0 or 1, or does not exist, so I know a vec with size 2 is precisely what I need...