Commit e1fa51f5 authored by Frank Richter's avatar Frank Richter Committed by Alexandre Julliard

setupapi: Duplicate behaviour of native SetupGetInfInformation with NULL…

setupapi: Duplicate behaviour of native SetupGetInfInformation with NULL ReturnBuffer and certain ReturnBufferSizes.
parent 8cbca5dc
...@@ -130,6 +130,7 @@ BOOL WINAPI SetupGetInfInformationW(LPCVOID InfSpec, DWORD SearchControl, ...@@ -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, ...@@ -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, ...@@ -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) ...@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment