ReactOS  0.4.15-dev-1049-g1062a29
recyclebin_v5.c File Reference
#include "recyclebin_private.h"
#include "sddl.h"
Include dependency graph for recyclebin_v5.c:

Go to the source code of this file.

Classes

struct  RecycleBin5
 

Functions

static BOOL IntDeleteRecursive (IN LPCWSTR FullName)
 
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_QueryInterface (IRecycleBin5 *This, REFIID riid, void **ppvObject)
 
static ULONG STDMETHODCALLTYPE RecycleBin5_RecycleBin5_AddRef (IRecycleBin5 *This)
 
static VOID RecycleBin5_Destructor (struct RecycleBin5 *s)
 
static ULONG STDMETHODCALLTYPE RecycleBin5_RecycleBin5_Release (IRecycleBin5 *This)
 
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_DeleteFile (IN IRecycleBin5 *This, IN LPCWSTR szFileName)
 
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_EmptyRecycleBin (IN IRecycleBin5 *This)
 
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_EnumObjects (IN IRecycleBin5 *This, OUT IRecycleBinEnumList **ppEnumList)
 
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_Delete (IN IRecycleBin5 *This, IN LPCWSTR pDeletedFileName, IN DELETED_FILE_RECORD *pDeletedFile)
 
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_Restore (IN IRecycleBin5 *This, IN LPCWSTR pDeletedFileName, IN DELETED_FILE_RECORD *pDeletedFile)
 
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_OnClosing (IN IRecycleBin5 *This, IN IRecycleBinEnumList *prbel)
 
static HRESULT RecycleBin5_Create (IN LPCWSTR Folder, IN PSID OwnerSid OPTIONAL)
 
HRESULT RecycleBin5_Constructor (IN LPCWSTR VolumePath, OUT IUnknown **ppUnknown)
 

Variables

CONST_VTBL struct IRecycleBin5Vtbl RecycleBin5Vtbl
 

Function Documentation

◆ IntDeleteRecursive()

static BOOL IntDeleteRecursive ( IN LPCWSTR  FullName)
static

Definition at line 14 of file recyclebin_v5.c.

16 {
17  DWORD RemovableAttributes = FILE_ATTRIBUTE_READONLY;
18  WIN32_FIND_DATAW FindData;
19  HANDLE hSearch = INVALID_HANDLE_VALUE;
20  LPWSTR FullPath = NULL, pFilePart;
23  BOOL ret = FALSE;
24 
27  {
29  ret = TRUE;
30  goto cleanup;
31  }
32  if (FileAttributes & RemovableAttributes)
33  {
34  if (!SetFileAttributesW(FullName, FileAttributes & ~RemovableAttributes))
35  goto cleanup;
36  }
38  {
39  /* Prepare file specification */
41  FullPath = HeapAlloc(GetProcessHeap(), 0, (dwLength + 1 + MAX_PATH + 1) * sizeof(WCHAR));
42  if (!FullPath)
43  {
45  goto cleanup;
46  }
47  wcscpy(FullPath, FullName);
48  if (FullPath[dwLength - 1] != '\\')
49  {
50  FullPath[dwLength] = '\\';
51  dwLength++;
52  }
53  pFilePart = &FullPath[dwLength];
54  wcscpy(pFilePart, L"*");
55 
56  /* Enumerate contents, and delete it */
57  hSearch = FindFirstFileW(FullPath, &FindData);
58  if (hSearch == INVALID_HANDLE_VALUE)
59  goto cleanup;
60  do
61  {
62  if (!(FindData.cFileName[0] == '.' &&
63  (FindData.cFileName[1] == '\0' || (FindData.cFileName[1] == '.' && FindData.cFileName[2] == '\0'))))
64  {
65  wcscpy(pFilePart, FindData.cFileName);
66  if (!IntDeleteRecursive(FullPath))
67  {
68  FindClose(hSearch);
69  goto cleanup;
70  }
71  }
72  }
73  while (FindNextFileW(hSearch, &FindData));
74  FindClose(hSearch);
76  goto cleanup;
77 
78  /* Remove (now empty) directory */
80  goto cleanup;
81  }
82  else
83  {
84  if (!DeleteFileW(FullName))
85  goto cleanup;
86  }
87  ret = TRUE;
88 
89 cleanup:
90  HeapFree(GetProcessHeap(), 0, FullPath);
91  return ret;
92 }
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:794
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
#define TRUE
Definition: types.h:120
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG FileAttributes
Definition: fltkernel.h:1230
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
#define ERROR_NO_MORE_FILES
Definition: winerror.h:121
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
#define MAX_PATH
Definition: compat.h:34
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PSTRING FullName
Definition: rtlfuncs.h:1649
#define SetLastError(x)
Definition: compat.h:500
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
int ret
_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
ULONG_PTR SIZE_T
Definition: typedefs.h:80
static BOOL IntDeleteRecursive(IN LPCWSTR FullName)
Definition: recyclebin_v5.c:14
char * cleanup(char *str)
Definition: wpickclick.c:99
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:483
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by RecycleBin5_RecycleBin5_Delete().

