Skip to content

Commit ed7fd35

Browse files
rabbitstackrabbitstack
and
rabbitstack
authored
chore(clr): Control CLR metadata parsing (#109)
A new option is provided to control whether the CLR metadata is parsed. By default, CLR metadata is parsed. Some users might not find it useful, and parsing this data is a waste of CPU cycles. Omitting CLR metadata can optimize PE parsing tasks. Co-authored-by: rabbitstack <[email protected]>
1 parent 17e5221 commit ed7fd35

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

dotnet.go

+4
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,10 @@ func (pe *File) parseCLRHeaderDirectory(rva, size uint32) error {
557557
// other structures fails later.
558558
pe.HasCLR = true
559559

560+
if pe.opts.OmitCLRMetadata {
561+
return nil
562+
}
563+
560564
offset = pe.GetOffsetFromRva(clrHeader.MetaData.VirtualAddress)
561565
mh, err := pe.parseMetadataHeader(offset, clrHeader.MetaData.Size)
562566
if err != nil {

file.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ package pe
66

77
import (
88
"errors"
9+
"github.com/edsrzf/mmap-go"
910
"os"
1011

11-
"github.com/edsrzf/mmap-go"
1212
"github.com/saferwall/pe/log"
1313
)
1414

@@ -112,6 +112,9 @@ type Options struct {
112112

113113
// OmitCLRHeaderDirectory determines if CLR header directory parsing is skipped, by default (false).
114114
OmitCLRHeaderDirectory bool
115+
116+
// OmitCLRMetadata determines if CLR metadata parsing is skipped, by default (false).
117+
OmitCLRMetadata bool
115118
}
116119

117120
// New instantiates a file instance with options given a file name.

0 commit comments

Comments
 (0)