ReactOS  0.4.14-dev-50-g13bb5e2
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  if (!SHFileOperationW(&op))
507  {
508  UnmapViewOfFile(pHeader);
510  }
511 
512  /* Clear last entry in the file */
513  MoveMemory(pRecord, pRecord + 1, (dwEntries - i - 1) * sizeof(DELETED_FILE_RECORD));
514  pLast = pRecord + (dwEntries - i - 1);
515  ZeroMemory(pLast, sizeof(DELETED_FILE_RECORD));
516  UnmapViewOfFile(pHeader);
517 
518  /* Resize file */
519  CloseHandle(s->hInfoMapped);
520  SetFilePointer(s->hInfo, -(LONG)sizeof(DELETED_FILE_RECORD), NULL, FILE_END);
521  SetEndOfFile(s->hInfo);
522  s->hInfoMapped = CreateFileMappingW(s->hInfo, NULL, PAGE_READWRITE | SEC_COMMIT, 0, 0, NULL);
523  if (!s->hInfoMapped)
525  return S_OK;
526  }
527  pRecord++;
528  }
529 
530  UnmapViewOfFile(pHeader);
532 }
533 
537  IN IRecycleBinEnumList *prbel)
538 {
540  TRACE("(%p, %p)\n", This, prbel);
541  s->EnumeratorCount--;
542  return S_OK;
543 }
544 
546 {
556 };
557 
558 static HRESULT
560  IN LPCWSTR Folder,
561  IN PSID OwnerSid OPTIONAL)
562 {
563  LPWSTR BufferName = NULL;
564  LPWSTR Separator; /* Pointer into BufferName buffer */
565  LPWSTR FileName; /* Pointer into BufferName buffer */
566  LPCSTR DesktopIniContents = "[.ShellClassInfo]\r\nCLSID={645FF040-5081-101B-9F08-00AA002F954E}\r\n";
567  INFO2_HEADER Info2Contents[] = { { 5, 0, 0, 0x320, 0 } };
568  DWORD BytesToWrite, BytesWritten, Needed;
570  HRESULT hr;
571 
572  Needed = (wcslen(Folder) + 1 + max(wcslen(RECYCLE_BIN_FILE_NAME), wcslen(L"desktop.ini")) + 1) * sizeof(WCHAR);
573  BufferName = HeapAlloc(GetProcessHeap(), 0, Needed);
574  if (!BufferName)
575  {
577  goto cleanup;
578  }
579 
580  wcscpy(BufferName, Folder);
581  Separator = wcsstr(&BufferName[3], L"\\");
582  if (Separator)
583  *Separator = UNICODE_NULL;
584  if (!CreateDirectoryW(BufferName, NULL) && GetLastError() != ERROR_ALREADY_EXISTS)
585  {
587  goto cleanup;
588  }
590  if (Separator)
591  {
592  *Separator = L'\\';
593  if (!CreateDirectoryW(BufferName, NULL) && GetLastError() != ERROR_ALREADY_EXISTS)
594  {
596  goto cleanup;
597  }
598  }
599 
600  if (OwnerSid)
601  {
602  //DWORD rc;
603 
604  /* Add ACL to allow only user/SYSTEM to open it */
605  /* FIXME: rc = SetNamedSecurityInfo(
606  BufferName,
607  SE_FILE_OBJECT,
608  ???,
609  OwnerSid,
610  NULL,
611  ???,
612  ???);
613  if (rc != ERROR_SUCCESS)
614  {
615  hr = HRESULT_FROM_WIN32(rc);
616  goto cleanup;
617  }
618  */
619  }
620 
621  wcscat(BufferName, L"\\");
622  FileName = &BufferName[wcslen(BufferName)];
623 
624  /* Create desktop.ini */
625  wcscpy(FileName, L"desktop.ini");
628  {
630  goto cleanup;
631  }
632  BytesToWrite = strlen(DesktopIniContents);
633  if (!WriteFile(hFile, DesktopIniContents, (DWORD)BytesToWrite, &BytesWritten, NULL))
634  {
636  goto cleanup;
637  }
638  if (BytesWritten != BytesToWrite)
639  {
640  hr = E_FAIL;
641  goto cleanup;
642  }
645 
646  /* Create empty INFO2 file */
650  {
652  goto cleanup;
653  }
654  BytesToWrite = sizeof(Info2Contents);
655  if (!WriteFile(hFile, Info2Contents, (DWORD)BytesToWrite, &BytesWritten, NULL))
656  {
658  goto cleanup;
659  }
660  if (BytesWritten == BytesToWrite)
661  hr = S_OK;
662  else
663  hr = E_FAIL;
664 
665 cleanup:
666  HeapFree(GetProcessHeap(), 0, BufferName);
669  return hr;
670 }
671 
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 }
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:38
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:3015
_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
#define TRUE
Definition: types.h:120
EXTERN_C const IID IID_IRecycleBin5
Definition: recyclebin_v5.h:28
#define CloseHandle
Definition: compat.h:398
#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:422
#define MapViewOfFile
Definition: compat.h:402
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
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:99
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
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
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:1632
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:56
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1782
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
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
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 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
struct _LARGE_INTEGER::@2201 u
#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
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
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:426
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:317
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
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:83
LONG HRESULT
Definition: typedefs.h:77
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:401
static HRESULT STDMETHODCALLTYPE RecycleBin5_RecycleBin5_OnClosing(IN IRecycleBin5 *This, IN IRecycleBinEnumList *prbel)
const GUID IID_IUnknown
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
#define FILE_MAP_WRITE
Definition: winbase.h:154
#define MAX_PATH
Definition: compat.h:26
#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
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
#define SetLastError(x)
Definition: compat.h:409
#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:414
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
REFIID LPVOID * ppvObject
Definition: precomp.h:44
#define GENERIC_READ
Definition: compat.h:124
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
_In_ HANDLE hFile
Definition: mswsock.h:90
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:78
struct _FileName FileName
Definition: fatprocs.h:884
#define S_OK
Definition: intsafe.h:59
#define CREATE_ALWAYS
Definition: disk.h:72
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:148
#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:400
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90
static BOOL IntDeleteRecursive(IN LPCWSTR FullName)
Definition: recyclebin_v5.c:14
#define OUT
Definition: typedefs.h:39
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:93
#define FILE_PERSISTENT_ACLS
Definition: from_kernel.h:236
UINT op
Definition: effect.c:223
#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:403
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:406
_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:394
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 SUCCEEDED(hr)
Definition: intsafe.h:57
LONGLONG QuadPart
Definition: typedefs.h:112
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