◆ 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: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
#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:51
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:49
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by GetDefaultRecycleBin().

◆ RecycleBin5_Create()

static HRESULT RecycleBin5_Create ( IN LPCWSTR  Folder,
IN PSID OwnerSid  OPTIONAL 
)
static

Definition at line 561 of file recyclebin_v5.c.

564 {
565  LPWSTR BufferName = NULL;
566  LPWSTR Separator; /* Pointer into BufferName buffer */
567  LPWSTR FileName; /* Pointer into BufferName buffer */
568  LPCSTR DesktopIniContents = "[.ShellClassInfo]\r\nCLSID={645FF040-5081-101B-9F08-00AA002F954E}\r\n";
569  INFO2_HEADER Info2Contents[] = { { 5, 0, 0, 0x320, 0 } };
570  DWORD BytesToWrite, BytesWritten, Needed;
572  HRESULT hr;
573 
574  Needed = (wcslen(Folder) + 1 + max(wcslen(RECYCLE_BIN_FILE_NAME), wcslen(L"desktop.ini")) + 1) * sizeof(WCHAR);
575  BufferName = HeapAlloc(GetProcessHeap(), 0, Needed);
576  if (!BufferName)
577  {
579  goto cleanup;
580  }
581 
582  wcscpy(BufferName, Folder);
583  Separator = wcsstr(&BufferName[3], L"\\");
584  if (Separator)
585  *Separator = UNICODE_NULL;
586  if (!CreateDirectoryW(BufferName, NULL) && GetLastError() != ERROR_ALREADY_EXISTS)
587  {
589  goto cleanup;
590  }
592  if (Separator)
593  {
594  *Separator = L'\\';
595  if (!CreateDirectoryW(BufferName, NULL) && GetLastError() != ERROR_ALREADY_EXISTS)
596  {
598  goto cleanup;
599  }
600  }
601 
602  if (OwnerSid)
603  {
604  //DWORD rc;
605 
606  /* Add ACL to allow only user/SYSTEM to open it */
607  /* FIXME: rc = SetNamedSecurityInfo(
608  BufferName,
609  SE_FILE_OBJECT,
610  ???,
611  OwnerSid,
612  NULL,
613  ???,
614  ???);
615  if (rc != ERROR_SUCCESS)
616  {
617  hr = HRESULT_FROM_WIN32(rc);
618  goto cleanup;
619  }
620  */
621  }
622 
623  wcscat(BufferName, L"\\");
624  FileName = &BufferName[wcslen(BufferName)];
625 
626  /* Create desktop.ini */
627  wcscpy(FileName, L"desktop.ini");
630  {
632  goto cleanup;
633  }
634  BytesToWrite = strlen(DesktopIniContents);
635  if (!WriteFile(hFile, DesktopIniContents, (DWORD)BytesToWrite, &BytesWritten, NULL))
636  {
638  goto cleanup;
639  }
640  if (BytesWritten != BytesToWrite)
641  {
642  hr = E_FAIL;
643  goto cleanup;
644  }
647 
648  /* Create empty INFO2 file */
652  {
654  goto cleanup;
655  }
656  BytesToWrite = sizeof(Info2Contents);
657  if (!WriteFile(hFile, Info2Contents, (DWORD)BytesToWrite, &BytesWritten, NULL))
658  {
660  goto cleanup;
661  }
662  if (BytesWritten == BytesToWrite)
663  hr = S_OK;
664  else
665  hr = E_FAIL;
666 
667 cleanup:
668  HeapFree(GetProcessHeap(), 0, BufferName);
671  return hr;
672 }
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:794
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define max(a, b)
Definition: svc.c:63
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
#define CloseHandle
Definition: compat.h:487
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define RECYCLE_BIN_FILE_NAME
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define E_FAIL
Definition: ddrawi.h:102
#define UNICODE_NULL
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
WCHAR Folder[ANY_SIZE]
const char * LPCSTR
Definition: xmlstorage.h:183
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
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
#define GENERIC_READ
Definition: compat.h:135
_In_ HANDLE hFile
Definition: mswsock.h:90
struct _FileName FileName
Definition: fatprocs.h:893
#define S_OK
Definition: intsafe.h:51
#define CREATE_ALWAYS
Definition: disk.h:72
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define CreateFileW
Definition: compat.h:489
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:483

