feat: dos header的读取写完了。

This commit is contained in:
2024-12-08 21:28:50 +08:00
parent f8ec30acfc
commit f837e7cdaf
19 changed files with 1065 additions and 185 deletions

View File

@@ -11,5 +11,5 @@ pub enum PEParseError {
#[error("Invalid optional header size")]
InvalidOptionalSize,
#[error("解析超出了文件范围")]
OutOfBounds
}
OutOfBounds,
}

View File

@@ -1,6 +1,8 @@
use super::types::*;
use bitflags::bitflags;
use serde::Serialize;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct ImageDosHeader {
pub e_magic: u16, // Magic number 固定值 0x5A4D
pub e_cblp: u16,

View File

@@ -1,4 +1,4 @@
pub mod error;
pub mod header;
pub mod types;
pub mod pe;
pub mod error;
pub mod types;

View File

@@ -1,5 +1,5 @@
use std::ops::{Deref, DerefMut};
use super::{error::PEParseError, header::*};
use std::ops::{Deref, DerefMut};
pub trait PE: Deref<Target = [u8]> + DerefMut<Target = [u8]> + Sized {
/// Get a reference to a type at a given offset.

View File

@@ -1,4 +1,9 @@
#[repr(C)]
pub struct Offset(pub u32);
use serde::Serialize;
pub struct RVA(pub u32);
#[repr(C)]
#[derive(Debug, Clone, Copy, Serialize)]
pub struct Offset(pub u32);
#[repr(C)]
#[derive(Debug, Clone, Copy, Serialize)]
pub struct RVA(pub u32);