Author: hpoussin
Date: Wed Oct 31 16:10:07 2007
New Revision: 30010
URL:
http://svn.reactos.org/svn/reactos?rev=30010&view=rev
Log:
Allocate enough memory to keep file details
Modified:
trunk/reactos/dll/win32/shell32/recyclebin.c
Modified: trunk/reactos/dll/win32/shell32/recyclebin.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/recycleb…
==============================================================================
--- trunk/reactos/dll/win32/shell32/recyclebin.c (original)
+++ trunk/reactos/dll/win32/shell32/recyclebin.c Wed Oct 31 16:10:07 2007
@@ -217,37 +217,43 @@
return E_NOTIMPL;
}
+
+PDELETED_FILE_DETAILS_W
+UnpackDetailsFromPidl(LPCITEMIDLIST pidl)
+{
+ return (PDELETED_FILE_DETAILS_W)&pidl->mkid.abID;
+}
+
BOOL
WINAPI
CBEnumBitBucket(IN PVOID Context, IN HANDLE hDeletedFile)
{
PDELETED_FILE_DETAILS_W pFileDetails;
- DWORD dwSize = 0;
+ DWORD dwSize, dwTotalSize;
LPITEMIDLIST pidl = NULL;
BOOL ret;
TRACE("CBEnumBitBucket entered\n");
- GetDeletedFileDetailsW(hDeletedFile,
- 0,
- NULL,
- &dwSize);
-
- if (!dwSize)
+ if (!GetDeletedFileDetailsW(hDeletedFile,
+ 0,
+ NULL,
+ &dwSize) &&
+ GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
ERR("GetDeletedFileDetailsW failed\n");
return FALSE;
}
-
- pidl = SHAlloc(dwSize);
+ dwTotalSize = FIELD_OFFSET(ITEMIDLIST, mkid.abID) + dwSize;
+
+ pidl = SHAlloc(dwTotalSize);
if (!pidl)
{
ERR("No memory\n");
return FALSE;
}
- pidl->mkid.cb = dwSize;
- pidl->mkid.abID[0] = 0;
- pFileDetails = (PDELETED_FILE_DETAILS_W) &pidl->mkid.abID[1];
+ pidl->mkid.cb = dwTotalSize;
+ pFileDetails = UnpackDetailsFromPidl(pidl);
if (!GetDeletedFileDetailsW(hDeletedFile,
dwSize,
@@ -260,13 +266,9 @@
}
ret = AddToEnumList((IEnumIDList*)Context, pidl);
+ TRACE("Returning %d\n", ret);
+ CloseRecycleBinHandle(hDeletedFile);
return ret;
-}
-
-PDELETED_FILE_DETAILS_W
-UnpackDetailsFromPidl(LPCITEMIDLIST pidl)
-{
- return (PDELETED_FILE_DETAILS_W)&pidl->mkid.abID[1];
}
static HRESULT WINAPI RecycleBin_EnumObjects(IShellFolder2 *iface, HWND hwnd, SHCONTF
grfFlags, IEnumIDList **ppenumIDList)