Referenced by RecycleBin5_Constructor().

◆ RecycleBin5_Destructor()

static VOID RecycleBin5_Destructor ( struct RecycleBin5 s)
static

Definition at line 147 of file recyclebin_v5.c.

149 {
150  TRACE("(%p)\n", s);
151 
152  if (s->hInfo && s->hInfo != INVALID_HANDLE_VALUE)
153  CloseHandle(s->hInfo);
154  if (s->hInfoMapped)
155  CloseHandle(s->hInfoMapped);
156  CoTaskMemFree(s);
157 }
#define CloseHandle
Definition: compat.h:487
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
#define TRACE(s)
Definition: solgame.cpp:4
GLdouble s
Definition: gl.h:2039

Referenced by RecycleBin5_Constructor(), and RecycleBin5_RecycleBin5_Release().

◆ RecycleBin5_RecycleBin5_AddRef()

static ULONG STDMETHODCALLTYPE RecycleBin5_RecycleBin5_AddRef ( IRecycleBin5 This)
static

Definition at line 137 of file recyclebin_v5.c.

139 {
141  ULONG refCount = InterlockedIncrement((PLONG)&s->ref);
142  TRACE("(%p)\n", This);
143  return refCount;
144 }
IRecycleBin5 recycleBinImpl
Definition: recyclebin_v5.c:97
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TRACE(s)
Definition: solgame.cpp:4
GLdouble s
Definition: gl.h:2039
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1
signed int * PLONG
Definition: retypes.h:5

◆ RecycleBin5_RecycleBin5_Delete()

static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_Delete ( IN IRecycleBin5 This,
IN LPCWSTR  pDeletedFileName,
IN DELETED_FILE_RECORD pDeletedFile 
)
static

Definition at line 404 of file recyclebin_v5.c.

408 {
411  PINFO2_HEADER pHeader;
412  DELETED_FILE_RECORD *pRecord, *pLast;
413  DWORD dwEntries, i;
414 
415  TRACE("(%p, %s, %p)\n", This, debugstr_w(pDeletedFileName), pDeletedFile);
416 
417  if (s->EnumeratorCount != 0)
419 
420  pHeader = MapViewOfFile(s->hInfoMapped, FILE_MAP_WRITE, 0, 0, 0);
421  if (!pHeader)
423 
424  FileSize.u.LowPart = GetFileSize(s->hInfo, &FileSize.u.HighPart);
425  if (FileSize.u.LowPart == 0)
426  {
427  UnmapViewOfFile(pHeader);
429  }
430  dwEntries = (DWORD)((FileSize.QuadPart - sizeof(INFO2_HEADER)) / sizeof(DELETED_FILE_RECORD));
431 
432  pRecord = (DELETED_FILE_RECORD *)(pHeader + 1);
433  for (i = 0; i < dwEntries; i++)
434  {
435  if (pRecord->dwRecordUniqueId == pDeletedFile->dwRecordUniqueId)
436  {
437  /* Delete file */
438  if (!IntDeleteRecursive(pDeletedFileName))
439  {
440  UnmapViewOfFile(pHeader);
442  }
443 
444  /* Clear last entry in the file */
445  MoveMemory(pRecord, pRecord + 1, (dwEntries - i - 1) * sizeof(DELETED_FILE_RECORD));
446  pLast = pRecord + (dwEntries - i - 1);
447  ZeroMemory(pLast, sizeof(DELETED_FILE_RECORD));
448  UnmapViewOfFile(pHeader);
449 
450  /* Resize file */
451  CloseHandle(s->hInfoMapped);
452  SetFilePointer(s->hInfo, -(LONG)sizeof(DELETED_FILE_RECORD), NULL, FILE_END);
453  SetEndOfFile(s->hInfo);
454  s->hInfoMapped = CreateFileMappingW(s->hInfo, NULL, PAGE_READWRITE | SEC_COMMIT, 0, 0, NULL);
455  if (!s->hInfoMapped)
457  return S_OK;
458  }
459  pRecord++;
460  }
461  UnmapViewOfFile(pHeader);
463 }
#define CloseHandle
Definition: compat.h:487
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define MapViewOfFile
Definition: compat.h:493
IRecycleBin5 recycleBinImpl
Definition: recyclebin_v5.c:97
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1004
struct _LARGE_INTEGER::@2263 u
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ZeroMemory
Definition: winbase.h:1648
#define MoveMemory
Definition: winbase.h:1645
#define DWORD
Definition: nt_native.h:44
struct _DELETED_FILE_RECORD DELETED_FILE_RECORD
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define SEC_COMMIT
Definition: mmtypes.h:99
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TRACE(s)
Definition: solgame.cpp:4
#define FILE_END
Definition: winbase.h:114
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:492
#define FILE_MAP_WRITE
Definition: winbase.h:154
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
GLdouble s
Definition: gl.h:2039
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define S_OK
Definition: intsafe.h:51
static BOOL IntDeleteRecursive(IN LPCWSTR FullName)
Definition: recyclebin_v5.c:14
#define UnmapViewOfFile
Definition: compat.h:494
#define SetFilePointer
Definition: compat.h:491
LONGLONG QuadPart
Definition: typedefs.h:114
#define PAGE_READWRITE
Definition: nt_native.h:1304

