lib/Parse/Win32Registry/Win95/File.pm

filter: Statementstmt 92.9% 289 / 311 Branchbran 71.7% 66 / 92 Conditioncond 37.5% 3 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 94.2% 49 / 52 Podpod 0.0% 0 / 9 totaltotal 85.5% 407 / 476 CC 51 SCAR 13.6
CC
51
Cov
87%
new
9.2
__ANON__
7.3
new
6.0
CRAP 3.9
« lib/Parse/Win32Registry/WinNT/File.pm ↑ Summary lib/Parse/Win32Registry/Value.pm »
1 package Parse::Win32Registry::Win95::File;
2  
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 13 ▶use base qw(Parse::Win32Registry::File);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 13 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 13 ▶use Parse::Win32Registry::Base qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 13 ▶use Parse::Win32Registry::Win95::Key;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 13 ▶use constant CREG_HEADER_LENGTH => 0x20;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 13 ▶use constant OFFSET_TO_RGKN_BLOCK => 0x20;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 22 ▶sub new {
Subroutine new: called CC=6 SCAR=17.9
Pod undocumented
17 22 my $class = shift;
18 22 ▶ my $filename = shift or croak 'No filename specified';
Branch: 1 branch
BranchTrueFalseTotal
my $filename = shift() or croak("No filename specified") 21 1 22
19  
20 21 ▶ open my $fh, '<', $filename or croak "Unable to open '$filename': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $filename or croak("Unable to open '${filename}': $!") 20 1 21
21  
22 # CREG Header
23 # 0x00 dword = 'CREG' signature
24 # 0x04
25 # 0x08 dword = offset to first rgdb block
26 # 0x0c
27 # 0x10 word = number of rgdb blocks
28  
29 20 my $bytes_read = sysread($fh, my $creg_header, CREG_HEADER_LENGTH);
30 20 ▶ if ($bytes_read != CREG_HEADER_LENGTH) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bytes_read != 32) 1 19 20
31 1 warnf('Could not read registry file header');
32 1 return;
33 }
34  
35 19 my ($creg_sig,
36 $offset_to_first_rgdb_block,
37 $num_rgdb_blocks) = unpack('a4x4Vx4v', $creg_header);
38  
39 19 ▶ if ($creg_sig ne 'CREG') {
Branch: 1 branch
BranchTrueFalseTotal
if ($creg_sig ne "CREG") 1 18 19
40 1 warnf('Invalid registry file signature');
41 1 return;
42 }
43  
44 18 my $self = {};
45 18 $self->{_filehandle} = $fh;
46 18 $self->{_filename} = $filename;
47 18 $self->{_length} = (stat $fh)[7];
48 18 $self->{_offset_to_first_rgdb_block} = $offset_to_first_rgdb_block;
49 18 $self->{_num_rgdb_blocks} = $num_rgdb_blocks;
50 18 bless $self, $class;
51  
52 # get_rgkn will cache the rgkn block for subsequent calls
53 18 my $rgkn_block = $self->get_rgkn;
54 18 ▶ return if !defined $rgkn_block; # warning will already have been made
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rgkn_block 2 16 18
55  
56 # Index the rgdb entries by id for faster look up
57 16 $self->_index_rgdb_entries;
58  
59 16 return $self;
60 }
61  
62 1 ▶sub get_timestamp {
Subroutine get_timestamp: called CC=1 SCAR=0.0
Pod undocumented
63 1 return undef;
64 }
65  
66 1 ▶sub get_timestamp_as_string {
Subroutine get_timestamp_as_string: called CC=1 SCAR=0.0
Pod undocumented
67 1 return iso8601(undef);
68 }
69  
70 1 ▶sub get_embedded_filename {
Subroutine get_embedded_filename: called CC=1 SCAR=0.0
Pod undocumented
71 1 return undef;
72 }
73  
74 9 ▶sub get_root_key {
Subroutine get_root_key: called CC=1 SCAR=0.0
Pod undocumented
75 9 my $self = shift;
76  
77 9 return $self->get_rgkn->get_root_key;
78 }
79  
80 2 ▶sub get_virtual_root_key {
Subroutine get_virtual_root_key: called CC=5 SCAR=16.4
Pod undocumented
81 2 my $self = shift;
82 2 my $fake_root = shift;
83  
84 2 my $root_key = $self->get_root_key;
85 2 ▶ return if !defined $root_key;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $root_key 0 2 2
86  
87 2 ▶ if (!defined $fake_root) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fake_root) 2 0 2
88 # guess virtual root from filename
89 2 my $filename = basename $self->{_filename};
90  
91 2 ▶ if ($filename =~ /USER/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($filename =~ /USER/i) { } 1 1 2
elsif ($filename =~ /SYSTEM/i) { } 1 0 1
92 1 $fake_root = 'HKEY_USERS';
93 }
94 elsif ($filename =~ /SYSTEM/i) {
95 1 $fake_root = 'HKEY_LOCAL_MACHINE';
96 }
97 else {
98 0 $fake_root = 'HKEY_UNKNOWN';
99 }
100 }
101  
102 2 $root_key->{_name} = $fake_root;
103 2 $root_key->{_key_path} = $fake_root;
104  
105 2 return $root_key;
106 }
107  
108 16 ▶sub _index_rgdb_entries {
Subroutine _index_rgdb_entries: called CC=4 SCAR=13.9
109 16 my $self = shift;
110  
111 16 my %index = ();
112  
113 # Build index of rgdb key entries
114 # Entries are only included if $key_block_num matches $rgdb_block_num
115 16 my $rgdb_block_num = 0;
116 16 my $rgdb_iter = $self->get_rgdb_iterator;
117 16 ▶ while (my $rgdb = $rgdb_iter->()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $rgdb = &$rgdb_iter()) 18 16 34
118 18 my $rgdb_key_iter = $rgdb->get_key_iterator;
119 18 ▶ while (my $rgdb_key = $rgdb_key_iter->()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $rgdb_key = &$rgdb_key_iter()) 88 18 106
120 88 my $key_id = $rgdb_key->{_id};
121 88 my $key_block_num = $key_id >> 16;
122 88 ▶ if ($rgdb_block_num == $key_block_num) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rgdb_block_num == $key_block_num) 88 0 88
123 88 $index{$key_id} = $rgdb_key;
124 }
125 }
126 18 $rgdb_block_num++;
127 }
128  
129 16 $self->{_rgdb_index} = \%index;
130 }
131  
132 0 ▶sub _dump_rgdb_index {
Subroutine _dump_rgdb_index: not called CC=2 SCAR=17.9
133 0 my $self = shift;
134  
135 0 my $rgdb_index = $self->{_rgdb_index};
136  
137 0 foreach my $key_id (sort { $a <=> $b } keys %$rgdb_index) {
138 0 my $rgdb_key = $rgdb_index->{$key_id};
139 printf qq{id=0x%x 0x%x,%d/%d "%s" vals=%d\n},
140 $key_id,
141 $rgdb_key->{_offset},
142 $rgdb_key->{_length_used},
143 $rgdb_key->{_length},
144 $rgdb_key->{_name},
145 0 $rgdb_key->{_num_values};
146 }
147 }
148  
149 301 ▶sub get_rgkn {
Subroutine get_rgkn: called CC=2 SCAR=6.9
Pod undocumented
150 301 my $self = shift;
151  
152 # Return cached rgkn block if present
153 301 ▶ if (defined $self->{_rgkn}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_rgkn"}) 283 18 301
154 283 return $self->{_rgkn};
155 }
156  
157 18 my $offset = OFFSET_TO_RGKN_BLOCK;
158 18 my $rgkn_block = Parse::Win32Registry::Win95::RGKN->new($self, $offset);
159 18 $self->{_rgkn} = $rgkn_block;
160 18 return $rgkn_block;
161 }
162  
163 18 ▶sub get_rgdb_iterator {
Subroutine get_rgdb_iterator: called CC=1 SCAR=0.0
Pod undocumented
164 18 my $self = shift;
165  
166 18 my $offset_to_next_rgdb_block = $self->{_offset_to_first_rgdb_block};
167 18 my $num_rgdb_blocks = $self->{_num_rgdb_blocks};
168  
169 18 my $end_of_file = $self->{_length};
170  
171 18 my $rgdb_block_num = 0;
172  
173 38 ▶ return Parse::Win32Registry::Iterator->new(sub {
Subroutine __ANON__: called CC=5 SCAR=16.2
174 38 ▶ if ($offset_to_next_rgdb_block > $end_of_file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset_to_next_rgdb_block > $end_of_file) 5 33 38
175 5 return; # no more rgdb blocks
176 }
177 33 ▶ if ($rgdb_block_num >= $num_rgdb_blocks) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rgdb_block_num >= $num_rgdb_blocks) 13 20 33
178 13 return; # no more rgdb blocks
179 }
180 20 $rgdb_block_num++;
181 20 ▶ if (my $rgdb_block = Parse::Win32Registry::Win95::RGDB->new($self,
Branch: 1 branch
BranchTrueFalseTotal
if (my $rgdb_block = "Parse::Win32Registry::Win95::RGDB"->new($self, $offset_to_next_rgdb_block)) 20 0 20
182 $offset_to_next_rgdb_block))
183 {
184 20 ▶ return unless $rgdb_block->get_length > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $rgdb_block->get_length > 0 0 20 20
185 20 $offset_to_next_rgdb_block += $rgdb_block->get_length;
186 20 return $rgdb_block;
187 }
188 18 });
189 }
190  
191 2 ▶sub get_block_iterator {
Subroutine get_block_iterator: called CC=1 SCAR=0.0
Pod undocumented
192 2 my $self = shift;
193  
194 2 my $rgdb_iter;
195  
196 6 ▶ return Parse::Win32Registry::Iterator->new(sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
197 6 ▶ if (!defined $rgdb_iter) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $rgdb_iter) 2 4 6
198 2 $rgdb_iter = $self->get_rgdb_iterator;
199 2 return $self->get_rgkn;
200 }
201 4 return $rgdb_iter->();
202 2 });
203 }
204  
205 13 *get_hbin_iterator = \&get_block_iterator;
206  
207  
208 package Parse::Win32Registry::Win95::RGKN;
209  
210 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
211 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
212  
213 13 ▶use base qw(Parse::Win32Registry::Entry);
Subroutine BEGIN: called CC=1 SCAR=0.0
214  
215 13 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
216 13 ▶use Parse::Win32Registry::Base qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
217  
218 13 ▶use constant RGKN_HEADER_LENGTH => 0x20;
Subroutine BEGIN: called CC=1 SCAR=0.0
219 13 ▶use constant OFFSET_TO_RGKN_BLOCK => 0x20;
Subroutine BEGIN: called CC=1 SCAR=0.0
220  
221 18 ▶sub new {
Subroutine new: called CC=6 SCAR=18.0
222 18 my $class = shift;
223 18 my $regfile = shift;
224 18 ▶ my $offset = shift || OFFSET_TO_RGKN_BLOCK;
Condition50%1/2
shift() || 32
l!l
180
MC/DC0%0/1
shift() || 32
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
225  
226 18 ▶ croak 'Missing registry file' if !defined $regfile;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $regfile 0 18 18
227 18 ▶ croak 'Missing offset' if !defined $offset;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $offset 0 18 18
228  
229 18 my $fh = $regfile->get_filehandle;
230  
231 # RGKN Block Header
232 # 0x0 dword = 'RGKN' signature
233 # 0x4 dword = length of rgkn block
234 # 0x8 dword = offset to root key entry (relative to start of rgkn block)
235  
236 18 sysseek($fh, $offset, 0);
237 18 my $bytes_read = sysread($fh, my $rgkn_header, RGKN_HEADER_LENGTH);
238 18 ▶ if ($bytes_read != RGKN_HEADER_LENGTH) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bytes_read != 32) 1 17 18
239 1 warnf('Could not read RGKN header at 0x%x', $offset);
240 1 return;
241 }
242  
243 17 my ($sig,
244 $rgkn_block_length,
245 $offset_to_root_key) = unpack('a4VV', $rgkn_header);
246  
247 17 ▶ if ($sig ne 'RGKN') {
Branch: 1 branch
BranchTrueFalseTotal
if ($sig ne "RGKN") 1 16 17
248 1 warnf('Invalid RGKN block signature at 0x%x', $offset);
249 1 return;
250 }
251  
252 16 $offset_to_root_key += $offset;
253  
254 16 my $self = {};
255 16 $self->{_regfile} = $regfile;
256 16 $self->{_offset} = $offset;
257 16 $self->{_length} = $rgkn_block_length;
258 16 $self->{_header_length} = RGKN_HEADER_LENGTH;
259 16 $self->{_allocated} = 1;
260 16 $self->{_tag} = 'rgkn block';
261 16 $self->{_offset_to_root_key} = $offset_to_root_key;
262 16 bless $self, $class;
263  
264 16 return $self;
265 }
266  
267 11 ▶sub get_root_key {
Subroutine get_root_key: called CC=1 SCAR=0.0
268 11 my $self = shift;
269  
270 11 my $regfile = $self->{_regfile};
271 11 my $offset_to_root_key = $self->{_offset_to_root_key};
272  
273 11 my $root_key = Parse::Win32Registry::Win95::Key->new($regfile,
274 $offset_to_root_key);
275 11 return $root_key;
276 }
277  
278 2 ▶sub get_entry_iterator {
Subroutine get_entry_iterator: called CC=2 SCAR=7.4
279 2 my $self = shift;
280  
281 2 my $root_key = $self->get_root_key;
282  
283 # In the unlikely event there is no root key, return an empty iterator
284 2 ▶ if (defined $root_key) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $root_key) { } 2 0 2
285 2 return $root_key->get_subtree_iterator;
286 }
287 else {
288 0 ▶ return Parse::Win32Registry::Iterator->new(sub {});
Subroutine __ANON__: not called CC=1 SCAR=6.9
289 }
290 }
291  
292  
293 package Parse::Win32Registry::Win95::RGDB;
294  
295 13 ▶use base qw(Parse::Win32Registry::Entry);
Subroutine BEGIN: called CC=1 SCAR=0.0
296  
297 13 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
298 13 ▶use Parse::Win32Registry::Base qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
299  
300 13 ▶use constant RGDB_HEADER_LENGTH => 0x20;
Subroutine BEGIN: called CC=1 SCAR=0.0
301  
302 20 ▶sub new {
Subroutine new: called CC=5 SCAR=16.5
303 20 my $class = shift;
304 20 my $regfile = shift;
305 20 my $offset = shift;
306  
307 20 ▶ croak 'Missing registry file' if !defined $regfile;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $regfile 0 20 20
308 20 ▶ croak 'Missing offset' if !defined $offset;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $offset 0 20 20
309  
310 20 my $fh = $regfile->get_filehandle;
311  
312 # RGDB Block Header
313 # 0x0 dword = 'RDGB' signature
314 # 0x4 dword = length of rgdb block
315  
316 20 sysseek($fh, $offset, 0);
317 20 my $bytes_read = sysread($fh, my $rgdb_header, RGDB_HEADER_LENGTH);
318 20 ▶ if ($bytes_read != RGDB_HEADER_LENGTH) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bytes_read != 32) 0 20 20
319 0 return;
320 }
321  
322 20 my ($sig,
323 $rgdb_block_length) = unpack('a4V', $rgdb_header);
324  
325 20 ▶ if ($sig ne 'RGDB') {
Branch: 1 branch
BranchTrueFalseTotal
if ($sig ne "RGDB") 0 20 20
326 0 return;
327 }
328  
329 20 my $self = {};
330 20 $self->{_regfile} = $regfile;
331 20 $self->{_offset} = $offset;
332 20 $self->{_length} = $rgdb_block_length;
333 20 $self->{_header_length} = RGDB_HEADER_LENGTH;
334 20 $self->{_allocated} = 1;
335 20 $self->{_tag} = 'rgdb block';
336 20 bless $self, $class;
337  
338 20 return $self;
339 }
340  
341 20 ▶sub get_key_iterator {
Subroutine get_key_iterator: called CC=1 SCAR=0.1
342 20 my $self = shift;
343  
344 20 my $regfile = $self->{_regfile};
345 20 my $offset = $self->{_offset};
346 20 my $length = $self->{_length};
347  
348 20 my $offset_to_next_rgdb_key = $offset + RGDB_HEADER_LENGTH;
349 20 my $end_of_rgdb_block = $offset + $length;
350  
351 112 ▶ return Parse::Win32Registry::Iterator->new(sub {
Subroutine __ANON__: called CC=5 SCAR=16.8
352 112 ▶ if ($offset_to_next_rgdb_key >= $end_of_rgdb_block) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset_to_next_rgdb_key >= $end_of_rgdb_block) 20 92 112
353 20 return;
354 }
355 92 ▶ if (my $rgdb_key = Parse::Win32Registry::Win95::RGDBKey->new($regfile,
Branch: 1 branch
BranchTrueFalseTotal
if (my $rgdb_key = "Parse::Win32Registry::Win95::RGDBKey"->new($regfile, $offset_to_next_rgdb_key)) 92 0 92
356 $offset_to_next_rgdb_key))
357 {
358 92 ▶ return unless $rgdb_key->get_length > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $rgdb_key->get_length > 0 0 92 92
359 92 $offset_to_next_rgdb_key += $rgdb_key->get_length;
360  
361 # Check rgdb key has not run past end of rgdb block
362 92 ▶ if ($offset_to_next_rgdb_key > $end_of_rgdb_block) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset_to_next_rgdb_key > $end_of_rgdb_block) 0 92 92
363 0 return;
364 }
365 92 return $rgdb_key;
366 }
367 20 });
368 }
369  
370 2 ▶sub get_entry_iterator {
Subroutine get_entry_iterator: called CC=1 SCAR=0.0
371 2 my $self = shift;
372  
373 2 my $value_iter;
374 2 my $key_iter = $self->get_key_iterator;
375  
376 14 ▶ return Parse::Win32Registry::Iterator->new(sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
377 14 ▶ if (defined $value_iter) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value_iter) 12 2 14
378 12 my $value = $value_iter->();
379 12 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 8 4 12
380 8 return $value;
381 }
382 }
383  
384 6 my $key = $key_iter->();
385 6 ▶ if (!defined $key) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $key) 2 4 6
386 2 return; # key iterator finished
387 }
388  
389 4 $value_iter = $key->get_value_iterator;
390 4 return $key;
391 2 });
392 }
393  
394  
395 package Parse::Win32Registry::Win95::RGDBKey;
396  
397 13 ▶use base qw(Parse::Win32Registry::Entry);
Subroutine BEGIN: called CC=1 SCAR=0.0
398  
399 13 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
400 13 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
401 13 ▶use Parse::Win32Registry::Base qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
402  
403 13 ▶use constant RGDB_ENTRY_HEADER_LENGTH => 0x14;
Subroutine BEGIN: called CC=1 SCAR=0.0
404  
405 92 ▶sub new {
Subroutine new: called CC=8 SCAR=22.2
406 92 my $class = shift;
407 92 my $regfile = shift;
408 92 my $offset = shift;
409  
410 92 ▶ croak 'Missing registry file' if !defined $regfile;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $regfile 0 92 92
411 92 ▶ croak 'Missing offset' if !defined $offset;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $offset 0 92 92
412  
413 92 my $fh = $regfile->get_filehandle;
414  
415 # RGDB Key Entry
416 # 0x00 dword = length of rgdb entry / offset to next rgdb entry
417 # (this length includes any following value entries)
418 # 0x04 dword = id (top word = block num, bottom word = id)
419 # 0x08 dword = bytes used (unpacked, but not used)
420 # 0x0c word = key name length
421 # 0x0e word = number of values
422 # 0x10 dword
423 # 0x14 = key name [for key name length bytes]
424 # followed immediately by any RGDB Value Entries belonging to this key
425  
426 92 sysseek($fh, $offset, 0);
427 92 my $bytes_read = sysread($fh, my $rgdb_key_entry, RGDB_ENTRY_HEADER_LENGTH);
428 92 ▶ if ($bytes_read != RGDB_ENTRY_HEADER_LENGTH) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bytes_read != 20) 0 92 92
429 0 return;
430 }
431  
432 92 my ($length,
433 $key_id,
434 $length_used,
435 $name_length,
436 $num_values) = unpack('VVVvv', $rgdb_key_entry);
437  
438 92 $bytes_read = sysread($fh, my $name, $name_length);
439 92 ▶ if ($bytes_read != $name_length) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bytes_read != $name_length) 0 92 92
440 0 return;
441 }
442 92 $name = decode($Parse::Win32Registry::Base::CODEPAGE, $name);
443  
444 # Calculate the length of the entry's key header
445 92 my $header_length = RGDB_ENTRY_HEADER_LENGTH + $name_length;
446  
447 # Check for invalid/unused entries
448 92 ▶ if ($key_id == 0xffffffff || $length_used == 0xffffffff
Branch: 1 branch
BranchTrueFalseTotal
if ($key_id == 4294967295 or $length_used == 4294967295 or $header_length > $length) 0 92 92
Condition33%2/6
$key_id == 4294967295 or $length_used == 4294967295 or $header_length > $length
l!l&&r!l&&!r
0092
$key_id == 4294967295 or $length_used == 4294967295
l!l&&r!l&&!r
0092
MC/DC0%0/3
$key_id == 4294967295 or $length_used == 4294967295 or $header_length > $length
$key_id == 4294967295 $length_used == 4294967295 $header_length > $length
Truth table25%1/4
A or B or C
A= $key_id == 4294967295B= $length_used == 4294967295C= $header_length > $length
ABCresult
1XX1
01X1
0011
0000
449 || $header_length > $length)
450 {
451 0 $name = '';
452 0 $header_length = RGDB_ENTRY_HEADER_LENGTH;
453 }
454  
455 92 my $self = {};
456 92 $self->{_regfile} = $regfile;
457 92 $self->{_offset} = $offset;
458 92 $self->{_length} = $length;
459 92 $self->{_length_used} = $length_used;
460 92 $self->{_header_length} = $header_length;
461 92 $self->{_allocated} = 1;
462 92 $self->{_tag} = 'rgdb key';
463 92 $self->{_id} = $key_id;
464 92 $self->{_name} = $name;
465 92 $self->{_name_length} = $name_length;
466 92 $self->{_num_values} = $num_values;
467 92 bless $self, $class;
468  
469 92 return $self;
470 }
471  
472 299 ▶sub get_name {
Subroutine get_name: called CC=1 SCAR=0.0
473 299 my $self = shift;
474  
475 299 return $self->{_name};
476 }
477  
478 0 ▶sub parse_info {
Subroutine parse_info: not called CC=1 SCAR=6.9
479 0 my $self = shift;
480  
481 my $info = sprintf '0x%x rgdb key len=0x%x/0x%x "%s" id=0x%x vals=%d',
482 $self->{_offset},
483 $self->{_length_used},
484 $self->{_length},
485 $self->{_name},
486 $self->{_id},
487 0 $self->{_num_values};
488  
489 0 return $info;
490 }
491  
492 144 ▶sub get_value_iterator {
Subroutine get_value_iterator: called CC=3 SCAR=11.4
493 144 my $self = shift;
494  
495 144 my $regfile = $self->{_regfile};
496  
497 144 my $num_values_remaining = $self->{_num_values};
498  
499 144 my $offset = $self->{_offset};
500  
501 # offset_to_next_rgdb_value can only be set to a valid offset
502 # if num_values_remaining > 0
503 144 my $offset_to_next_rgdb_value = 0xffffffff;
504 144 ▶ if ($num_values_remaining > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num_values_remaining > 0) 119 25 144
505 $offset_to_next_rgdb_value = $offset
506 119 + $self->{_header_length};
507 }
508  
509 144 my $end_of_rgdb_key = $offset + $self->{_length};
510  
511 # don't attempt to return values if id is invalid...
512 144 ▶ if ($self->{_id} == 0xffffffff) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_id"} == 4294967295) 0 144 144
513 0 $num_values_remaining = 0;
514 }
515  
516 3321 ▶ return Parse::Win32Registry::Iterator->new(sub {
Subroutine __ANON__: called CC=6 SCAR=19.9
517 3321 ▶ if ($num_values_remaining-- <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num_values_remaining-- <= 0) 134 3187 3321
518 134 return;
519 }
520 3187 ▶ if ($offset_to_next_rgdb_value == 0xffffffff) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset_to_next_rgdb_value == 4294967295) 0 3187 3187
521 0 return;
522 }
523 3187 ▶ if ($offset_to_next_rgdb_value > $end_of_rgdb_key) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset_to_next_rgdb_value > $end_of_rgdb_key) 0 3187 3187
524 0 return;
525 }
526 3187 ▶ if (my $value = Parse::Win32Registry::Win95::Value->new($regfile,
Branch: 1 branch
BranchTrueFalseTotal
if (my $value = 'Parse::Win32Registry::Win95::Value'->new($regfile, $offset_to_next_rgdb_value)) { } 3187 0 3187
527 $offset_to_next_rgdb_value))
528 {
529 3187 ▶ return unless $value->get_length > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $value->get_length > 0 0 3187 3187
530 3187 $offset_to_next_rgdb_value += $value->get_length;
531 3187 return $value;
532 }
533 else {
534 0 return; # no more values
535 }
536 144 });
537 }
538  
539 13 1;
540  
« lib/Parse/Win32Registry/WinNT/File.pm ↑ Summary lib/Parse/Win32Registry/Value.pm »