Home | History | Annotate | Download | only in Archive
      1 // DLLExports2.cpp
      2 
      3 #include "StdAfx.h"
      4 
      5 #include "../../Common/MyWindows.h"
      6 
      7 #include "../../Common/MyInitGuid.h"
      8 
      9 #if defined(_7ZIP_LARGE_PAGES)
     10 #include "../../../C/Alloc.h"
     11 #endif
     12 
     13 #include "../../Common/ComTry.h"
     14 
     15 #include "../../Windows/NtCheck.h"
     16 #include "../../Windows/PropVariant.h"
     17 
     18 #include "../ICoder.h"
     19 #include "../IPassword.h"
     20 
     21 #include "../Common/CreateCoder.h"
     22 
     23 #include "IArchive.h"
     24 
     25 HINSTANCE g_hInstance;
     26 
     27 #define NT_CHECK_FAIL_ACTION return FALSE;
     28 
     29 #ifdef _WIN32
     30 extern "C"
     31 BOOL WINAPI DllMain(
     32   #ifdef UNDER_CE
     33   HANDLE
     34   #else
     35   HINSTANCE
     36   #endif
     37   hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
     38 {
     39   if (dwReason == DLL_PROCESS_ATTACH)
     40   {
     41     // OutputDebugStringA("7z.dll DLL_PROCESS_ATTACH");
     42     g_hInstance = (HINSTANCE)hInstance;
     43     NT_CHECK;
     44   }
     45   /*
     46   if (dwReason == DLL_PROCESS_DETACH)
     47   {
     48     OutputDebugStringA("7z.dll DLL_PROCESS_DETACH");
     49   }
     50   */
     51   return TRUE;
     52 }
     53 #endif
     54 
     55 DEFINE_GUID(CLSID_CArchiveHandler,
     56     k_7zip_GUID_Data1,
     57     k_7zip_GUID_Data2,
     58     k_7zip_GUID_Data3_Common,
     59     0x10, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00);
     60 
     61 STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject);
     62 STDAPI CreateHasher(const GUID *clsid, IHasher **hasher);
     63 STDAPI CreateArchiver(const GUID *clsid, const GUID *iid, void **outObject);
     64 
     65 STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
     66 {
     67   // COM_TRY_BEGIN
     68   *outObject = 0;
     69   if (*iid == IID_ICompressCoder ||
     70       *iid == IID_ICompressCoder2 ||
     71       *iid == IID_ICompressFilter)
     72     return CreateCoder(clsid, iid, outObject);
     73   if (*iid == IID_IHasher)
     74     return CreateHasher(clsid, (IHasher **)outObject);
     75   return CreateArchiver(clsid, iid, outObject);
     76   // COM_TRY_END
     77 }
     78 
     79 STDAPI SetLargePageMode()
     80 {
     81   #if defined(_7ZIP_LARGE_PAGES)
     82   SetLargePageSize();
     83   #endif
     84   return S_OK;
     85 }
     86 
     87 extern bool g_CaseSensitive;
     88 
     89 STDAPI SetCaseSensitive(Int32 caseSensitive)
     90 {
     91   g_CaseSensitive = (caseSensitive != 0);
     92   return S_OK;
     93 }
     94 
     95 #ifdef EXTERNAL_CODECS
     96 
     97 CExternalCodecs g_ExternalCodecs;
     98 
     99 STDAPI SetCodecs(ICompressCodecsInfo *compressCodecsInfo)
    100 {
    101   COM_TRY_BEGIN
    102 
    103   // OutputDebugStringA(compressCodecsInfo ? "SetCodecs" : "SetCodecs NULL");
    104   if (compressCodecsInfo)
    105   {
    106     g_ExternalCodecs.GetCodecs = compressCodecsInfo;
    107     return g_ExternalCodecs.Load();
    108   }
    109   g_ExternalCodecs.ClearAndRelease();
    110   return S_OK;
    111 
    112   COM_TRY_END
    113 }
    114 
    115 #else
    116 
    117 STDAPI SetCodecs(ICompressCodecsInfo *)
    118 {
    119   return S_OK;
    120 }
    121 
    122 #endif
    123