Fixes issue #26, where DOS Stubs were being zeroed out incorrectly.

Thanks to kulinacs for the issue report!
This commit is contained in:
awgh
2023-04-18 20:54:12 -07:00
parent 9605c99179
commit febe44e596
+3 -3
View File
@@ -98,7 +98,7 @@ func newFileInternal(r io.ReaderAt, memoryMode bool) (*File, error) {
binary.Read(sr, binary.LittleEndian, &f.DosHeader)
dosHeaderSize := binary.Size(f.DosHeader)
if dosHeaderSize > int(f.DosHeader.AddressOfNewExeHeader) {
if dosHeaderSize < int(f.DosHeader.AddressOfNewExeHeader) {
binary.Read(sr, binary.LittleEndian, &f.DosStub)
f.DosExists = true
} else {
@@ -441,7 +441,7 @@ func (e *FormatError) Error() string {
return "unknown error"
}
//RVAToFileOffset Converts a Relative offset to the actual offset in the file.
// RVAToFileOffset Converts a Relative offset to the actual offset in the file.
func (f *File) RVAToFileOffset(rva uint32) uint32 {
var offset uint32
for _, section := range f.Sections {
@@ -452,7 +452,7 @@ func (f *File) RVAToFileOffset(rva uint32) uint32 {
return offset
}
//IsManaged returns true if the loaded PE file references the CLR header (aka is a .net exe)
// IsManaged returns true if the loaded PE file references the CLR header (aka is a .net exe)
func (f *File) IsManaged() bool {
switch v := f.OptionalHeader.(type) {
case *OptionalHeader32: