-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathRT74578.patch
66 lines (62 loc) · 2.47 KB
/
RT74578.patch
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
--- Struct.pm Sun Feb 12 06:39:26 2012
+++ Struct.pm Mon Feb 13 12:22:16 2012
@@ -212,9 +212,10 @@
$packed_size += $subpacksize;
}
else {
+ my $repeat = 1;
if ($type =~ /\w\*(\d+)/) {
- my $size = $1;
- $type = "a$size";
+ $repeat = $1;
+ $type = "a$repeat";
}
DEBUG "(PM)Struct::getPack($self->{__typedef__}) ++ $type\n";
@@ -230,7 +231,7 @@
$type_size = Win32::API::Type::sizeof($orig);
$type_align = (($packed_size + $type_size) % $type_size);
$packing .= "x" x $type_align . $type;
- $packed_size += $type_size + $type_align;
+ $packed_size += ( $type_size * $repeat ) + $type_align;
}
}
@@ -267,7 +268,7 @@
foreach my $member (@{$self->{typedef}}) {
($name, $type, $orig) = @$member;
if ($type eq '>') {
- my ($subpacking, @subitems, $subpacksize) = $self->{$name}->getUnpack();
+ my ($subpacking, $subpacksize, @subitems) = $self->{$name}->getUnpack();
DEBUG "(PM)Struct::getUnpack($self->{__typedef__}) ++ $subpacking\n";
$packing .= $subpacking;
$packed_size += $subpacksize;
@@ -274,26 +275,27 @@
push(@items, @subitems);
}
else {
+ my $repeat = 1;
if ($type =~ /\w\*(\d+)/) {
- my $size = $1;
- $type = "Z$size";
+ $repeat = $1;
+ $type = "Z$repeat";
}
DEBUG "(PM)Struct::getUnpack($self->{__typedef__}) ++ $type\n";
$type_size = Win32::API::Type::sizeof($orig);
$type_align = (($packed_size + $type_size) % $type_size);
$packing .= "x" x $type_align . $type;
- $packed_size += $type_size + $type_align;
+ $packed_size += ( $type_size * $repeat ) + $type_align;
push(@items, $name);
}
}
DEBUG "(PM)Struct::getUnpack($self->{__typedef__}): unpack($packing, @items)\n";
- return ($packing, @items, $packed_size);
+ return ($packing, $packed_size, @items);
}
sub Unpack {
my $self = shift;
- my ($packing, @items) = $self->getUnpack();
+ my ($packing, undef, @items) = $self->getUnpack();
my @itemvalue = unpack($packing, $self->{buffer});
DEBUG "(PM)Struct::Unpack: unpack($packing, buffer) = @itemvalue\n";
foreach my $i (0 .. $#items) {