1 /* 2 * PROJECT: ReactOS Zip Shell Extension 3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) 4 * PURPOSE: zipfldr entrypoint 5 * COPYRIGHT: Copyright 2017 Mark Jansen (mark.jansen@reactos.org) 6 */ 7 8 #include "precomp.h" 9 10 HMODULE g_hModule = NULL; 11 LONG g_ModuleRefCnt = 0; 12 13 #include <initguid.h> 14 15 DEFINE_GUID(CLSID_ZipFolderStorageHandler, 0xe88dcce0, 0xb7b3, 0x11d1, 0xa9, 0xf0, 0x00, 0xaa, 0x00, 0x60, 0xfa, 0x31); 16 DEFINE_GUID(CLSID_ZipFolderSendTo, 0x888dca60, 0xfc0a, 0x11cf, 0x8f, 0x0f, 0x00, 0xc0, 0x4f, 0xd7, 0xd0, 0x62); 17 DEFINE_GUID(CLSID_ZipFolderContextMenu, 0xb8cdcb65, 0xb1bf, 0x4b42, 0x94, 0x28, 0x1d, 0xfd, 0xb7, 0xee, 0x92, 0xaf); 18 DEFINE_GUID(CLSID_ZipFolderRightDragHandler,0xbd472f60, 0x27fa, 0x11cf, 0xb8, 0xb4, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00); 19 DEFINE_GUID(CLSID_ZipFolderDropHandler, 0xed9d80b9, 0xd157, 0x457b, 0x91, 0x92, 0x0e, 0x72, 0x80, 0x31, 0x3b, 0xf0); 20 21 /* IExplorerCommand: Extract All */ 22 DEFINE_GUID(CLSID_ZipFolderExtractAllCommand, 0xc3d9647b, 0x8fd9, 0x4ee6, 0x8b, 0xc7, 0x82, 0x7, 0x80, 0x9, 0x10, 0x5a); 23 24 25 class CZipFldrModule : public CComModule 26 { 27 public: 28 }; 29 30 31 BEGIN_OBJECT_MAP(ObjectMap) 32 OBJECT_ENTRY(CLSID_ZipFolderStorageHandler, CZipFolder) 33 OBJECT_ENTRY(CLSID_ZipFolderContextMenu, CZipFolder) 34 END_OBJECT_MAP() 35 36 CZipFldrModule gModule; 37 38 39 #include "minizip/ioapi.h" 40 #include "minizip/iowin32.h" 41 42 zlib_filefunc64_def g_FFunc; 43 44 static void init_zlib() 45 { 46 fill_win32_filefunc64W(&g_FFunc); 47 } 48 49 EXTERN_C 50 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) 51 { 52 switch (dwReason) 53 { 54 case DLL_PROCESS_ATTACH: 55 DisableThreadLibraryCalls(hInstance); 56 g_hModule = hInstance; 57 gModule.Init(ObjectMap, hInstance, NULL); 58 init_zlib(); 59 break; 60 } 61 62 return TRUE; 63 } 64 65 STDAPI DllCanUnloadNow() 66 { 67 if (g_ModuleRefCnt) 68 return S_FALSE; 69 return gModule.DllCanUnloadNow(); 70 } 71 72 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) 73 { 74 return gModule.DllGetClassObject(rclsid, riid, ppv); 75 } 76 77 STDAPI DllRegisterServer() 78 { 79 HRESULT hr; 80 81 hr = gModule.DllRegisterServer(FALSE); 82 if (FAILED_UNEXPECTEDLY(hr)) 83 return hr; 84 85 hr = gModule.UpdateRegistryFromResource(IDR_ZIPFLDR, TRUE, NULL); 86 if (FAILED(hr)) 87 return hr; 88 89 return S_OK; 90 } 91 92 STDAPI DllUnregisterServer() 93 { 94 HRESULT hr; 95 96 hr = gModule.DllUnregisterServer(FALSE); 97 if (FAILED_UNEXPECTEDLY(hr)) 98 return hr; 99 100 hr = gModule.UpdateRegistryFromResource(IDR_ZIPFLDR, FALSE, NULL); 101 if (FAILED(hr)) 102 return hr; 103 104 return S_OK; 105 } 106 107 EXTERN_C 108 BOOL WINAPI 109 RouteTheCall( 110 IN HWND hWndOwner, 111 IN HINSTANCE hInstance, 112 IN LPCSTR lpStringArg, 113 IN INT Show) 114 { 115 CStringW path = lpStringArg; 116 PathRemoveBlanksW(path.GetBuffer()); 117 path.ReleaseBuffer(); 118 path = L"\"" + path + L"\""; 119 ShellExecuteW(NULL, L"open", L"explorer.exe", path.GetString(), NULL, SW_SHOWNORMAL); 120 return TRUE; 121 } 122