ReactOS 0.4.15-dev-7942-gd23573b
vfdshutil.cpp File Reference
#include <windows.h>
#include <objbase.h>
#include <stdio.h>
#include "vfdtypes.h"
#include "vfdapi.h"
#include "vfdlib.h"
#include "vfdshcfact.h"
#include <initguid.h>
#include <shlguid.h>
#include "vfdshguid.h"
Include dependency graph for vfdshutil.cpp:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 
#define INITGUID
 
#define REGKEY_APPROVED    "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"
 

Functions

STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppvOut)
 
STDAPI DllCanUnloadNow (void)
 
static void MakeGuidString (LPTSTR str, const GUID &guid)
 
DWORD WINAPI VfdRegisterHandlers ()
 
DWORD WINAPI VfdUnregisterHandlers ()
 
DWORD WINAPI VfdCheckHandlers ()
 

Macro Definition Documentation

◆ INITGUID

#define INITGUID

Definition at line 28 of file vfdshutil.cpp.

◆ REGKEY_APPROVED

#define REGKEY_APPROVED    "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"

Definition at line 39 of file vfdshutil.cpp.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 11 of file vfdshutil.cpp.

Function Documentation

◆ DllCanUnloadNow()

STDAPI DllCanUnloadNow ( void  )

Definition at line 76 of file vfdshutil.cpp.

77{
78 VFDTRACE(0,
79 ("DllCanUnloadNow - %s\n", (g_cDllRefCnt ? "No" : "Yes")));
80
81 return (g_cDllRefCnt ? S_FALSE : S_OK);
82}
#define S_OK
Definition: intsafe.h:52
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
UINT g_cDllRefCnt
#define S_FALSE
Definition: winerror.h:2357

◆ DllGetClassObject()

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

Definition at line 50 of file vfdshutil.cpp.

54{
55 VFDTRACE(0,
56 ("DllGetClassObject\n"));
57
58 *ppvOut = NULL;
59
60 if (IsEqualIID(rclsid, CLSID_VfdShellExt)) {
61 CVfdFactory *pFactory = new CVfdFactory;
62
63 if (!pFactory) {
64 return E_OUTOFMEMORY;
65 }
66
67 return pFactory->QueryInterface(riid, ppvOut);
68 }
69
71}
STDMETHODIMP QueryInterface(REFIID, LPVOID *)
Definition: vfdshcfact.cpp:47
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
REFIID riid
Definition: atlbase.h:39
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663

◆ MakeGuidString()

static void MakeGuidString ( LPTSTR  str,
const GUID guid 
)
inlinestatic

Definition at line 88 of file vfdshutil.cpp.

89{
90 sprintf(str, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
91 guid.Data1, guid.Data2, guid.Data3,
92 guid.Data4[0], guid.Data4[1],
93 guid.Data4[2], guid.Data4[3], guid.Data4[4],
94 guid.Data4[5], guid.Data4[6], guid.Data4[7]);
95}
const GUID * guid
#define sprintf(buf, format,...)
Definition: sprintf.c:55
const WCHAR * str

Referenced by VfdCheckHandlers(), VfdRegisterHandlers(), and VfdUnregisterHandlers().

◆ VfdCheckHandlers()

DWORD WINAPI VfdCheckHandlers ( )

Definition at line 393 of file vfdshutil.cpp.

394{
396 TCHAR guid_str[40];
397 DWORD temp;
398 DWORD ret;
399
400 MakeGuidString(guid_str, CLSID_VfdShellExt);
401
402 sprintf(buf, "CLSID\\%s", guid_str);
403
404 VFDTRACE(0, ("HKCR\\%s\n", buf));
405
406 temp = sizeof(buf);
407
409
410 if (ret != ERROR_SUCCESS) {
411 return ret;
412 }
413
416 }
417
418 return ERROR_SUCCESS;
419}
#define _stricmp
Definition: cat.c:22
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static calc_node_t temp
Definition: rpn_ieee.c:38
int32_t * PLONG
Definition: typedefs.h:58
#define VFDEXT_DESCRIPTION
Definition: vfdlib.h:58
static void MakeGuidString(LPTSTR str, const GUID &guid)
Definition: vfdshutil.cpp:88
int ret
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define RegQueryValue
Definition: winreg.h:523
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
char TCHAR
Definition: xmlstorage.h:189

