summaryrefslogtreecommitdiff
path: root/crates/windows-kernel-rs/src/memory.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-01-03 14:27:39 -0800
committerFuwn <[email protected]>2022-01-03 14:27:39 -0800
commit057a8eeb023ce07e971e9ed98111a269df8049bb (patch)
tree50ee379be6d695ae7a788b3df8101f0f1a1207c2 /crates/windows-kernel-rs/src/memory.rs
parentfix(windows-kernel-rs): traits (diff)
downloaddriver-057a8eeb023ce07e971e9ed98111a269df8049bb.tar.xz
driver-057a8eeb023ce07e971e9ed98111a269df8049bb.zip
fix(windows-kernel-rs): impl Into to impl From
Diffstat (limited to 'crates/windows-kernel-rs/src/memory.rs')
-rw-r--r--crates/windows-kernel-rs/src/memory.rs48
1 files changed, 40 insertions, 8 deletions
diff --git a/crates/windows-kernel-rs/src/memory.rs b/crates/windows-kernel-rs/src/memory.rs
index cb5d2e9..d2ad77b 100644
--- a/crates/windows-kernel-rs/src/memory.rs
+++ b/crates/windows-kernel-rs/src/memory.rs
@@ -30,19 +30,33 @@ impl From<u64> for PhysicalAddress {
fn from(value: u64) -> Self { Self(value) }
}
-impl Into<u64> for PhysicalAddress {
- fn into(self) -> u64 { self.0 }
+// impl Into<u64> for PhysicalAddress {
+// fn into(self) -> u64 { self.0 }
+// }
+impl From<PhysicalAddress> for u64 {
+ fn from(p: PhysicalAddress) -> Self {
+ p.0
+ }
}
impl From<PHYSICAL_ADDRESS> for PhysicalAddress {
fn from(value: PHYSICAL_ADDRESS) -> Self { Self(unsafe { value.QuadPart } as _) }
}
-impl Into<PHYSICAL_ADDRESS> for PhysicalAddress {
- fn into(self) -> PHYSICAL_ADDRESS {
+// impl Into<PHYSICAL_ADDRESS> for PhysicalAddress {
+// fn into(self) -> PHYSICAL_ADDRESS {
+// let mut addr: PHYSICAL_ADDRESS = unsafe { core::mem::zeroed() };
+//
+// addr.QuadPart = self.0 as _;
+//
+// addr
+// }
+// }
+impl From<PhysicalAddress> for PHYSICAL_ADDRESS {
+ fn from(p: PhysicalAddress) -> Self {
let mut addr: PHYSICAL_ADDRESS = unsafe { core::mem::zeroed() };
- addr.QuadPart = self.0 as _;
+ addr.QuadPart = p.0 as _;
addr
}
@@ -57,11 +71,29 @@ pub enum CopyAddress {
unsafe impl Send for CopyAddress {}
unsafe impl Sync for CopyAddress {}
-impl Into<(u32, MM_COPY_ADDRESS)> for CopyAddress {
- fn into(self) -> (u32, MM_COPY_ADDRESS) {
+// impl Into<(u32, MM_COPY_ADDRESS)> for CopyAddress {
+// fn into(self) -> (u32, MM_COPY_ADDRESS) {
+// let mut copy_addr: MM_COPY_ADDRESS = unsafe { core::mem::zeroed() };
+//
+// let flags = match self {
+// CopyAddress::Virtual(addr) => {
+// copy_addr.__bindgen_anon_1.VirtualAddress = addr as _;
+// MM_COPY_MEMORY_VIRTUAL
+// }
+// CopyAddress::Physical(addr) => {
+// copy_addr.__bindgen_anon_1.PhysicalAddress = addr.into();
+// MM_COPY_MEMORY_PHYSICAL
+// }
+// };
+//
+// (flags, copy_addr)
+// }
+// }
+impl From<CopyAddress> for (u32, MM_COPY_ADDRESS) {
+ fn from(c: CopyAddress) -> Self {
let mut copy_addr: MM_COPY_ADDRESS = unsafe { core::mem::zeroed() };
- let flags = match self {
+ let flags = match c {
CopyAddress::Virtual(addr) => {
copy_addr.__bindgen_anon_1.VirtualAddress = addr as _;
MM_COPY_MEMORY_VIRTUAL