Implement StringTableDuplicate.

svn path=/trunk/; revision=16383
This commit is contained in:
Eric Kohl 2005-07-02 21:32:37 +00:00
parent 396b274742
commit d23d39a743
4 changed files with 77 additions and 4 deletions

View file

@ -838,6 +838,7 @@ DWORD WINAPI StampFileSecurity(PCWSTR, PSECURITY_DESCRIPTOR);
DWORD WINAPI StringTableAddString(HSTRING_TABLE, LPWSTR, DWORD); DWORD WINAPI StringTableAddString(HSTRING_TABLE, LPWSTR, DWORD);
VOID WINAPI StringTableDestroy(HSTRING_TABLE); VOID WINAPI StringTableDestroy(HSTRING_TABLE);
HSTRING_TABLE WINAPI StringTableDuplicate(HSTRING_TABLE);
HSTRING_TABLE WINAPI StringTableInitialize(VOID); HSTRING_TABLE WINAPI StringTableInitialize(VOID);
DWORD WINAPI StringTableLookUpString(HSTRING_TABLE, LPWSTR, DWORD); DWORD WINAPI StringTableLookUpString(HSTRING_TABLE, LPWSTR, DWORD);
LPWSTR WINAPI StringTableStringFromId(HSTRING_TABLE, DWORD); LPWSTR WINAPI StringTableStringFromId(HSTRING_TABLE, DWORD);

View file

@ -516,7 +516,7 @@
@ stdcall StringTableAddString(ptr wstr long) @ stdcall StringTableAddString(ptr wstr long)
@ stub StringTableAddStringEx @ stub StringTableAddStringEx
@ stdcall StringTableDestroy(ptr) @ stdcall StringTableDestroy(ptr)
@ stub StringTableDuplicate @ stdcall StringTableDuplicate(ptr)
@ stub StringTableEnum @ stub StringTableEnum
@ stub StringTableGetExtraData @ stub StringTableGetExtraData
@ stdcall StringTableInitialize() @ stdcall StringTableInitialize()

View file

@ -36,9 +36,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
typedef struct _STRING_TABLE typedef struct _STRING_TABLE
{ {
LPWSTR *pSlots; /* 0x00 */ LPWSTR *pSlots;
DWORD dwUsedSlots; /* 0x04 */ DWORD dwUsedSlots;
DWORD dwMaxSlots; /* 0x08 */ DWORD dwMaxSlots;
} STRING_TABLE, *PSTRING_TABLE; } STRING_TABLE, *PSTRING_TABLE;
@ -221,6 +221,77 @@ StringTableAddString(HSTRING_TABLE hStringTable,
} }
/**************************************************************************
* StringTableDuplicate [SETUPAPI.@]
*
* Duplicates a given string table.
*
* PARAMS
* hStringTable [I] Handle to the string table
*
* RETURNS
* Success: Handle to the duplicated string table
* Failure: NULL
*
*/
HSTRING_TABLE WINAPI
StringTableDuplicate(HSTRING_TABLE hStringTable)
{
PSTRING_TABLE pSourceTable;
PSTRING_TABLE pDestinationTable;
DWORD i;
DWORD length;
TRACE("%p\n", (PVOID)hStringTable);
pSourceTable = (PSTRING_TABLE)hStringTable;
if (pSourceTable == NULL)
{
ERR("Invalid hStringTable!\n");
return (HSTRING_TABLE)NULL;
}
pDestinationTable = MyMalloc(sizeof(STRING_TABLE));
if (pDestinationTable == NULL)
{
ERR("Cound not allocate a new string table!\n");
return (HSTRING_TABLE)NULL;
}
memset(pDestinationTable, 0, sizeof(STRING_TABLE));
pDestinationTable->pSlots = MyMalloc(sizeof(LPWSTR) * pSourceTable->dwMaxSlots);
if (pDestinationTable->pSlots == NULL)
{
MyFree(pDestinationTable);
return (HSTRING_TABLE)NULL;
}
memset(pDestinationTable->pSlots, 0, sizeof(LPWSTR) * pSourceTable->dwMaxSlots);
pDestinationTable->dwUsedSlots = 0;
pDestinationTable->dwMaxSlots = pSourceTable->dwMaxSlots;
for (i = 0; i < pSourceTable->dwMaxSlots; i++)
{
if (pSourceTable->pSlots[i] != NULL)
{
length = lstrlenW(pSourceTable->pSlots[i]) + sizeof(WCHAR);
pDestinationTable->pSlots[i] = MyMalloc(length);
if (pDestinationTable->pSlots[i] != NULL)
{
memcpy(pDestinationTable->pSlots[i],
pSourceTable->pSlots[i],
length);
pDestinationTable->dwUsedSlots++;
}
}
}
return (HSTRING_TABLE)pDestinationTable;
}
/************************************************************************** /**************************************************************************
* StringTableLookUpString [SETUPAPI.@] * StringTableLookUpString [SETUPAPI.@]
* *

View file

@ -1350,6 +1350,7 @@ WINSETUPAPI DWORD WINAPI StampFileSecurity(PCWSTR, PSECURITY_DESCRIPTOR);
WINSETUPAPI DWORD WINAPI StringTableAddString(HSTRING_TABLE, LPWSTR, DWORD); WINSETUPAPI DWORD WINAPI StringTableAddString(HSTRING_TABLE, LPWSTR, DWORD);
WINSETUPAPI VOID WINAPI StringTableDestroy(HSTRING_TABLE); WINSETUPAPI VOID WINAPI StringTableDestroy(HSTRING_TABLE);
WINSETUPAPI HSTRING_TABLE WINAPI StringTableDuplicate(HSTRING_TABLE);
WINSETUPAPI HSTRING_TABLE WINAPI StringTableInitialize(VOID); WINSETUPAPI HSTRING_TABLE WINAPI StringTableInitialize(VOID);
WINSETUPAPI DWORD WINAPI StringTableLookUpString(HSTRING_TABLE, LPWSTR, DWORD); WINSETUPAPI DWORD WINAPI StringTableLookUpString(HSTRING_TABLE, LPWSTR, DWORD);
WINSETUPAPI LPWSTR WINAPI StringTableStringFromId(HSTRING_TABLE, DWORD); WINSETUPAPI LPWSTR WINAPI StringTableStringFromId(HSTRING_TABLE, DWORD);