Implement StringTableDuplicate. Modified: trunk/reactos/include/wine/setupapi.h Modified: trunk/reactos/lib/setupapi/setupapi.spec Modified: trunk/reactos/lib/setupapi/stringtable.c Modified: trunk/reactos/w32api/include/setupapi.h _____
Modified: trunk/reactos/include/wine/setupapi.h --- trunk/reactos/include/wine/setupapi.h 2005-07-02 19:26:43 UTC (rev 16382) +++ trunk/reactos/include/wine/setupapi.h 2005-07-02 21:32:37 UTC (rev 16383) @@ -838,6 +838,7 @@
DWORD WINAPI StringTableAddString(HSTRING_TABLE, LPWSTR, DWORD); VOID WINAPI StringTableDestroy(HSTRING_TABLE); +HSTRING_TABLE WINAPI StringTableDuplicate(HSTRING_TABLE); HSTRING_TABLE WINAPI StringTableInitialize(VOID); DWORD WINAPI StringTableLookUpString(HSTRING_TABLE, LPWSTR, DWORD); LPWSTR WINAPI StringTableStringFromId(HSTRING_TABLE, DWORD); _____
Modified: trunk/reactos/lib/setupapi/setupapi.spec --- trunk/reactos/lib/setupapi/setupapi.spec 2005-07-02 19:26:43 UTC (rev 16382) +++ trunk/reactos/lib/setupapi/setupapi.spec 2005-07-02 21:32:37 UTC (rev 16383) @@ -516,7 +516,7 @@
@ stdcall StringTableAddString(ptr wstr long) @ stub StringTableAddStringEx @ stdcall StringTableDestroy(ptr) -@ stub StringTableDuplicate +@ stdcall StringTableDuplicate(ptr) @ stub StringTableEnum @ stub StringTableGetExtraData @ stdcall StringTableInitialize() _____
Modified: trunk/reactos/lib/setupapi/stringtable.c --- trunk/reactos/lib/setupapi/stringtable.c 2005-07-02 19:26:43 UTC (rev 16382) +++ trunk/reactos/lib/setupapi/stringtable.c 2005-07-02 21:32:37 UTC (rev 16383) @@ -36,9 +36,9 @@
typedef struct _STRING_TABLE { - LPWSTR *pSlots; /* 0x00 */ - DWORD dwUsedSlots; /* 0x04 */ - DWORD dwMaxSlots; /* 0x08 */ + LPWSTR *pSlots; + DWORD dwUsedSlots; + DWORD dwMaxSlots; } STRING_TABLE, *PSTRING_TABLE;
@@ -222,6 +222,77 @@
/*********************************************************************** *** + * 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.@] * * Searches a string table for a given string. _____
Modified: trunk/reactos/w32api/include/setupapi.h --- trunk/reactos/w32api/include/setupapi.h 2005-07-02 19:26:43 UTC (rev 16382) +++ trunk/reactos/w32api/include/setupapi.h 2005-07-02 21:32:37 UTC (rev 16383) @@ -1350,6 +1350,7 @@
WINSETUPAPI DWORD WINAPI StringTableAddString(HSTRING_TABLE, LPWSTR, DWORD); WINSETUPAPI VOID WINAPI StringTableDestroy(HSTRING_TABLE); +WINSETUPAPI HSTRING_TABLE WINAPI StringTableDuplicate(HSTRING_TABLE); WINSETUPAPI HSTRING_TABLE WINAPI StringTableInitialize(VOID); WINSETUPAPI DWORD WINAPI StringTableLookUpString(HSTRING_TABLE, LPWSTR, DWORD); WINSETUPAPI LPWSTR WINAPI StringTableStringFromId(HSTRING_TABLE, DWORD);