aboutsummaryrefslogtreecommitdiff
path: root/src/basedef.rs
diff options
context:
space:
mode:
authorpravic <[email protected]>2016-04-28 23:29:31 +0300
committerpravic <[email protected]>2016-04-28 23:29:31 +0300
commit60f48d27f3d0a87020e6b196d7d4a99f1eebd6ed (patch)
treec321204059c13b68ba76dd444afd15a439ea3add /src/basedef.rs
parentsmall updates for samples (diff)
downloadwinapi-kmd-rs-60f48d27f3d0a87020e6b196d7d4a99f1eebd6ed.tar.xz
winapi-kmd-rs-60f48d27f3d0a87020e6b196d7d4a99f1eebd6ed.zip
km updates for Winsock network drivers WIP
Diffstat (limited to 'src/basedef.rs')
-rw-r--r--src/basedef.rs76
1 files changed, 73 insertions, 3 deletions
diff --git a/src/basedef.rs b/src/basedef.rs
index fb8dfbb..d8e779b 100644
--- a/src/basedef.rs
+++ b/src/basedef.rs
@@ -16,12 +16,32 @@ pub enum km_void {
__variant2,
}
+pub type CHAR = i8;
+pub type CCHAR = i8;
+pub type USHORT = u16;
+pub type CSHORT = i16;
+pub type ULONG = u32;
+
pub type VOID = km_void;
pub type PVOID = *mut VOID;
pub type PCVOID = *const VOID;
+pub type SIZE_T = usize;
+
+pub type ULONG_PTR = usize;
+pub type PEPROCESS = PVOID;
pub type PETHREAD = PVOID;
+pub type PSECURITY_DESCRIPTOR = PVOID;
+
+pub type PGUID = PVOID;
+pub type PCGUID = PCVOID;
+
+pub type PSTR = *mut u8;
+pub type PWSTR = *mut u16;
+pub type PCSTR = *const u8;
+pub type PCWSTR = *const u16;
+
pub type PIO_APC_ROUTINE = Option<extern "system" fn (ApcContext: PCVOID, IoStatusBlock: *const IO_STATUS_BLOCK, Reserved: u32)>;
@@ -29,11 +49,8 @@ extern "system"
{
pub fn KeGetCurrentIrql() -> KIRQL;
pub fn KeRaiseIrqlToDpcLevel() -> KIRQL;
- pub fn KfLowerIrql(NewIrql: KIRQL) -> KIRQL;
- pub fn KfRaiseIrql(NewIrql: KIRQL) -> KIRQL;
}
-
/// Doubly linked list structure.
#[repr(C)]
pub struct LIST_ENTRY
@@ -44,6 +61,7 @@ pub struct LIST_ENTRY
/// Spin Lock.
#[repr(C)]
+#[derive(Default)]
pub struct KSPIN_LOCK
{
pub lock: usize,
@@ -63,14 +81,29 @@ pub struct DISPATCHER_HEADER
/// An I/O status block.
#[repr(C)]
+#[derive(Default, Clone, Copy)]
pub struct IO_STATUS_BLOCK
{
+ /// Completion status.
pub Status: ::NTSTATUS,
+ /// Request-dependent value.
pub Information: usize,
}
pub type PIO_STATUS_BLOCK = *mut IO_STATUS_BLOCK;
+impl IO_STATUS_BLOCK {
+ /// Return integer value for `Information` field.
+ pub fn as_size(&self) -> usize {
+ self.Information
+ }
+
+ /// Return the pointer of specified object type.
+ pub fn as_ptr<T>(&self) -> *const T {
+ unsafe { ::core::mem::transmute(self.Information) }
+ }
+}
+
/// Processor modes.
#[repr(u8)]
@@ -90,3 +123,40 @@ pub mod IO_PRIORITY {
pub const IO_DISK_INCREMENT: KPRIORITY_BOOST = 1;
pub const EVENT_INCREMENT: KPRIORITY_BOOST = 1;
}
+
+pub type KPRIORITY = IO_PRIORITY::KPRIORITY_BOOST;
+
+/// Memory Descriptor List (MDL)
+#[repr(C)]
+pub struct MDL
+{
+ Next: *mut MDL,
+ Size: i16,
+ MdlFlags: i16,
+ Process: PEPROCESS,
+ MappedSystemVa: PVOID,
+ StartVa: PVOID,
+ ByteCount: u32,
+ ByteOffset: u32,
+}
+
+pub type PMDL = *mut MDL;
+
+#[repr(i16)]
+pub enum MDL_FLAGS {
+ MDL_MAPPED_TO_SYSTEM_VA = 0x0001,
+ MDL_PAGES_LOCKED = 0x0002,
+ MDL_SOURCE_IS_NONPAGED_POOL = 0x0004,
+ MDL_ALLOCATED_FIXED_SIZE = 0x0008,
+ MDL_PARTIAL = 0x0010,
+ MDL_PARTIAL_HAS_BEEN_MAPPED = 0x0020,
+ MDL_IO_PAGE_READ = 0x0040,
+ MDL_WRITE_OPERATION = 0x0080,
+ MDL_PARENT_MAPPED_SYSTEM_VA = 0x0100,
+ MDL_LOCK_HELD = 0x0200,
+ MDL_SCATTER_GATHER_VA = 0x0400,
+ MDL_IO_SPACE = 0x0800,
+ MDL_NETWORK_HEADER = 0x1000,
+ MDL_MAPPING_CAN_FAIL = 0x2000,
+ MDL_ALLOCATED_MUST_SUCCEED = 0x4000,
+}