Add files via upload

This commit is contained in:
T800 2017-02-25 20:44:11 +01:00 committed by GitHub
commit d27edd5948
18 changed files with 6472 additions and 1 deletions

65
CBXShell/CBXShell.cpp Normal file
View file

@ -0,0 +1,65 @@
// CBXshell.cpp : Implementation of DLL Exports.
#include "stdafx.h"
#include "resource.h"
#include <initguid.h>
#include "CBXshell.h"
#include "CBXShell_i.c"
#include "CBXShellClass.h"
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_CBXShell, CCBXShell)
END_OBJECT_MAP()
/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
_Module.Init(ObjectMap, hInstance, &LIBID_CBXSHELLLib);
DisableThreadLibraryCalls(hInstance);
}
else
if (dwReason == DLL_PROCESS_DETACH)
{
_Module.Term();
}
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _Module.GetClassObject(rclsid, riid, ppv);
}
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
return _Module.RegisterServer(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
// Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
return _Module.UnregisterServer(TRUE);
}

5
CBXShell/CBXShell.def Normal file
View file

@ -0,0 +1,5 @@
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE

40
CBXShell/CBXShell.idl Normal file
View file

@ -0,0 +1,40 @@
// CBXShell.idl : IDL source for CBXShell.dll
//
// This file will be processed by the MIDL tool to
// produce the type library (CBXShell.tlb) and marshalling code.
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(677D0B3B-E0A8-4ECC-BD7E-1BCC96E388EA),
dual,
helpstring("ICBXShell Interface"),
pointer_default(unique)
]
interface ICBXShell : IDispatch
{
};
[
uuid(FC1558B6-3992-4ACE-B032-EB3273751A1B),
version(1.0),
helpstring("CBXShell 1.0 Type Library")
]
library CBXSHELLLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(9E6ECB90-5A61-42BD-B851-D3297D9C7F39),
helpstring("CBXShell Class")
]
coclass CBXShell
{
[default] interface ICBXShell;
};
};

62
CBXShell/CBXShell.rc Normal file
View file

