From d9666cf046a8453b33b3e2fbf4d82295a9f87df3 Mon Sep 17 00:00:00 2001 From: Igor Pavlov Date: Sat, 20 Jan 2007 00:00:00 +0000 Subject: 4.44 beta --- CPP/7zip/Archive/Zip/DllExports.cpp | 152 ++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100755 CPP/7zip/Archive/Zip/DllExports.cpp (limited to 'CPP/7zip/Archive/Zip/DllExports.cpp') diff --git a/CPP/7zip/Archive/Zip/DllExports.cpp b/CPP/7zip/Archive/Zip/DllExports.cpp new file mode 100755 index 00000000..da2a15a4 --- /dev/null +++ b/CPP/7zip/Archive/Zip/DllExports.cpp @@ -0,0 +1,152 @@ +// DLLExports.cpp + +#include "StdAfx.h" + +#include "Common/MyInitGuid.h" +#include "Common/ComTry.h" +#include "ZipHandler.h" +#include "Windows/PropVariant.h" +#include "../../ICoder.h" +#include "../../IPassword.h" +#include "../../Crypto/WzAES/WzAES.h" +#include "../Common/CodecsPath.h" + +// {23170F69-40C1-278B-0401-080000000100} +DEFINE_GUID(CLSID_CCompressDeflateEncoder, +0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00); + +// {23170F69-40C1-278B-0401-080000000000} +DEFINE_GUID(CLSID_CCompressDeflateDecoder, +0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00); + +// {23170F69-40C1-278B-0401-090000000100} +DEFINE_GUID(CLSID_CCompressDeflate64Encoder, +0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x09, 0x00, 0x00, 0x00, 0x01, 0x00); + +// {23170F69-40C1-278B-0401-090000000000} +DEFINE_GUID(CLSID_CCompressDeflate64Decoder, +0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00); + +// {23170F69-40C1-278B-0402-020000000100} +DEFINE_GUID(CLSID_CCompressBZip2Encoder, +0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00); + +// {23170F69-40C1-278B-0402-020000000000} +DEFINE_GUID(CLSID_CCompressBZip2Decoder, +0x23170F69, 0x40C1, 0x278B, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00); + +// {23170F69-40C1-278B-0401-060000000000} +DEFINE_GUID(CLSID_CCompressImplodeDecoder, +0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00); + +// {23170F69-40C1-278B-06F1-0101000000100} +DEFINE_GUID(CLSID_CCryptoZipEncoder, +0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00); + +// {23170F69-40C1-278B-06F1-0101000000000} +DEFINE_GUID(CLSID_CCryptoZipDecoder, +0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00); + +// {23170F69-40C1-278A-1000-000110010000} +DEFINE_GUID(CLSID_CZipHandler, + 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x01, 0x00, 0x00); + +HINSTANCE g_hInstance; +#ifndef _UNICODE +bool g_IsNT = false; +static bool IsItWindowsNT() +{ + OSVERSIONINFO versionInfo; + versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); + if (!::GetVersionEx(&versionInfo)) + return false; + return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); +} +#endif + +void GetCryptoFolderPrefix(TCHAR *path) +{ + CSysString s = GetCodecsFolderPrefix(); + lstrcpy(path, s); +} + +extern "C" +BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) +{ + if (dwReason == DLL_PROCESS_ATTACH) + { + g_hInstance = hInstance; + #ifndef _UNICODE + g_IsNT = IsItWindowsNT(); + #endif + } + return TRUE; +} + + +STDAPI CreateObject( + const GUID *classID, + const GUID *interfaceID, + void **outObject) +{ + COM_TRY_BEGIN + *outObject = 0; + if (*classID != CLSID_CZipHandler) + return CLASS_E_CLASSNOTAVAILABLE; + int needIn = *interfaceID == IID_IInArchive; + int needOut = *interfaceID == IID_IOutArchive; + if (needIn || needOut) + { + NArchive::NZip::CHandler *temp = new NArchive::NZip::CHandler; + if (needIn) + { + CMyComPtr inArchive = (IInArchive *)temp; + *outObject = inArchive.Detach(); + } + else + { + CMyComPtr outArchive = (IOutArchive *)temp; + *outObject = outArchive.Detach(); + } + } + else + return E_NOINTERFACE; + COM_TRY_END + return S_OK; +} + +STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value) +{ + NWindows::NCOM::CPropVariant propVariant; + switch(propID) + { + case NArchive::kName: + propVariant = L"Zip"; + break; + case NArchive::kClassID: + { + if ((value->bstrVal = ::SysAllocStringByteLen( + (const char *)&CLSID_CZipHandler, sizeof(GUID))) != 0) + value->vt = VT_BSTR; + return S_OK; + } + case NArchive::kExtension: + propVariant = L"zip jar xpi"; + break; + case NArchive::kUpdate: + propVariant = true; + break; + case NArchive::kKeepName: + propVariant = false; + break; + case NArchive::kStartSignature: + { + const char sig[] = { 0x50, 0x4B, 0x03, 0x04 }; + if ((value->bstrVal = ::SysAllocStringByteLen(sig, 4)) != 0) + value->vt = VT_BSTR; + return S_OK; + } + } + propVariant.Detach(value); + return S_OK; +} -- cgit v1.2.3