Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
François Dubois
@francoisduboisx_twitter
what I tried is :
let mut username = OsStr::new("fdubois").encode_wide().chain(Some(0).intoiter()).collect::<Vec<>>();
let mut domain = OsStr::new(".").encode_wide().chain(Some(0).intoiter()).collect::<Vec<>>();
let mut password = OsStr::new("1234").encode_wide().chain(Some(0).intoiter()).collect::<Vec<>>();
let handle:i32 = 0;
unsafe {
    let result = LogonUserW(username.as_mut_ptr(),
               domain.as_mut_ptr(),
               password.as_mut_ptr(),
               0,
                0,
                handle as *mut *mut c_void
                );

    println!("{}", result);
}
I don't know how to build the handle
I tried with c_void because I saw that PHANDLE is defined as mut HANDLE and HANDLE is defined as mut c_void
Peter Atashian
@retep998
@francoisduboisx_twitter let mut token = std::ptr::null_mut(); LogonUserW(..., &mut token); and now token holds your HANDLE
François Dubois
@francoisduboisx_twitter
@retep998 Thank you very much. But null_mut() is not NULL ? The token has to be allocated in rust. I guess it allocates a pointer with 0 in it and this is what we want here.
Awesome, seems to work, thank you very much
Peter Atashian
@retep998
NULL is useless in Rust because Rust doesn't have implicit pointer coercions.
Whereas null_mut() is a generic function that will return a null pointer of any type you desire
François Dubois
@francoisduboisx_twitter
awesome. One more question : All constant like LOGON32_PROVIDER_DEFAULT, where should it be defined ?
François Dubois
@francoisduboisx_twitter
Ok, I think I found, um/winnt contains all constants
I should add constant for logonuser, thanks
François Dubois
@francoisduboisx_twitter
@retep998 What should I do for the compilation condition :
//#if(_WIN32_WINNT >= 0x0500)
pub const LOGON32_LOGON_NETWORK_CLEARTEXT: ULONG = 8;
pub const LOGON32_LOGON_NEW_CREDENTIALS: ULONG = 9;
//#endif // (_WIN32_WINNT >= 0x0500)
I guess it is not a problem to always define those constant and remove the compilation condition ?
Peter Atashian
@retep998
@francoisduboisx_twitter Constants should be defined in the module corresponding to the header they are from. In the case of LOGON32_PROVIDER_DEFAULT it is defined in um/winbase.h
and those _WIN32_WINNT conditionals can basically be ignored because winapi does not support restricting the API for older versions
Bruno Bigras
@bbigras
How can I figure the UUID of a CLSID thing? I would like to add CLSID_ADSystemInfo.
Peter Atashian
@retep998
@bbigras
class DECLSPEC_UUID("50B6327F-AFD1-11d2-9CB9-0000F87A369E")
ADSystemInfo;
That's a quote from the header itself, and is how you would find the uuid for a class
Defcronyke
@defcronyke
Hi, I am on Windows and trying to run cargo doc --open on a project which uses rand (which pulls in winapi), but when I try the command, it tries to document winapi, and building it fails with thousands of errors about unused variables and such. What am I doing wrong?
it is just the guessing game project from the rust book
I am using rust-nightly
endeav0r
@endeav0r
I’m just getting started with winapi-rs. Any idea why I can’t use winapi::um::minwinbase::SECURITY_ATTRIBUTES:
error[E0432]: unresolved import `winapi::um::minwinbase`                                                                        
 --> src/main.rs:4:17                                                                                                           
  |                                                                                                                             
4 | use winapi::um::minwinbase::SECURITY_ATTRIBUTES;                                                                            
  |                 ^^^^^^^^^^ Could not find `minwinbase` in `um`
endeav0r
@endeav0r
well, ok, figured that out
endeav0r
@endeav0r
Now I’m trying to pass a DEBUG_EVENT to WaitForDebugEvent .
In order to do this, I need to create a DEBUG_EVENT, but because DEBUG_EVENT.DEBUG_EVENT_u doesn’t have anyway to create it, I can’t create a DEBUG_EVENT, and so I can’t create an empty argument to pass to WaitForDebugEvent.
I’m a little stuck on this one
Mykhailo Osypov
@mosyp
Hello guys, how one would create an instance of winapi::um::synchapi::OVERLAPPED_u?
this one is not working:
50 |         let u = OVERLAPPED_u([0, 0]);
   |                 ^^^^^^^^^^^^ constructor is not visible here due to private fields
Mykhailo Osypov
@mosyp
ah, union macro does not include pub in ints constuctor, prepared a pr retep998/winapi-rs#672
@retep998 Is there any chance it will bve merged and released? The workaround is only to provide custom fn/strcut externs for the whole call tree
Daniel Hines
@d4hines
Hello all. I'm a JS dev looking to do some deeper Win32 integration from NodeJS, so I'm evaluating options. How active/widely used is winapi-rs?
Peter Atashian
@retep998
@d4hines winapi is very widely used, and is generally the only option anyways
basically anything in the rust ecosystem that needs to talk to windows api uses winapi
@woodgear
hi guys,we need your help
we currently use rust write windows driver and has deploy it to product env.
we add some km binding of winapi
is a brief example how we do.
cargo xbuild + custom target + km binding of winapi.
i afraid of request a PR cause we juse use it in our company. but of couse we want to make it merge into winapi.
@woodgear
we use rust-bindgen to transform ddk header file to rust and edit it manual to pick up function or struct what we used.
how you guys think?
@retep998
Peter Atashian
@retep998
@woodgear I do want to have bindings to kernel mode stuff, however actually linking to kernel mode specific stuff is a very hairy problem right now
types and constants can be provided just fine though
@woodgear
why? what the difference?
@woodgear
what the problem is? maybe be we could fix that
Peter Atashian
@retep998
@woodgear I'd need Rust to officially bless certain targets for windows kernel mode, so I can detect them and link to different things for them.
@woodgear
en,maybe a branch like feature/km? we could not do nothing but just wait for rust officially .
i will open a pr to push rust add windows kernel mode target (by the way where should i go? rust/rustup?)