@ -0,0 +1,62 @@
// Generated by ResEdit 1.4.8
// Copyright (C) 2006-2009
// http://www.resedit.net
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include <atlres.h>
#include "resource.h"
IDR_CBXShell REGISTRY "CBXShell.rgs"
1 TYPELIB "CBXShell.tlb"
//
// String Table resources
//
STRINGTABLE
{
IDS_PROJNAME "CBXShell"
IDS_CBXSHELL_DESC "CBXShell Class"
}
//
// Version Information resources
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,6,2,0
PRODUCTVERSION 4,6,2,0
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
{
BLOCK "StringFileInfo"
{
BLOCK "040904b0"
{
VALUE "CompanyName", "T800 Productions\0"
VALUE "Dependencies", "gdiplus.dll, unrar.dll\0"
#ifdef _WIN64
VALUE "FileDescription", "Image Archive Shell Extension 64-bit\0"
#else
VALUE "FileDescription", "Image Archive Shell Extension 32-bit\0"
#endif
VALUE "FileVersion", "4.6.2.0\0"
VALUE "LegalCopyright", "T800 Productions © 2011\0"
VALUE "ProductName", "CBX Shell\0"
VALUE "ProductVersion", "4.6.2.0\0"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 1033, 1200
}
}

80
CBXShell/CBXShell.rgs Normal file
View file

@ -0,0 +1,80 @@
HKCU
{
NoRemove Software
{
NoRemove Classes
{
NoRemove .cbz
{
shellex
{
{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1} = s '{9E6ECB90-5A61-42BD-B851-D3297D9C7F39}'
{00021500-0000-0000-C000-000000000046} = s '{9E6ECB90-5A61-42BD-B851-D3297D9C7F39}'
}
}
NoRemove .cbr
{
shellex
{
{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1} = s '{9E6ECB90-5A61-42BD-B851-D3297D9C7F39}'
{00021500-0000-0000-C000-000000000046} = s '{9E6ECB90-5A61-42BD-B851-D3297D9C7F39}'
}
}
}
}
}
HKLM
{
NoRemove Software
{
NoRemove Classes
{
CBXShell.CBXShell.1 = s 'CBXShell Class'
{
CLSID = s '{9E6ECB90-5A61-42BD-B851-D3297D9C7F39}'
}
CBXShell.CBXShell = s 'CBXShell Class'
{
CLSID = s '{9E6ECB90-5A61-42BD-B851-D3297D9C7F39}'
CurVer = s 'CBXShell.CBXShell.1'
}
NoRemove CLSID
{
ForceRemove {9E6ECB90-5A61-42BD-B851-D3297D9C7F39} = s 'CBXShell Class'
{
ProgID = s 'CBXShell.CBXShell.1'
VersionIndependentProgID = s 'CBXShell.CBXShell'
ForceRemove 'Programmable'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
'TypeLib' = s '{9E6ECB90-5A61-42BD-B851-D3297D9C7F39}'
}
}
}
NoRemove Microsoft
{
NoRemove Windows
{
NoRemove CurrentVersion
{
NoRemove 'Shell Extensions'
{
NoRemove Approved
{
val {9E6ECB90-5A61-42BD-B851-D3297D9C7F39} = s 'CBXShell Class'
}
}
}
}
}
}
}

632
CBXShell/CBXShell.vcproj Normal file
View file

@ -0,0 +1,632 @@
<?xml version="1.0" encoding="windows-1250"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="CBXShell"
ProjectGUID="{1A108438-5306-4026-B269-41BAA61ACCB3}"
RootNamespace="CBXShell"
Keyword="AtlProj"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1050"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
SuppressStartupBanner="true"
ModuleDefinitionFile=".\CBXShell.def"
GenerateDebugInformation="true"
SubSystem="2"
RandomizedBaseAddress="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/CBXShell.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
WarningLevel="3"
SuppressStartupBanner="true"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG;_WIN64"
Culture="1050"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
SuppressStartupBanner="true"
ModuleDefinitionFile=".\CBXShell.def"
GenerateDebugInformation="true"
SubSystem="2"
RandomizedBaseAddress="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/CBXShell.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
UseOfATL="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="2"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1050"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
SuppressStartupBanner="true"
ModuleDefinitionFile=".\CBXShell.def"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release/CBXShell.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
UseOfATL="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="2"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG;_WIN64"
Culture="1050"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
SuppressStartupBanner="true"
ModuleDefinitionFile=".\CBXShell.def"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release/CBXShell.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="CBXShell.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="StdAfx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
<File
RelativePath="StdAfx.h"
>
</File>
<File
RelativePath=".\targetver.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
>
<File
RelativePath="CBXShell.rc"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions=""
AdditionalIncludeDirectories="$(OUTDIR)"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions=""
AdditionalIncludeDirectories="$(OUTDIR)"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions=""
AdditionalIncludeDirectories="$(OUTDIR)"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions=""
AdditionalIncludeDirectories="$(OUTDIR)"
/>
</FileConfiguration>
</File>
<File
RelativePath="Resource.h"
>
</File>
</Filter>
<Filter
Name="COM"
>
<File
RelativePath="CBXShell.def"
>
</File>
<File
RelativePath="CBXShell.idl"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCMIDLTool"
GenerateStublessProxies="true"
TypeLibraryName=".\CBXShell.tlb"
HeaderFileName="CBXShell.h"
InterfaceIdentifierFileName="CBXShell_i.c"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCMIDLTool"
GenerateStublessProxies="true"
TypeLibraryName=".\CBXShell.tlb"
HeaderFileName="CBXShell.h"
InterfaceIdentifierFileName="CBXShell_i.c"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCMIDLTool"
GenerateStublessProxies="true"
TypeLibraryName=".\CBXShell.tlb"
HeaderFileName="CBXShell.h"
InterfaceIdentifierFileName="CBXShell_i.c"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCMIDLTool"
GenerateStublessProxies="true"
TypeLibraryName=".\CBXShell.tlb"
HeaderFileName="CBXShell.h"
InterfaceIdentifierFileName="CBXShell_i.c"
/>
</FileConfiguration>
</File>
<File
RelativePath="CBXShell.rgs"
>
</File>
<File
RelativePath="CBXShellClass.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="CBXShellClass.h"
>
</File>
</Filter>
<Filter
Name="CBX"
>
<File
RelativePath=".\cbxArchive.h"
>
</File>
<File
RelativePath=".\unrar.h"
>
</File>
<File
RelativePath=".\unzip.cpp"
>
</File>
<File
RelativePath=".\unzip.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,19 @@
// CBXShellClass.cpp : Implementation of CCBXshellApp and DLL registration.
#include "stdafx.h"
#include "CBXShell.h"
#include "CBXShellClass.h"
HRESULT CCBXShell::FinalConstruct(void)
{
ATLTRACE("CCBXShell::FinalConstruct\n");
m_cbx.LoadRegistrySettings();
return S_OK;
}
void CCBXShell::FinalRelease(void)
{
ATLTRACE("CCBXShell::FinalRelease\n");
}

62
CBXShell/CBXShellClass.h Normal file
View file

@ -0,0 +1,62 @@
#ifndef _CBXSHELLCLASS_541926D5_D807_4CCB_9F35_8464657CC196_
#define _CBXSHELLCLASS_541926D5_D807_4CCB_9F35_8464657CC196_
#pragma once
#include "resource.h" // main symbols
#include "cbxArchive.h"
/////////////////////////////////////////////////////////////////////////////
// CCBXShell
class ATL_NO_VTABLE CCBXShell :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CCBXShell,&CLSID_CBXShell>,
public IDispatchImpl<ICBXShell, &IID_ICBXShell, &LIBID_CBXSHELLLib>,
public IPersistFile,
public IExtractImage2,
public IQueryInfo
{
public:
HRESULT FinalConstruct(void);
void FinalRelease(void);
BEGIN_COM_MAP(CCBXShell)
COM_INTERFACE_ENTRY(ICBXShell)
COM_INTERFACE_ENTRY(IPersistFile)
COM_INTERFACE_ENTRY(IQueryInfo)
COM_INTERFACE_ENTRY(IExtractImage)
COM_INTERFACE_ENTRY(IExtractImage2)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
DECLARE_REGISTRY_RESOURCEID(IDR_CBXShell)
DECLARE_PROTECT_FINAL_CONSTRUCT()
// IPersistFile
STDMETHOD(Load)(LPCOLESTR wszFile, DWORD dwMode) { return m_cbx.OnLoad(wszFile); }
STDMETHOD(GetClassID)(LPCLSID clsid){return E_NOTIMPL;}
STDMETHOD(IsDirty)(VOID){return E_NOTIMPL;}
STDMETHOD(Save)(LPCOLESTR, BOOL){return E_NOTIMPL;}
STDMETHOD(SaveCompleted)(LPCOLESTR){return E_NOTIMPL;}
STDMETHOD(GetCurFile)(LPOLESTR FAR*){return E_NOTIMPL;}
// IExtractImage/IExtractImage2
STDMETHOD(GetLocation)(LPWSTR pszPathBuffer, DWORD cchMax,
DWORD *pdwPriority, const SIZE *prgSize,
DWORD dwRecClrDepth, DWORD *pdwFlags) { return m_cbx.OnGetLocation(prgSize, pdwFlags); }
STDMETHOD(Extract)(HBITMAP* phBmpThumbnail) { return m_cbx.OnExtract(phBmpThumbnail); }
// IExtractImage2
STDMETHOD(GetDateStamp)(FILETIME *pDateStamp) { return m_cbx.OnGetDateStamp(pDateStamp);}
// IQueryInfo
STDMETHOD(GetInfoTip)(DWORD dwFlags, LPWSTR* ppwszTip) { return m_cbx.OnGetInfoTip(ppwszTip);}
STDMETHOD(GetInfoFlags)(LPDWORD pdwFlags) { *pdwFlags = 0; return E_NOTIMPL;}
private:
__cbx::CCBXArchive m_cbx;
};
#endif//_CBXSHELLCLASS_541926D5_D807_4CCB_9F35_8464657CC196_

12
CBXShell/StdAfx.cpp Normal file
View file

@ -0,0 +1,12 @@
// stdafx.cpp : source file that includes just the standard includes
// stdafx.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#ifdef _ATL_STATIC_REGISTRY
#include <statreg.h>
#include <statreg.cpp>
#endif
#include <atlimpl.cpp>

23
CBXShell/StdAfx.h Normal file
View file

@ -0,0 +1,23 @@
#ifndef _STDAFX_C5E3BAAB_1D97_4C7F_AB90_2D4397D95F13_
#define _STDAFX_C5E3BAAB_1D97_4C7F_AB90_2D4397D95F13_
#pragma once
#ifndef UNICODE
#define UNICODE// UNICODE-only project
#endif
#define STRICT
#include "targetver.h"
#define _ATL_APARTMENT_THREADED
#include <atlbase.h>
#include <atlapp.h>// WTL project
extern CComModule _Module;
#include <atlcom.h>
#endif//_STDAFX_C5E3BAAB_1D97_4C7F_AB90_2D4397D95F13_

753
CBXShell/cbxArchive.h Normal file
View file

@ -0,0 +1,753 @@
///////////////////////////////////////////////
// v4.6
//////////////////////////////////////////////
// CCBXShell functionality implementation
#ifndef _CBXARCHIVE_442B998D_B9C0_4AB0_BB2A_BC9C0AA10053_
#define _CBXARCHIVE_442B998D_B9C0_4AB0_BB2A_BC9C0AA10053_
#ifndef STRICT
#define STRICT
#endif
#include <shlObj.h>
#include <shlwapi.h>
#pragma comment(lib,"shlwapi.lib")
//#include "gdiplus.h" // uncomment if needed
//#pragma comment(lib,"gdiplus.lib")
//ATL headers
//#include <atlstr.h> // uncomment if needed
#include <atlimage.h>
#include <atlfile.h>
// WTL headers
#include <atlgdi.h>
#include "unrar.h"
#ifdef _WIN64
#pragma comment(lib,"unrar64.lib")
#else
#pragma comment(lib,"unrar.lib")
#endif
#include "unzip.h"
#define CBXMEM_MAXBUFFER_SIZE 33554432 //32mb
#define CBXTYPE int
#define CBXTYPE_NONE 0
#define CBXTYPE_ZIP 1
#define CBXTYPE_CBZ 2
#define CBXTYPE_RAR 3
#define CBXTYPE_CBR 4
#define CBX_APP_KEY _T("Software\\T800 Productions\\{9E6ECB90-5A61-42BD-B851-D3297D9C7F39}")
namespace __cbx {
// unused
//template <class T> class CBuffer
//{
//public:
// CBuffer(){m_buf=NULL;}
// virtual ~CBuffer(){ ::CoTaskMemFree(m_buf); m_buf=NULL;}
//public:
// T* Allocate(SIZE_T s, BOOL bAutozero=FALSE)
// {
// m_buf=::CoTaskMemAlloc(s*sizeof(T));//COM compatible //'new' throws
// if (m_buf && bAutozero) SecureZeroMemory(m_buf, s*sizeof(T));
// return (T*)m_buf;
// }
// operator LPVOID () {return m_buf;}
// operator T* () {return (T*)m_buf;}
//private:
// LPVOID m_buf;
//};
//typedef CBuffer<BYTE> CByteBuffer;
class CUnzip
{
public:
CUnzip() { hz=NULL; }
virtual ~CUnzip(){::CloseZip(hz);}
public:
bool Open(LPCTSTR zfile)
{
if (zfile==NULL) return false;
HZIP temp_hz=::OpenZip(zfile, NULL);//try new
if (temp_hz==NULL) return false;
Close();//close old
hz=temp_hz;
if (ZR_OK!=::GetZipItem(hz,-1, &maindirEntry)) return false;
return true;
}
bool GetItem(int zi)
{
zr=::GetZipItem(hz, zi, &ZipEntry);
return (ZR_OK==zr);
}
bool UnzipItemToMembuffer(int index, void *z,unsigned int len)
{
zr=::UnzipItem(hz, index, z, len);
return (ZR_OK==zr);
}
void Close()
{
CloseZip(hz);
hz=NULL;//critical!
}
inline BOOL ItemIsDirectory() {return (BOOL)(CUnzip::GetItemAttributes() & 0x0010);}
int GetItemCount() const {return maindirEntry.index;}
long GetItemPackedSize() const {return ZipEntry.comp_size;}
long GetItemUnpackedSize() const {return ZipEntry.unc_size;}
DWORD GetItemAttributes() const {return ZipEntry.attr;}
LPCTSTR GetItemName() {return ZipEntry.name;}
private:
ZIPENTRY ZipEntry, maindirEntry;
HZIP hz;
ZRESULT zr;
};
// unrar wrapper
typedef const RARHeaderDataEx* LPCRARHeaderDataEx;
typedef const RAROpenArchiveDataEx* LPCRAROpenArchiveDataEx;
class CUnRar
{
public:
CUnRar() { if (RAR_DLL_VERSION>RARGetDllVersion()) throw RAR_DLL_VERSION; _init(); }
virtual ~CUnRar(){Close();_init();}
public:
BOOL Open(LPCTSTR rarfile, BOOL bListingOnly=TRUE, char* cmtBuf=NULL, UINT cmtBufSize=0, char* password=NULL)
{
if (m_harc) return FALSE;//must close old first
SecureZeroMemory(&m_arcinfo, sizeof(RAROpenArchiveDataEx));
#ifndef UNICODE
m_arcinfo.ArcName=(PTCHAR)rarfile;
#else
m_arcinfo.ArcNameW=(PTCHAR)rarfile;
#endif
m_arcinfo.OpenMode=bListingOnly ? RAR_OM_LIST : RAR_OM_EXTRACT;
m_arcinfo.CmtBuf=cmtBuf;
m_arcinfo.CmtBufSize=cmtBufSize;
m_harc=RAROpenArchiveEx(&m_arcinfo);
if (m_harc==NULL || m_arcinfo.OpenResult!=0) return FALSE;
if (password) RARSetPassword(m_harc,password);
RARSetCallback(m_harc, __rarCallbackProc, (LPARAM)this);
return TRUE;
}
BOOL Close() { if (m_harc) m_ret=RARCloseArchive(m_harc); return (m_ret!=0);}
inline LPCRAROpenArchiveDataEx GetArchiveInfo() {return &m_arcinfo;}
inline LPCRARHeaderDataEx GetItemInfo() {return &m_iteminfo;}
inline void SetPassword(char* password) {RARSetPassword(m_harc, password);}
inline int GetLastError() {return m_ret;}
//inline UINT GetArchiveFlags() {return m_arcinfo.Flags;}
//inline UINT GetItemFlags(){return m_iteminfo.Flags;}
inline BOOL IsArchiveVolume() {return (BOOL)(m_arcinfo.Flags & 0x0001);}
inline BOOL IsArchiveComment() {return (BOOL)(m_arcinfo.Flags & 0x0002);}
inline BOOL IsArchiveLocked() {return (BOOL)(m_arcinfo.Flags & 0x0004);}
inline BOOL IsArchiveSolid() {return (BOOL)(m_arcinfo.Flags & 0x0008);}
inline BOOL IsArchivePartN() {return (BOOL)(m_arcinfo.Flags & 0x0010);}
inline BOOL IsArchiveSigned() {return (BOOL)(m_arcinfo.Flags & 0x0020);}
inline BOOL IsArchiveRecoveryRecord() {return (BOOL)(m_arcinfo.Flags & 0x0040);}
inline BOOL IsArchiveEncryptedHeaders() {return (BOOL)(m_arcinfo.Flags & 0x0080);}
inline BOOL IsArchiveFirstVolume() {return (BOOL)(m_arcinfo.Flags & 0x0100);}
BOOL ReadItemInfo()
{
SecureZeroMemory(&m_iteminfo, sizeof(RARHeaderDataEx));
m_ret=RARReadHeaderEx(m_harc, &m_iteminfo);
return (m_ret==0);
}
inline BOOL IsItemDirectory() {return ((m_iteminfo.Flags & 0x00E0)==0x00E0);}
inline LPCTSTR GetItemName()
{
#ifdef UNICODE
return (LPCTSTR)(GetItemInfo()->FileNameW);
#else
return (LPCTSTR)CUnRar::GetItemInfo()->FileName;
#endif
}
//MAKEUINT64
inline UINT64 GetItemPackedSize64() {return ((((UINT64)m_iteminfo.PackSizeHigh)<<32) | m_iteminfo.PackSize);}
inline UINT64 GetItemUnpackedSize64() {return ((((UINT64)m_iteminfo.UnpSizeHigh)<<32) | m_iteminfo.UnpSize);}
virtual BOOL ProcessItem()
{
m_ret=RARProcessFileW(m_harc,RAR_TEST,NULL,NULL);
if (m_ret!=0) return FALSE;
return TRUE;
}
virtual BOOL SkipItem()
{
m_ret=RARProcessFile(m_harc,RAR_SKIP,NULL,NULL);
return (m_ret==0);
}
virtual BOOL SkipItems(UINT64 si)
{
UINT64 _i;//0 skips?
for (_i=0; _i<si; _i++) {if (!ReadItemInfo() || !SkipItem()) return FALSE;}
return TRUE;
}
virtual int CallbackProc(UINT msg, LPARAM UserData, LPARAM P1, LPARAM P2)
{
if (msg==UCM_PROCESSDATA) return ProcessItemData((LPBYTE)P1,(ULONG)P2);
return -1;
}
virtual int ProcessItemData(LPBYTE pBuf, ULONG dwBufSize)
{
if (m_pIs)
{
ULONG br=0;
if (S_OK==m_pIs->Write(pBuf, dwBufSize, &br))
if (br==dwBufSize) return 1;
}
return -1;
}
void SetIStream(IStream* pIs){_ASSERTE(pIs);m_pIs=pIs;}
private:
HANDLE m_harc;
RARHeaderDataEx m_iteminfo;
RAROpenArchiveDataEx m_arcinfo;
int m_ret;
IStream* m_pIs;
void _init()
{
m_harc=NULL;
m_pIs=NULL;
m_ret=0;
SecureZeroMemory(&m_arcinfo, sizeof(RAROpenArchiveDataEx));
SecureZeroMemory(&m_iteminfo, sizeof(RARHeaderDataEx));
}
//raw callback function
public:
static int PASCAL __rarCallbackProc(UINT msg,LPARAM UserData,LPARAM P1,LPARAM P2)
{
CUnRar* _pc=(CUnRar*)UserData;
return _pc->CallbackProc(msg,UserData,P1,P2);
}
};
class CCBXArchive
{
public:
CCBXArchive()
{
m_bSort=TRUE;//default
//GetRegSettings();
m_thumbSize.cx=m_thumbSize.cy=0;
m_cbxType=CBXTYPE_NONE;
m_pIs=NULL;
}
virtual ~CCBXArchive()
{
if (m_pIs) {m_pIs->Release(); m_pIs=NULL;}
}
public:
////////////////////////////////////////
// IPersistFile::Load
HRESULT OnLoad(LPCOLESTR wszFile)
{
//ATLTRACE("IPersistFile::Load\n");
#ifndef UNICODE
USES_CONVERSION;
m_cbxFile=OLE2T((WCHAR*)wszFile);
#else
m_cbxFile=wszFile;
#endif
m_cbxType=GetCBXType(PathFindExtension(m_cbxFile));
return S_OK;
}
////////////////////////////////////
// IExtractImage::GetLocation(LPWSTR pszPathBuffer, DWORD cchMax, DWORD *pdwPriority, const SIZE *prgSize, DWORD dwRecClrDepth, DWORD *pdwFlags)
HRESULT OnGetLocation(const SIZE *prgSize, DWORD *pdwFlags)
{
//ATLTRACE("IExtractImage2::GetLocation\n");
m_thumbSize.cx=prgSize->cx;
m_thumbSize.cy=prgSize->cy;
*pdwFlags |= (IEIFLAG_CACHE | IEIFLAG_REFRESH);//cache thumbnails
//if (*pdwFlags & IEIFLAG_ASYNC) return E_PENDING;//Windows XP and earlier
#ifdef _DEBUG
if (*pdwFlags & IEIFLAG_ASYNC) ATLTRACE("\nIExtractImage::GetLocation : IEIFLAG_ASYNC flag set\n");
#endif
return NOERROR;
}
////////////////////////////////////
// IExtractImage2::GetDateStamp(FILETIME *pDateStamp)
HRESULT OnGetDateStamp(FILETIME *pDateStamp)
{
//ATLTRACE("IExtractImage2::GetDateStamp\n");
FILETIME ftCreationTime, ftLastAccessTime, ftLastWriteTime;
CAtlFile _f;
if (S_OK!=_f.Create(m_cbxFile,GENERIC_READ,FILE_SHARE_READ,OPEN_EXISTING,0)) return E_FAIL;
//alternatively GetFileInformationByHandle?
if (!GetFileTime(_f, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime)) return E_FAIL;
*pDateStamp = ftLastWriteTime;
return NOERROR;
}
////////////////////////////////////
//IExtractImage::Extract(HBITMAP* phBmpThumbnail)
HRESULT OnExtract(HBITMAP* phBmpThumbnail)
{
*phBmpThumbnail=NULL;
//ATLTRACE("IExtractImage::Extract\n");
try {
switch (m_cbxType)
{
case CBXTYPE_ZIP:
case CBXTYPE_CBZ:
{
CUnzip _z;
if (!_z.Open(m_cbxFile)) return E_FAIL;
j=_z.GetItemCount();
if (j==0) return E_FAIL;
CString prevname;//helper vars
int thumbindex=-1;
for (i=0; i<j; i++)
{
if (!_z.GetItem(i)) break;
if (_z.ItemIsDirectory() || (_z.GetItemUnpackedSize() > CBXMEM_MAXBUFFER_SIZE)) continue;
if ((_z.GetItemPackedSize()==0) || (_z.GetItemUnpackedSize()==0)) continue;
if (IsImage(_z.GetItemName()))
{
if (thumbindex<0) thumbindex=i;// assign thumbindex if already sorted
if (!m_bSort) break;//if NoSort
if (prevname.IsEmpty()) prevname=_z.GetItemName();//can't compare empty string
//take only first alphabetical name
if (-1==StrCmpLogicalW(_z.GetItemName(), prevname))
{
thumbindex=i;
prevname=_z.GetItemName();
}
}
}//for loop
if (thumbindex<0) return E_FAIL;
//go to thumb index
if (!_z.GetItem(thumbindex)) return E_FAIL;
//create thumb //GHND
HGLOBAL hG = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (SIZE_T)_z.GetItemUnpackedSize());
if (hG)
{
bool b=false;
LPVOID pBuf=::GlobalLock(hG);
if (pBuf)
b=_z.UnzipItemToMembuffer(thumbindex, pBuf, _z.GetItemUnpackedSize());
if (::GlobalUnlock(hG)==0 && GetLastError()==NO_ERROR)
{
if (b)
{
IStream* pIs=NULL;
if (S_OK==CreateStreamOnHGlobal(hG, TRUE, (LPSTREAM*)&pIs))//autofree hG
{
*phBmpThumbnail= ThumbnailFromIStream(pIs, &m_thumbSize);
pIs->Release();
pIs=NULL;
}
}
}
//GlobalFree(hG);//autofreed
}
return ((*phBmpThumbnail) ? S_OK : E_FAIL);
}//dtors!
break;
case CBXTYPE_RAR:
case CBXTYPE_CBR:
{
CUnRar _r;
__int64 thumbindex=-1;
if (m_bSort)
{
thumbindex=FindThumbnailSortRAR(m_cbxFile);
if (thumbindex<0) return E_FAIL;
}
if (!_r.Open(m_cbxFile, FALSE)) return E_FAIL;
if (m_bSort)
{
//archive flags already checked, go to thumbindex
if (!_r.SkipItems(thumbindex)) return E_FAIL;
if (!_r.ReadItemInfo()) return E_FAIL;
}
else
{
//skip solid (long processing time), volumes or encrypted file headers
if (_r.IsArchiveSolid() || _r.IsArchiveVolume() || _r.IsArchiveEncryptedHeaders()) return E_FAIL;
while (_r.ReadItemInfo())
{
//skip directory/empty/ file bigger than 32mb
if (!(_r.IsItemDirectory() || (_r.GetItemPackedSize64()==0) ||
(_r.GetItemUnpackedSize64()==0) || (_r.GetItemUnpackedSize64() > CBXMEM_MAXBUFFER_SIZE)))
{
if (IsImage(_r.GetItemName())) {thumbindex=TRUE; break;}
}
_r.SkipItem();//don't forget
}
}//else
if (thumbindex<0) return E_FAIL;
//create thumb
IStream* pIs = NULL;
HGLOBAL hG = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (SIZE_T)_r.GetItemUnpackedSize64());
if (hG)
{
if (S_OK==CreateStreamOnHGlobal(hG, TRUE, (LPSTREAM*)&pIs))
{
_r.SetIStream(pIs);
if (_r.ProcessItem()) *phBmpThumbnail= ThumbnailFromIStream(pIs, &m_thumbSize);
}
}
GlobalFree(hG);
pIs->Release();
return ((*phBmpThumbnail) ? S_OK : E_FAIL );
}//dtors!
break;
default:return E_FAIL;
}
}
catch (...){ ATLTRACE("exception in IExtractImage::Extract\n"); return S_FALSE;}
return S_OK;
}
//////////////////////////////
//IQueryInfo::GetInfoTip(DWORD dwFlags, LPWSTR *ppwszTip)
HRESULT OnGetInfoTip(LPWSTR *ppwszTip)
{
//ATLTRACE("IQueryInfo::GetInfoTip\n");
try
{
CString tip;
__int64 _fs;
if (!GetFileSizeCrt(m_cbxFile, _fs)) return E_FAIL;
TCHAR _tf[16];// SecureZeroMemory?
switch (m_cbxType)
{
case CBXTYPE_ZIP:
if (_fs==0) tip=_T("ZIP Archive\nSize: 0 bytes");
else
{
if (GetImageCountZIP(m_cbxFile, i,j))
tip.Format(_T("ZIP Archive\n%d Images\n%d Files\nSize: %s"),
i, j, StrFormatByteSize64(_fs, _tf, 16));
else tip.Format(_T("ZIP Archive\nSize: %s"), StrFormatByteSize64(_fs, _tf, 16));
}
break;
case CBXTYPE_CBZ:
if (_fs==0) tip=_T("ZIP Image Archive\nSize: 0 bytes");
else
{
if (GetImageCountZIP(m_cbxFile, i,j))
tip.Format(_T("ZIP Image Archive\n%d Images\n%d Files\nSize: %s"),
i, j, StrFormatByteSize64(_fs, _tf, 16));
else tip.Format(_T("ZIP Image Archive\nSize: %s"), StrFormatByteSize64(_fs, _tf, 16));
}
break;
case CBXTYPE_RAR:
if (_fs==0) tip=_T("RAR Archive\nSize: 0 bytes");
else
{
if (GetImageCountRAR(m_cbxFile, i,j))
tip.Format(_T("RAR Archive\n%d Images\n%d Files\nSize: %s"),
i, j, StrFormatByteSize64(_fs, _tf, 16));
else tip.Format(_T("RAR Archive\nSize: %s"), StrFormatByteSize64(_fs, _tf, 16));
}
break;
case CBXTYPE_CBR:
if (_fs==0) tip=_T("RAR Image Archive\nSize: 0 bytes");
else
{
if (GetImageCountRAR(m_cbxFile, i,j))
tip.Format(_T("RAR Image Archive\n%d Images\n%d Files\nSize: %s"),
i, j, StrFormatByteSize64(_fs, _tf, 16));
else tip.Format(_T("RAR Image Archive\nSize: %s"), StrFormatByteSize64(_fs, _tf, 16));
}
break;
default: ATLTRACE("IQueryInfo::GetInfoTip : CBXTYPE_NONE\n");return E_FAIL;
}
*ppwszTip = (WCHAR*) ::CoTaskMemAlloc( (tip.GetLength()+1)*sizeof(WCHAR) );//caller must call CoTaskMemFree
if (*ppwszTip==NULL) return E_FAIL;
if (0!=::wcscpy_s(*ppwszTip, tip.GetLength()+1, tip)) return E_FAIL;
return S_OK;
}
catch (...){ ATLTRACE("exception in IQueryInfo::GetInfoTip\n"); return S_FALSE;}
return S_FALSE;
}
private:
CString m_cbxFile;//overcome MAX_PATH limit?
SIZE m_thumbSize;
int i,j;//helpers
CBXTYPE m_cbxType;
IStream* m_pIs;
BOOL m_bSort;
private:
inline BOOL GetFileSizeCrt(LPCTSTR pszFile, __int64 &fsize)
{
_stat64 _s;
_s.st_size=0;
if (0!=::_tstat64(pszFile, &_s)) return FALSE;
fsize=_s.st_size;
return TRUE;
}
inline BOOL StrEqual(LPCTSTR psz1,LPCTSTR psz2) {return (::StrCmpI(psz1, psz2)==0);}
BOOL IsImage(LPCTSTR szFile)
{
LPWSTR _e=PathFindExtension(szFile);
if (StrEqual(_e, _T(".bmp"))) return TRUE;
if (StrEqual(_e, _T(".ico"))) return TRUE;
if (StrEqual(_e, _T(".gif"))) return TRUE;
if (StrEqual(_e, _T(".jpg"))) return TRUE;
if (StrEqual(_e, _T(".jpe"))) return TRUE;
if (StrEqual(_e, _T(".jfif"))) return TRUE;
if (StrEqual(_e, _T(".jpeg"))) return TRUE;
if (StrEqual(_e, _T(".png"))) return TRUE;
if (StrEqual(_e, _T(".tif"))) return TRUE;
if (StrEqual(_e, _T(".tiff"))) return TRUE;
return FALSE;
}
inline CBXTYPE GetCBXType(LPCTSTR szExt)
{
if (StrEqual(szExt, _T(".cbz"))) return CBXTYPE_CBZ;
if (StrEqual(szExt, _T(".zip"))) return CBXTYPE_ZIP;
if (StrEqual(szExt, _T(".cbr"))) return CBXTYPE_CBR;
if (StrEqual(szExt, _T(".rar"))) return CBXTYPE_RAR;
//by popular demand
if (StrEqual(szExt, _T(".epub"))) return CBXTYPE_CBZ;
if (StrEqual(szExt, _T(".phz"))) return CBXTYPE_CBZ;
return CBXTYPE_NONE;
}
BOOL GetImageCountZIP(LPCTSTR cbzFile, int &imagecount, int &filecount)
{
imagecount=0;
filecount=0;
CUnzip _z;
if (!_z.Open(cbzFile)) return FALSE;
//empty zip is still valid
if (_z.GetItemCount()==0) return TRUE;
int _i;
for (_i=0; _i<_z.GetItemCount(); _i++)
{
if (!_z.GetItem(_i)) return FALSE;
//skip dirs
if (_z.ItemIsDirectory()) continue;
if (IsImage(_z.GetItemName())) imagecount+=1;
filecount+=1;
}
return TRUE;
}
BOOL GetImageCountRAR(LPCTSTR cbrFile, int &imagecount, int &filecount)
{
imagecount=0;
filecount=0;
CUnRar cr;
if (!cr.Open(cbrFile)) return FALSE;
//enum solid / skip volumes or encrypted file header archives
if (cr.IsArchiveVolume() || cr.IsArchiveEncryptedHeaders()) return FALSE;
while (cr.ReadItemInfo())
{
//skip dirs
if (!cr.IsItemDirectory())
{
if (IsImage(cr.GetItemName())) imagecount+=1;
filecount+=1;
}
if (!cr.SkipItem()) return FALSE;
}
return TRUE;
}
HBITMAP ThumbnailFromIStream(IStream* pIs, const LPSIZE pThumbSize)
{
ATLASSERT(pIs);
CImage ci;//uses gdi+ internally
if (S_OK!=ci.Load(pIs)) return NULL;
//check size
int tw=ci.GetWidth();
int th=ci.GetHeight();
float rx=(float)pThumbSize->cx/(float)tw;
float ry=(float)pThumbSize->cy/(float)th;
//if bigger size
if ((rx<1) || (ry<1))
{
CDC hdcNew=::CreateCompatibleDC(NULL);
if (hdcNew.IsNull()) return NULL;
hdcNew.SetStretchBltMode(HALFTONE);
hdcNew.SetBrushOrg(0,0, NULL);
//variables retain values until assignment
tw=(int)(min(rx,ry)*tw);//C424 warning workaround
th=(int)(min(rx,ry)*th);
CBitmap hbmpNew;
hbmpNew.CreateCompatibleBitmap(ci.GetDC(), tw,th);
ci.ReleaseDC();//don't forget!
if (hbmpNew.IsNull()) return NULL;
HBITMAP hbmpOld=hdcNew.SelectBitmap(hbmpNew);
hdcNew.FillSolidRect(0,0, tw,th, RGB(255,255,255));//white background
ci.Draw(hdcNew, 0,0, tw,th, 0,0, ci.GetWidth(),ci.GetHeight());//too late for error checks
hdcNew.SelectBitmap(hbmpOld);
return hbmpNew.Detach();
}
return ci.Detach();
}
////unused
//HBITMAP ThumbnailFromBuffer(LPCBYTE pBuf, const ULONG dwBufSize, const LPSIZE pThumbSize)
//{
// HBITMAP hBmp = NULL;
// IStream* pIs = NULL;
// HGLOBAL hG = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, dwBufSize);
// if (hG)
// {
// if (S_OK==CreateStreamOnHGlobal(hG, TRUE, (LPSTREAM*)&pIs))
// {
// ULONG br;
// if (S_OK==pIs->Write(pBuf, dwBufSize, &br))//transfer buffer data
// {
// if (br==dwBufSize) hBmp=ThumbnailFromIStream(pIs, pThumbSize);
// }
// }
// }
// GlobalFree(hG);
// pIs->Release();
//return hBmp;
//}
__int64 FindThumbnailSortRAR(LPCTSTR pszFile)
{
CUnRar _r;
if (!_r.Open(pszFile)) return -1;
//skip solid (long processing time), volumes or encrypted file headers
if (_r.IsArchiveSolid() || _r.IsArchiveVolume() || _r.IsArchiveEncryptedHeaders()) return -1;
UINT64 _ps,_us;//my speed optimization?
CString prevname;
__int64 thumbindex=-1;
__int64 i=-1;//start at none (-1)
while (_r.ReadItemInfo())
{
i+=1;
_ps=_r.GetItemPackedSize64();
_us=_r.GetItemUnpackedSize64();
//skip directory/emtpy file/bigger than 32mb
if (_r.IsItemDirectory() || (_us>CBXMEM_MAXBUFFER_SIZE) || (_ps==0) || (_us==0))
{_r.SkipItem();continue;}
//take only index of first alphabetical name
if (IsImage(_r.GetItemName()))
{
//can't compare empty string
if (prevname.IsEmpty()) prevname=_r.GetItemName();
if (thumbindex<0) thumbindex=i;// assign thumbindex if already sorted
//sort by name
if (-1==StrCmpLogicalW(_r.GetItemName(), prevname))
{
thumbindex=i;
prevname=_r.GetItemName();
}
}
_r.SkipItem();//don't forget
}
return thumbindex;
}
public:
void LoadRegistrySettings()
{
DWORD _d;
CRegKey _rk;
if (ERROR_SUCCESS==_rk.Open(HKEY_CURRENT_USER, CBX_APP_KEY, KEY_READ))
{
if (ERROR_SUCCESS==_rk.QueryDWORDValue(_T("NoSort"), _d))
m_bSort=(_d==FALSE);
}
}
#ifdef _DEBUG
public:
void debug_SetSort(BOOL bS=TRUE) {m_bSort=bS;}
#endif
};//class _CCBXArchive
}//namespace __cbx
#endif//_CBXARCHIVE_442B998D_B9C0_4AB0_BB2A_BC9C0AA10053_

