ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: Hank on July 24, 2020, 01:50:24 PM

Title: Bug Report - Microsoft DLL
Post by: Hank on July 24, 2020, 01:50:24 PM
The attached file comes from a Microsoft, however, Exiftool fails to read the file properly (VirusTotal however can read the file properly).
Thoughts?

System: Linux / Windows
Version(s): 10.58 (Linux) / 12.01 (Windows)
Command: Exiftool System.Reflection.Emit.dll
Output:      Error                           : File format error

Thank you

Title: Re: Bug Report - Microsoft DLL
Post by: Phil Harvey on July 25, 2020, 06:49:53 AM
Thanks for this report.  I'll look into it as soon as I get a chance.

- Phil
Title: Re: Bug Report - Microsoft DLL
Post by: Hank on September 30, 2020, 09:30:23 AM
Just to add to this mystery, or perhaps this is an Ah-Ha! moment (no Eureka's and running nude down the streets here, mainly cause locals frown upon that sort of thing).

I believe that these failing binaries have been built with Mono.
Title: Re: Bug Report - Microsoft DLL
Post by: Phil Harvey on September 30, 2020, 10:06:13 AM
Quote from: Hank on September 30, 2020, 09:30:23 AM
(no Eureka's and running nude down the streets here, mainly cause locals frown upon that sort of thing).

Here too.  Go figure.  Germany seems to be ahead of the curve with this. (https://www.nydailynews.com/news/world/ny-naked-german-fergal-hog-laptop-20200808-i6rrgjy6cbg3bjc7dnxxhcm7fa-story.html)

- Phil
Title: Re: Bug Report - Microsoft DLL
Post by: Phil Harvey on October 13, 2020, 08:33:13 AM
Sorry for the delay in responding.  The problem is that the file size reported in the header is invalid (ie. zero).  I'll patch ExifTool 12.08 to issue a warning instead of a format error for this, which will allow the file to be recognized.

- Phil
Title: Re: Bug Report - Microsoft DLL
Post by: Hank on October 13, 2020, 11:11:20 AM
No problems on the delay- actually thank you, because I have now started to hack in Perl and found the same thing:
The line :
return 0 if $fileSize < 0x40;
in EXE.pm is where I found the issue.
I will continue to play with the code and see if I can get the rest of the information to be revealed.
Which brings up an interesting question:
How do you accept submissions?
Title: Re: Bug Report - Microsoft DLL
Post by: Hank on October 13, 2020, 01:16:59 PM
And the other patch to the code:

Module EXE.pm

#------------------------------------------------------------------------------
# Process Windows PE file data dictionary
# Inputs: 0) ExifTool object ref, 1) dirInfo ref
# Returns: true on success
sub ProcessPEDict($$)
{
    my ($et, $dirInfo) = @_;
    my $raf = $$dirInfo{RAF};
    my $dataPt = $$dirInfo{DataPt};
    my $dirLen = length($$dataPt);
    my ($pos, @sections, %dirInfo);
my $rsrcfound = "false";
my $name = "";

# Hack Hack Hack 
# Need to know if we have both .rsrc and .text
# if both or only .rsrc, then only look at .rsrc
# else look at .text
    for ($pos=0; $pos+40<=$dirLen; $pos+=40) {
        $name = substr($$dataPt, $pos, 8);
if ($name eq ".rsrc\0\0\0") {
$rsrcfound = "true";
}
}

    # loop through all sections
    for ($pos=0; $pos+40<=$dirLen; $pos+=40) {
        $name = substr($$dataPt, $pos, 8);
        my $va = Get32u($dataPt, $pos + 12);
        my $size = Get32u($dataPt, $pos + 16);
        my $offset = Get32u($dataPt, $pos + 20);
        # remember the section offsets for the VirtualAddress lookup later
        push @sections, { Base => $offset, Size => $size, VirtualAddress => $va };
        # save details of the first resource section
        %dirInfo = (
            RAF      => $raf,
            Base     => $offset,
            DirStart => 0,   # (relative to Base)
            DirLen   => $size,
            Sections => \@sections,
        ) if ($name eq ".rsrc\0\0\0" and not %dirInfo) or ($name eq ".text\0\0\0" and $rsrcfound eq "false" and not %dirInfo);
    }
    # process the first resource section
    ProcessPEResources($et, \%dirInfo) or return 0 if %dirInfo;

    return 1;
}


Title: Re: Bug Report - Microsoft DLL
Post by: Phil Harvey on October 13, 2020, 01:32:11 PM
Interesting.  Can you send me a sample which doesn't contain the rsrc so I can test this?  My email is philharvey66 at gmail.com

Thanks.

- Phil
Title: Re: Bug Report - Microsoft DLL
Post by: Hank on October 13, 2020, 01:42:21 PM
The file attached to my bug report is one such.
Title: Re: Bug Report - Microsoft DLL
Post by: Phil Harvey on October 13, 2020, 01:52:38 PM
Thanks.

- Phil
Title: Re: Bug Report - Microsoft DLL
Post by: Hank on October 15, 2020, 12:42:53 PM
I see that a patch has been applied (and far more elegant than my solution).
Thanks!
Title: Re: Bug Report - Microsoft DLL
Post by: Phil Harvey on October 15, 2020, 02:40:29 PM
Yes.  And thank you!

But I forgot to add a comment in the version history (https://exiftool.org/history.html).  Done now.

- Phil