Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
KiraCoding committed Sep 13, 2024
1 parent 36c4338 commit fb577de
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@ version = "0.58.0"
features = [
"Win32_System_LibraryLoader",
"Win32_System_SystemServices",
"Win32_System_Diagnostics_Debug",
"Win32_System_SystemInformation",
]
28 changes: 28 additions & 0 deletions src/header.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use crate::Base;
use core::slice::from_raw_parts;

#[derive(Debug)]
pub struct Header {
base: Base,
len: usize,
}

impl Header {
/// Returns a base pointer of this section.
#[inline]
pub fn base(&self) -> Base {
self.base
}

/// Returns the length of this section.
#[inline]
#[allow(clippy::len_without_is_empty)]
pub fn len(&self) -> usize {
self.len
}

#[inline]
pub fn as_slice(&self) -> &[u8] {
unsafe { from_raw_parts(self.base.as_nonnull().as_ptr(), self.len) }
}
}
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
//! # Inka
mod base;
mod header;
mod program;
mod section;

pub use base::Base;
pub use header::Header;
pub use program::{program, Program};
pub use section::Section;

pub type Name = &'static str;
4 changes: 2 additions & 2 deletions src/section.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::Base;
use crate::{Base, Name};
use core::ops::Index;
use core::ptr::NonNull;
use core::slice::{from_raw_parts, SliceIndex};
Expand All @@ -8,7 +8,7 @@ use rayon::slice::ParallelSlice;
/// Represents a `Section` of the program in memory, providing access to its name, base address, and length.
#[derive(Debug)]
pub struct Section {
name: &'static str,
name: Name,
base: Base,
len: usize,
}
Expand Down

0 comments on commit fb577de

Please sign in to comment.