View file

@ -1 +1,7 @@
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
#define IDR_CBXShell 102
#define IDS_PROJNAME 40000
#define IDS_CBXSHELL_DESC 40001

11
CBXShell/targetver.h Normal file
View file

@ -0,0 +1,11 @@
#ifndef _TARGETVER_E445D0B7_6F75_4678_BE5E_274C8455B5A4_
#define _TARGETVER_E445D0B7_6F75_4678_BE5E_274C8455B5A4_
//#define WINVER 0x0500
#define _WIN32_WINNT _WIN32_WINNT_WINXP
//#define _WIN32_IE _WIN32_IE_IE55 // StrCmpLogicalW needs 5.5 min
//#define _RICHEDIT_VER 0x0200
#endif//_TARGETVER_E445D0B7_6F75_4678_BE5E_274C8455B5A4_

146
CBXShell/unrar.h Normal file
View file

@ -0,0 +1,146 @@
#ifndef _UNRAR_DLL_
#define _UNRAR_DLL_
#pragma pack(1)
#define ERAR_END_ARCHIVE 10
#define ERAR_NO_MEMORY 11
#define ERAR_BAD_DATA 12
#define ERAR_BAD_ARCHIVE 13
#define ERAR_UNKNOWN_FORMAT 14
#define ERAR_EOPEN 15
#define ERAR_ECREATE 16
#define ERAR_ECLOSE 17
#define ERAR_EREAD 18
#define ERAR_EWRITE 19
#define ERAR_SMALL_BUF 20
#define ERAR_UNKNOWN 21
#define ERAR_MISSING_PASSWORD 22
#define RAR_OM_LIST 0
#define RAR_OM_EXTRACT 1
#define RAR_OM_LIST_INCSPLIT 2
#define RAR_SKIP 0
#define RAR_TEST 1
#define RAR_EXTRACT 2
#define RAR_VOL_ASK 0
#define RAR_VOL_NOTIFY 1
#define RAR_DLL_VERSION 5
#ifdef _UNIX
#define CALLBACK
#define PASCAL
#define LONG long
#define HANDLE void *
#define LPARAM long
#define UINT unsigned int
#endif
struct RARHeaderData
{
char ArcName[260];
char FileName[260];
unsigned int Flags;
unsigned int PackSize;
unsigned int UnpSize;
unsigned int HostOS;
unsigned int FileCRC;
unsigned int FileTime;
unsigned int UnpVer;
unsigned int Method;
unsigned int FileAttr;
char *CmtBuf;
unsigned int CmtBufSize;
unsigned int CmtSize;
unsigned int CmtState;
};
struct RARHeaderDataEx
{
char ArcName[1024];
wchar_t ArcNameW[1024];
char FileName[1024];
wchar_t FileNameW[1024];
unsigned int Flags;
unsigned int PackSize;
unsigned int PackSizeHigh;
unsigned int UnpSize;
unsigned int UnpSizeHigh;
unsigned int HostOS;
unsigned int FileCRC;
unsigned int FileTime;
unsigned int UnpVer;
unsigned int Method;
unsigned int FileAttr;
char *CmtBuf;
unsigned int CmtBufSize;
unsigned int CmtSize;
unsigned int CmtState;
unsigned int Reserved[1024];
};
struct RAROpenArchiveData
{
char *ArcName;
unsigned int OpenMode;
unsigned int OpenResult;
char *CmtBuf;
unsigned int CmtBufSize;
unsigned int CmtSize;
unsigned int CmtState;
};
typedef int (CALLBACK *UNRARCALLBACK)(UINT msg,LPARAM UserData,LPARAM P1,LPARAM P2);
struct RAROpenArchiveDataEx
{
char *ArcName;
wchar_t *ArcNameW;
unsigned int OpenMode;
unsigned int OpenResult;
char *CmtBuf;
unsigned int CmtBufSize;
unsigned int CmtSize;
unsigned int CmtState;
unsigned int Flags;
UNRARCALLBACK Callback;
LPARAM UserData;
unsigned int Reserved[28];
};
enum UNRARCALLBACK_MESSAGES {
UCM_CHANGEVOLUME,UCM_PROCESSDATA,UCM_NEEDPASSWORD
};
typedef int (PASCAL *CHANGEVOLPROC)(char *ArcName,int Mode);
typedef int (PASCAL *PROCESSDATAPROC)(unsigned char *Addr,int Size);
#ifdef __cplusplus
extern "C" {
#endif
HANDLE PASCAL RAROpenArchive(struct RAROpenArchiveData *ArchiveData);
HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *ArchiveData);
int PASCAL RARCloseArchive(HANDLE hArcData);
int PASCAL RARReadHeader(HANDLE hArcData,struct RARHeaderData *HeaderData);
int PASCAL RARReadHeaderEx(HANDLE hArcData,struct RARHeaderDataEx *HeaderData);
int PASCAL RARProcessFile(HANDLE hArcData,int Operation,char *DestPath,char *DestName);
int PASCAL RARProcessFileW(HANDLE hArcData,int Operation,wchar_t *DestPath,wchar_t *DestName);
void PASCAL RARSetCallback(HANDLE hArcData,UNRARCALLBACK Callback,LPARAM UserData);
void PASCAL RARSetChangeVolProc(HANDLE hArcData,CHANGEVOLPROC ChangeVolProc);
void PASCAL RARSetProcessDataProc(HANDLE hArcData,PROCESSDATAPROC ProcessDataProc);
void PASCAL RARSetPassword(HANDLE hArcData,char *Password);
int PASCAL RARGetDllVersion();
#ifdef __cplusplus
}
#endif
#pragma pack()
#endif

