ReactOS 0.4.17-dev-966-gf06eace
zipfldr.cpp File Reference
#include "precomp.h"
#include <initguid.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 50 of file zipfldr.cpp.

51{
56 {
58 return TRUE;
59 }
60 return FALSE;
61}
#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 64 of file zipfldr.cpp.

65{
66 WCHAR szTarget[MAX_PATH], szSendToFile[MAX_PATH];
67
68 LoadStringW(g_hModule, IDS_FRIENDLYNAME, szTarget, _countof(szTarget));
69
70 StringCbCopyW(szSendToFile, sizeof(szSendToFile), pszSendTo);
71 PathAppendW(szSendToFile, szTarget);
72 StringCbCatW(szSendToFile, sizeof(szSendToFile), L".ZFSendToTarget");
73 if (!CreateEmptyFile(szSendToFile))
74 {
75 DPRINT1("CreateEmptyFile('%ls')\n", szSendToFile);
76 return E_FAIL;
77 }
78 return S_OK;
79}
#define DPRINT1
Definition: precomp.h:8
#define E_FAIL
Definition: ddrawi.h:102
#define IDS_FRIENDLYNAME
Definition: resource.h:76
#define MAX_PATH
Definition: compat.h:34
#define L(x)
Definition: resources.c:13
#define S_OK
Definition: intsafe.h:52
#define PathAppendW
Definition: pathcch.h:310
short WCHAR
Definition: pedump.c:58
#define LoadStringW
Definition: utils.h:64
#define _countof(array)
Definition: sndvol32.h:70
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
static BOOL CreateEmptyFile(PCWSTR pszFile)
Definition: zipfldr.cpp:50
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 126 of file zipfldr.cpp.

127{
128 if (g_ModuleRefCnt)
129 return S_FALSE;
130 return gModule.DllCanUnloadNow();
131}
HRESULT DllCanUnloadNow()
Definition: atlbase.h:1030
#define S_FALSE
Definition: winerror.h:3451
CZipFldrModule gModule
Definition: zipfldr.cpp:39
LONG g_ModuleRefCnt
Definition: zipfldr.cpp:12

◆ DllGetClassObject()

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

Definition at line 133 of file zipfldr.cpp.

134{
135 return gModule.DllGetClassObject(rclsid, riid, ppv);
136}
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 111 of file zipfldr.cpp.

112{
113 switch (dwReason)
114 {
118 gModule.Init(ObjectMap, hInstance, NULL);
119 init_zlib();
120 break;
121 }
122
123 return TRUE;
124}
DWORD dwReason
Definition: misc.cpp:135
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:44

◆ DllRegisterServer()

STDAPI DllRegisterServer ( void  )

Definition at line 138 of file zipfldr.cpp.

139{
140 HRESULT hr;
141
144 return hr;
145
147 if (FAILED(hr))
148 return hr;
149
150 WCHAR szSendTo[MAX_PATH];
151 hr = GetDefaultUserSendTo(szSendTo);
152 if (SUCCEEDED(hr))
153 CreateSendToZip(szSendTo);
154
155 return S_OK;
156}
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
HRESULT hr
Definition: delayimp.cpp:582
#define IDR_ZIPFLDR
Definition: resource.h:12
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:33
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
static HRESULT GetDefaultUserSendTo(PWSTR pszPath)
Definition: zipfldr.cpp:82
static HRESULT CreateSendToZip(PCWSTR pszSendTo)
Definition: zipfldr.cpp:64

◆ DllUnregisterServer()

STDAPI DllUnregisterServer ( void  )

Definition at line 158 of file zipfldr.cpp.

159{
160 HRESULT hr;
161
164 return hr;
165
167 if (FAILED(hr))
168 return hr;
169
170 return S_OK;
171}
HRESULT DllUnregisterServer(BOOL bUnRegTypeLib=TRUE)
Definition: atlbase.h:1047

◆ GetDefaultUserSendTo()

static HRESULT GetDefaultUserSendTo ( PWSTR  pszPath)
static

Definition at line 82 of file zipfldr.cpp.

83{
85 SHGFP_TYPE_DEFAULT, pszPath);
86}
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2717
#define CSIDL_SENDTO
Definition: shlobj.h:2200
@ SHGFP_TYPE_DEFAULT
Definition: shlobj.h:2168

Referenced by DllRegisterServer().

◆ GetZipCodePage()

UINT GetZipCodePage ( BOOL  bUnZip)

Definition at line 88 of file zipfldr.cpp.

89{
90 WCHAR szValue[16];
91 DWORD dwType, cbValue = sizeof(szValue);
92 UINT nDefaultCodePage = (bUnZip ? CP_ACP : CP_UTF8);
93
94 LONG error = SHGetValueW(HKEY_CURRENT_USER, L"Software\\ReactOS",
95 (bUnZip ? L"UnZipCodePage" : L"ZipCodePage"),
96 &dwType, szValue, &cbValue);
97 if (error != ERROR_SUCCESS)
98 return nDefaultCodePage;
99
100 if (cbValue == sizeof(DWORD) && (dwType == REG_DWORD || dwType == REG_BINARY))
101 return *(DWORD*)szValue;
102
103 if (dwType != REG_SZ && dwType != REG_EXPAND_SZ)
104 return nDefaultCodePage;
105
106 szValue[_countof(szValue) - 1] = UNICODE_NULL;
107 return (UINT)wcstol(szValue, NULL, 0);
108}
#define REG_SZ
Definition: layer.c:22
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CP_ACP
Definition: compat.h:109
_ACRTIMP __msvcrt_long __cdecl wcstol(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2752
DWORD WINAPI SHGetValueW(HKEY hkey, const WCHAR *subkey, const WCHAR *value, DWORD *type, void *data, DWORD *data_len)
Definition: main.c:2222
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned int UINT
Definition: sysinfo.c:13
#define error(str)
Definition: mkdosfs.c:1605
#define REG_BINARY
Definition: nt_native.h:1499
#define REG_EXPAND_SZ
Definition: nt_native.h:1497
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
#define REG_DWORD
Definition: sdbapi.c:615
#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 44 of file zipfldr.cpp.

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

Referenced by DllMain().

◆ RouteTheCallW()

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

Definition at line 175 of file zipfldr.cpp.

176{
177 CStringW path = lpStringArg;
178 PathRemoveBlanksW(path.GetBuffer());
179 path.ReleaseBuffer();
180 path = L"\"" + path + L"\"";
181
182 WCHAR app[MAX_PATH];
184 PathAppendW(app, L"explorer.exe");
185
186 ShellExecuteW(NULL, L"open", app, path.GetString(), NULL, Show ? Show : SW_SHOWNORMAL);
187 return TRUE;
188}
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2370
void WINAPI PathRemoveBlanksW(WCHAR *path)
Definition: path.c:1886
#define SW_SHOWNORMAL
Definition: winuser.h:781
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2787

Variable Documentation

◆ g_FFunc

Definition at line 42 of file zipfldr.cpp.

Referenced by CZipExtract::Extract(), init_zlib(), and 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