ReactOS 0.4.15-dev-8102-g108db8f
recyclebin_private.h File Reference
#include <stdio.h>
#include <shlobj.h>
#include "recyclebin.h"
#include "recyclebin_v5.h"
#include <wine/debug.h>
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for recyclebin_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _INFO2_HEADER
 

Macros

#define COBJMACROS
 
#define RECYCLE_BIN_DIRECTORY_WITH_ACL   L"RECYCLER"
 
#define RECYCLE_BIN_DIRECTORY_WITHOUT_ACL   L"RECYCLED"
 
#define RECYCLE_BIN_FILE_NAME   L"INFO2"
 
#define ROUND_UP(N, S)   ((( (N) + (S) - 1) / (S) ) * (S) )
 

Typedefs

typedef struct _INFO2_HEADER INFO2_HEADER
 
typedef struct _INFO2_HEADERPINFO2_HEADER
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (recyclebin)
 
HRESULT RecycleBinGeneric_Constructor (OUT IUnknown **ppUnknown)
 
HRESULT RecycleBinGenericEnum_Constructor (OUT IRecycleBinEnumList **pprbel)
 
HRESULT RecycleBin5_Constructor (IN LPCWSTR VolumePath, OUT IUnknown **ppUnknown)
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 6 of file recyclebin_private.h.

◆ RECYCLE_BIN_DIRECTORY_WITH_ACL

#define RECYCLE_BIN_DIRECTORY_WITH_ACL   L"RECYCLER"

Definition at line 18 of file recyclebin_private.h.

◆ RECYCLE_BIN_DIRECTORY_WITHOUT_ACL

#define RECYCLE_BIN_DIRECTORY_WITHOUT_ACL   L"RECYCLED"

Definition at line 19 of file recyclebin_private.h.

◆ RECYCLE_BIN_FILE_NAME

#define RECYCLE_BIN_FILE_NAME   L"INFO2"

Definition at line 20 of file recyclebin_private.h.

◆ ROUND_UP

#define ROUND_UP (   N,
  S 
)    ((( (N) + (S) - 1) / (S) ) * (S) )

Definition at line 22 of file recyclebin_private.h.

Typedef Documentation

◆ INFO2_HEADER

◆ PINFO2_HEADER

Function Documentation

◆ RecycleBin5_Constructor()

HRESULT RecycleBin5_Constructor ( IN LPCWSTR  VolumePath,
OUT IUnknown **  ppUnknown 
)

Definition at line 675 of file recyclebin_v5.c.