Referenced by Shell(), and Status().

◆ VfdRegisterHandlers()

DWORD WINAPI VfdRegisterHandlers ( )

Definition at line 100 of file vfdshutil.cpp.

101{
103 TCHAR guid_str[40];
104 HKEY hKey;
105 DWORD temp;
106 DWORD ret;
107
108 MakeGuidString(guid_str, CLSID_VfdShellExt);
109
110 //
111 // Register the GUID in the CLSID subtree
112 //
113 sprintf(buf, "CLSID\\%s", guid_str);
114
115 VFDTRACE(0, ("HKCR\\%s\n", buf));
116
119 0, KEY_ALL_ACCESS, NULL, &hKey, &temp);
120
121 if (ret != ERROR_SUCCESS) {
122 return ret;
123 }
124
126 temp = sizeof(buf);
127
129 hKey, NULL, NULL, NULL, (PBYTE)buf, &temp);
130
131 if (ret != ERROR_SUCCESS) {
133 return ret;
134 }
135
138 return ERROR_FILE_EXISTS;
139 }
140 }
141 else {
142
143 VFDTRACE(0, ("@=" VFDEXT_DESCRIPTION "\n"));
144
147
149
150 if (ret != ERROR_SUCCESS) {
151 return ret;
152 }
153 }
154
155 //
156 // Register the executable path
157 //
158 sprintf(buf, "CLSID\\%s\\InProcServer32", guid_str);
159
160 VFDTRACE(0, ("HKCR\\%s\n", buf));
161
165
166 if (ret != ERROR_SUCCESS) {
167 return ret;
168 }
169
171
172 VFDTRACE(0, ("@=%s\n", buf));
173
175 hKey, NULL, NULL, REG_SZ, (PBYTE)buf, temp + 1);
176
177 if (ret != ERROR_SUCCESS) {
179 return ret;
180 }
181
182 VFDTRACE(0, ("ThreadingModel=Apartment\n"));
183
184 ret = RegSetValueEx(hKey, "ThreadingModel", NULL, REG_SZ,
185 (PBYTE)"Apartment", sizeof("Apartment"));
186
188
189 if (ret != ERROR_SUCCESS) {
190 return ret;
191 }
192
193 //
194 // Register context menu handler
195 //
196 VFDTRACE(0, ("HKCR\\" VFDEXT_MENU_REGKEY "\n"));
197
201
202 if (ret != ERROR_SUCCESS) {
203 return ret;
204 }
205
206 VFDTRACE(0, ("@=%s\n", guid_str));
207
209 (PBYTE)guid_str, strlen(guid_str) + 1);
210
212
213 if (ret != ERROR_SUCCESS) {
214 return ret;
215 }
216
217 //
218 // Register Drag&Drop handler
219 //
220 if (!IS_WINDOWS_NT()) {
221 //
222 // Windows NT does not support Drag&Drop handlers ???
223 //
224 VFDTRACE(0, ("HKCR\\" VFDEXT_DND_REGKEY "\n"));
225
229
230 if (ret != ERROR_SUCCESS) {
231 return ret;
232 }
233
234 VFDTRACE(0, ("@=%s\n", guid_str));
235
237 (PBYTE)guid_str, strlen(guid_str) + 1);
238
240
241 if (ret != ERROR_SUCCESS) {
242 return ret;
243 }
244 }
245
246 //
247 // Register property sheet handler
248 //
249 VFDTRACE(0, ("HKCR\\" VFDEXT_PROP_REGKEY "\n"));
250
254
255 if (ret != ERROR_SUCCESS) {
256 return ret;
257 }
258
259 VFDTRACE(0, ("@=%s\n", guid_str));
260
262 (PBYTE)guid_str, strlen(guid_str) + 1);
263
265
266 if (ret != ERROR_SUCCESS) {
267 return ret;
268 }
269
270 //
271 // Register approved extensions entry
272 //
273 VFDTRACE(0, ("HKLM\\" REGKEY_APPROVED "\n"));
274
277 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL);
278
279 if (ret != ERROR_SUCCESS) {
280 return ret;
281 }
282
283 VFDTRACE(0,
284 ("%s=" VFDEXT_DESCRIPTION "\n", guid_str));
285
286 ret = RegSetValueEx(hKey, guid_str, NULL, REG_SZ,
288
290
291 return ret;
292}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define RegCloseKey(hKey)
Definition: registry.h:49
FxAutoRegKey hKey
#define REG_SZ
Definition: layer.c:22
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define REG_OPENED_EXISTING_KEY
Definition: nt_native.h:1085
BYTE * PBYTE
Definition: pedump.c:66
#define IS_WINDOWS_NT()
Definition: vfdcmd.c:159
HINSTANCE g_hDllModule
#define VFDEXT_MENU_REGKEY
Definition: vfdlib.h:59
#define VFDEXT_PROP_REGKEY
Definition: vfdlib.h:61
#define VFDEXT_DND_REGKEY
Definition: vfdlib.h:60
#define REGKEY_APPROVED
Definition: vfdshutil.cpp:39
#define GetModuleFileName
Definition: winbase.h:3831
#define ERROR_FILE_EXISTS
Definition: winerror.h:165
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define RegQueryValueEx
Definition: winreg.h:524

