-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Remove wrapper functions from c.rs #128092
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
use crate::ffi::CStr; | ||
use crate::mem; | ||
use crate::os::raw::{c_uint, c_ulong, c_ushort, c_void}; | ||
use crate::os::windows::io::{AsRawHandle, BorrowedHandle}; | ||
use crate::ptr; | ||
|
||
pub(super) mod windows_targets; | ||
|
@@ -114,89 +113,6 @@ if #[cfg(not(target_vendor = "uwp"))] { | |
} | ||
} | ||
|
||
pub unsafe extern "system" fn WriteFileEx( | ||
hFile: BorrowedHandle<'_>, | ||
lpBuffer: *mut ::core::ffi::c_void, | ||
nNumberOfBytesToWrite: u32, | ||
lpOverlapped: *mut OVERLAPPED, | ||
lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE, | ||
) -> BOOL { | ||
windows_sys::WriteFileEx( | ||
hFile.as_raw_handle(), | ||
lpBuffer.cast::<u8>(), | ||
nNumberOfBytesToWrite, | ||
lpOverlapped, | ||
lpCompletionRoutine, | ||
) | ||
} | ||
|
||
pub unsafe extern "system" fn ReadFileEx( | ||
hFile: BorrowedHandle<'_>, | ||
lpBuffer: *mut ::core::ffi::c_void, | ||
nNumberOfBytesToRead: u32, | ||
lpOverlapped: *mut OVERLAPPED, | ||
lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE, | ||
) -> BOOL { | ||
windows_sys::ReadFileEx( | ||
hFile.as_raw_handle(), | ||
lpBuffer.cast::<u8>(), | ||
nNumberOfBytesToRead, | ||
lpOverlapped, | ||
lpCompletionRoutine, | ||
) | ||
} | ||
|
||
cfg_if::cfg_if! { | ||
if #[cfg(not(target_vendor = "uwp"))] { | ||
pub unsafe fn NtReadFile( | ||
filehandle: BorrowedHandle<'_>, | ||
event: HANDLE, | ||
apcroutine: PIO_APC_ROUTINE, | ||
apccontext: *mut c_void, | ||
iostatusblock: &mut IO_STATUS_BLOCK, | ||
buffer: *mut crate::mem::MaybeUninit<u8>, | ||
length: u32, | ||
byteoffset: Option<&i64>, | ||
key: Option<&u32>, | ||
) -> NTSTATUS { | ||
windows_sys::NtReadFile( | ||
filehandle.as_raw_handle(), | ||
event, | ||
apcroutine, | ||
apccontext, | ||
iostatusblock, | ||
buffer.cast::<c_void>(), | ||
length, | ||
byteoffset.map(|o| o as *const i64).unwrap_or(ptr::null()), | ||
key.map(|k| k as *const u32).unwrap_or(ptr::null()), | ||
) | ||
} | ||
pub unsafe fn NtWriteFile( | ||
filehandle: BorrowedHandle<'_>, | ||
event: HANDLE, | ||
apcroutine: PIO_APC_ROUTINE, | ||
apccontext: *mut c_void, | ||
iostatusblock: &mut IO_STATUS_BLOCK, | ||
buffer: *const u8, | ||
length: u32, | ||
byteoffset: Option<&i64>, | ||
key: Option<&u32>, | ||
) -> NTSTATUS { | ||
windows_sys::NtWriteFile( | ||
filehandle.as_raw_handle(), | ||
event, | ||
apcroutine, | ||
apccontext, | ||
iostatusblock, | ||
buffer.cast::<c_void>(), | ||
length, | ||
byteoffset.map(|o| o as *const i64).unwrap_or(ptr::null()), | ||
key.map(|k| k as *const u32).unwrap_or(ptr::null()), | ||
) | ||
} | ||
} | ||
} | ||
|
||
// Use raw-dylib to import ProcessPrng as we can't rely on there being an import library. | ||
cfg_if::cfg_if! { | ||
if #[cfg(not(target_vendor = "win7"))] { | ||
|
@@ -331,29 +247,29 @@ compat_fn_with_fallback! { | |
} | ||
#[cfg(target_vendor = "uwp")] | ||
pub fn NtReadFile( | ||
filehandle: BorrowedHandle<'_>, | ||
filehandle: HANDLE, | ||
event: HANDLE, | ||
apcroutine: PIO_APC_ROUTINE, | ||
apccontext: *mut c_void, | ||
iostatusblock: &mut IO_STATUS_BLOCK, | ||
buffer: *mut crate::mem::MaybeUninit<u8>, | ||
apccontext: *const core::ffi::c_void, | ||
iostatusblock: *mut IO_STATUS_BLOCK, | ||
buffer: *mut core::ffi::c_void, | ||
length: u32, | ||
byteoffset: Option<&i64>, | ||
key: Option<&u32> | ||
Comment on lines
-341
to
-342
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these lifetimes would have been very useful if the thing we returned also had a lifetime... unfortunately... |
||
byteoffset: *const i64, | ||
key: *const u32 | ||
) -> NTSTATUS { | ||
STATUS_NOT_IMPLEMENTED | ||
} | ||
#[cfg(target_vendor = "uwp")] | ||
pub fn NtWriteFile( | ||
filehandle: BorrowedHandle<'_>, | ||
filehandle: HANDLE, | ||
event: HANDLE, | ||
apcroutine: PIO_APC_ROUTINE, | ||
apccontext: *mut c_void, | ||
iostatusblock: &mut IO_STATUS_BLOCK, | ||
buffer: *const u8, | ||
apccontext: *const core::ffi::c_void, | ||
iostatusblock: *mut IO_STATUS_BLOCK, | ||
buffer: *const core::ffi::c_void, | ||
length: u32, | ||
byteoffset: Option<&i64>, | ||
key: Option<&u32> | ||
byteoffset: *const i64, | ||
key: *const u32 | ||
) -> NTSTATUS { | ||
STATUS_NOT_IMPLEMENTED | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we add
core::ffi
to the module imports here?