setupapi: Add an initial implementation of SetupGetInfInformation.

oldstable
James Hawkins 2006-02-07 16:24:17 +01:00 committed by Alexandre Julliard
parent 647329d2dd
commit 21fb7ab6a1
3 changed files with 115 additions and 55 deletions

View File

@ -33,6 +33,99 @@
WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
/* fills the PSP_INF_INFORMATION struct fill_info is TRUE
* always returns the required size of the information
*/
static BOOL fill_inf_info(HINF inf, PSP_INF_INFORMATION buffer, DWORD size, DWORD *required)
{
LPCWSTR filename = PARSER_get_inf_filename(inf);
DWORD total_size = FIELD_OFFSET(SP_INF_INFORMATION, VersionData)
+ (lstrlenW(filename) + 1) * sizeof(WCHAR);
if (required) *required = total_size;
/* FIXME: we need to parse the INF file to find the correct version info */
if (buffer)
{
if (size < total_size)
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
buffer->InfStyle = INF_STYLE_WIN4;
buffer->InfCount = 1;
/* put the filename in buffer->VersionData */
lstrcpyW((LPWSTR)&buffer->VersionData[0], filename);
}
return TRUE;
}
/***********************************************************************
* SetupGetInfInformationA (SETUPAPI.@)
*
* BUGS
* If SearchControl is anything other than INFINFO_INF_SPEC_IS_HINF,
* then InfSpec needs to be converted to unicode.
*/
BOOL WINAPI SetupGetInfInformationA(LPCVOID InfSpec, DWORD SearchControl,
PSP_INF_INFORMATION ReturnBuffer,
DWORD ReturnBufferSize, PDWORD RequiredSize)
{
return SetupGetInfInformationW(InfSpec, SearchControl, ReturnBuffer,
ReturnBufferSize, RequiredSize);
}
/***********************************************************************
* SetupGetInfInformationW (SETUPAPI.@)
*
* BUGS
* Only handles the case when InfSpec is an INF handle.
*/
BOOL WINAPI SetupGetInfInformationW(LPCVOID InfSpec, DWORD SearchControl,
PSP_INF_INFORMATION ReturnBuffer,
DWORD ReturnBufferSize, PDWORD RequiredSize)
{
HINF inf = (HINF)InfSpec;
TRACE("(%p, %ld, %p, %ld, %p)\n", InfSpec, SearchControl, ReturnBuffer,
ReturnBufferSize, RequiredSize);
if (!inf)
{
if (SearchControl == INFINFO_INF_SPEC_IS_HINF)
SetLastError(ERROR_INVALID_HANDLE);
else
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (inf == INVALID_HANDLE_VALUE)
{
SetLastError(ERROR_FILE_NOT_FOUND);
return FALSE;
}
if (SearchControl < INFINFO_INF_SPEC_IS_HINF ||
SearchControl > INFINFO_INF_PATH_LIST_SEARCH)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (SearchControl != INFINFO_INF_SPEC_IS_HINF)
{
FIXME("Unhandled search control: %ld\n", SearchControl);
if (RequiredSize)
*RequiredSize = 0;
return FALSE;
}
return fill_inf_info(inf, ReturnBuffer, ReturnBufferSize, RequiredSize);
}
/***********************************************************************
* SetupQueryInfFileInformationA (SETUPAPI.@)
*/

View File

@ -150,30 +150,6 @@ BOOL WINAPI SetupCopyOEMInfW(PCWSTR sourceinffile, PCWSTR sourcemedialoc,
return FALSE;
}
/***********************************************************************
* SetupGetInfInformationA (SETUPAPI.@)
*/
BOOL WINAPI SetupGetInfInformationA( LPCVOID InfSpec, DWORD SearchControl,
PSP_INF_INFORMATION ReturnBuffer,
DWORD ReturnBufferSize, PDWORD RequiredSize)
{
FIXME("(%p, %ld, %p, %ld, %p) Stub!\n",
InfSpec, SearchControl, ReturnBuffer, ReturnBufferSize, RequiredSize );
return TRUE;
}
/***********************************************************************
* SetupGetInfInformationW (SETUPAPI.@)
*/
BOOL WINAPI SetupGetInfInformationW( LPCVOID InfSpec, DWORD SearchControl,
PSP_INF_INFORMATION ReturnBuffer,
DWORD ReturnBufferSize, PDWORD RequiredSize)
{
FIXME("(%p, %ld, %p, %ld, %p) Stub!\n",
InfSpec, SearchControl, ReturnBuffer, ReturnBufferSize, RequiredSize );
return TRUE;
}
/***********************************************************************
* SetupInitializeFileLogW(SETUPAPI.@)
*/

View File

@ -137,24 +137,18 @@ static void test_SetupGetInfInformation(void)
size = 0xdeadbeef;
SetLastError(0xbeefcafe);
ret = pSetupGetInfInformationA(NULL, INFINFO_INF_SPEC_IS_HINF, NULL, 0, &size);
todo_wine
{
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
ok(GetLastError() == ERROR_INVALID_HANDLE,
"Expected ERROR_INVALID_HANDLE, got %ld\n", GetLastError());
}
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
ok(GetLastError() == ERROR_INVALID_HANDLE,
"Expected ERROR_INVALID_HANDLE, got %ld\n", GetLastError());
ok(size == 0xdeadbeef, "Expected size to remain unchanged\n");
/* try an invalid inf filename */
size = 0xdeadbeef;
SetLastError(0xbeefcafe);
ret = pSetupGetInfInformationA(NULL, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, 0, &size);
todo_wine
{
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
}
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
ok(size == 0xdeadbeef, "Expected size to remain unchanged\n");
create_inf_file(inf_filename);
@ -163,41 +157,38 @@ static void test_SetupGetInfInformation(void)
size = 0xdeadbeef;
SetLastError(0xbeefcafe);
ret = pSetupGetInfInformationA(inf_filename, -1, NULL, 0, &size);
todo_wine
{
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
}
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
ok(size == 0xdeadbeef, "Expected size to remain unchanged\n");
/* try a nonexistent inf file */
size = 0xdeadbeef;
SetLastError(0xbeefcafe);
ret = pSetupGetInfInformationA("idontexist", INFINFO_INF_NAME_IS_ABSOLUTE, NULL, 0, &size);
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
todo_wine
{
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
ok(size == 0xdeadbeef, "Expected size to remain unchanged\n");
}
ok(size == 0xdeadbeef, "Expected size to remain unchanged\n");
/* successfully open the inf file */
size = 0xdeadbeef;
ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, 0, &size);
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
todo_wine
{
ok(size != 0xdeadbeef, "Expected a valid size on return\n");
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 */
SetLastError(0xbeefcafe);
ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size, &size);
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
todo_wine
{
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
}
@ -207,29 +198,29 @@ static void test_SetupGetInfInformation(void)
/* try valid ReturnBuffer but too small size */
SetLastError(0xbeefcafe);
ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, info, size - 1, &size);
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
todo_wine
{
ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"Expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
}
/* successfully get the inf information */
ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, info, size, &size);
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
todo_wine
{
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
ok(check_info_filename(info, inf_filename), "Expected returned filename to be equal\n");
}
HeapFree(GetProcessHeap(), 0, info);
/* try the INFINFO_INF_SPEC_IS_HINF search flag */
hinf = pSetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
info = alloc_inf_info(hinf, INFINFO_INF_SPEC_IS_HINF, &size);
ret = pSetupGetInfInformationA(hinf, INFINFO_INF_SPEC_IS_HINF, info, size, &size);
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
todo_wine
{
ok(check_info_filename(info, inf_filename), "Expected returned filename to be equal\n");
}
ok(check_info_filename(info, inf_filename), "Expected returned filename to be equal\n");
pSetupCloseInfFile(hinf);
lstrcpyA(inf_one, WIN_DIR);
@ -247,9 +238,9 @@ static void test_SetupGetInfInformation(void)
/* test the INFINFO_DEFAULT_SEARCH search flag */
ret = pSetupGetInfInformationA("test.inf", INFINFO_DEFAULT_SEARCH, info, size, &size);
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
todo_wine
{
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
ok(check_info_filename(info, inf_one), "Expected returned filename to be equal\n");
}
@ -258,9 +249,9 @@ static void test_SetupGetInfInformation(void)
/* test the INFINFO_REVERSE_DEFAULT_SEARCH search flag */
ret = pSetupGetInfInformationA("test.inf", INFINFO_REVERSE_DEFAULT_SEARCH, info, size, &size);
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
todo_wine
{
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
ok(check_info_filename(info, inf_two), "Expected returned filename to be equal\n");
}