blob: ad70db806ab2135b86c5a29519279dd401c8693d (
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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
// RegistryPlugins.cpp
#include "StdAfx.h"
#include "../../../Windows/DLL.h"
#include "../../../Windows/FileFind.h"
#include "../../../Windows/PropVariant.h"
#include "IFolder.h"
#include "RegistryPlugins.h"
using namespace NWindows;
using namespace NFile;
/*
static const TCHAR *kLMBasePath = TEXT("Software\\7-Zip\\FM");
static const TCHAR *kPluginsKeyName = TEXT("Plugins");
static const TCHAR *kPluginsOpenClassIDValue = TEXT("CLSID");
static const TCHAR *kPluginsOptionsClassIDValue = TEXT("Options");
static const TCHAR *kPluginsTypeValue = TEXT("Type");
static CSysString GetFileFolderPluginsKeyName()
{
return CSysString(kLMBasePath) + CSysString(TEXT('\\')) +
CSysString(kPluginsKeyName);
}
*/
typedef UINT32 (WINAPI * GetPluginPropertyFunc)(PROPID propID, PROPVARIANT *value);
static bool ReadPluginInfo(CPluginInfo &pluginInfo, bool needCheckDll)
{
if (needCheckDll)
{
NDLL::CLibrary lib;
if (!lib.LoadEx(pluginInfo.FilePath, LOAD_LIBRARY_AS_DATAFILE))
return false;
}
NDLL::CLibrary lib;
if (!lib.Load(pluginInfo.FilePath))
return false;
GetPluginPropertyFunc getPluginProperty = (GetPluginPropertyFunc)lib.GetProc("GetPluginProperty");
if (getPluginProperty == NULL)
return false;
NCOM::CPropVariant prop;
if (getPluginProperty(NPlugin::kName, &prop) != S_OK)
return false;
if (prop.vt != VT_BSTR)
return false;
pluginInfo.Name = prop.bstrVal;
prop.Clear();
if (getPluginProperty(NPlugin::kClassID, &prop) != S_OK)
return false;
if (prop.vt == VT_EMPTY)
pluginInfo.ClassIDDefined = false;
else if (prop.vt != VT_BSTR)
return false;
else
{
pluginInfo.ClassIDDefined = true;
pluginInfo.ClassID = *(const GUID *)prop.bstrVal;
}
prop.Clear();
if (getPluginProperty(NPlugin::kOptionsClassID, &prop) != S_OK)
return false;
if (prop.vt == VT_EMPTY)
pluginInfo.OptionsClassIDDefined = false;
else if (prop.vt != VT_BSTR)
return false;
else
{
pluginInfo.OptionsClassIDDefined = true;
pluginInfo.OptionsClassID = *(const GUID *)prop.bstrVal;
}
prop.Clear();
if (getPluginProperty(NPlugin::kType, &prop) != S_OK)
return false;
if (prop.vt == VT_EMPTY)
pluginInfo.Type = kPluginTypeFF;
else if (prop.vt == VT_UI4)
pluginInfo.Type = (EPluginType)prop.ulVal;
else
return false;
return true;
}
void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins)
{
plugins.Clear();
FString baseFolderPrefix = NDLL::GetModuleDirPrefix();
{
CPluginInfo pluginInfo;
pluginInfo.FilePath = baseFolderPrefix + FTEXT("7-zip.dll");
if (::ReadPluginInfo(pluginInfo, false))
plugins.Add(pluginInfo);
}
FString folderPath = baseFolderPrefix + FTEXT("Plugins") FSTRING_PATH_SEPARATOR;
NFind::CEnumerator enumerator(folderPath + FCHAR_ANY_MASK);
NFind::CFileInfo fileInfo;
while (enumerator.Next(fileInfo))
{
if (fileInfo.IsDir())
continue;
CPluginInfo pluginInfo;
pluginInfo.FilePath = folderPath + fileInfo.Name;
if (::ReadPluginInfo(pluginInfo, true))
plugins.Add(pluginInfo);
}
}
void ReadFileFolderPluginInfoList(CObjectVector<CPluginInfo> &plugins)
{
ReadPluginInfoList(plugins);
for (unsigned i = 0; i < plugins.Size();)
if (plugins[i].Type != kPluginTypeFF)
plugins.Delete(i);
else
i++;
{
CPluginInfo p;
// p.FilePath.Empty();
p.Type = kPluginTypeFF;
p.Name = L"7-Zip";
// p.ClassID = CLSID_CAgentArchiveHandler;
p.ClassIDDefined = true;
// p.OptionsClassID;
p.OptionsClassIDDefined = false;
plugins.Add(p);
}
}
|