-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.php
97 lines (76 loc) · 2.02 KB
/
main.php
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* Copyright 2019 Stefano Moioli <[email protected]>
*/
spl_autoload_register();
use Common\System;
use WinSxS\{Component, Manifest, Package, SystemFile};
class ComponentStore {
public static function ensureLoaded() {
$reg = System::getRegistry();
if(!$reg->enumerate("HKLM\\COMPONENTS")){
system("REG LOAD HKLM\\COMPONENTS %windir%\\system32\\config\\COMPONENTS >NUL");
}
}
public static function unload(){
system("REG UNLOAD HKLM\\COMPONENTS >NUL");
}
}
function handlePackage(Package $pkg){
$tpl= <<<EOS
[{$pkg->getKey()->getFullPath()}]
=> Name : {$pkg->getName()}
=> Client : {$pkg->getInstallClient()}
=> Location : {$pkg->getInstallLocation()}
=> InstallName : {$pkg->getInstallName()}
=> InstallUser : {$pkg->getInstallUser()}
== Owners ==
EOS;
$owners = $pkg->getOwnerPackages();
foreach($owners as $ownerPkg){
if($pkg->getName() != $ownerPkg->getName()){
$tpl.= handlePackage($ownerPkg);
}
}
return $tpl;
}
function iterManifests(){
$root = System::getSysRoot();
$iter = new DirectoryIterator("{$root}\\WinSxS\\Manifests");
foreach($iter as $file){
if(pathinfo($file, PATHINFO_EXTENSION) != "manifest")
continue;
$path = $file->getPathname();
$manifest = new Manifest($path);
$tpl = <<<EOS
=== {$manifest->getName()} ===
=> FilePath : {$manifest->getFilePath()}
EOS;
$cmp = Component::fromName(System::getRegistry(), $manifest->getName());
$tpl.= <<<EOS
=== Component ===
=> Name : {$cmp->getName()}
=> Ident: {$cmp->getIdentity()}
EOS;
$deployments = $cmp->getDeployments();
foreach($deployments as $depl){
$cat = $depl->getCatalog();
$deployments = $cat->getDeployments();
$tpl .= <<<EOS
=== Deployment ===
=> Name : {$depl->getName()}
=> AppID: {$depl->getAppID()}
=== Catalog ===
=> Name : {$cat->getName()}
=== Packages ===
EOS;
foreach($depl->getPackages() as $pkg){
$tpl .= handlePackage($pkg);
}
print($tpl);
}
}
}
ComponentStore::ensureLoaded();
iterManifests();
ComponentStore::unload();