ReactOS  0.4.15-dev-1033-gd7d716a
recyclebin_v5.c
Go to the documentation of this file.
1 /*
2  * PROJECT: Recycle bin management
3  * LICENSE: GPL v2 - See COPYING in the top level directory
4  * FILE: lib/recyclebin/recyclebin_v5.c
5  * PURPOSE: Deals with recycle bins of Windows 2000/XP/2003
6  * PROGRAMMERS: Copyright 2006-2007 Hervé Poussineau (hpoussin@reactos.org)
7  */
8 
9 #include "recyclebin_private.h"
10 
11 #include "sddl.h"
12 
13 static BOOL
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 }
93 
95 {
100 
102 
104  WCHAR Folder[ANY_SIZE]; /* [drive]:\[RECYCLE_BIN_DIRECTORY]\{SID} */
105 };
106 
110  REFIID riid,
111  void **ppvObject)
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 }
135 
139 {
141  ULONG refCount = InterlockedIncrement((PLONG)&s->ref);
142  TRACE("(%p)\n", This);
143  return refCount;
144 }
145 
146 static VOID
148  struct RecycleBin5 *s)
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 }
158 
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 }
175 
179  IN LPCWSTR szFileName)
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 }
350 
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 }
376 
380  OUT IRecycleBinEnumList **ppEnumList)
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 }
402 
406  IN LPCWSTR pDeletedFileName,
407  IN DELETED_FILE_RECORD *pDeletedFile)
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 }
464 
468  IN LPCWSTR pDeletedFileName,
469  IN DELETED_FILE_RECORD *pDeletedFile)
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 }
535 
539  IN IRecycleBinEnumList *prbel)
540 {
542  TRACE("(%p, %p)\n", This, prbel);
543  s->EnumeratorCount--;
544  return S_OK;
545 }
546 
548 {
558 };
559 
560 static HRESULT
562  IN LPCWSTR Folder,
563  IN PSID OwnerSid OPTIONAL)
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 }
673 
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 }
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:944
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
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 IN
Definition: typedefs.h:39
EXTERN_C const IID IID_IRecycleBin
Definition: recyclebin.h:249
CONST_VTBL struct IRecycleBin5Vtbl RecycleBin5Vtbl
#define max(a, b)
Definition: svc.c:63
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD _Out_opt_ LPSTR * lpFilePart
Definition: winbase.h:3038
_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 REFIID
Definition: guiddef.h:118
EXTERN_C const IID IID_IRecycleBin5
Definition: recyclebin_v5.h:28
#define CloseHandle
Definition: compat.h:487
#define E_NOINTERFACE
Definition: winerror.h:2364
#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
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
static HRESULT RecycleBin5_Create(IN LPCWSTR Folder, IN PSID OwnerSid OPTIONAL)
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
IRecycleBin5 recycleBinImpl
Definition: recyclebin_v5.c:97
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
REFIID riid
Definition: precomp.h:44
EXTERN_C const IID IID_IRecycleBinEnumList
Definition: recyclebin.h:248
#define FO_COPY
Definition: shellapi.h:134
#define CP_ACP
Definition: compat.h:109
HANDLE hInfoMapped
Definition: recyclebin_v5.c:99
static ULONG STDMETHODCALLTYPE RecycleBin5_RecycleBin5_AddRef(IRecycleBin5 *This)
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1154
struct _DELETED_FILE_RECORD * PDELETED_FILE_RECORD
#define RECYCLE_BIN_FILE_NAME
HRESULT RecycleBin5_Constructor(IN LPCWSTR VolumePath, OUT IUnknown **ppUnknown)
#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:1059
#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
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_DeleteFile(IN IRecycleBin5 *This, IN LPCWSTR szFileName)
#define INVALID_FILE_SIZE
Definition: winbase.h:529
#define MoveMemory
Definition: winbase.h:1645
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
Definition: security.c:3259
#define NO_ERROR
Definition: dderror.h:5
#define E_FAIL
Definition: ddrawi.h:102
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:58
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1918
DWORD dwAttributes
Definition: vdmdbg.h:34
CHAR FileNameA[MAX_PATH]
Definition: recyclebin_v5.h:15
#define RECYCLE_BIN_DIRECTORY_WITH_ACL
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
LPWSTR VolumePath
#define SEC_COMMIT
Definition: mmtypes.h:99
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
#define CONST_VTBL
Definition: objbase.h:222
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
#define GENERIC_WRITE
Definition: nt_native.h:90
#define debugstr_w
Definition: kernel32.h:32
BOOL WINAPI MoveFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName)
Definition: move.c:1044
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
#define S_FALSE
Definition: winerror.h:2357
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
smooth NULL
Definition: ftsmooth.c:416
WCHAR Folder[ANY_SIZE]
const char * LPCSTR
Definition: xmlstorage.h:183
_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 debugstr_guid
Definition: kernel32.h:35
#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 RECYCLE_BIN_DIRECTORY_WITHOUT_ACL
#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
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
DWORD EnumeratorCount
BOOL WINAPI GetDiskFreeSpaceW(IN LPCWSTR lpRootPathName, OUT LPDWORD lpSectorsPerCluster, OUT LPDWORD lpBytesPerSector, OUT LPDWORD lpNumberOfFreeClusters, OUT LPDWORD lpTotalNumberOfClusters)
Definition: disk.c:173
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_Delete(IN IRecycleBin5 *This, IN LPCWSTR pDeletedFileName, IN DELETED_FILE_RECORD *pDeletedFile)
VOID WINAPI GetSystemTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:327
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define TOKEN_QUERY
Definition: setypes.h:874
#define FILE_END
Definition: winbase.h:114
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
LONG HRESULT
Definition: typedefs.h:79
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:492
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_OnClosing(IN IRecycleBin5 *This, IN IRecycleBinEnumList *prbel)
const GUID IID_IUnknown
#define FILE_MAP_WRITE
Definition: winbase.h:154
#define MAX_PATH
Definition: compat.h:34
#define swprintf(buf, format,...)
Definition: sprintf.c:56
DWORD ClusterSize
Definition: format.c:67
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
WCHAR FileNameW[MAX_PATH]
Definition: recyclebin_v5.h:20
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PSTRING FullName
Definition: rtlfuncs.h:1649
UINT op
Definition: effect.c:224
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
#define SetLastError(x)
Definition: compat.h:500
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
HANDLE hInfo
Definition: recyclebin_v5.c:98
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_EnumObjects(IN IRecycleBin5 *This, OUT IRecycleBinEnumList **ppEnumList)
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_QueryInterface(IRecycleBin5 *This, REFIID riid, void **ppvObject)
#define GetFileSizeEx
Definition: compat.h:505
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
#define InterlockedDecrement
Definition: armddk.h:52
GLenum GLsizei len
Definition: glext.h:6722
interface IRecycleBin5 IRecycleBin5
Definition: recyclebin_v5.h:27
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
GLdouble s
Definition: gl.h:2039
#define GetCurrentProcess()
Definition: compat.h:507
REFIID LPVOID * ppvObject
Definition: precomp.h:44
#define GENERIC_READ
Definition: compat.h:135
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define wcsrchr
Definition: compat.h:16
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ERR(fmt,...)
Definition: debug.h:110
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
ULONG_PTR SIZE_T
Definition: typedefs.h:80
struct _FileName FileName
Definition: fatprocs.h:893
#define S_OK
Definition: intsafe.h:51
#define CREATE_ALWAYS
Definition: disk.h:72
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
#define InterlockedIncrement
Definition: armddk.h:53
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
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)
_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
static VOID RecycleBin5_Destructor(struct RecycleBin5 *s)
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
#define ANY_SIZE
Definition: recyclebin.h:20
#define CreateFileW
Definition: compat.h:489
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
static BOOL IntDeleteRecursive(IN LPCWSTR FullName)
Definition: recyclebin_v5.c:14
#define OUT
Definition: typedefs.h:40
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1
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 ERROR_INVALID_NAME
Definition: compat.h:103
#define FILE_PERSISTENT_ACLS
Definition: from_kernel.h:236
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define E_POINTER
Definition: winerror.h:2365
#define UnmapViewOfFile
Definition: compat.h:494
signed int * PLONG
Definition: retypes.h:5
int tolower(int c)
Definition: utclib.c:902
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:483
HRESULT RecycleBin5Enum_Constructor(IN IRecycleBin5 *prb, IN HANDLE hInfo, IN HANDLE hInfoMapped, IN LPCWSTR szPrefix, OUT IUnknown **ppUnknown)
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_EmptyRecycleBin(IN IRecycleBin5 *This)
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define SetFilePointer
Definition: compat.h:491
#define SUCCEEDED(hr)
Definition: intsafe.h:49
LONGLONG QuadPart
Definition: typedefs.h:114
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68