Image-ExifTool
view release on metacpan or search on metacpan
lib/Image/ExifTool/LNK.pm view on Meta::CPAN
DataPt => \$buff,
DataPos => $raf->Tell() - $len,
Size => $len,
);
}
# read string data
my @strings = qw(Description RelativePath WorkingDirectory
CommandLineArguments IconFileName);
for ($i=0; $i<@strings; ++$i) {
my ($val, $limit);
my $mask = 0x04 << $i;
next unless $flags & $mask;
$raf->Read($buff, 2) == 2 or $et->Warn("Invalid $strings[$i] string"), return 1;
my $pos = $raf->Tell();
$len = unpack('v', $buff) or next;
# Windows doesn't follow their own specification and limits the length
# for most of these strings (ref 3)
if ($i != 3 and $len >= 260) {
$limit = 1;
if ($len > 260) {
$len = 260;
$et->Warn('LNK string data overrun! Possible security issue');
}
}
# characters are 2 bytes if Unicode flag is set
$len *= 2 if $isUnicode;
$raf->Read($buff, $len) or $et->Warn("Truncated $strings[$i] string"), return 1;
# remove last character if string is at length limit (Windows treats this as a null)
if ($limit) {
$len -= $isUnicode ? 2 : 1;
$buff = substr($buff, 0, $len);
}
$val = $et->Decode($buff, 'UTF16') if $isUnicode;
$et->HandleTag($tagTablePtr, 0x30000 | $mask, $val,
DataPt => \$buff,
DataPos => $pos,
Size => $len,
);
}
# read extra data
while ($raf->Read($buff, 4) == 4) {
$len = unpack('V', $buff);
last if $len < 4;
$len -= 4;
$raf->Read($buf2, $len) == $len or $et->Warn('Truncated extra data'), last;
next unless $len > 4;
$buff .= $buf2;
my $tag = Get32u(\$buff, 4);
my $tagInfo = $$tagTablePtr{$tag};
unless (ref $tagInfo eq 'HASH' and $$tagInfo{SubDirectory}) {
$tagInfo = $$tagTablePtr{0xa0000000};
}
$et->HandleTag($tagTablePtr, $tag, undef,
DataPt => \$buff,
DataPos => $raf->Tell() - $len - 4,
TagInfo => $tagInfo,
);
}
# check for an overlay
my $pos = $raf->Tell();
$len = 0;
for (;;) {
$i = $raf->Read($buff, 65536);
last unless $i;
$len += $i;
$bad = 1 if not $bad and $buff =~ /[^\0]/;
}
if ($bad) {
$et->Warn(sprintf('Unknown %d-byte overlay at offset 0x%x', $len, $pos));
} elsif ($len) {
$et->Warn("$len bytes of null padding at end of file");
}
return 1;
}
1; # end
__END__
=head1 NAME
Image::ExifTool::LNK - Read MS Shell Link (.LNK) meta information
=head1 SYNOPSIS
This module is used by Image::ExifTool
=head1 DESCRIPTION
This module contains definitions required by Image::ExifTool to extract meta
information MS Shell Link (Windows shortcut) files.
=head1 AUTHOR
Copyright 2003-2026, Phil Harvey (philharvey66 at gmail.com)
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=head1 REFERENCES
=over 4
=item L<http://msdn.microsoft.com/en-us/library/dd871305(PROT.10).aspx>
=item L<http://www.i2s-lab.com/Papers/The_Windows_Shortcut_File_Format.pdf>
=item L<https://harfanglab.io/insidethelab/sadfuture-xdspy-latest-evolution/#tid_specifications_ignored>
=item L<https://github.com/libyal/libfwsi/blob/main/documentation/Windows%20Shell%20Item%20format.asciidoc>
=item L<https://github.com/EricZimmerman/Lnk/blob/master/Lnk/ShellItems/ShellBag0x00.cs>
=back
=head1 SEE ALSO
L<Image::ExifTool::TagNames/LNK Tags>,
L<Image::ExifTool(3pm)|Image::ExifTool>
=cut
( run in 2.921 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )