ReactOS  0.4.14-dev-833-g5f692ed
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 672 of file recyclebin_v5.c.

673 {
674  struct RecycleBin5 *s = NULL;
675  DWORD FileSystemFlags;
676  LPCWSTR RecycleBinDirectory;
677  HANDLE tokenHandle = INVALID_HANDLE_VALUE;
678  PTOKEN_USER TokenUserInfo = NULL;
679  LPWSTR StringSid = NULL, p;
680  DWORD Needed, DirectoryLength;
681  INT len;
682  HRESULT hr;
683 
684  if (!ppUnknown)
685  return E_POINTER;
686 
687  /* Get information about file system */
689  VolumePath,
690  NULL,
691  0,
692  NULL,
693  NULL,
694  &FileSystemFlags,
695  NULL,
696  0))
697  {
699  goto cleanup;
700  }
701  if (!(FileSystemFlags & FILE_PERSISTENT_ACLS))
702  RecycleBinDirectory = RECYCLE_BIN_DIRECTORY_WITHOUT_ACL;
703  else
704  {
705  RecycleBinDirectory = RECYCLE_BIN_DIRECTORY_WITH_ACL;
706 
707  /* Get user SID */
708  if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &tokenHandle))
709  {
711  goto cleanup;
712  }
713  if (GetTokenInformation(tokenHandle, TokenUser, NULL, 0, &Needed))
714  {
715  hr = E_FAIL;
716  goto cleanup;
717  }
719  {
721  goto cleanup;
722  }
723  TokenUserInfo = HeapAlloc(GetProcessHeap(), 0, Needed);
724  if (!TokenUserInfo)
725  {
726  hr = E_OUTOFMEMORY;
727  goto cleanup;
728  }
729  if (!GetTokenInformation(tokenHandle, TokenUser, TokenUserInfo, (DWORD)Needed, &Needed))
730  {
732  goto cleanup;
733  }
734  if (!ConvertSidToStringSidW(TokenUserInfo->User.Sid, &StringSid))
735  {
737  goto cleanup;
738  }
739  }
740 
741  DirectoryLength = wcslen(VolumePath) + wcslen(RecycleBinDirectory) + 1;
742  if (StringSid)
743  DirectoryLength += wcslen(StringSid) + 1;
744  DirectoryLength += 1 + wcslen(RECYCLE_BIN_FILE_NAME);
745  DirectoryLength += wcslen(VolumePath) + 1;
746  Needed = (DirectoryLength + 1) * sizeof(WCHAR);
747 
748  s = CoTaskMemAlloc(sizeof(struct RecycleBin5) + Needed);
749  if (!s)
750  {
751  hr = E_OUTOFMEMORY;
752  goto cleanup;
753  }
754  ZeroMemory(s, sizeof(struct RecycleBin5));
755  s->recycleBinImpl.lpVtbl = &RecycleBin5Vtbl;
756  s->ref = 1;
757  if (StringSid)
758  len = swprintf(s->Folder, L"%s%s\\%s", VolumePath, RecycleBinDirectory, StringSid);
759  else
760  len = swprintf(s->Folder, L"%s%s", VolumePath, RecycleBinDirectory);
761  p = &s->Folder[len];
763  s->hInfo = CreateFileW(s->Folder, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
765  {
766  *p = UNICODE_NULL;
767  hr = RecycleBin5_Create(s->Folder, TokenUserInfo ? TokenUserInfo->User.Sid : NULL);
768  *p = L'\\';
769  if (!SUCCEEDED(hr))
770  goto cleanup;
771  s->hInfo = CreateFileW(s->Folder, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
772  }
773  if (s->hInfo == INVALID_HANDLE_VALUE)
774  {
776  goto cleanup;
777  }
778  s->hInfoMapped = CreateFileMappingW(s->hInfo, NULL, PAGE_READWRITE | SEC_COMMIT, 0, 0, NULL);
779  if (!s->hInfoMapped)
780  {
782  goto cleanup;
783  }
784  *p = UNICODE_NULL;
785  s->VolumePath = p + 1;
786  wcscpy(s->VolumePath, VolumePath);
787 
788  *ppUnknown = (IUnknown *)&s->recycleBinImpl;
789 
790  hr = S_OK;
791 
792 cleanup:
793  if (tokenHandle != INVALID_HANDLE_VALUE)
794  CloseHandle(tokenHandle);
795  HeapFree(GetProcessHeap(), 0, TokenUserInfo);
796  if (StringSid)
797  LocalFree(StringSid);
798  if (!SUCCEEDED(hr))
799  {
800  if (s)
802  }
803  return hr;
804 }
CONST_VTBL struct IRecycleBin5Vtbl RecycleBin5Vtbl
#define CloseHandle
Definition: compat.h:406
#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:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1642
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
Definition: security.c:3259
#define E_FAIL
Definition: ddrawi.h:102
int32_t INT
Definition: typedefs.h:56
#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:434
#define GetProcessHeap()
Definition: compat.h:403
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:77
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:409
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
#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 GENERIC_READ
Definition: compat.h:124
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:408
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:404
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:402
#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:404

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:1642
#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:404

Referenced by RecycleBinGeneric_RecycleBin_EnumObjects().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( recyclebin  )