◆ RecycleBin5_RecycleBin5_DeleteFile()

static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_DeleteFile ( IN IRecycleBin5 This,
IN LPCWSTR  szFileName 
)
static

Definition at line 177 of file recyclebin_v5.c.

180 {
182  LPWSTR szFullName = NULL;
183  DWORD dwBufferLength = 0;
186  WCHAR DeletedFileName[MAX_PATH];
187  DWORD len;
189  PINFO2_HEADER pHeader = NULL;
190  PDELETED_FILE_RECORD pDeletedFile;
192  DWORD dwAttributes, dwEntries;
193  SYSTEMTIME SystemTime;
194  DWORD ClusterSize, BytesPerSector, SectorsPerCluster;
195  HRESULT hr;
196 
197  TRACE("(%p, %s)\n", This, debugstr_w(szFileName));
198 
199  if (s->EnumeratorCount != 0)
201 
202  /* Get full file name */
203  while (TRUE)
204  {
205  len = GetFullPathNameW(szFileName, dwBufferLength, szFullName, &lpFilePart);
206  if (len == 0)
207  {
208  if (szFullName)
209  CoTaskMemFree(szFullName);
211  }
212  else if (len < dwBufferLength)
213  break;
214  if (szFullName)
215  CoTaskMemFree(szFullName);
216  dwBufferLength = len;
217  szFullName = CoTaskMemAlloc(dwBufferLength * sizeof(WCHAR));
218  if (!szFullName)
220  }
221 
222  /* Check if file exists */
223  dwAttributes = GetFileAttributesW(szFullName);
225  {
226  CoTaskMemFree(szFullName);
228  }
229 
230  if (dwBufferLength < 2 || szFullName[1] != ':')
231  {
232  /* Not a local file */
233  CoTaskMemFree(szFullName);
235  }
236 
237  hFile = CreateFileW(szFullName, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
239  {
241  goto cleanup;
242  }
243 
244  /* Increase INFO2 file size */
245  CloseHandle(s->hInfoMapped);
246  SetFilePointer(s->hInfo, sizeof(DELETED_FILE_RECORD), NULL, FILE_END);
247  SetEndOfFile(s->hInfo);
248  s->hInfoMapped = CreateFileMappingW(s->hInfo, NULL, PAGE_READWRITE | SEC_COMMIT, 0, 0, NULL);
249  if (!s->hInfoMapped)
250  {
252  goto cleanup;
253  }
254 
255  /* Open INFO2 file */
256  pHeader = MapViewOfFile(s->hInfoMapped, FILE_MAP_WRITE, 0, 0, 0);
257  if (!pHeader)
258  {
260  goto cleanup;
261  }
262 
263  /* Get number of entries */
264  FileSize.u.LowPart = GetFileSize(s->hInfo, &FileSize.u.HighPart);
265  if (FileSize.u.LowPart < sizeof(INFO2_HEADER))
266  {
268  goto cleanup;
269  }
270  dwEntries = (DWORD)((FileSize.QuadPart - sizeof(INFO2_HEADER)) / sizeof(DELETED_FILE_RECORD)) - 1;
271  pDeletedFile = ((PDELETED_FILE_RECORD)(pHeader + 1)) + dwEntries;
272 
273  /* Get file size */
274 #if 0
276  {
278  goto cleanup;
279  }
280 #else
281  FileSize.u.LowPart = GetFileSize(hFile, &FileSize.u.HighPart);
282  if (FileSize.u.LowPart == INVALID_FILE_SIZE && GetLastError() != NO_ERROR)
283  {
285  goto cleanup;
286  }
287 #endif
288  /* Check if file size is > 4Gb */
289  if (FileSize.u.HighPart != 0)
290  {
291  /* Yes, this recyclebin can't support this file */
293  goto cleanup;
294  }
295  pHeader->dwTotalLogicalSize += FileSize.u.LowPart;
296 
297  /* Generate new name */
298  Extension = wcsrchr(szFullName, '.');
299  ZeroMemory(pDeletedFile, sizeof(DELETED_FILE_RECORD));
300  if (dwEntries == 0)
301  pDeletedFile->dwRecordUniqueId = 0;
302  else
303  {
304  PDELETED_FILE_RECORD pLastDeleted = ((PDELETED_FILE_RECORD)(pHeader + 1)) + dwEntries - 1;
305  pDeletedFile->dwRecordUniqueId = pLastDeleted->dwRecordUniqueId + 1;
306  }
307  pDeletedFile->dwDriveNumber = tolower(szFullName[0]) - 'a';
308  _snwprintf(DeletedFileName, MAX_PATH, L"%s\\D%c%lu%s", s->Folder, pDeletedFile->dwDriveNumber + 'a', pDeletedFile->dwRecordUniqueId, Extension);
309 
310  /* Get cluster size */
311  if (!GetDiskFreeSpaceW(s->VolumePath, &SectorsPerCluster, &BytesPerSector, NULL, NULL))
312  {
314  goto cleanup;
315  }
316  ClusterSize = BytesPerSector * SectorsPerCluster;
317 
318  /* Get current time */
319  GetSystemTime(&SystemTime);
320  if (!SystemTimeToFileTime(&SystemTime, &pDeletedFile->DeletionTime))
321  {
323  goto cleanup;
324  }
325  pDeletedFile->dwPhysicalFileSize = ROUND_UP(FileSize.u.LowPart, ClusterSize);
326 
327  /* Set name */
328  wcscpy(pDeletedFile->FileNameW, szFullName);
329  if (WideCharToMultiByte(CP_ACP, 0, pDeletedFile->FileNameW, -1, pDeletedFile->FileNameA, MAX_PATH, NULL, NULL) == 0)
330  {
333  goto cleanup;
334  }
335 
336  /* Move file */
337  if (MoveFileW(szFullName, DeletedFileName))
338  hr = S_OK;
339  else
341 
342 cleanup:
343  if (pHeader)
344  UnmapViewOfFile(pHeader);
347  CoTaskMemFree(szFullName);
348  return hr;
349 }
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD _Out_opt_ LPSTR * lpFilePart
Definition: winbase.h:3038
#define CloseHandle
Definition: compat.h:487
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define ROUND_UP(n, align)
Definition: eventvwr.h:31
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define MapViewOfFile
Definition: compat.h:493
#define WideCharToMultiByte
Definition: compat.h:111
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
IRecycleBin5 recycleBinImpl
Definition: recyclebin_v5.c:97
#define CP_ACP
Definition: compat.h:109
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1004
struct _DELETED_FILE_RECORD * PDELETED_FILE_RECORD
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
struct _LARGE_INTEGER::@2263 u
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ZeroMemory
Definition: winbase.h:1648
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1105
#define INVALID_FILE_SIZE
Definition: winbase.h:529
#define NO_ERROR
Definition: dderror.h:5
#define DWORD
Definition: nt_native.h:44
DWORD dwAttributes
Definition: vdmdbg.h:34
CHAR FileNameA[MAX_PATH]
Definition: recyclebin_v5.h:15
struct _DELETED_FILE_RECORD DELETED_FILE_RECORD
#define SEC_COMMIT
Definition: mmtypes.h:99
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
#define debugstr_w
Definition: kernel32.h:32
BOOL WINAPI MoveFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName)
Definition: move.c:1044
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:523
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
BOOL WINAPI GetDiskFreeSpaceW(IN LPCWSTR lpRootPathName, OUT LPDWORD lpSectorsPerCluster, OUT LPDWORD lpBytesPerSector, OUT LPDWORD lpNumberOfFreeClusters, OUT LPDWORD lpTotalNumberOfClusters)
Definition: disk.c:173
VOID WINAPI GetSystemTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:327
#define TRACE(s)
Definition: solgame.cpp:4
#define FILE_END
Definition: winbase.h:114
__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 FILE_MAP_WRITE
Definition: winbase.h:154
#define MAX_PATH
Definition: compat.h:34
DWORD ClusterSize
Definition: format.c:67
WCHAR FileNameW[MAX_PATH]
Definition: recyclebin_v5.h:20
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
#define SetLastError(x)
Definition: compat.h:500
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define GetFileSizeEx
Definition: compat.h:505
_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
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
GLdouble s
Definition: gl.h:2039
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define wcsrchr
Definition: compat.h:16
_In_ HANDLE hFile
Definition: mswsock.h:90
#define S_OK
Definition: intsafe.h:51
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
#define CreateFileW
Definition: compat.h:489
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ERROR_INVALID_NAME
Definition: compat.h:103
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define UnmapViewOfFile
Definition: compat.h:494
int tolower(int c)
Definition: utclib.c:902
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
#define SetFilePointer
Definition: compat.h:491
LONGLONG QuadPart
Definition: typedefs.h:114
#define PAGE_READWRITE
Definition: nt_native.h:1304

