-
-
Save CReimer/d8de01aa1bf2a0e097fc021829976730 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings FATAL => 'all'; | |
open (my $fh, "<", "Win10_USB-BT400_Driver_Package/64/bcbtums-win8x64-brcm.inf"); | |
my $data; | |
while (<$fh>) { | |
$data .= $_; | |
} | |
$data =~ s/\r//g; | |
my %index; | |
foreach my $line ($data =~ /(^.*?USB\\VID.*?$)/gm) { | |
# print Dumper($line); | |
my ($link, $vid, $pid) = $line =~ /%=(.*?),.*?USB\\VID_(.*?)&PID_(.*?) /; | |
next unless $link; | |
$index{$link} = { } unless $index{$link}; | |
$index{$link}{"$vid:$pid"} = 1; | |
} | |
my %copylist; | |
foreach my $link (keys(%index)) { | |
(my $block) = $data =~ /\[$link.NTamd64\]\n(.*?)\n\n\[/s; | |
(my @temp) = $block =~ /^CopyFiles=(.*?)$/gm; | |
$copylist{$link} = \@temp; | |
} | |
my %final; | |
foreach my $key (keys(%copylist)) { | |
foreach my $single (@{$copylist{$key}}) { | |
(my $block) = $data =~ /\[$single\]\n(.*?)\n\n\[/s; | |
next unless $block; | |
(my $hex) = $block =~ /^(.*?\.hex)$/m; | |
next unless $hex; | |
my @temp = keys(%{$index{$key}}); | |
$final{$temp[0]} = $hex; | |
} | |
} | |
foreach my $key (keys(%final)) { | |
print "$key: $final{$key}\n"; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment