1
1
/// Parsing Options structure for the PE parser
2
+ #[ non_exhaustive]
2
3
#[ derive( Debug , Copy , Clone ) ]
3
4
pub struct ParseOptions {
4
5
/// Wether the parser should resolve rvas or not. Default: true
@@ -8,14 +9,35 @@ pub struct ParseOptions {
8
9
/// memory](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#other-contents-of-the-file).
9
10
/// For on-disk representations, leave as true. Default: true
10
11
pub parse_attribute_certificates : bool ,
12
+ /// Whether or not to end with an error in case of incorrect data or continue parsing if able. Default: ParseMode::Strict
13
+ pub parse_mode : ParseMode ,
11
14
}
12
15
13
- impl ParseOptions {
16
+ #[ derive( Debug , Copy , Clone ) ]
17
+ pub enum ParseMode {
18
+ /// Always end with error on incorrect data
19
+ Strict ,
20
+ /// Incorrect data will not cause to end with error if possible
21
+ Permissive ,
22
+ }
23
+
24
+ impl Default for ParseOptions {
14
25
/// Returns a parse options structure with default values
15
- pub fn default ( ) -> Self {
26
+ fn default ( ) -> Self {
16
27
ParseOptions {
17
28
resolve_rva : true ,
18
29
parse_attribute_certificates : true ,
30
+ parse_mode : ParseMode :: Strict ,
31
+ }
32
+ }
33
+ }
34
+
35
+ impl ParseOptions {
36
+ pub ( crate ) fn te ( ) -> Self {
37
+ Self {
38
+ resolve_rva : false ,
39
+ parse_attribute_certificates : false ,
40
+ parse_mode : ParseMode :: Strict ,
19
41
}
20
42
}
21
43
}
0 commit comments