ReactOS  0.4.13-dev-563-g0561610
iconoverlay.cpp
Go to the documentation of this file.
1 /* Copyright (c) Mark Harmstone 2016-17
2  *
3  * This file is part of WinBtrfs.
4  *
5  * WinBtrfs is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public Licence as published by
7  * the Free Software Foundation, either version 3 of the Licence, or
8  * (at your option) any later version.
9  *
10  * WinBtrfs is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public Licence for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public Licence
16  * along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
17 
18 #include "shellext.h"
19 #ifndef __REACTOS__
20 #include <windows.h>
21 #include <winternl.h>
22 #else
23 #define WIN32_NO_STATUS
24 #include <windef.h>
25 #include <winbase.h>
26 #include <ndk/iofuncs.h>
27 #endif
28 #include "iconoverlay.h"
29 #ifndef __REACTOS__
30 #include "../btrfsioctl.h"
31 #else
32 #include "btrfsioctl.h"
33 #endif
34 
36  if (riid == IID_IUnknown || riid == IID_IShellIconOverlayIdentifier) {
37  *ppObj = static_cast<IShellIconOverlayIdentifier*>(this);
38  AddRef();
39  return S_OK;
40  }
41 
42  *ppObj = nullptr;
43  return E_NOINTERFACE;
44 }
45 
47  if (GetModuleFileNameW(module, pwszIconFile, cchMax) == 0)
48  return E_FAIL;
49 
51  return E_FAIL;
52 
53  if (!pIndex)
54  return E_INVALIDARG;
55 
56  if (!pdwFlags)
57  return E_INVALIDARG;
58 
59  *pIndex = 0;
60  *pdwFlags = ISIOI_ICONFILE | ISIOI_ICONINDEX;
61 
62  return S_OK;
63 }
64 
66  if (!pPriority)
67  return E_INVALIDARG;
68 
69  *pPriority = 0;
70 
71  return S_OK;
72 }
73 
75  win_handle h;
78  btrfs_get_file_ids bgfi;
79 
81 
82  if (h == INVALID_HANDLE_VALUE)
83  return S_FALSE;
84 
85  Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_GET_FILE_IDS, nullptr, 0, &bgfi, sizeof(btrfs_get_file_ids));
86 
87  if (!NT_SUCCESS(Status))
88  return S_FALSE;
89 
90  return (bgfi.inode == 0x100 && !bgfi.top) ? S_OK : S_FALSE;
91 }
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:607
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define REFIID
Definition: guiddef.h:113
#define E_NOINTERFACE
Definition: winerror.h:2364
#define ISIOI_ICONFILE
Definition: shlobj.h:2483
REFIID riid
Definition: precomp.h:44
uint16_t * PWSTR
Definition: typedefs.h:54
LONG NTSTATUS
Definition: precomp.h:26
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
NTSYSCALLAPI NTSTATUS NTAPI NtFsControlFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG FsControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength)
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define E_FAIL
Definition: ddrawi.h:102
#define FILE_SHARE_READ
Definition: compat.h:125
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
#define OPEN_EXISTING
Definition: compat.h:426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
unsigned long DWORD
Definition: ntddk_ex.h:95
#define __stdcall
Definition: typedefs.h:25
UINT cchMax
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
virtual HRESULT __stdcall IsMemberOf(PCWSTR pwszPath, DWORD dwAttrib)
Definition: iconoverlay.cpp:74
#define FSCTL_BTRFS_GET_FILE_IDS
Definition: btrfsioctl.h:8
Status
Definition: gdiplustypes.h:24
#define S_OK
Definition: intsafe.h:59
_Out_ PULONG _Out_ PULONG pIndex
Definition: ndis.h:4564
ULONG __stdcall AddRef()
Definition: iconoverlay.h:39
#define ISIOI_ICONINDEX
Definition: shlobj.h:2484
#define CreateFileW
Definition: compat.h:400
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39
virtual HRESULT __stdcall GetPriority(int *pPriority)
Definition: iconoverlay.cpp:65
virtual HRESULT __stdcall GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int *pIndex, DWORD *pdwFlags)
Definition: iconoverlay.cpp:46
HRESULT __stdcall QueryInterface(REFIID riid, void **ppObj)
Definition: iconoverlay.cpp:35
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10