ReactOS  0.4.15-dev-1377-ga59cecd
recyclebin_private.h File Reference
#include <stdio.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 16 of file recyclebin_private.h.

◆ RECYCLE_BIN_DIRECTORY_WITHOUT_ACL

#define RECYCLE_BIN_DIRECTORY_WITHOUT_ACL   L"RECYCLED"

Definition at line 17 of file recyclebin_private.h.

◆ RECYCLE_BIN_FILE_NAME

#define RECYCLE_BIN_FILE_NAME   L"INFO2"

Definition at line 18 of file recyclebin_private.h.

◆ ROUND_UP

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

Definition at line 20 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 */
692  VolumePath,
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  {
729  hr = E_OUTOFMEMORY;
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  {
754  hr = E_OUTOFMEMORY;
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 
795 cleanup:
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 }
CONST_VTBL struct IRecycleBin5Vtbl RecycleBin5Vtbl
#define CloseHandle
Definition: compat.h:598
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static HRESULT RecycleBin5_Create(IN LPCWSTR Folder, IN PSID OwnerSid OPTIONAL)
#define RECYCLE_BIN_FILE_NAME
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ZeroMemory
Definition: winbase.h:1648
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
Definition: security.c:3259
#define E_FAIL
Definition: ddrawi.h:102
int32_t INT
Definition: typedefs.h:58
#define RECYCLE_BIN_DIRECTORY_WITH_ACL
LPWSTR VolumePath
#define SEC_COMMIT
Definition: mmtypes.h:99
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define UNICODE_NULL
if SUCCEEDED(hr)
#define GENERIC_WRITE
Definition: nt_native.h:90
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define RECYCLE_BIN_DIRECTORY_WITHOUT_ACL
#define OPEN_EXISTING
Definition: compat.h:634
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define TOKEN_QUERY
Definition: setypes.h:874
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:603
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
#define GetCurrentProcess()
Definition: compat.h:618
#define GENERIC_READ
Definition: compat.h:135
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 S_OK
Definition: intsafe.h:51
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static VOID RecycleBin5_Destructor(struct RecycleBin5 *s)
#define NULL
Definition: types.h:112
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
#define CreateFileW
Definition: compat.h:600
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
SID_AND_ATTRIBUTES User
Definition: setypes.h:956
char * cleanup(char *str)
Definition: wpickclick.c:99
#define FILE_PERSISTENT_ACLS
Definition: from_kernel.h:236
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define E_POINTER
Definition: winerror.h:2365
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:594
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

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 }
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
CONST_VTBL struct IRecycleBinVtbl RecycleBinGenericVtbl
GLdouble s
Definition: gl.h:2039
#define S_OK
Definition: intsafe.h:51
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426

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 }
#define ZeroMemory
Definition: winbase.h:1648
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
CONST_VTBL struct IRecycleBinEnumListVtbl RecycleBinGenericEnumVtbl
GLdouble s
Definition: gl.h:2039
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426

Referenced by RecycleBinGeneric_RecycleBin_EnumObjects().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( recyclebin  )