1cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky// DLLExports2.cpp
2baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
3baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "StdAfx.h"
4baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
5baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../../Common/MyInitGuid.h"
6baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
7cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky#if defined(_7ZIP_LARGE_PAGES)
8baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../../../C/Alloc.h"
9baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#endif
10baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
11baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../../Common/ComTry.h"
12baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
13baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../../Windows/NtCheck.h"
14baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../../Windows/PropVariant.h"
15baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
16baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../ICoder.h"
17baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../IPassword.h"
18baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
19baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "IArchive.h"
20baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
21baa3858d3f5d128a5c8466b700098109edcad5f2repo syncHINSTANCE g_hInstance;
22baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
23baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#define NT_CHECK_FAIL_ACTION return FALSE;
24baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
25baa3858d3f5d128a5c8466b700098109edcad5f2repo syncextern "C"
26baa3858d3f5d128a5c8466b700098109edcad5f2repo syncBOOL WINAPI DllMain(
27baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  #ifdef UNDER_CE
28baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  HANDLE
29baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  #else
30baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  HINSTANCE
31baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  #endif
32baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
33baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{
34baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  if (dwReason == DLL_PROCESS_ATTACH)
35baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  {
36baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    g_hInstance = (HINSTANCE)hInstance;
37baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    NT_CHECK;
38baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  }
39baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  return TRUE;
40baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}
41baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
42baa3858d3f5d128a5c8466b700098109edcad5f2repo syncDEFINE_GUID(CLSID_CArchiveHandler,
43baa3858d3f5d128a5c8466b700098109edcad5f2repo sync0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00);
44baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
45baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstatic const UInt16 kDecodeId = 0x2790;
46baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
47baa3858d3f5d128a5c8466b700098109edcad5f2repo syncDEFINE_GUID(CLSID_CCodec,
48cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky0x23170F69, 0x40C1, kDecodeId, 0, 0, 0, 0, 0, 0, 0, 0);
49baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
50baa3858d3f5d128a5c8466b700098109edcad5f2repo syncSTDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject);
51cd66d540cead3f8200b0c73bad9c276d67896c3dDavid SrbeckySTDAPI CreateHasher(const GUID *clsid, IHasher **hasher);
52baa3858d3f5d128a5c8466b700098109edcad5f2repo syncSTDAPI CreateArchiver(const GUID *classID, const GUID *iid, void **outObject);
53baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
54baa3858d3f5d128a5c8466b700098109edcad5f2repo syncSTDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
55baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{
56baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  // COM_TRY_BEGIN
57baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  *outObject = 0;
58cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  if (*iid == IID_ICompressCoder ||
59cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky      *iid == IID_ICompressCoder2 ||
60cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky      *iid == IID_ICompressFilter)
61baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    return CreateCoder(clsid, iid, outObject);
62cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  if (*iid == IID_IHasher)
63cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky    return CreateHasher(clsid, (IHasher **)outObject);
64cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  return CreateArchiver(clsid, iid, outObject);
65baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  // COM_TRY_END
66baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}
67baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
68baa3858d3f5d128a5c8466b700098109edcad5f2repo syncSTDAPI SetLargePageMode()
69baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{
70cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  #if defined(_7ZIP_LARGE_PAGES)
71baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  SetLargePageSize();
72baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  #endif
73baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  return S_OK;
74baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}
75cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky
76cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbeckyextern bool g_CaseSensitive;
77cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky
78cd66d540cead3f8200b0c73bad9c276d67896c3dDavid SrbeckySTDAPI SetCaseSensitive(Int32 caseSensitive)
79cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky{
80cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  g_CaseSensitive = (caseSensitive != 0);
81cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky  return S_OK;
82cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky}
83