shlwapi: Use publicly defined structure DATABLOCK_HEADER instead of redefining it locally.
This commit is contained in:
parent
d0e068744a
commit
c15245d9cc
|
@ -24,36 +24,28 @@
|
||||||
|
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
|
#include "winuser.h"
|
||||||
#include "objbase.h"
|
#include "objbase.h"
|
||||||
|
#include "shlobj.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
||||||
|
|
||||||
/* DataBlock list element (ordinals 17-22) */
|
/* dwSignature for contained DATABLOCK_HEADER items */
|
||||||
typedef struct tagSHLWAPI_CLIST
|
|
||||||
{
|
|
||||||
ULONG ulSize; /* Size of this list element and its data */
|
|
||||||
ULONG ulId; /* If 0xFFFFFFFF, The real element follows */
|
|
||||||
/* Item data (or a contained SHLWAPI_CLIST) follows... */
|
|
||||||
} SHLWAPI_CLIST, *LPSHLWAPI_CLIST;
|
|
||||||
|
|
||||||
typedef const SHLWAPI_CLIST* LPCSHLWAPI_CLIST;
|
|
||||||
|
|
||||||
/* ulId for contained SHLWAPI_CLIST items */
|
|
||||||
#define CLIST_ID_CONTAINER (~0U)
|
#define CLIST_ID_CONTAINER (~0U)
|
||||||
|
|
||||||
HRESULT WINAPI SHAddDataBlock(LPSHLWAPI_CLIST*,LPCSHLWAPI_CLIST);
|
HRESULT WINAPI SHAddDataBlock(LPDBLIST*,const DATABLOCK_HEADER*);
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* NextItem
|
* NextItem
|
||||||
*
|
*
|
||||||
* Internal helper: move a DataBlock pointer to the next item.
|
* Internal helper: move a DataBlock pointer to the next item.
|
||||||
*/
|
*/
|
||||||
static inline LPSHLWAPI_CLIST NextItem(LPSHLWAPI_CLIST lpList)
|
static inline LPDATABLOCK_HEADER NextItem(LPDBLIST lpList)
|
||||||
{
|
{
|
||||||
char* address = (char*)lpList;
|
char* address = (char*)lpList;
|
||||||
address += lpList->ulSize;
|
address += lpList->cbSize;
|
||||||
return (LPSHLWAPI_CLIST)address;
|
return (LPDATABLOCK_HEADER)address;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
@ -93,27 +85,27 @@ static inline LPSHLWAPI_CLIST NextItem(LPSHLWAPI_CLIST lpList)
|
||||||
*
|
*
|
||||||
* These functions are slow for large objects and long lists.
|
* These functions are slow for large objects and long lists.
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI SHWriteDataBlockList(IStream* lpStream, LPSHLWAPI_CLIST lpList)
|
HRESULT WINAPI SHWriteDataBlockList(IStream* lpStream, LPDBLIST lpList)
|
||||||
{
|
{
|
||||||
ULONG ulSize;
|
ULONG ulSize;
|
||||||
HRESULT hRet = E_FAIL;
|
HRESULT hRet = S_OK;
|
||||||
|
|
||||||
TRACE("(%p,%p)\n", lpStream, lpList);
|
TRACE("(%p,%p)\n", lpStream, lpList);
|
||||||
|
|
||||||
if(lpList)
|
if(lpList)
|
||||||
{
|
{
|
||||||
while (lpList->ulSize)
|
while (lpList->cbSize)
|
||||||
{
|
{
|
||||||
LPSHLWAPI_CLIST lpItem = lpList;
|
LPDATABLOCK_HEADER lpItem = lpList;
|
||||||
|
|
||||||
if(lpList->ulId == CLIST_ID_CONTAINER)
|
if(lpList->dwSignature == CLIST_ID_CONTAINER)
|
||||||
lpItem++;
|
lpItem++;
|
||||||
|
|
||||||
hRet = IStream_Write(lpStream,lpItem,lpItem->ulSize,&ulSize);
|
hRet = IStream_Write(lpStream,lpItem,lpItem->cbSize,&ulSize);
|
||||||
if (FAILED(hRet))
|
if (FAILED(hRet))
|
||||||
return hRet;
|
return hRet;
|
||||||
|
|
||||||
if(lpItem->ulSize != ulSize)
|
if(lpItem->cbSize != ulSize)
|
||||||
return STG_E_MEDIUMFULL;
|
return STG_E_MEDIUMFULL;
|
||||||
|
|
||||||
lpList = NextItem(lpList);
|
lpList = NextItem(lpList);
|
||||||
|
@ -149,11 +141,11 @@ HRESULT WINAPI SHWriteDataBlockList(IStream* lpStream, LPSHLWAPI_CLIST lpList)
|
||||||
* When read from a file, list objects are limited in size to 64k.
|
* When read from a file, list objects are limited in size to 64k.
|
||||||
* See SHWriteDataBlockList.
|
* See SHWriteDataBlockList.
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI SHReadDataBlockList(IStream* lpStream, LPSHLWAPI_CLIST* lppList)
|
HRESULT WINAPI SHReadDataBlockList(IStream* lpStream, LPDBLIST* lppList)
|
||||||
{
|
{
|
||||||
SHLWAPI_CLIST bBuff[128]; /* Temporary storage for new list item */
|
DATABLOCK_HEADER bBuff[128]; /* Temporary storage for new list item */
|
||||||
ULONG ulBuffSize = sizeof(bBuff);
|
ULONG ulBuffSize = sizeof(bBuff);
|
||||||
LPSHLWAPI_CLIST pItem = bBuff;
|
LPDATABLOCK_HEADER pItem = bBuff;
|
||||||
ULONG ulRead, ulSize;
|
ULONG ulRead, ulSize;
|
||||||
HRESULT hRet = S_OK;
|
HRESULT hRet = S_OK;
|
||||||
|
|
||||||
|
@ -189,18 +181,18 @@ HRESULT WINAPI SHReadDataBlockList(IStream* lpStream, LPSHLWAPI_CLIST* lppList)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (ulSize >= sizeof(SHLWAPI_CLIST))
|
else if (ulSize >= sizeof(DATABLOCK_HEADER))
|
||||||
{
|
{
|
||||||
/* Add this new item to the list */
|
/* Add this new item to the list */
|
||||||
if(ulSize > ulBuffSize)
|
if(ulSize > ulBuffSize)
|
||||||
{
|
{
|
||||||
/* We need more buffer space, allocate it */
|
/* We need more buffer space, allocate it */
|
||||||
LPSHLWAPI_CLIST lpTemp;
|
LPDATABLOCK_HEADER lpTemp;
|
||||||
|
|
||||||
if (pItem == bBuff)
|
if (pItem == bBuff)
|
||||||
lpTemp = (LPSHLWAPI_CLIST)LocalAlloc(LMEM_ZEROINIT, ulSize);
|
lpTemp = (LPDATABLOCK_HEADER)LocalAlloc(LMEM_ZEROINIT, ulSize);
|
||||||
else
|
else
|
||||||
lpTemp = (LPSHLWAPI_CLIST)LocalReAlloc((HLOCAL)pItem, ulSize,
|
lpTemp = (LPDATABLOCK_HEADER)LocalReAlloc((HLOCAL)pItem, ulSize,
|
||||||
LMEM_ZEROINIT|LMEM_MOVEABLE);
|
LMEM_ZEROINIT|LMEM_MOVEABLE);
|
||||||
|
|
||||||
if(!lpTemp)
|
if(!lpTemp)
|
||||||
|
@ -212,11 +204,11 @@ HRESULT WINAPI SHReadDataBlockList(IStream* lpStream, LPSHLWAPI_CLIST* lppList)
|
||||||
pItem = lpTemp;
|
pItem = lpTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
pItem->ulSize = ulSize;
|
pItem->cbSize = ulSize;
|
||||||
ulSize -= sizeof(pItem->ulSize); /* already read this member */
|
ulSize -= sizeof(pItem->cbSize); /* already read this member */
|
||||||
|
|
||||||
/* Read the item Id and data */
|
/* Read the item Id and data */
|
||||||
hRet = IStream_Read(lpStream, &pItem->ulId, ulSize, &ulRead);
|
hRet = IStream_Read(lpStream, &pItem->dwSignature, ulSize, &ulRead);
|
||||||
|
|
||||||
if(FAILED(hRet) || ulRead != ulSize)
|
if(FAILED(hRet) || ulRead != ulSize)
|
||||||
break;
|
break;
|
||||||
|
@ -246,7 +238,7 @@ HRESULT WINAPI SHReadDataBlockList(IStream* lpStream, LPSHLWAPI_CLIST* lppList)
|
||||||
* NOTES
|
* NOTES
|
||||||
* See SHWriteDataBlockList.
|
* See SHWriteDataBlockList.
|
||||||
*/
|
*/
|
||||||
VOID WINAPI SHFreeDataBlockList(LPSHLWAPI_CLIST lpList)
|
VOID WINAPI SHFreeDataBlockList(LPDBLIST lpList)
|
||||||
{
|
{
|
||||||
TRACE("(%p)\n", lpList);
|
TRACE("(%p)\n", lpList);
|
||||||
|
|
||||||
|
@ -269,13 +261,13 @@ VOID WINAPI SHFreeDataBlockList(LPSHLWAPI_CLIST lpList)
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* If the size of the element to be inserted is less than the size of a
|
* If the size of the element to be inserted is less than the size of a
|
||||||
* SHLWAPI_CLIST node, or the Id for the item is CLIST_ID_CONTAINER,
|
* DATABLOCK_HEADER node, or the Id for the item is CLIST_ID_CONTAINER,
|
||||||
* the call returns S_OK but does not actually add the element.
|
* the call returns S_OK but does not actually add the element.
|
||||||
* See SHWriteDataBlockList.
|
* See SHWriteDataBlockList.
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI SHAddDataBlock(LPSHLWAPI_CLIST* lppList, LPCSHLWAPI_CLIST lpNewItem)
|
HRESULT WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewItem)
|
||||||
{
|
{
|
||||||
LPSHLWAPI_CLIST lpInsertAt = NULL;
|
LPDATABLOCK_HEADER lpInsertAt = NULL;
|
||||||
ULONG ulSize;
|
ULONG ulSize;
|
||||||
|
|
||||||
TRACE("(%p,%p)\n", lppList, lpNewItem);
|
TRACE("(%p,%p)\n", lppList, lpNewItem);
|
||||||
|
@ -283,23 +275,23 @@ HRESULT WINAPI SHAddDataBlock(LPSHLWAPI_CLIST* lppList, LPCSHLWAPI_CLIST lpNewIt
|
||||||
if(!lppList || !lpNewItem )
|
if(!lppList || !lpNewItem )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
if (lpNewItem->ulSize < sizeof(SHLWAPI_CLIST) ||
|
if (lpNewItem->cbSize < sizeof(DATABLOCK_HEADER) ||
|
||||||
lpNewItem->ulId == CLIST_ID_CONTAINER)
|
lpNewItem->dwSignature == CLIST_ID_CONTAINER)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
||||||
ulSize = lpNewItem->ulSize;
|
ulSize = lpNewItem->cbSize;
|
||||||
|
|
||||||
if(ulSize & 0x3)
|
if(ulSize & 0x3)
|
||||||
{
|
{
|
||||||
/* Tune size to a ULONG boundary, add space for container element */
|
/* Tune size to a ULONG boundary, add space for container element */
|
||||||
ulSize = ((ulSize + 0x3) & 0xFFFFFFFC) + sizeof(SHLWAPI_CLIST);
|
ulSize = ((ulSize + 0x3) & 0xFFFFFFFC) + sizeof(DATABLOCK_HEADER);
|
||||||
TRACE("Creating container item, new size = %d\n", ulSize);
|
TRACE("Creating container item, new size = %d\n", ulSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!*lppList)
|
if(!*lppList)
|
||||||
{
|
{
|
||||||
/* An empty list. Allocate space for terminal ulSize also */
|
/* An empty list. Allocate space for terminal ulSize also */
|
||||||
*lppList = (LPSHLWAPI_CLIST)LocalAlloc(LMEM_ZEROINIT,
|
*lppList = (LPDATABLOCK_HEADER)LocalAlloc(LMEM_ZEROINIT,
|
||||||
ulSize + sizeof(ULONG));
|
ulSize + sizeof(ULONG));
|
||||||
lpInsertAt = *lppList;
|
lpInsertAt = *lppList;
|
||||||
}
|
}
|
||||||
|
@ -307,44 +299,44 @@ HRESULT WINAPI SHAddDataBlock(LPSHLWAPI_CLIST* lppList, LPCSHLWAPI_CLIST lpNewIt
|
||||||
{
|
{
|
||||||
/* Append to the end of the list */
|
/* Append to the end of the list */
|
||||||
ULONG ulTotalSize = 0;
|
ULONG ulTotalSize = 0;
|
||||||
LPSHLWAPI_CLIST lpIter = *lppList;
|
LPDATABLOCK_HEADER lpIter = *lppList;
|
||||||
|
|
||||||
/* Iterate to the end of the list, calculating the total size */
|
/* Iterate to the end of the list, calculating the total size */
|
||||||
while (lpIter->ulSize)
|
while (lpIter->cbSize)
|
||||||
{
|
{
|
||||||
ulTotalSize += lpIter->ulSize;
|
ulTotalSize += lpIter->cbSize;
|
||||||
lpIter = NextItem(lpIter);
|
lpIter = NextItem(lpIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Increase the size of the list */
|
/* Increase the size of the list */
|
||||||
lpIter = (LPSHLWAPI_CLIST)LocalReAlloc((HLOCAL)*lppList,
|
lpIter = (LPDATABLOCK_HEADER)LocalReAlloc((HLOCAL)*lppList,
|
||||||
ulTotalSize + ulSize+sizeof(ULONG),
|
ulTotalSize + ulSize+sizeof(ULONG),
|
||||||
LMEM_ZEROINIT | LMEM_MOVEABLE);
|
LMEM_ZEROINIT | LMEM_MOVEABLE);
|
||||||
if(lpIter)
|
if(lpIter)
|
||||||
{
|
{
|
||||||
*lppList = lpIter;
|
*lppList = lpIter;
|
||||||
lpInsertAt = (LPSHLWAPI_CLIST)((char*)lpIter + ulTotalSize); /* At end */
|
lpInsertAt = (LPDATABLOCK_HEADER)((char*)lpIter + ulTotalSize); /* At end */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lpInsertAt)
|
if(lpInsertAt)
|
||||||
{
|
{
|
||||||
/* Copy in the new item */
|
/* Copy in the new item */
|
||||||
LPSHLWAPI_CLIST lpDest = lpInsertAt;
|
LPDATABLOCK_HEADER lpDest = lpInsertAt;
|
||||||
|
|
||||||
if(ulSize != lpNewItem->ulSize)
|
if(ulSize != lpNewItem->cbSize)
|
||||||
{
|
{
|
||||||
lpInsertAt->ulSize = ulSize;
|
lpInsertAt->cbSize = ulSize;
|
||||||
lpInsertAt->ulId = CLIST_ID_CONTAINER;
|
lpInsertAt->dwSignature = CLIST_ID_CONTAINER;
|
||||||
lpDest++;
|
lpDest++;
|
||||||
}
|
}
|
||||||
memcpy(lpDest, lpNewItem, lpNewItem->ulSize);
|
memcpy(lpDest, lpNewItem, lpNewItem->cbSize);
|
||||||
|
|
||||||
/* Terminate the list */
|
/* Terminate the list */
|
||||||
lpInsertAt = NextItem(lpInsertAt);
|
lpInsertAt = NextItem(lpInsertAt);
|
||||||
lpInsertAt->ulSize = 0;
|
lpInsertAt->cbSize = 0;
|
||||||
|
|
||||||
return lpNewItem->ulSize;
|
return lpNewItem->cbSize;
|
||||||
}
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -356,7 +348,7 @@ HRESULT WINAPI SHAddDataBlock(LPSHLWAPI_CLIST* lppList, LPCSHLWAPI_CLIST lpNewIt
|
||||||
*
|
*
|
||||||
* PARAMS
|
* PARAMS
|
||||||
* lppList [O] List to remove the item from
|
* lppList [O] List to remove the item from
|
||||||
* ulId [I] Id of item to remove
|
* dwSignature [I] Id of item to remove
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: TRUE.
|
* Success: TRUE.
|
||||||
|
@ -365,22 +357,22 @@ HRESULT WINAPI SHAddDataBlock(LPSHLWAPI_CLIST* lppList, LPCSHLWAPI_CLIST lpNewIt
|
||||||
* NOTES
|
* NOTES
|
||||||
* See SHWriteDataBlockList.
|
* See SHWriteDataBlockList.
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI SHRemoveDataBlock(LPSHLWAPI_CLIST* lppList, ULONG ulId)
|
BOOL WINAPI SHRemoveDataBlock(LPDBLIST* lppList, DWORD dwSignature)
|
||||||
{
|
{
|
||||||
LPSHLWAPI_CLIST lpList = 0;
|
LPDATABLOCK_HEADER lpList = 0;
|
||||||
LPSHLWAPI_CLIST lpItem = NULL;
|
LPDATABLOCK_HEADER lpItem = NULL;
|
||||||
LPSHLWAPI_CLIST lpNext;
|
LPDATABLOCK_HEADER lpNext;
|
||||||
ULONG ulNewSize;
|
ULONG ulNewSize;
|
||||||
|
|
||||||
TRACE("(%p,%d)\n", lppList, ulId);
|
TRACE("(%p,%d)\n", lppList, dwSignature);
|
||||||
|
|
||||||
if(lppList && (lpList = *lppList))
|
if(lppList && (lpList = *lppList))
|
||||||
{
|
{
|
||||||
/* Search for item in list */
|
/* Search for item in list */
|
||||||
while (lpList->ulSize)
|
while (lpList->cbSize)
|
||||||
{
|
{
|
||||||
if(lpList->ulId == ulId ||
|
if(lpList->dwSignature == dwSignature ||
|
||||||
(lpList->ulId == CLIST_ID_CONTAINER && lpList[1].ulId == ulId))
|
(lpList->dwSignature == CLIST_ID_CONTAINER && lpList[1].dwSignature == dwSignature))
|
||||||
{
|
{
|
||||||
lpItem = lpList; /* Found */
|
lpItem = lpList; /* Found */
|
||||||
break;
|
break;
|
||||||
|
@ -395,11 +387,11 @@ BOOL WINAPI SHRemoveDataBlock(LPSHLWAPI_CLIST* lppList, ULONG ulId)
|
||||||
lpList = lpNext = NextItem(lpItem);
|
lpList = lpNext = NextItem(lpItem);
|
||||||
|
|
||||||
/* Locate the end of the list */
|
/* Locate the end of the list */
|
||||||
while (lpList->ulSize)
|
while (lpList->cbSize)
|
||||||
lpList = NextItem(lpList);
|
lpList = NextItem(lpList);
|
||||||
|
|
||||||
/* Resize the list */
|
/* Resize the list */
|
||||||
ulNewSize = LocalSize((HLOCAL)*lppList) - lpItem->ulSize;
|
ulNewSize = LocalSize((HLOCAL)*lppList) - lpItem->cbSize;
|
||||||
|
|
||||||
/* Copy following elements over lpItem */
|
/* Copy following elements over lpItem */
|
||||||
memmove(lpItem, lpNext, (char *)lpList - (char *)lpNext + sizeof(ULONG));
|
memmove(lpItem, lpNext, (char *)lpList - (char *)lpNext + sizeof(ULONG));
|
||||||
|
@ -411,7 +403,7 @@ BOOL WINAPI SHRemoveDataBlock(LPSHLWAPI_CLIST* lppList, ULONG ulId)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lpList = (LPSHLWAPI_CLIST)LocalReAlloc((HLOCAL)*lppList, ulNewSize,
|
lpList = (LPDATABLOCK_HEADER)LocalReAlloc((HLOCAL)*lppList, ulNewSize,
|
||||||
LMEM_ZEROINIT|LMEM_MOVEABLE);
|
LMEM_ZEROINIT|LMEM_MOVEABLE);
|
||||||
if(lpList)
|
if(lpList)
|
||||||
*lppList = lpList;
|
*lppList = lpList;
|
||||||
|
@ -426,7 +418,7 @@ BOOL WINAPI SHRemoveDataBlock(LPSHLWAPI_CLIST* lppList, ULONG ulId)
|
||||||
*
|
*
|
||||||
* PARAMS
|
* PARAMS
|
||||||
* lpList [I] List to search
|
* lpList [I] List to search
|
||||||
* ulId [I] Id of item to find
|
* dwSignature [I] Id of item to find
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: A pointer to the list item found
|
* Success: A pointer to the list item found
|
||||||
|
@ -435,17 +427,17 @@ BOOL WINAPI SHRemoveDataBlock(LPSHLWAPI_CLIST* lppList, ULONG ulId)
|
||||||
* NOTES
|
* NOTES
|
||||||
* See SHWriteDataBlockList.
|
* See SHWriteDataBlockList.
|
||||||
*/
|
*/
|
||||||
LPSHLWAPI_CLIST WINAPI SHFindDataBlock(LPSHLWAPI_CLIST lpList, ULONG ulId)
|
LPDATABLOCK_HEADER WINAPI SHFindDataBlock(LPDBLIST lpList, DWORD dwSignature)
|
||||||
{
|
{
|
||||||
TRACE("(%p,%d)\n", lpList, ulId);
|
TRACE("(%p,%d)\n", lpList, dwSignature);
|
||||||
|
|
||||||
if(lpList)
|
if(lpList)
|
||||||
{
|
{
|
||||||
while(lpList->ulSize)
|
while(lpList->cbSize)
|
||||||
{
|
{
|
||||||
if(lpList->ulId == ulId)
|
if(lpList->dwSignature == dwSignature)
|
||||||
return lpList; /* Matched */
|
return lpList; /* Matched */
|
||||||
else if(lpList->ulId == CLIST_ID_CONTAINER && lpList[1].ulId == ulId)
|
else if(lpList->dwSignature == CLIST_ID_CONTAINER && lpList[1].dwSignature == dwSignature)
|
||||||
return lpList + 1; /* Contained item matches */
|
return lpList + 1; /* Contained item matches */
|
||||||
|
|
||||||
lpList = NextItem(lpList);
|
lpList = NextItem(lpList);
|
||||||
|
|
Loading…
Reference in New Issue