ReactOS 0.4.15-dev-5672-gf73ac17
fontext.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Font Shell Extension
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Shell extension entry point
5 * COPYRIGHT: Copyright 2019,2020 Mark Jansen <mark.jansen@reactos.org>
6 */
7
8#include "precomp.h"
9
11
12const GUID CLSID_CFontExt = { 0xbd84b380, 0x8ca2, 0x1069, { 0xab, 0x1d, 0x08, 0x00, 0x09, 0x48, 0xf5, 0x34 } };
13
14
16{
17public:
18 void Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE h, const GUID *plibid)
19 {
20 g_FontCache = new CFontCache();
21 CComModule::Init(p, h, plibid);
22 }
23
24 void Term()
25 {
26 delete g_FontCache;
29 }
30};
31
32BEGIN_OBJECT_MAP(ObjectMap)
35
36
39
40
42{
44 return S_FALSE;
45 return gModule.DllCanUnloadNow();
46}
47
49{
50 return gModule.DllGetClassObject(rclsid, riid, ppv);
51}
52
53
55{
56 WCHAR Path[MAX_PATH] = { 0 };
57 static const char DesktopIniContents[] = "[.ShellClassInfo]\r\n"
58 "CLSID={BD84B380-8CA2-1069-AB1D-08000948F534}\r\n"
59 "IconResource=%SystemRoot%\\system32\\shell32.dll,-39\r\n"; // IDI_SHELL_FONTS_FOLDER
61 HRESULT hr;
62
65 return hr;
66
69 return hr;
70
71 // Make this a system folder:
72 // Ideally this should not be done here, but when installing
73 // Otherwise, livecd won't have this set properly
76 {
79 }
80 else
81 {
82 ERR("Unable to get attributes for fonts folder (%d)\n", GetLastError());
83 }
84
85 if (!PathAppendW(Path, L"desktop.ini"))
86 return E_FAIL;
87
91
92 DWORD BytesWritten, BytesToWrite = strlen(DesktopIniContents);
93 if (WriteFile(hFile, DesktopIniContents, (DWORD)BytesToWrite, &BytesWritten, NULL))
94 hr = (BytesToWrite == BytesWritten) ? S_OK : E_FAIL;
95 else
98 return hr;
99}
100
102{
104}
105
106
109{
110 switch (dwReason)
111 {
114 gModule.Init(ObjectMap, hInstance, NULL);
115 break;
117 gModule.Term();
118 break;
119 }
120
121 return TRUE;
122}
CFontCache * g_FontCache
Definition: CFontCache.cpp:12
PRTL_UNICODE_STRING_BUFFER Path
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
DWORD dwReason
Definition: misc.cpp:154
#define STDAPI
Definition: basetyps.h:41
#define EXTERN_C
Definition: basetyps.h:12
#define ERR(fmt,...)
Definition: debug.h:110
HINSTANCE hInstance
Definition: charmap.c:19
void Term()
Definition: atlbase.h:821
HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: atlbase.h:936
HRESULT DllUnregisterServer(BOOL bUnRegTypeLib=TRUE)
Definition: atlbase.h:946
HRESULT Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE, const GUID *plibid)
Definition: atlbase.h:798
HRESULT DllCanUnloadNow()
Definition: atlbase.h:929
HRESULT DllRegisterServer(BOOL bRegTypeLib=TRUE)
Definition: atlbase.h:941
void Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE h, const GUID *plibid)
Definition: fontext.cpp:18
void Term()
Definition: fontext.cpp:24
#define E_FAIL
Definition: ddrawi.h:102
#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 DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:794
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2558
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:126
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
EXTERN_C BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
Definition: fontext.cpp:108
STDAPI DllRegisterServer()
Definition: fontext.cpp:54
const GUID CLSID_CFontExt
Definition: fontext.cpp:12
LONG g_ModuleRefCnt
Definition: fontext.cpp:37
STDAPI DllCanUnloadNow()
Definition: fontext.cpp:41
STDAPI DllUnregisterServer()
Definition: fontext.cpp:101
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: fontext.cpp:48
CFontExtModule gModule
Definition: fontext.cpp:38
GLfloat GLfloat p
Definition: glext.h:8902
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define END_OBJECT_MAP()
Definition: atlcom.h:652
#define OBJECT_ENTRY(clsid, class)
Definition: atlcom.h:654
#define BEGIN_OBJECT_MAP(x)
Definition: atlcom.h:650
#define CREATE_ALWAYS
Definition: disk.h:72
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define GENERIC_WRITE
Definition: nt_native.h:90
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
HRESULT hr
Definition: shlfolder.c:183
#define CSIDL_FONTS
Definition: shlobj.h:2044
DWORD dwAttributes
Definition: vdmdbg.h:34
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
__wchar_t WCHAR
Definition: xmlstorage.h:180