setupapi: Duplicate behaviour of native SetupGetInfInformation with NULL ReturnBuffer and certain ReturnBufferSizes.

This commit is contained in:
Frank Richter 2006-09-22 13:17:46 +02:00 committed by Alexandre Julliard
parent 8cbca5dcfd
commit e1fa51f59c
2 changed files with 21 additions and 8 deletions

View File

@ -130,6 +130,7 @@ BOOL WINAPI SetupGetInfInformationW(LPCVOID InfSpec, DWORD SearchControl,
{
HINF inf;
BOOL ret;
DWORD infSize;
TRACE("(%p, %ld, %p, %ld, %p)\n", InfSpec, SearchControl, ReturnBuffer,
ReturnBufferSize, RequiredSize);
@ -144,12 +145,6 @@ BOOL WINAPI SetupGetInfInformationW(LPCVOID InfSpec, DWORD SearchControl,
return FALSE;
}
if (!ReturnBuffer && ReturnBufferSize)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
switch (SearchControl)
{
case INFINFO_INF_SPEC_IS_HINF:
@ -181,7 +176,13 @@ BOOL WINAPI SetupGetInfInformationW(LPCVOID InfSpec, DWORD SearchControl,
return FALSE;
}
ret = fill_inf_info(inf, ReturnBuffer, ReturnBufferSize, RequiredSize);
ret = fill_inf_info(inf, ReturnBuffer, ReturnBufferSize, &infSize);
if (!ReturnBuffer && (ReturnBufferSize >= infSize))
{
SetLastError(ERROR_INVALID_PARAMETER);
ret = FALSE;
}
if (RequiredSize) *RequiredSize = infSize;
if (SearchControl >= INFINFO_INF_NAME_IS_ABSOLUTE)
SetupCloseInfFile(inf);

View File

@ -177,13 +177,25 @@ static void test_SetupGetInfInformation(void)
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
ok(size != 0xdeadbeef, "Expected a valid size on return\n");
/* set ReturnBuffer to NULL and ReturnBufferSize to non-zero */
/* set ReturnBuffer to NULL and ReturnBufferSize to non-zero value 'size' */
SetLastError(0xbeefcafe);
ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size, &size);
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
/* set ReturnBuffer to NULL and ReturnBufferSize to non-zero value 'size-1' */
ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size-1, &size);
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
/* some tests for behaviour with a NULL RequiredSize pointer */
ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, 0, NULL);
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size - 1, NULL);
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size, NULL);
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
info = HeapAlloc(GetProcessHeap(), 0, size);
/* try valid ReturnBuffer but too small size */