setupapi: Add some tests for StringTableLookUpStringEx. Make them pass.
This commit is contained in:
parent
0184dea2d4
commit
601870a435
|
@ -273,6 +273,7 @@ StringTableAddStringEx(HSTRING_TABLE hStringTable, LPWSTR lpString,
|
||||||
return ~0u;
|
return ~0u;
|
||||||
}
|
}
|
||||||
memcpy(pStringTable->pSlots[i].pData, lpExtraData, dwExtraDataSize);
|
memcpy(pStringTable->pSlots[i].pData, lpExtraData, dwExtraDataSize);
|
||||||
|
pStringTable->pSlots[i].dwSize = dwExtraDataSize;
|
||||||
pStringTable->dwUsedSlots++;
|
pStringTable->dwUsedSlots++;
|
||||||
return i + 1;
|
return i + 1;
|
||||||
}
|
}
|
||||||
|
@ -492,7 +493,7 @@ StringTableLookUpStringEx(HSTRING_TABLE hStringTable,
|
||||||
if (!lstrcmpW(pStringTable->pSlots[i].pString, lpString))
|
if (!lstrcmpW(pStringTable->pSlots[i].pString, lpString))
|
||||||
{
|
{
|
||||||
if (lpExtraData)
|
if (lpExtraData)
|
||||||
memcpy(lpExtraData, pStringTable->pSlots[i].pData, pStringTable->pSlots[i].dwSize);
|
memcpy(lpExtraData, pStringTable->pSlots[i].pData, (DWORD)lpReserved);
|
||||||
return i + 1;
|
return i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -501,7 +502,7 @@ StringTableLookUpStringEx(HSTRING_TABLE hStringTable,
|
||||||
if (!lstrcmpiW(pStringTable->pSlots[i].pString, lpString))
|
if (!lstrcmpiW(pStringTable->pSlots[i].pString, lpString))
|
||||||
{
|
{
|
||||||
if (lpExtraData)
|
if (lpExtraData)
|
||||||
memcpy(lpExtraData, pStringTable->pSlots[i].pData, pStringTable->pSlots[i].dwSize);
|
memcpy(lpExtraData, pStringTable->pSlots[i].pData, (DWORD)lpReserved);
|
||||||
return i + 1;
|
return i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ static DWORD (WINAPI *pStringTableAddStringEx)(HSTRING_TABLE, LPWSTR, DWORD,
|
||||||
static VOID (WINAPI *pStringTableDestroy)(HSTRING_TABLE);
|
static VOID (WINAPI *pStringTableDestroy)(HSTRING_TABLE);
|
||||||
static HSTRING_TABLE (WINAPI *pStringTableDuplicate)(HSTRING_TABLE hStringTable);
|
static HSTRING_TABLE (WINAPI *pStringTableDuplicate)(HSTRING_TABLE hStringTable);
|
||||||
static HSTRING_TABLE (WINAPI *pStringTableInitialize)(VOID);
|
static HSTRING_TABLE (WINAPI *pStringTableInitialize)(VOID);
|
||||||
|
static HSTRING_TABLE (WINAPI *pStringTableInitializeEx)(DWORD, DWORD);
|
||||||
static DWORD (WINAPI *pStringTableLookUpString)(HSTRING_TABLE, LPWSTR, DWORD);
|
static DWORD (WINAPI *pStringTableLookUpString)(HSTRING_TABLE, LPWSTR, DWORD);
|
||||||
static DWORD (WINAPI *pStringTableLookUpStringEx)(HSTRING_TABLE, LPWSTR, DWORD, LPVOID, LPDWORD);
|
static DWORD (WINAPI *pStringTableLookUpStringEx)(HSTRING_TABLE, LPWSTR, DWORD, LPVOID, LPDWORD);
|
||||||
static LPWSTR (WINAPI *pStringTableStringFromId)(HSTRING_TABLE, DWORD);
|
static LPWSTR (WINAPI *pStringTableStringFromId)(HSTRING_TABLE, DWORD);
|
||||||
|
@ -65,6 +66,10 @@ static void load_it_up(void)
|
||||||
if (!pStringTableInitialize)
|
if (!pStringTableInitialize)
|
||||||
pStringTableInitialize = (void*)GetProcAddress(hdll, "pSetupStringTableInitialize");
|
pStringTableInitialize = (void*)GetProcAddress(hdll, "pSetupStringTableInitialize");
|
||||||
|
|
||||||
|
pStringTableInitializeEx = (void*)GetProcAddress(hdll, "StringTableInitializeEx");
|
||||||
|
if (!pStringTableInitializeEx)
|
||||||
|
pStringTableInitializeEx = (void*)GetProcAddress(hdll, "pSetupStringTableInitializeEx");
|
||||||
|
|
||||||
pStringTableAddString = (void*)GetProcAddress(hdll, "StringTableAddString");
|
pStringTableAddString = (void*)GetProcAddress(hdll, "StringTableAddString");
|
||||||
if (!pStringTableAddString)
|
if (!pStringTableAddString)
|
||||||
pStringTableAddString = (void*)GetProcAddress(hdll, "pSetupStringTableAddString");
|
pStringTableAddString = (void*)GetProcAddress(hdll, "pSetupStringTableAddString");
|
||||||
|
@ -221,8 +226,10 @@ static void test_StringTableLookUpString(void)
|
||||||
|
|
||||||
static void test_StringTableLookUpStringEx(void)
|
static void test_StringTableLookUpStringEx(void)
|
||||||
{
|
{
|
||||||
DWORD retval, retval2, hstring, hString, hfoo;
|
static WCHAR uilevel[] = {'U','I','L','E','V','E','L',0};
|
||||||
|
DWORD retval, retval2, hstring, hString, hfoo, data;
|
||||||
HANDLE table, table2;
|
HANDLE table, table2;
|
||||||
|
char buffer[4];
|
||||||
|
|
||||||
table = pStringTableInitialize();
|
table = pStringTableInitialize();
|
||||||
ok(table != NULL,"Failed to Initialize String Table\n");
|
ok(table != NULL,"Failed to Initialize String Table\n");
|
||||||
|
@ -273,6 +280,30 @@ static void test_StringTableLookUpStringEx(void)
|
||||||
retval, hString);
|
retval, hString);
|
||||||
|
|
||||||
pStringTableDestroy(table);
|
pStringTableDestroy(table);
|
||||||
|
|
||||||
|
table = pStringTableInitializeEx(0x1000, 0);
|
||||||
|
ok(table != NULL, "failed to initialize string table\n");
|
||||||
|
|
||||||
|
data = 0xaaaaaaaa;
|
||||||
|
retval = pStringTableAddStringEx(table, uilevel, 0x5, &data, sizeof(data));
|
||||||
|
ok(retval != ~0u, "failed to add 'UILEVEL' to string table\n");
|
||||||
|
|
||||||
|
memset(buffer, 0x55, sizeof(buffer));
|
||||||
|
retval = pStringTableLookUpStringEx(table, uilevel, ST_CASE_SENSITIVE_COMPARE, buffer, (LPDWORD)0);
|
||||||
|
ok(retval != ~0u, "failed find 'UILEVEL' in string table\n");
|
||||||
|
ok(memcmp(buffer, &data, 4), "unexpected data\n");
|
||||||
|
|
||||||
|
memset(buffer, 0x55, sizeof(buffer));
|
||||||
|
retval = pStringTableLookUpStringEx(table, uilevel, ST_CASE_SENSITIVE_COMPARE, buffer, (LPDWORD)2);
|
||||||
|
ok(retval != ~0u, "failed find 'UILEVEL' in string table\n");
|
||||||
|
ok(!memcmp(buffer, &data, 2), "unexpected data\n");
|
||||||
|
|
||||||
|
memset(buffer, 0x55, sizeof(buffer));
|
||||||
|
retval = pStringTableLookUpStringEx(table, uilevel, ST_CASE_SENSITIVE_COMPARE, buffer, (LPDWORD)sizeof(buffer));
|
||||||
|
ok(retval != ~0u, "failed find 'UILEVEL' in string table\n");
|
||||||
|
ok(!memcmp(buffer, &data, 4), "unexpected data\n");
|
||||||
|
|
||||||
|
pStringTableDestroy(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_StringTableStringFromId(void)
|
static void test_StringTableStringFromId(void)
|
||||||
|
|
Loading…
Reference in New Issue