ReactOS  0.4.15-dev-1018-g0695ecb
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 674 of file recyclebin_v5.c.

675 {
676  struct RecycleBin5 *s = NULL;
677  DWORD FileSystemFlags;
678  LPCWSTR RecycleBinDirectory;
679  HANDLE tokenHandle = INVALID_HANDLE_VALUE;
680  PTOKEN_USER TokenUserInfo = NULL;
681  LPWSTR StringSid = NULL, p;
682  DWORD Needed, DirectoryLength;
683  INT len;
684  HRESULT hr;
685 
686  if (!ppUnknown)
687  return E_POINTER;
688 
689  /* Get information about file system */
691  VolumePath,
692  NULL,
693  0,
694  NULL,
695  NULL,
696  &FileSystemFlags,
697  NULL,
698  0))
699  {
701  goto cleanup;
702  }
703  if (!(FileSystemFlags & FILE_PERSISTENT_ACLS))
704  RecycleBinDirectory = RECYCLE_BIN_DIRECTORY_WITHOUT_ACL;
705  else
706  {
707  RecycleBinDirectory = RECYCLE_BIN_DIRECTORY_WITH_ACL;
708 
709  /* Get user SID */
710  if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &tokenHandle))
711  {
713  goto cleanup;
714  }
715  if (GetTokenInformation(tokenHandle, TokenUser, NULL, 0, &Needed))
716  {
717  hr = E_FAIL;
718  goto cleanup;
719  }
721  {
723  goto cleanup;
724  }
725  TokenUserInfo = HeapAlloc(GetProcessHeap(), 0, Needed);
726  if (!TokenUserInfo)
727  {
728  hr = E_OUTOFMEMORY;
729  goto cleanup;
730  }
731  if (!GetTokenInformation(tokenHandle, TokenUser, TokenUserInfo, (DWORD)Needed, &Needed))
732  {
734  goto cleanup;
735  }
736  if (!ConvertSidToStringSidW(TokenUserInfo->User.Sid, &StringSid))
737  {
739  goto cleanup;
740  }
741  }
742 
743  DirectoryLength = wcslen(VolumePath) + wcslen(RecycleBinDirectory) + 1;
744  if (StringSid)
745  DirectoryLength += wcslen(StringSid) + 1;
746  DirectoryLength += 1 + wcslen(RECYCLE_BIN_FILE_NAME);
747  DirectoryLength += wcslen(VolumePath) + 1;
748  Needed = (DirectoryLength + 1) * sizeof(WCHAR);
749 
750  s = CoTaskMemAlloc(sizeof(struct RecycleBin5) + Needed);
751  if (!s)
752  {
753  hr = E_OUTOFMEMORY;
754  goto cleanup;
755  }
756  ZeroMemory(s, sizeof(struct RecycleBin5));
757  s->recycleBinImpl.lpVtbl = &RecycleBin5Vtbl;
758  s->ref = 1;
759  if (StringSid)
760  len = swprintf(s->Folder, L"%s%s\\%s", VolumePath, RecycleBinDirectory, StringSid);
761  else
762  len = swprintf(s->Folder, L"%s%s", VolumePath, RecycleBinDirectory);
763  p = &s->Folder[len];
765  s->hInfo = CreateFileW(s->Folder, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
767  {
768  *p = UNICODE_NULL;
769  hr = RecycleBin5_Create(s->Folder, TokenUserInfo ? TokenUserInfo->User.Sid : NULL);
770  *p = L'\\';
771  if (!SUCCEEDED(hr))
772  goto cleanup;
773  s->hInfo = CreateFileW(s->Folder, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
774  }
775  if (s->hInfo == INVALID_HANDLE_VALUE)
776  {
778  goto cleanup;
779  }
780  s->hInfoMapped = CreateFileMappingW(s->hInfo, NULL, PAGE_READWRITE | SEC_COMMIT, 0, 0, NULL);
781  if (!s->hInfoMapped)
782  {
784  goto cleanup;
785  }
786  *p = UNICODE_NULL;
787  s->VolumePath = p + 1;
788  wcscpy(s->VolumePath, VolumePath);
789 
790  *ppUnknown = (IUnknown *)&s->recycleBinImpl;
791 
792  hr = S_OK;
793 
794 cleanup:
795  if (tokenHandle != INVALID_HANDLE_VALUE)
796  CloseHandle(tokenHandle);
797  HeapFree(GetProcessHeap(), 0, TokenUserInfo);
798  if (StringSid)
799  LocalFree(StringSid);
800  if (!SUCCEEDED(hr))
801  {
802  if (s)
804  }
805  return hr;
806 }
CONST_VTBL struct IRecycleBin5Vtbl RecycleBin5Vtbl
#define CloseHandle
Definition: compat.h:487
#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:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#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
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define RECYCLE_BIN_DIRECTORY_WITHOUT_ACL
#define OPEN_EXISTING
Definition: compat.h:523
#define GetProcessHeap()
Definition: compat.h:484
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:492
#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:507
#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:59
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static VOID RecycleBin5_Destructor(struct RecycleBin5 *s)
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
#define CreateFileW
Definition: compat.h:489
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:483
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#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:59
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  )