Referenced by Shell().

◆ VfdUnregisterHandlers()

DWORD WINAPI VfdUnregisterHandlers ( )

Definition at line 297 of file vfdshutil.cpp.

298{
300 TCHAR guid_str[40];
301 HKEY hKey;
302 DWORD temp;
303 DWORD ret;
304
305 MakeGuidString(guid_str, CLSID_VfdShellExt);
306
307 sprintf(buf, "CLSID\\%s", guid_str);
308
309 VFDTRACE(0, ("HKCR\\%s\n", buf));
310
311 temp = sizeof(buf);
312
314
315 if (ret != ERROR_SUCCESS) {
316 return ret;
317 }
318
321 }
322
323 sprintf(buf, "CLSID\\%s\\InProcServer32", guid_str);
324
325 VFDTRACE(0, ("HKCR\\%s\n", buf));
326
328
329 if (ret != ERROR_SUCCESS) {
330 return ret;
331 }
332
333 sprintf(buf, "CLSID\\%s", guid_str);
334
335 VFDTRACE(0, ("HKCR\\%s\n", buf));
336
338
339 if (ret != ERROR_SUCCESS) {
340 return ret;
341 }
342
343 VFDTRACE(0, ("HKCR\\" VFDEXT_MENU_REGKEY "\n"));
344
346
347 if (ret != ERROR_SUCCESS) {
348 return ret;
349 }
350
351 if (!IS_WINDOWS_NT()) {
352
353 // Windows NT doesn't support Drag & Drop handlers ???
354
355 VFDTRACE(0, ("HKCR\\" VFDEXT_DND_REGKEY "\n"));
356
358
359 if (ret != ERROR_SUCCESS) {
360 return ret;
361 }
362 }
363
364 VFDTRACE(0, ("HKCR\\" VFDEXT_PROP_REGKEY "\n"));
365
367
368 if (ret != ERROR_SUCCESS) {
369 return ret;
370 }
371
372 VFDTRACE(0, ("HKLM\\" REGKEY_APPROVED "\n"));
373
377 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL);
378
379 if (ret != ERROR_SUCCESS) {
380 return ret;
381 }
382
383 ret = RegDeleteValue(hKey, guid_str);
384
386
387 return ret;
388}
#define RegDeleteKey
Definition: winreg.h:502
#define RegDeleteValue
Definition: winreg.h:508

Referenced by Shell().