Skip to content

Commit

Permalink
read/pe: add ResourceName::raw_data method (gimli-rs#487)
Browse files Browse the repository at this point in the history
Gives access to the raw bytes of the name string, instead of a u16
slice.
  • Loading branch information
vthib authored Nov 20, 2022
1 parent f691ba1 commit e97a305
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/read/pe/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ impl ResourceName {
.read_slice::<U16Bytes<LE>>(&mut offset, len.get(LE).into())
.read_error("Invalid resource name length")
}

/// Returns the string buffer as raw bytes.
pub fn raw_data<'data>(&self, directory: ResourceDirectory<'data>) -> Result<&'data [u8]> {
self.data(directory).map(crate::pod::bytes_of_slice)
}
}

/// A resource name or ID.
Expand Down

0 comments on commit e97a305

Please sign in to comment.