◆ RecycleBin5_RecycleBin5_EmptyRecycleBin()

static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_EmptyRecycleBin ( IN IRecycleBin5 This)
static

Definition at line 352 of file recyclebin_v5.c.

354 {
355  IRecycleBinEnumList *prbel;
356  IRecycleBinFile *prbf;
357  HRESULT hr;
358 
359  TRACE("(%p)\n", This);
360 
361  while (TRUE)
362  {
363  hr = IRecycleBin5_EnumObjects(This, &prbel);
364  if (!SUCCEEDED(hr))
365  return hr;
366  hr = IRecycleBinEnumList_Next(prbel, 1, &prbf, NULL);
367  IRecycleBinEnumList_Release(prbel);
368  if (hr == S_FALSE)
369  return S_OK;
370  hr = IRecycleBinFile_Delete(prbf);
371  IRecycleBinFile_Release(prbf);
372  if (!SUCCEEDED(hr))
373  return hr;
374  }
375 }
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:51
#define SUCCEEDED(hr)
Definition: intsafe.h:49

◆ RecycleBin5_RecycleBin5_EnumObjects()

static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_EnumObjects ( IN IRecycleBin5 This,
OUT IRecycleBinEnumList **  ppEnumList 
)
static

Definition at line 378 of file recyclebin_v5.c.

