-
-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finish porting advapi32 to v0.3 #447
Conversation
Unused macros? Is this a CI issue or did I break something? I tried building each of the features that I added or modified with Rust stable and I don't get any errors. |
It's a new nightly lint that got caught in |
@austinwagner That issue is being addressed in #446. |
@austinwagner Your header import declarations in |
Yes it's clear why it's failing this time. 🙂 Apparently I'm not good at quickly eyeballing alphabetical order. I'm going to fix it as soon as I get home from work. The error message shows me all of the build.rs sorting problems, but is there a way to quickly sort the imports in the other files? I haven't tried rustfmt because I don't know if it will keep the rest of the file formatted the way that our Benevolent Bunny likes. |
I believe the only errors are in |
Is using the |
|
No I did not know. My search for intrinsics led me to a page that said they will likely never make it to stable. "...they should be used through stabilized interfaces in the rest of the standard library" makes it sound like you can't access the intrinsics on stable when |
|
@austinwagner Needs rebasing now that #448 was merged. |
@Susurrus Is rebasing the right approach or should I just merge again like I did for smaller conflicts? I've never contributed to a large, popular repo so I don't know what's considered best practice. |
I always rebase rather than merge as if bisecting ever needs to be done, it's easier with less merge nodes. I also find it easier to review PRs that don't have a ton of extraneous "merge ..." nodes. |
I also rebase and squash/edit commits to get rid of all of those small "fix ..." commits (like you have in this commit). The way I look at my commits is that they should always result in a compilable source tree. That's not always possible, but I strive for it. So merging smaller fix commits into the original commit that broke thing before merging is nice. |
You answered my next question before I got to ask it 😃 I'll take care of this as soon as I'm able so the PR can be nice and clean! I do have one more question for now: was splitting up the commits by header a good approach? I specifically used hunk staging to isolate each one even though I didn't actually start making commits until I finished the porting. |
You have some commits which are actually rebased versions of commits by @Susurrus which makes it a lot harder to review this PR. Once those commits are rebased away so this PR is just your commits, I'll be able to review it. |
@austinwagner Re the single-header commits, I haven't seen @retep998 complain about it yet, but it at least makes it easy for me to review and check that I have all the necessary changes for a single header/family of headers to be enabled. |
5108a82
to
c5e9b05
Compare
All cleaned up with a rebase |
timezoneapi's functions are in |
src/shared/evntrace.rs
Outdated
LoggerNameOffset: ULONG, | ||
}} | ||
pub type PEVENT_TRACE_PROPERTIES = *mut EVENT_TRACE_PROPERTIES; | ||
// TODO: The single item structs are defined with the ":" bitfield syntax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this TODO still need to be resolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh it looks like I simply forgot to remove the comment after I found the macro to handle bitfields.
src/shared/evntprov.rs
Outdated
} | ||
#[inline(always)] | ||
pub unsafe fn EventDescCreate( | ||
EventDescriptor: PEVENT_DESCRIPTOR, Id: USHORT, Version: UCHAR, Channel: UCHAR, Level: UCHAR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These arguments all need to be on different lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This applies to the following function declarations as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize that style applied to function definitions. Thought it was only for the declarations. I'll go through all the files and validate that I don't have the same issue elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@retep998 Looking at some existing #[inline]
functions, if everything up to and including the open curly bracket fits within the 99 character limit then the parameters should all stay on a single line, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For function definitions (functions with bodies), if the function signature fits within a single line then it can stay on one line but it's not required. If it isn't a single line, then it should follow the same one parameter per line that all other definitions follow.
However, you shouldn't be using #[inline(always)]
. Function definitions should always use #[inline]
.
StringSecurityDescriptor: *mut LPWSTR, | ||
StringSecurityDescriptorLen: PULONG, | ||
) -> BOOL; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget end of file newlines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Github ignore EOF newlines? It was missing before, but it's definitely there now. Checked the file directly downloaded from Github in a hex editor to make sure I wasn't going crazy.
src/shared/wmistr.rs
Outdated
#[cfg(target_arch = "x86_64")] | ||
const __SIZE_OF_WMIREGGUIDW_u: usize = 8; | ||
UNION2!{union WMIREGGUIDW_u { | ||
[u8; __SIZE_OF_WMIREGGUIDW_u], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recently added support for UNION2
to have two storages specified, one for 32bit and one for 64bit. Also, an array of u8
is usually the wrong thing because the union needs to have the correct alignment (otherwise when placed inside a struct it could have the wrong position resulting in issues like #452).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you determine which to use then? I just got the sizes by looking at the output of sizeof()
in C++ for both 32 and 64 bit builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
char const * type_for_alignment(uintptr_t align) {
switch (align) {
case 1: return "u8";
case 2: return "u16";
case 4: return "u32";
case 8: return "u64";
}
throw;
}
#define PRINT_UNION(x) cout << "[" << type_for_alignment(alignof(x)) << "; " << sizeof(x) / alignof(x) << "]" << endl;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's handy! I think it makes sense to add this block of code and the new UNION2
style to CONTRIBUTING.md
. The rules regarding function definition styles and EOF newlines should probably also be there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@austinwagner UNION2
is already documented. I just updated #456 about the other things discussed her excluding this example code. I'll add this alignment example to UNION2
however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, you're right that the dual-alignment UNION2
isn't documented. I'm doing that now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@austinwagner Does my latest commit for #456 make things clear?
c5e9b05
to
c4f2cdb
Compare
@austinwagner This needs to be updated with the recent merge of #454. |
c4f2cdb
to
19ff1a0
Compare
Fixes: - Add namedpipeapi to Cargo.toml - Typo correction in namedpipeapi header
3139b95
to
80ce6ee
Compare
PR currently failing CI. |
* Mark timezoneapi as dependent on advapi32.dll * Add advapi32 functions to winsvc * Add accctrl in preparation for aclapi * Add aclapi * Add ImpersonateNamedPipeClient to namedpipeapi Fixes: - Add namedpipeapi to Cargo.toml - Typo correction in namedpipeapi header * Add advapi32 functions to lsalookup * Add winefs * Add advapi32 functions to wincred * Add wct * Add advapi32 functions to securitybaseapi * Add advapi32 functions to processthreadsapi * Add advapi32 functions to ntsecapi * Add evntprov * Add wmistr * Add evntrace and evntcons * Add sddl * Add appmgmt * Add ntlsa * Add mschapp * Add perflib * Add winsafer * Fix securitybaseapi imports
Used @Susurrus's fork as a base.
All functions exported by advapi32 that can be found in the SDK headers* have been added to their corresponding Rust files with the exception of SetServiceBits (um/LMServer.h). If a Rust version of a header already existed then only the required pieces were added to the file. If the Rust file didn't exist already the full header was ported to the extent I was able to.
*139 functions are exported from the DLL but have no declaration in any header in the latest Windows SDK.