ReactOS 0.4.15-dev-7942-gd23573b
zipfldr.cpp File Reference
#include "precomp.h"
#include <initguid.h>
#include "minizip/ioapi.h"
#include "minizip/iowin32.h"
Include dependency graph for zipfldr.cpp:

Go to the source code of this file.

Classes

class  CZipFldrModule
 

Functions

 DEFINE_GUID (CLSID_ZipFolderStorageHandler, 0xe88dcce0, 0xb7b3, 0x11d1, 0xa9, 0xf0, 0x00, 0xaa, 0x00, 0x60, 0xfa, 0x31)
 
 DEFINE_GUID (CLSID_ZipFolderSendTo, 0x888dca60, 0xfc0a, 0x11cf, 0x8f, 0x0f, 0x00, 0xc0, 0x4f, 0xd7, 0xd0, 0x62)
 
 DEFINE_GUID (CLSID_ZipFolderContextMenu, 0xb8cdcb65, 0xb1bf, 0x4b42, 0x94, 0x28, 0x1d, 0xfd, 0xb7, 0xee, 0x92, 0xaf)
 
 DEFINE_GUID (CLSID_ZipFolderRightDragHandler, 0xbd472f60, 0x27fa, 0x11cf, 0xb8, 0xb4, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00)
 
 DEFINE_GUID (CLSID_ZipFolderDropHandler, 0xed9d80b9, 0xd157, 0x457b, 0x91, 0x92, 0x0e, 0x72, 0x80, 0x31, 0x3b, 0xf0)
 
 DEFINE_GUID (CLSID_ZipFolderExtractAllCommand, 0xc3d9647b, 0x8fd9, 0x4ee6, 0x8b, 0xc7, 0x82, 0x7, 0x80, 0x9, 0x10, 0x5a)
 
static void init_zlib ()
 
static BOOL CreateEmptyFile (PCWSTR pszFile)
 
static HRESULT CreateSendToZip (PCWSTR pszSendTo)
 
static HRESULT GetDefaultUserSendTo (PWSTR pszPath)
 
UINT GetZipCodePage (BOOL bUnZip)
 
EXTERN_C BOOL WINAPI DllMain (HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
 
STDAPI DllCanUnloadNow ()
 
STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv)
 
STDAPI DllRegisterServer ()
 
STDAPI DllUnregisterServer ()
 
EXTERN_C BOOL WINAPI RouteTheCallW (IN HWND hWndOwner, IN HINSTANCE hInstance, IN PCWSTR lpStringArg, IN INT Show)
 

Variables

HMODULE g_hModule = NULL
 
LONG g_ModuleRefCnt = 0
 
CZipFldrModule gModule
 
zlib_filefunc64_def g_FFunc
 

Function Documentation

◆ CreateEmptyFile()

static BOOL CreateEmptyFile ( PCWSTR  pszFile)
static

Definition at line 52 of file zipfldr.cpp.

53{
58 {
60 return TRUE;
61 }
62 return FALSE;
63}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
#define CREATE_ALWAYS
Definition: disk.h:72
_In_ HANDLE hFile
Definition: mswsock.h:90
#define GENERIC_WRITE
Definition: nt_native.h:90

Referenced by CreateSendToZip().

◆ CreateSendToZip()

static HRESULT CreateSendToZip ( PCWSTR  pszSendTo)
static

Definition at line 66 of file zipfldr.cpp.

67{
68 WCHAR szTarget[MAX_PATH], szSendToFile[MAX_PATH];
69
70 LoadStringW(g_hModule, IDS_FRIENDLYNAME, szTarget, _countof(szTarget));
71
72 StringCbCopyW(szSendToFile, sizeof(szSendToFile), pszSendTo);
73 PathAppendW(szSendToFile, szTarget);
74 StringCbCatW(szSendToFile, sizeof(szSendToFile), L".ZFSendToTarget");
75 if (!CreateEmptyFile(szSendToFile))
76 {
77 DPRINT1("CreateEmptyFile('%ls')\n", szSendToFile);
78 return E_FAIL;
79 }
80 return S_OK;
81}
#define DPRINT1
Definition: precomp.h:8
#define E_FAIL
Definition: ddrawi.h:102
#define IDS_FRIENDLYNAME
Definition: resource.h:75
#define MAX_PATH
Definition: compat.h:34
#define S_OK
Definition: intsafe.h:52
#define L(x)
Definition: ntvdm.h:50
#define PathAppendW
Definition: pathcch.h:309
#define _countof(array)
Definition: sndvol32.h:68
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL CreateEmptyFile(PCWSTR pszFile)
Definition: zipfldr.cpp:52
HMODULE g_hModule
Definition: zipfldr.cpp:11