676{
677 struct RecycleBin5 *s = NULL;
678 DWORD FileSystemFlags;
679 LPCWSTR RecycleBinDirectory;
680 HANDLE tokenHandle = INVALID_HANDLE_VALUE;
681 PTOKEN_USER TokenUserInfo = NULL;
682 LPWSTR StringSid = NULL, p;
683 DWORD Needed, DirectoryLength;
684 INT len;
685 HRESULT hr;
686
687 if (!ppUnknown)
688 return E_POINTER;
689
690 /* Get information about file system */
693 NULL,
694 0,
695 NULL,
696 NULL,
697 &FileSystemFlags,
698 NULL,
699 0))
700 {
702 goto cleanup;
703 }
704 if (!(FileSystemFlags & FILE_PERSISTENT_ACLS))
705 RecycleBinDirectory = RECYCLE_BIN_DIRECTORY_WITHOUT_ACL;
706 else
707 {
708 RecycleBinDirectory = RECYCLE_BIN_DIRECTORY_WITH_ACL;
709
710 /* Get user SID */
711 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &tokenHandle))
712 {
714 goto cleanup;
715 }
716 if (GetTokenInformation(tokenHandle, TokenUser, NULL, 0, &Needed))
717 {
718 hr = E_FAIL;
719 goto cleanup;
720 }
722 {
724 goto cleanup;
725 }
726 TokenUserInfo = HeapAlloc(GetProcessHeap(), 0, Needed);
727 if (!TokenUserInfo)
728 {
730 goto cleanup;
731 }
732 if (!GetTokenInformation(tokenHandle, TokenUser, TokenUserInfo, (DWORD)Needed, &Needed))
733 {
735 goto cleanup;
736 }
737 if (!ConvertSidToStringSidW(TokenUserInfo->User.Sid, &StringSid))
738 {
740 goto cleanup;
741 }
742 }
743
744 DirectoryLength = wcslen(VolumePath) + wcslen(RecycleBinDirectory) + 1;
745 if (StringSid)
746 DirectoryLength += wcslen(StringSid) + 1;
747 DirectoryLength += 1 + wcslen(RECYCLE_BIN_FILE_NAME);
748 DirectoryLength += wcslen(VolumePath) + 1;
749 Needed = (DirectoryLength + 1) * sizeof(WCHAR);
750
751 s = CoTaskMemAlloc(sizeof(struct RecycleBin5) + Needed);
752 if (!s)
753 {
755 goto cleanup;
756 }
757 ZeroMemory(s, sizeof(struct RecycleBin5));
758 s->recycleBinImpl.lpVtbl = &RecycleBin5Vtbl;
759 s->ref = 1;
760 if (StringSid)
761 len = swprintf(s->Folder, L"%s%s\\%s", VolumePath, RecycleBinDirectory, StringSid);
762 else
763 len = swprintf(s->Folder, L"%s%s", VolumePath, RecycleBinDirectory);
764 p = &s->Folder[len];
766 s->hInfo = CreateFileW(s->Folder, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
768 {
769 *p = UNICODE_NULL;
770 hr = RecycleBin5_Create(s->Folder, TokenUserInfo ? TokenUserInfo->User.Sid : NULL);
771 *p = L'\\';
772 if (!SUCCEEDED(hr))
773 goto cleanup;
774 s->hInfo = CreateFileW(s->Folder, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
775 }
776 if (s->hInfo == INVALID_HANDLE_VALUE)
777 {
779 goto cleanup;
780 }
781 s->hInfoMapped = CreateFileMappingW(s->hInfo, NULL, PAGE_READWRITE | SEC_COMMIT, 0, 0, NULL);
782 if (!s->hInfoMapped)
783 {
785 goto cleanup;
786 }
787 *p = UNICODE_NULL;
788 s->VolumePath = p + 1;
789 wcscpy(s->VolumePath, VolumePath);
790
791 *ppUnknown = (IUnknown *)&s->recycleBinImpl;
792
793 hr = S_OK;
794
795cleanup:
796 if (tokenHandle != INVALID_HANDLE_VALUE)
797 CloseHandle(tokenHandle);
798 HeapFree(GetProcessHeap(), 0, TokenUserInfo);
799 if (StringSid)
800 LocalFree(StringSid);
801 if (!SUCCEEDED(hr))
802 {
803 if (s)
805 }
806 return hr;
807}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
Definition: security.c:3583
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define GetCurrentProcess()
Definition: compat.h:759
#define GENERIC_READ
Definition: compat.h:135
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CreateFileW
Definition: compat.h:741
static void cleanup(void)
Definition: main.c:1335
BOOL WINAPI GetVolumeInformationW(IN LPCWSTR lpRootPathName, IN LPWSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPWSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:226
#define swprintf
Definition: precomp.h:40
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_PERSISTENT_ACLS
Definition: from_kernel.h:236
GLdouble s
Definition: gl.h:2039
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
if(dx< 0)
Definition: linetemp.h:194
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define SEC_COMMIT
Definition: mmtypes.h:100
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define GENERIC_WRITE
Definition: nt_native.h:90
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
#define RECYCLE_BIN_DIRECTORY_WITH_ACL
#define RECYCLE_BIN_FILE_NAME
#define RECYCLE_BIN_DIRECTORY_WITHOUT_ACL
static VOID RecycleBin5_Destructor(struct RecycleBin5 *s)
CONST_VTBL struct IRecycleBin5Vtbl RecycleBin5Vtbl
static HRESULT RecycleBin5_Create(IN LPCWSTR Folder, IN PSID OwnerSid OPTIONAL)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
HRESULT hr
Definition: shlfolder.c:183
LPWSTR VolumePath
SID_AND_ATTRIBUTES User
Definition: setypes.h:1010
int32_t INT
Definition: typedefs.h:58
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define E_POINTER
Definition: winerror.h:2365
#define TOKEN_QUERY
Definition: setypes.h:928
@ TokenUser
Definition: setypes.h:966
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by GetDefaultRecycleBin().

◆ RecycleBinGeneric_Constructor()

HRESULT RecycleBinGeneric_Constructor ( OUT IUnknown **  ppUnknown)

Definition at line 200 of file recyclebin_generic.c.

201{
202 /* This RecycleBin implementation was introduced to be able to manage all
203 * drives at once, and instanciate the 'real' implementations when needed */
204 struct RecycleBinGeneric *s;
205
206 s = CoTaskMemAlloc(sizeof(struct RecycleBinGeneric));
207 if (!s)
208 return E_OUTOFMEMORY;
209 s->ref = 1;
210 s->recycleBinImpl.lpVtbl = &RecycleBinGenericVtbl;
211
212 *ppUnknown = (IUnknown *)&s->recycleBinImpl;
213 return S_OK;
214}
CONST_VTBL struct IRecycleBinVtbl RecycleBinGenericVtbl

Referenced by GetDefaultRecycleBin().

◆ RecycleBinGenericEnum_Constructor()

HRESULT RecycleBinGenericEnum_Constructor ( OUT IRecycleBinEnumList **  pprbel)

Definition at line 219 of file recyclebin_generic_enumerator.c.

221{
222 struct RecycleBinGenericEnum *s;
223
224 s = CoTaskMemAlloc(sizeof(struct RecycleBinGenericEnum));
225 if (!s)
226 return E_OUTOFMEMORY;
227 ZeroMemory(s, sizeof(struct RecycleBinGenericEnum));
228 s->ref = 1;
229 s->recycleBinEnumImpl.lpVtbl = &RecycleBinGenericEnumVtbl;
230
231 *pprbel = &s->recycleBinEnumImpl;
232 return IRecycleBinEnumList_Reset(*pprbel);
233}
CONST_VTBL struct IRecycleBinEnumListVtbl RecycleBinGenericEnumVtbl

Referenced by RecycleBinGeneric_RecycleBin_EnumObjects().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( recyclebin  )