mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-08 04:07:02 -06:00
23.01
This commit is contained in:
@@ -2,138 +2,144 @@
|
||||
|
||||
#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;
|
||||
// using namespace NWindows;
|
||||
// using namespace NFile;
|
||||
|
||||
/*
|
||||
static LPCTSTR const kLMBasePath = TEXT("Software\\7-Zip\\FM");
|
||||
typedef UINT32 (WINAPI * Func_GetPluginProperty)(PROPID propID, PROPVARIANT *value);
|
||||
|
||||
static LPCTSTR const kPluginsKeyName = TEXT("Plugins");
|
||||
static LPCTSTR const kPluginsOpenClassIDValue = TEXT("CLSID");
|
||||
static LPCTSTR const kPluginsOptionsClassIDValue = TEXT("Options");
|
||||
static LPCTSTR const 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)
|
||||
static bool ReadPluginInfo(CPluginInfo &plugin, bool needCheckDll)
|
||||
{
|
||||
if (needCheckDll)
|
||||
{
|
||||
NDLL::CLibrary lib;
|
||||
if (!lib.LoadEx(pluginInfo.FilePath, LOAD_LIBRARY_AS_DATAFILE))
|
||||
if (!lib.LoadEx(plugin.FilePath, LOAD_LIBRARY_AS_DATAFILE))
|
||||
return false;
|
||||
}
|
||||
NDLL::CLibrary lib;
|
||||
if (!lib.Load(pluginInfo.FilePath))
|
||||
if (!lib.Load(plugin.FilePath))
|
||||
return false;
|
||||
GetPluginPropertyFunc getPluginProperty = (GetPluginPropertyFunc)lib.GetProc("GetPluginProperty");
|
||||
if (getPluginProperty == NULL)
|
||||
const
|
||||
Func_GetPluginProperty
|
||||
f_GetPluginProperty = ZIP7_GET_PROC_ADDRESS(
|
||||
Func_GetPluginProperty, lib.Get_HMODULE(),
|
||||
"GetPluginProperty");
|
||||
if (!f_GetPluginProperty)
|
||||
return false;
|
||||
|
||||
|
||||
NCOM::CPropVariant prop;
|
||||
if (getPluginProperty(NPlugin::kName, &prop) != S_OK)
|
||||
if (f_GetPluginProperty(NPlugin::kType, &prop) != S_OK)
|
||||
return false;
|
||||
if (prop.vt == VT_EMPTY)
|
||||
plugin.Type = kPluginTypeFF;
|
||||
else if (prop.vt == VT_UI4)
|
||||
plugin.Type = (EPluginType)prop.ulVal;
|
||||
else
|
||||
return false;
|
||||
prop.Clear();
|
||||
|
||||
if (f_GetPluginProperty(NPlugin::kName, &prop) != S_OK)
|
||||
return false;
|
||||
if (prop.vt != VT_BSTR)
|
||||
return false;
|
||||
pluginInfo.Name = prop.bstrVal;
|
||||
plugin.Name = prop.bstrVal;
|
||||
prop.Clear();
|
||||
|
||||
if (getPluginProperty(NPlugin::kClassID, &prop) != S_OK)
|
||||
if (f_GetPluginProperty(NPlugin::kClassID, &prop) != S_OK)
|
||||
return false;
|
||||
if (prop.vt == VT_EMPTY)
|
||||
pluginInfo.ClassIDDefined = false;
|
||||
plugin.ClassID_Defined = false;
|
||||
else if (prop.vt != VT_BSTR)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
pluginInfo.ClassIDDefined = true;
|
||||
pluginInfo.ClassID = *(const GUID *)(const void *)prop.bstrVal;
|
||||
plugin.ClassID_Defined = true;
|
||||
plugin.ClassID = *(const GUID *)(const void *)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 *)(const void *)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();
|
||||
if (f_GetPluginProperty(NPlugin::kOptionsClassID, &prop) != S_OK)
|
||||
return false;
|
||||
if (prop.vt == VT_EMPTY)
|
||||
plugin.OptionsClassID_Defined = false;
|
||||
else if (prop.vt != VT_BSTR)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
CPluginInfo pluginInfo;
|
||||
pluginInfo.FilePath = baseFolderPrefix + FTEXT("7-zip.dll");
|
||||
if (::ReadPluginInfo(pluginInfo, false))
|
||||
plugins.Add(pluginInfo);
|
||||
}
|
||||
FString folderPath = baseFolderPrefix;
|
||||
folderPath += "Plugins" STRING_PATH_SEPARATOR;
|
||||
NFind::CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(folderPath);
|
||||
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);
|
||||
plugin.OptionsClassID_Defined = true;
|
||||
plugin.OptionsClassID = *(const GUID *)(const void *)prop.bstrVal;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void ReadFileFolderPluginInfoList(CObjectVector<CPluginInfo> &plugins)
|
||||
{
|
||||
/*
|
||||
{
|
||||
// very old 7-zip used agent plugin in "7-zip.dll"
|
||||
// but then agent code was moved to 7zfm.
|
||||
// so now we don't need to load "7-zip.dll" here
|
||||
CPluginInfo plugin;
|
||||
plugin.FilePath = baseFolderPrefix + FTEXT("7-zip.dll");
|
||||
if (::ReadPluginInfo(plugin, false))
|
||||
if (plugin.Type == kPluginTypeFF)
|
||||
plugins.Add(plugin);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
FString folderPath = NDLL::GetModuleDirPrefix();
|
||||
folderPath += "Plugins" STRING_PATH_SEPARATOR;
|
||||
NFind::CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(folderPath);
|
||||
NFind::CFileInfo fi;
|
||||
while (enumerator.Next(fi))
|
||||
{
|
||||
if (fi.IsDir())
|
||||
continue;
|
||||
CPluginInfo plugin;
|
||||
plugin.FilePath = folderPath + fi.Name;
|
||||
if (::ReadPluginInfo(plugin, true))
|
||||
if (plugin.Type == kPluginTypeFF)
|
||||
plugins.Add(plugin);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
ReadPluginInfoList(plugins);
|
||||
for (unsigned i = 0; i < plugins.Size();)
|
||||
if (plugins[i].Type != kPluginTypeFF)
|
||||
plugins.Delete(i);
|
||||
else
|
||||
i++;
|
||||
*/
|
||||
|
||||
/*
|
||||
void ReadFileFolderPluginInfoList(CObjectVector<CPluginInfo> &plugins)
|
||||
{
|
||||
plugins.Clear();
|
||||
{
|
||||
CPluginInfo p;
|
||||
}
|
||||
|
||||
{
|
||||
CPluginInfo &plugin = plugins.AddNew();
|
||||
// p.FilePath.Empty();
|
||||
p.Type = kPluginTypeFF;
|
||||
p.Name = "7-Zip";
|
||||
// p.ClassID = CLSID_CAgentArchiveHandler;
|
||||
p.ClassIDDefined = true;
|
||||
// p.OptionsClassID;
|
||||
p.OptionsClassIDDefined = false;
|
||||
plugins.Add(p);
|
||||
plugin.Type = kPluginTypeFF;
|
||||
plugin.Name = "7-Zip";
|
||||
// plugin.ClassID = CLSID_CAgentArchiveHandler;
|
||||
// plugin.ClassID_Defined = true;
|
||||
// plugin.ClassID_Defined = false;
|
||||
// plugin.OptionsClassID_Defined = false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user