Referenced by DllRegisterServer().

◆ DEFINE_GUID() [1/6]

DEFINE_GUID ( CLSID_ZipFolderContextMenu  ,
0xb8cdcb65  ,
0xb1bf  ,
0x4b42  ,
0x94  ,
0x28  ,
0x1d  ,
0xfd  ,
0xb7  ,
0xee  ,
0x92  ,
0xaf   
)

◆ DEFINE_GUID() [2/6]

DEFINE_GUID ( CLSID_ZipFolderDropHandler  ,
0xed9d80b9  ,
0xd157  ,
0x457b  ,
0x91  ,
0x92  ,
0x0e  ,
0x72  ,
0x80  ,
0x31  ,
0x3b  ,
0xf0   
)

◆ DEFINE_GUID() [3/6]

DEFINE_GUID ( CLSID_ZipFolderExtractAllCommand  ,
0xc3d9647b  ,
0x8fd9  ,
0x4ee6  ,
0x8b  ,
0xc7  ,
0x82  ,
0x7  ,
0x80  ,
0x9  ,
0x10  ,
0x5a   
)

◆ DEFINE_GUID() [4/6]

DEFINE_GUID ( CLSID_ZipFolderRightDragHandler  ,
0xbd472f60  ,
0x27fa  ,
0x11cf  ,
0xb8  ,
0xb4  ,
0x44  ,
0x45  ,
0x53  ,
0x54  ,
0x00  ,
0x00   
)

◆ DEFINE_GUID() [5/6]

DEFINE_GUID ( CLSID_ZipFolderSendTo  ,
0x888dca60  ,
0xfc0a  ,
0x11cf  ,
0x8f  ,
0x0f  ,
0x00  ,
0xc0  ,
0x4f  ,
0xd7  ,
0xd0  ,
0x62   
)

◆ DEFINE_GUID() [6/6]

DEFINE_GUID ( CLSID_ZipFolderStorageHandler  ,
0xe88dcce0  ,
0xb7b3  ,
0x11d1  ,
0xa9  ,
0xf0  ,
0x00  ,
0xaa  ,
0x00  ,
0x60  ,
0xfa  ,
0x31   
)

◆ DllCanUnloadNow()

STDAPI DllCanUnloadNow ( void  )

Definition at line 128 of file zipfldr.cpp.

129{
130 if (g_ModuleRefCnt)
131 return S_FALSE;
132 return gModule.DllCanUnloadNow();
133}
HRESULT DllCanUnloadNow()
Definition: atlbase.h:1030
#define S_FALSE
Definition: winerror.h:2357
CZipFldrModule gModule
Definition: zipfldr.cpp:38
LONG g_ModuleRefCnt
Definition: zipfldr.cpp:12

◆ DllGetClassObject()

STDAPI DllGetClassObject ( REFCLSID  rclsid,
REFIID  riid,
LPVOID ppv 
)

Definition at line 135 of file zipfldr.cpp.

136{
137 return gModule.DllGetClassObject(rclsid, riid, ppv);
138}
HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: atlbase.h:1037
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39

◆ DllMain()

EXTERN_C BOOL WINAPI DllMain ( HINSTANCE  hInstance,
DWORD  dwReason,
LPVOID  lpReserved 
)

Definition at line 113 of file zipfldr.cpp.

114{
115 switch (dwReason)
116 {
120 gModule.Init(ObjectMap, hInstance, NULL);
121 init_zlib();
122 break;
123 }
124
125 return TRUE;
126}
DWORD dwReason
Definition: misc.cpp:154
HINSTANCE hInstance
Definition: charmap.c:19
HRESULT Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE, const GUID *plibid)
Definition: atlbase.h:886
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
static void init_zlib()
Definition: zipfldr.cpp:46

◆ DllRegisterServer()

STDAPI DllRegisterServer ( void  )

Definition at line 140 of file zipfldr.cpp.

141{
142 HRESULT hr;
143
146 return hr;
147
149 if (FAILED(hr))
150 return hr;
151
152 WCHAR szSendTo[MAX_PATH];
153 hr = GetDefaultUserSendTo(szSendTo);
154 if (SUCCEEDED(hr))
155 CreateSendToZip(szSendTo);
156
157 return S_OK;
158}
HRESULT WINAPI UpdateRegistryFromResource(LPCTSTR lpszRes, BOOL bRegister, struct _ATL_REGMAP_ENTRY *pMapEntries=NULL)
Definition: atlbase.h:489
HRESULT DllRegisterServer(BOOL bRegTypeLib=TRUE)
Definition: atlbase.h:1042
#define IDR_ZIPFLDR
Definition: resource.h:12
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183
static HRESULT GetDefaultUserSendTo(PWSTR pszPath)
Definition: zipfldr.cpp:84
static HRESULT CreateSendToZip(PCWSTR pszSendTo)
Definition: zipfldr.cpp:66