BIN
CBXShell/unrar.lib Normal file

Binary file not shown.

BIN
CBXShell/unrar64.lib Normal file

Binary file not shown.

4329
CBXShell/unzip.cpp Normal file

File diff suppressed because it is too large Load diff

226
CBXShell/unzip.h Normal file
View file

@ -0,0 +1,226 @@
#ifndef _unzip_H
#define _unzip_H
//
#ifdef ZIP_STD
#include <time.h>
#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
#ifndef MAX_PATH
#define MAX_PATH 1024
#endif
typedef unsigned long DWORD;
typedef char TCHAR;
typedef FILE* HANDLE;
typedef time_t FILETIME;
#endif
// UNZIPPING functions -- for unzipping.
// This file is a repackaged form of extracts from the zlib code available
// at www.gzip.org/zlib, by Jean-Loup Gailly and Mark Adler. The original
// copyright notice may be found in unzip.cpp. The repackaging was done
// by Lucian Wischik to simplify and extend its use in Windows/C++. Also
// encryption and unicode filenames have been added.
#ifndef _zip_H
DECLARE_HANDLE(HZIP);
#endif
// An HZIP identifies a zip file that has been opened
typedef DWORD ZRESULT;
// return codes from any of the zip functions. Listed later.
typedef struct
{ int index; // index of this file within the zip
TCHAR name[MAX_PATH]; // filename within the zip
DWORD attr; // attributes, as in GetFileAttributes.
FILETIME atime,ctime,mtime;// access, create, modify filetimes
long comp_size; // sizes of item, compressed and uncompressed. These
long unc_size; // may be -1 if not yet known (e.g. being streamed in)
} ZIPENTRY;
HZIP OpenZip(const TCHAR *fn, const char *password);
HZIP OpenZip(void *z,unsigned int len, const char *password);
HZIP OpenZipHandle(HANDLE h, const char *password);
// OpenZip - opens a zip file and returns a handle with which you can
// subsequently examine its contents. You can open a zip file from:
// from a pipe: OpenZipHandle(hpipe_read,0);
// from a file (by handle): OpenZipHandle(hfile,0);
// from a file (by name): OpenZip("c:\\test.zip","password");
// from a memory block: OpenZip(bufstart, buflen,0);
// If the file is opened through a pipe, then items may only be
// accessed in increasing order, and an item may only be unzipped once,
// although GetZipItem can be called immediately before and after unzipping
// it. If it's opened in any other way, then full random access is possible.
// Note: pipe input is not yet implemented.
// Note: zip passwords are ascii, not unicode.
// Note: for windows-ce, you cannot close the handle until after CloseZip.
// but for real windows, the zip makes its own copy of your handle, so you
// can close yours anytime.
ZRESULT GetZipItem(HZIP hz, int index, ZIPENTRY *ze);
// GetZipItem - call this to get information about an item in the zip.
// If index is -1 and the file wasn't opened through a pipe,
// then it returns information about the whole zipfile
// (and in particular ze.index returns the number of index items).
// Note: the item might be a directory (ze.attr & FILE_ATTRIBUTE_DIRECTORY)
// See below for notes on what happens when you unzip such an item.
// Note: if you are opening the zip through a pipe, then random access
// is not possible and GetZipItem(-1) fails and you can't discover the number
// of items except by calling GetZipItem on each one of them in turn,
// starting at 0, until eventually the call fails. Also, in the event that
// you are opening through a pipe and the zip was itself created into a pipe,
// then then comp_size and sometimes unc_size as well may not be known until
// after the item has been unzipped.
ZRESULT FindZipItem(HZIP hz, const TCHAR *name, bool ic, int *index, ZIPENTRY *ze);
// FindZipItem - finds an item by name. ic means 'insensitive to case'.
// It returns the index of the item, and returns information about it.
// If nothing was found, then index is set to -1 and the function returns
// an error code.
ZRESULT UnzipItem(HZIP hz, int index, const TCHAR *fn);
ZRESULT UnzipItem(HZIP hz, int index, void *z,unsigned int len);
ZRESULT UnzipItemHandle(HZIP hz, int index, HANDLE h);
// UnzipItem - given an index to an item, unzips it. You can unzip to:
// to a pipe: UnzipItemHandle(hz,i, hpipe_write);
// to a file (by handle): UnzipItemHandle(hz,i, hfile);
// to a file (by name): UnzipItem(hz,i, ze.name);
// to a memory block: UnzipItem(hz,i, buf,buflen);
// In the final case, if the buffer isn't large enough to hold it all,
// then the return code indicates that more is yet to come. If it was
// large enough, and you want to know precisely how big, GetZipItem.
// Note: zip files are normally stored with relative pathnames. If you
// unzip with ZIP_FILENAME a relative pathname then the item gets created
// relative to the current directory - it first ensures that all necessary
// subdirectories have been created. Also, the item may itself be a directory.
// If you unzip a directory with ZIP_FILENAME, then the directory gets created.
// If you unzip it to a handle or a memory block, then nothing gets created
// and it emits 0 bytes.
ZRESULT SetUnzipBaseDir(HZIP hz, const TCHAR *dir);
// if unzipping to a filename, and it's a relative filename, then it will be relative to here.
// (defaults to current-directory).
ZRESULT CloseZip(HZIP hz);
// CloseZip - the zip handle must be closed with this function.
unsigned int FormatZipMessage(ZRESULT code, TCHAR *buf,unsigned int len);
// FormatZipMessage - given an error code, formats it as a string.
// It returns the length of the error message. If buf/len points
// to a real buffer, then it also writes as much as possible into there.
// These are the result codes:
#define ZR_OK 0x00000000 // nb. the pseudo-code zr-recent is never returned,
#define ZR_RECENT 0x00000001 // but can be passed to FormatZipMessage.
// The following come from general system stuff (e.g. files not openable)
#define ZR_GENMASK 0x0000FF00
#define ZR_NODUPH 0x00000100 // couldn't duplicate the handle
#define ZR_NOFILE 0x00000200 // couldn't create/open the file
#define ZR_NOALLOC 0x00000300 // failed to allocate some resource
#define ZR_WRITE 0x00000400 // a general error writing to the file
#define ZR_NOTFOUND 0x00000500 // couldn't find that file in the zip
#define ZR_MORE 0x00000600 // there's still more data to be unzipped
#define ZR_CORRUPT 0x00000700 // the zipfile is corrupt or not a zipfile
#define ZR_READ 0x00000800 // a general error reading the file
#define ZR_PASSWORD 0x00001000 // we didn't get the right password to unzip the file
// The following come from mistakes on the part of the caller
#define ZR_CALLERMASK 0x00FF0000
#define ZR_ARGS 0x00010000 // general mistake with the arguments
#define ZR_NOTMMAP 0x00020000 // tried to ZipGetMemory, but that only works on mmap zipfiles, which yours wasn't
#define ZR_MEMSIZE 0x00030000 // the memory size is too small
#define ZR_FAILED 0x00040000 // the thing was already failed when you called this function
#define ZR_ENDED 0x00050000 // the zip creation has already been closed
#define ZR_MISSIZE 0x00060000 // the indicated input file size turned out mistaken
#define ZR_PARTIALUNZ 0x00070000 // the file had already been partially unzipped
#define ZR_ZMODE 0x00080000 // tried to mix creating/opening a zip
// The following come from bugs within the zip library itself
#define ZR_BUGMASK 0xFF000000
#define ZR_NOTINITED 0x01000000 // initialisation didn't work
#define ZR_SEEK 0x02000000 // trying to seek in an unseekable file
#define ZR_NOCHANGE 0x04000000 // changed its mind on storage, but not allowed
#define ZR_FLATE 0x05000000 // an internal error in the de/inflation code
// e.g.
//
// SetCurrentDirectory("c:\\docs\\stuff");
// HZIP hz = OpenZip("c:\\stuff.zip",0);
// ZIPENTRY ze; GetZipItem(hz,-1,&ze); int numitems=ze.index;
// for (int i=0; i<numitems; i++)
// { GetZipItem(hz,i,&ze);
// UnzipItem(hz,i,ze.name);
// }
// CloseZip(hz);
//
//
// HRSRC hrsrc = FindResource(hInstance,MAKEINTRESOURCE(1),RT_RCDATA);
// HANDLE hglob = LoadResource(hInstance,hrsrc);
// void *zipbuf=LockResource(hglob);
// unsigned int ziplen=SizeofResource(hInstance,hrsrc);
// HZIP hz = OpenZip(zipbuf, ziplen, 0);
// - unzip to a membuffer -
// ZIPENTRY ze; int i; FindZipItem(hz,"file.dat",true,&i,&ze);
// char *ibuf = new char[ze.unc_size];
// UnzipItem(hz,i, ibuf, ze.unc_size);
// delete[] ibuf;
// - unzip to a fixed membuff -
// ZIPENTRY ze; int i; FindZipItem(hz,"file.dat",true,&i,&ze);
// char ibuf[1024]; ZRESULT zr=ZR_MORE; unsigned long totsize=0;
// while (zr==ZR_MORE)
// { zr = UnzipItem(hz,i, ibuf,1024);
// unsigned long bufsize=1024; if (zr==ZR_OK) bufsize=ze.unc_size-totsize;
// totsize+=bufsize;
// }
// - unzip to a pipe -
// HANDLE hwrite; HANDLE hthread=CreateWavReaderThread(&hwrite);
// int i; ZIPENTRY ze; FindZipItem(hz,"sound.wav",true,&i,&ze);
// UnzipItemHandle(hz,i, hwrite);
// CloseHandle(hwrite);
// WaitForSingleObject(hthread,INFINITE);
// CloseHandle(hwrite); CloseHandle(hthread);
// - finished -
// CloseZip(hz);
// // note: no need to free resources obtained through Find/Load/LockResource
//
//
// SetCurrentDirectory("c:\\docs\\pipedzipstuff");
// HANDLE hread,hwrite; CreatePipe(&hread,&hwrite,0,0);
// CreateZipWriterThread(hwrite);
// HZIP hz = OpenZipHandle(hread,0);
// for (int i=0; ; i++)
// { ZIPENTRY ze;
// ZRESULT zr=GetZipItem(hz,i,&ze); if (zr!=ZR_OK) break; // no more
// UnzipItem(hz,i, ze.name);
// }
// CloseZip(hz);
//
//
// Now we indulge in a little skullduggery so that the code works whether
// the user has included just zip or both zip and unzip.
// Idea: if header files for both zip and unzip are present, then presumably
// the cpp files for zip and unzip are both present, so we will call
// one or the other of them based on a dynamic choice. If the header file
// for only one is present, then we will bind to that particular one.
ZRESULT CloseZipU(HZIP hz);
unsigned int FormatZipMessageU(ZRESULT code, TCHAR *buf,unsigned int len);
bool IsZipHandleU(HZIP hz);
#ifdef _zip_H
#undef CloseZip
#define CloseZip(hz) (IsZipHandleU(hz)?CloseZipU(hz):CloseZipZ(hz))
#else
#define CloseZip CloseZipU
#define FormatZipMessage FormatZipMessageU
#endif
#endif // _unzip_H