381 {
383  IRecycleBinEnumList *prbel;
384  HRESULT hr;
385  IUnknown *pUnk;
386 
387  TRACE("(%p, %p)\n", This, ppEnumList);
388 
389  hr = RecycleBin5Enum_Constructor(This, s->hInfo, s->hInfoMapped, s->Folder, &pUnk);
390  if (!SUCCEEDED(hr))
391  return hr;
392 
393  hr = IUnknown_QueryInterface(pUnk, &IID_IRecycleBinEnumList, (void **)&prbel);
394  if (SUCCEEDED(hr))
395  {
396  s->EnumeratorCount++;
397  *ppEnumList = prbel;
398  }
399  IUnknown_Release(pUnk);
400  return hr;
401 }
HRESULT hr
Definition: shlfolder.c:183
IRecycleBin5 recycleBinImpl
Definition: recyclebin_v5.c:97
EXTERN_C const IID IID_IRecycleBinEnumList
Definition: recyclebin.h:248
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
GLdouble s
Definition: gl.h:2039
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
HRESULT RecycleBin5Enum_Constructor(IN IRecycleBin5 *prb, IN HANDLE hInfo, IN HANDLE hInfoMapped, IN LPCWSTR szPrefix, OUT IUnknown **ppUnknown)
#define SUCCEEDED(hr)
Definition: intsafe.h:49

