File tree Expand file tree Collapse file tree 3 files changed +6
-7
lines changed Expand file tree Collapse file tree 3 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -191,8 +191,8 @@ pub struct Header {
191
191
impl Header {
192
192
// Read a kernel header from the first two sectors of a file
193
193
pub fn from_file ( f : & mut dyn Read ) -> Result < Self , Error > {
194
- let mut data: [ u8 ; 1024 ] = [ 0 ; 1024 ] ;
195
- let mut region = MemoryRegion :: from_bytes ( & mut data) ;
194
+ let data: [ u8 ; 1024 ] = [ 0 ; 1024 ] ;
195
+ let mut region = MemoryRegion :: from_bytes ( & data) ;
196
196
197
197
f. seek ( 0 ) ?;
198
198
f. load_file ( & mut region) ?;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ impl MemoryRegion {
16
16
}
17
17
18
18
/// Take a slice and turn it into a region of memory
19
- pub fn from_bytes ( data : & mut [ u8 ] ) -> MemoryRegion {
19
+ pub fn from_bytes ( data : & [ u8 ] ) -> MemoryRegion {
20
20
MemoryRegion {
21
21
base : data. as_ptr ( ) as u64 ,
22
22
length : data. len ( ) as u64 ,
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ impl<'a> Loader<'a> {
78
78
return Err ( Error :: FileError ) ;
79
79
}
80
80
81
- let dos_region = MemoryRegion :: from_bytes ( & mut data) ;
81
+ let dos_region = MemoryRegion :: from_bytes ( & data) ;
82
82
83
83
// 'MZ' magic
84
84
if dos_region. read_u16 ( 0 ) != 0x5a4d {
@@ -92,7 +92,7 @@ impl<'a> Loader<'a> {
92
92
return Err ( Error :: InvalidExecutable ) ;
93
93
}
94
94
95
- let pe_region = MemoryRegion :: from_bytes ( & mut data[ pe_header_offset as usize ..] ) ;
95
+ let pe_region = MemoryRegion :: from_bytes ( & data[ pe_header_offset as usize ..] ) ;
96
96
97
97
// The Microsoft specification uses offsets relative to the COFF area
98
98
// which is 4 after the signature (so all offsets are +4 relative to the spec)
@@ -109,8 +109,7 @@ impl<'a> Loader<'a> {
109
109
self . num_sections = pe_region. read_u16 ( 6 ) ;
110
110
111
111
let optional_header_size = pe_region. read_u16 ( 20 ) ;
112
- let optional_region =
113
- MemoryRegion :: from_bytes ( & mut data[ ( 24 + pe_header_offset) as usize ..] ) ;
112
+ let optional_region = MemoryRegion :: from_bytes ( & data[ ( 24 + pe_header_offset) as usize ..] ) ;
114
113
115
114
if optional_region. read_u16 ( 0 ) != Self :: OPTIONAL_HEADER_MAGIC {
116
115
return Err ( Error :: InvalidExecutable ) ;
You can’t perform that action at this time.
0 commit comments