Newbie to RUST, looking for some advice


Hi forum,
I’m new to Rust and really like the approach behind it. I have never been so experienced in C/c++ that I could be sure that my programs will not just crash due to some memory problems and it seems that Rust solves a lot of my problems.
I’m just trying to implement my first little project under Windows and came to a general problem. I need to call in order to obtain the SID of a user. I just used cargo and became familiar with the concept of crates so that I should in principle be able to call into a Windows API. However, I’m lost with the translation of all the data types that the function expects.

BOOL WINAPI LookupAccountName(
In_opt LPCTSTR lpSystemName,
In LPCTSTR lpAccountName,
Out_opt PSID Sid,
Inout LPDWORD cbSid,
Out_opt LPTSTR ReferencedDomainName,
Inout LPDWORD cchReferencedDomainName,
I searched this forum and found Tidy pattern to work with LPSTR (mutable char array) but that does only seem to solve a small part of my problem. Is there anybody here able (and willing) to help me out with a working example as a starting point? Any help would be greatly appreciated.


Have a look at the WinAPI crate for examples.

While that specific function is not implemented there yet, the meaning is that it should contain all Windows API functions. So I’d recommend to directly implement it in that crate and then file a PR on github.


Hi troplin,
Thanks for the answer. I looked at the WinAPI crate before. As far as I understood it, it aims to provide a kind of wrapper around all WinAPI functions. However, as you mentioned, the function that I’m after is not yet implemented. And honestly, I think that implementing it there goes a little beyond my competence.


I’d rather say it’s easier, because that crate already provides all necessary types.
Have a look at:
You just have to insert the correct definition there.

If you need help, just ask.


I see your point. Maybe it’s really more easy to realize it there.
But here directly comes my first question:
Why ist the function listed in rather than under


Go to that link, scroll down to the “Requirements” table and you will see why :wink:


Hm, I spent some time to look thru the structure of the repository and it really seems to be that simple :slight_smile:
I added the functions that I need to
Is that all I need to do in order to use the functions via this crate? I would appreciate if you could have a short look before I open a Pull Request…


I suggest that you just try it out, that’s why you’re doing all this, no? :wink:
You should do that anyway before you open a PR.

You should probably adjust the formatting a bit to be consistent with the rest, i.e. indent the parameters and split the parameter list to multiple lines.
Otherwise it look good to me.
Not sure if you should also add it to ./tests/

But in case of doubt just go ahead, you can still make corrections afterward