summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl.straw/lib/Win32/Exe/ResourceEntry.pm
blob: a44a65daf3d51ebb6c70f13074e60b7ebfe52797 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# $File: //local/member/autrijus/Win32-Exe/lib/Win32/Exe/ResourceEntry.pm $ $Author: autrijus $
# $Revision: #7 $ $Change: 1130 $ $Date: 2004-02-17T15:40:29.640821Z $

package Win32::Exe::ResourceEntry;

use strict;
use base 'Win32::Exe::Base';
use constant FORMAT => (
    Data	    => 'V',
    E_RVA	    => 'V',
);
use constant HIGH_BIT => 0x80_00_00_00;
use Win32::Exe::ResourceData;

sub high_bit {
    my ($self) = @_;
    return +HIGH_BIT;
}

sub path {
    my ($self) = @_;
    return $self->parent->path;
}

sub PathName {
    my ($self) = @_;
    return join('/', '', $self->path, $self->Name);
}

sub VirtualAddress {
    my ($self) = @_;
    $self->E_RVA & ~($self->high_bit);
}

sub SetVirtualAddress {
    my ($self, $data) = @_;
    $self->SetE_RVA($data | $self->IsDirectory);
}

sub IsDirectory {
    my ($self) = @_;
    $self->E_RVA & ($self->high_bit);
}

sub initialize {
    my ($self) = @_;
    my $section = $self->first_parent('Resources');
    my $data = $section->substr($self->VirtualAddress, 12);
    my $res_data = Win32::Exe::ResourceData->new(\$data, { parent => $self });
    $res_data->initialize;
    $self->{res_data} = $res_data;
}

sub Data {
    my ($self) = @_;
    return $self->{res_data}->Data;
}

sub CodePage {
    my ($self) = @_;
    return $self->{res_data}->CodePage;
}

sub object {
    my ($self) = @_;
    return $self->{res_data}->object;
}

1;