setupapi: Duplicate behaviour of native SetupGetInfInformation with NULL ReturnBuffer and certain ReturnBufferSizes.
This commit is contained in:
parent
8cbca5dcfd
commit
e1fa51f59c
|
@ -130,6 +130,7 @@ BOOL WINAPI SetupGetInfInformationW(LPCVOID InfSpec, DWORD SearchControl,
|
||||||
{
|
{
|
||||||
HINF inf;
|
HINF inf;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
DWORD infSize;
|
||||||
|
|
||||||
TRACE("(%p, %ld, %p, %ld, %p)\n", InfSpec, SearchControl, ReturnBuffer,
|
TRACE("(%p, %ld, %p, %ld, %p)\n", InfSpec, SearchControl, ReturnBuffer,
|
||||||
ReturnBufferSize, RequiredSize);
|
ReturnBufferSize, RequiredSize);
|
||||||
|
@ -144,12 +145,6 @@ BOOL WINAPI SetupGetInfInformationW(LPCVOID InfSpec, DWORD SearchControl,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ReturnBuffer && ReturnBufferSize)
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (SearchControl)
|
switch (SearchControl)
|
||||||
{
|
{
|
||||||
case INFINFO_INF_SPEC_IS_HINF:
|
case INFINFO_INF_SPEC_IS_HINF:
|
||||||
|
@ -181,7 +176,13 @@ BOOL WINAPI SetupGetInfInformationW(LPCVOID InfSpec, DWORD SearchControl,
|
||||||
return FALSE;
|
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)
|
if (SearchControl >= INFINFO_INF_NAME_IS_ABSOLUTE)
|
||||||
SetupCloseInfFile(inf);
|
SetupCloseInfFile(inf);
|
||||||
|
|
|
@ -177,13 +177,25 @@ static void test_SetupGetInfInformation(void)
|
||||||
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
|
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
|
||||||
ok(size != 0xdeadbeef, "Expected a valid size on return\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);
|
SetLastError(0xbeefcafe);
|
||||||
ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size, &size);
|
ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size, &size);
|
||||||
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
|
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
|
||||||
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
|
"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);
|
info = HeapAlloc(GetProcessHeap(), 0, size);
|
||||||
|
|
||||||
/* try valid ReturnBuffer but too small size */
|
/* try valid ReturnBuffer but too small size */
|
||||||
|
|
Loading…
Reference in New Issue