◆ RecycleBin5_RecycleBin5_OnClosing()

static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_OnClosing ( IN IRecycleBin5 This,
IN IRecycleBinEnumList *  prbel 
)
static

Definition at line 537 of file recyclebin_v5.c.

540 {
542  TRACE("(%p, %p)\n", This, prbel);
543  s->EnumeratorCount--;
544  return S_OK;
545 }
IRecycleBin5 recycleBinImpl
Definition: recyclebin_v5.c:97
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TRACE(s)
Definition: solgame.cpp:4
GLdouble s
Definition: gl.h:2039
#define S_OK
Definition: intsafe.h:51

◆ RecycleBin5_RecycleBin5_QueryInterface()

static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_QueryInterface ( IRecycleBin5 This,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 108 of file recyclebin_v5.c.

112 {
114 
115  TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppvObject);
116 
117  if (!ppvObject)
118  return E_POINTER;
119 
121  *ppvObject = &s->recycleBinImpl;
122  else if (IsEqualIID(riid, &IID_IRecycleBin))
123  *ppvObject = &s->recycleBinImpl;
124  else if (IsEqualIID(riid, &IID_IRecycleBin5))
125  *ppvObject = &s->recycleBinImpl;
126  else
127  {
128  *ppvObject = NULL;
129  return E_NOINTERFACE;
130  }
131 
132  IUnknown_AddRef(This);
133  return S_OK;
134 }
EXTERN_C const IID IID_IRecycleBin
Definition: recyclebin.h:249
EXTERN_C const IID IID_IRecycleBin5
Definition: recyclebin_v5.h:28
#define E_NOINTERFACE
Definition: winerror.h:2364
IRecycleBin5 recycleBinImpl
Definition: recyclebin_v5.c:97
REFIID riid
Definition: precomp.h:44
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
GLdouble s
Definition: gl.h:2039
REFIID LPVOID * ppvObject
Definition: precomp.h:44
#define S_OK
Definition: intsafe.h:51
#define E_POINTER
Definition: winerror.h:2365
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ RecycleBin5_RecycleBin5_Release()

static ULONG STDMETHODCALLTYPE RecycleBin5_RecycleBin5_Release ( IRecycleBin5 This)
static

Definition at line 160 of file recyclebin_v5.c.

162 {
164  ULONG refCount;
165 
166  TRACE("(%p)\n", This);
167 
168  refCount = InterlockedDecrement((PLONG)&s->ref);
169 
170  if (refCount == 0)
172 
173  return refCount;
174 }
IRecycleBin5 recycleBinImpl
Definition: recyclebin_v5.c:97
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedDecrement
Definition: armddk.h:52
GLdouble s
Definition: gl.h:2039
static VOID RecycleBin5_Destructor(struct RecycleBin5 *s)
unsigned int ULONG
Definition: retypes.h:1
signed int * PLONG
Definition: retypes.h:5

◆ RecycleBin5_RecycleBin5_Restore()

static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_Restore ( IN IRecycleBin5 This,
IN LPCWSTR  pDeletedFileName,
IN DELETED_FILE_RECORD pDeletedFile 
)
static

Definition at line 466 of file recyclebin_v5.c.