◆ DllUnregisterServer()

STDAPI DllUnregisterServer ( void  )

Definition at line 160 of file zipfldr.cpp.

161{
162 HRESULT hr;
163
166 return hr;
167
169 if (FAILED(hr))
170 return hr;
171
172 return S_OK;
173}
HRESULT DllUnregisterServer(BOOL bUnRegTypeLib=TRUE)
Definition: atlbase.h:1047

◆ GetDefaultUserSendTo()

static HRESULT GetDefaultUserSendTo ( PWSTR  pszPath)
static

Definition at line 84 of file zipfldr.cpp.

85{
87 SHGFP_TYPE_DEFAULT, pszPath);
88}
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2589
#define CSIDL_SENDTO
Definition: shlobj.h:2167
@ SHGFP_TYPE_DEFAULT
Definition: shlobj.h:2135

Referenced by DllRegisterServer().

◆ GetZipCodePage()

UINT GetZipCodePage ( BOOL  bUnZip)

Definition at line 90 of file zipfldr.cpp.

91{
92 WCHAR szValue[16];
93 DWORD dwType, cbValue = sizeof(szValue);
94 UINT nDefaultCodePage = (bUnZip ? CP_ACP : CP_UTF8);
95
96 LONG error = SHGetValueW(HKEY_CURRENT_USER, L"Software\\ReactOS",
97 (bUnZip ? L"UnZipCodePage" : L"ZipCodePage"),
98 &dwType, szValue, &cbValue);
99 if (error != ERROR_SUCCESS)
100 return nDefaultCodePage;
101
102 if (cbValue == sizeof(DWORD) && (dwType == REG_DWORD || dwType == REG_BINARY))
103 return *(DWORD*)szValue;
104
105 if (dwType != REG_SZ && dwType != REG_EXPAND_SZ)
106 return nDefaultCodePage;
107
108 szValue[_countof(szValue) - 1] = UNICODE_NULL;
109 return (UINT)wcstol(szValue, NULL, 0);
110}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CP_ACP
Definition: compat.h:109
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1236
unsigned long DWORD
Definition: ntddk_ex.h:95
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define REG_SZ
Definition: layer.c:22
#define error(str)
Definition: mkdosfs.c:1605
unsigned int UINT
Definition: ndis.h:50
#define REG_BINARY
Definition: nt_native.h:1496
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
#define REG_DWORD
Definition: sdbapi.c:596
#define CP_UTF8
Definition: nls.h:20
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by CZipCreatorImpl::JustDoIt().

◆ init_zlib()

static void init_zlib ( )
static

Definition at line 46 of file zipfldr.cpp.

47{
49}
void fill_win32_filefunc64W(zlib_filefunc64_def *pzlib_filefunc_def)
Definition: iowin32.c:457
zlib_filefunc64_def g_FFunc
Definition: zipfldr.cpp:44

Referenced by DllMain().

◆ RouteTheCallW()

EXTERN_C BOOL WINAPI RouteTheCallW ( IN HWND  hWndOwner,
IN HINSTANCE  hInstance,
IN PCWSTR  lpStringArg,
IN INT  Show 
)

Definition at line 177 of file zipfldr.cpp.

178{
179 CStringW path = lpStringArg;
180 PathRemoveBlanksW(path.GetBuffer());
181 path.ReleaseBuffer();
182 path = L"\"" + path + L"\"";
183
184 WCHAR app[MAX_PATH];
186 PathAppendW(app, L"explorer.exe");
187
188 ShellExecuteW(NULL, L"open", app, path.GetString(), NULL, Show ? Show : SW_SHOWNORMAL);
189 return TRUE;
190}
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
VOID WINAPI PathRemoveBlanksW(LPWSTR lpszPath)
Definition: path.c:920
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2402
#define SW_SHOWNORMAL
Definition: winuser.h:770

Variable Documentation

◆ g_FFunc

Definition at line 44 of file zipfldr.cpp.

Referenced by CZipExtract::Extract(), init_zlib(), and CZipFolder::STDMETHODIMP_().

◆ g_hModule

HMODULE g_hModule = NULL

Definition at line 11 of file zipfldr.cpp.

Referenced by CreateSendToZip(), and DllMain().

◆ g_ModuleRefCnt

LONG g_ModuleRefCnt = 0

Definition at line 12 of file zipfldr.cpp.

Referenced by DllCanUnloadNow().

◆ gModule