470 {
473  PINFO2_HEADER pHeader;
474  DELETED_FILE_RECORD *pRecord, *pLast;
475  DWORD dwEntries, i;
477 
478  TRACE("(%p, %s, %p)\n", This, debugstr_w(pDeletedFileName), pDeletedFile);
479 
480  if (s->EnumeratorCount != 0)
482 
483  pHeader = MapViewOfFile(s->hInfoMapped, FILE_MAP_WRITE, 0, 0, 0);
484  if (!pHeader)
486 
487  FileSize.u.LowPart = GetFileSize(s->hInfo, &FileSize.u.HighPart);
488  if (FileSize.u.LowPart == 0)
489  {
490  UnmapViewOfFile(pHeader);
492  }
493  dwEntries = (DWORD)((FileSize.QuadPart - sizeof(INFO2_HEADER)) / sizeof(DELETED_FILE_RECORD));
494 
495  pRecord = (DELETED_FILE_RECORD *)(pHeader + 1);
496  for (i = 0; i < dwEntries; i++)
497  {
498  if (pRecord->dwRecordUniqueId == pDeletedFile->dwRecordUniqueId)
499  {
500  /* Restore file */
501  ZeroMemory(&op, sizeof(op));
502  op.wFunc = FO_COPY;
503  op.pFrom = pDeletedFileName;
504  op.pTo = pDeletedFile->FileNameW;
505 
506  int res = SHFileOperationW(&op);
507  if (res)
508  {
509  ERR("SHFileOperationW failed with 0x%x\n", res);
510  UnmapViewOfFile(pHeader);
511  return E_FAIL;
512  }
513 
514  /* Clear last entry in the file */
515  MoveMemory(pRecord, pRecord + 1, (dwEntries - i - 1) * sizeof(DELETED_FILE_RECORD));
516  pLast = pRecord + (dwEntries - i - 1);
517  ZeroMemory(pLast, sizeof(DELETED_FILE_RECORD));
518  UnmapViewOfFile(pHeader);
519 
520  /* Resize file */
521  CloseHandle(s->hInfoMapped);
522  SetFilePointer(s->hInfo, -(LONG)sizeof(DELETED_FILE_RECORD), NULL, FILE_END);
523  SetEndOfFile(s->hInfo);
524  s->hInfoMapped = CreateFileMappingW(s->hInfo, NULL, PAGE_READWRITE | SEC_COMMIT, 0, 0, NULL);
525  if (!s->hInfoMapped)
527  return S_OK;
528  }
529  pRecord++;
530  }
531 
532  UnmapViewOfFile(pHeader);
534 }
#define CloseHandle
Definition: compat.h:487
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define MapViewOfFile
Definition: compat.h:493
IRecycleBin5 recycleBinImpl
Definition: recyclebin_v5.c:97
#define FO_COPY
Definition: shellapi.h:134
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1004
struct _LARGE_INTEGER::@2263 u
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ZeroMemory
Definition: winbase.h:1648
#define MoveMemory
Definition: winbase.h:1645
#define E_FAIL
Definition: ddrawi.h:102
#define DWORD
Definition: nt_native.h:44
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1918
struct _DELETED_FILE_RECORD DELETED_FILE_RECORD
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define SEC_COMMIT
Definition: mmtypes.h:99
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TRACE(s)
Definition: solgame.cpp:4
#define FILE_END
Definition: winbase.h:114
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:492
#define FILE_MAP_WRITE
Definition: winbase.h:154
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT op
Definition: effect.c:224
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
GLdouble s
Definition: gl.h:2039
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:51
GLuint res
Definition: glext.h:9613
#define UnmapViewOfFile
Definition: compat.h:494
#define SetFilePointer
Definition: compat.h:491
LONGLONG QuadPart
Definition: typedefs.h:114
#define PAGE_READWRITE
Definition: nt_native.h:1304

Variable Documentation

◆ RecycleBin5Vtbl

Initial value:
=
{
}
static ULONG STDMETHODCALLTYPE RecycleBin5_RecycleBin5_AddRef(IRecycleBin5 *This)
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_DeleteFile(IN IRecycleBin5 *This, IN LPCWSTR szFileName)
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_Delete(IN IRecycleBin5 *This, IN LPCWSTR pDeletedFileName, IN DELETED_FILE_RECORD *pDeletedFile)
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_OnClosing(IN IRecycleBin5 *This, IN IRecycleBinEnumList *prbel)
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_EnumObjects(IN IRecycleBin5 *This, OUT IRecycleBinEnumList **ppEnumList)
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_QueryInterface(IRecycleBin5 *This, REFIID riid, void **ppvObject)
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_Restore(IN IRecycleBin5 *This, IN LPCWSTR pDeletedFileName, IN DELETED_FILE_RECORD *pDeletedFile)
static ULONG STDMETHODCALLTYPE RecycleBin5_RecycleBin5_Release(IRecycleBin5 *This)
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_EmptyRecycleBin(IN IRecycleBin5 *This)

Definition at line 547 of file recyclebin_v5.c.

Referenced by RecycleBin5_Constructor().