setupapi: Partially implement SetupQueryInfOriginalFileInformationW.
Implement SetupQueryInfOriginalFileInformationA on top of SetupQueryInfOriginalFileInformationW.
This commit is contained in:
parent
712bffb54e
commit
c572ddb40c
|
@ -616,9 +616,31 @@ BOOL WINAPI SetupQueryInfOriginalFileInformationA(
|
||||||
PSP_ALTPLATFORM_INFO AlternativePlatformInfo,
|
PSP_ALTPLATFORM_INFO AlternativePlatformInfo,
|
||||||
PSP_ORIGINAL_FILE_INFO_A OriginalFileInfo)
|
PSP_ORIGINAL_FILE_INFO_A OriginalFileInfo)
|
||||||
{
|
{
|
||||||
FIXME("(%p, %d, %p, %p): stub\n", InfInformation, InfIndex,
|
BOOL ret;
|
||||||
|
SP_ORIGINAL_FILE_INFO_W OriginalFileInfoW;
|
||||||
|
|
||||||
|
TRACE("(%p, %d, %p, %p)\n", InfInformation, InfIndex,
|
||||||
AlternativePlatformInfo, OriginalFileInfo);
|
AlternativePlatformInfo, OriginalFileInfo);
|
||||||
|
|
||||||
|
if (OriginalFileInfo->cbSize != sizeof(*OriginalFileInfo))
|
||||||
|
{
|
||||||
|
ERR("incorrect OriginalFileInfo->cbSize of %d\n", OriginalFileInfo->cbSize);
|
||||||
|
SetLastError( ERROR_INVALID_USER_BUFFER );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
OriginalFileInfoW.cbSize = sizeof(OriginalFileInfoW);
|
||||||
|
ret = SetupQueryInfOriginalFileInformationW(InfInformation, InfIndex,
|
||||||
|
AlternativePlatformInfo, &OriginalFileInfoW);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, OriginalFileInfoW.OriginalInfName, MAX_PATH,
|
||||||
|
OriginalFileInfo->OriginalInfName, MAX_PATH, NULL, NULL);
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, OriginalFileInfoW.OriginalCatalogName, MAX_PATH,
|
||||||
|
OriginalFileInfo->OriginalCatalogName, MAX_PATH, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -629,7 +651,31 @@ BOOL WINAPI SetupQueryInfOriginalFileInformationW(
|
||||||
PSP_ALTPLATFORM_INFO AlternativePlatformInfo,
|
PSP_ALTPLATFORM_INFO AlternativePlatformInfo,
|
||||||
PSP_ORIGINAL_FILE_INFO_W OriginalFileInfo)
|
PSP_ORIGINAL_FILE_INFO_W OriginalFileInfo)
|
||||||
{
|
{
|
||||||
|
LPCWSTR inf_name;
|
||||||
|
|
||||||
FIXME("(%p, %d, %p, %p): stub\n", InfInformation, InfIndex,
|
FIXME("(%p, %d, %p, %p): stub\n", InfInformation, InfIndex,
|
||||||
AlternativePlatformInfo, OriginalFileInfo);
|
AlternativePlatformInfo, OriginalFileInfo);
|
||||||
return FALSE;
|
|
||||||
|
if (OriginalFileInfo->cbSize != sizeof(*OriginalFileInfo))
|
||||||
|
{
|
||||||
|
ERR("incorrect OriginalFileInfo->cbSize of %d\n", OriginalFileInfo->cbSize);
|
||||||
|
return ERROR_INVALID_USER_BUFFER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: we should get OriginalCatalogName from CatalogFile line in
|
||||||
|
* the original inf file and cache it, but that would require building a
|
||||||
|
* .pnf file. */
|
||||||
|
OriginalFileInfo->OriginalCatalogName[0] = '\0';
|
||||||
|
|
||||||
|
/* FIXME: not quite correct as we just return the same file name as
|
||||||
|
* destination (copied) inf file, not the source (original) inf file.
|
||||||
|
* to fix it properly would require building a .pnf file */
|
||||||
|
/* file name is stored in VersionData field of InfInformation */
|
||||||
|
inf_name = strrchrW((LPWSTR)&InfInformation->VersionData[0], '\\');
|
||||||
|
if (inf_name) inf_name++;
|
||||||
|
else inf_name = (LPWSTR)&InfInformation->VersionData[0];
|
||||||
|
|
||||||
|
strcpyW(OriginalFileInfo->OriginalInfName, inf_name);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,42 @@ static BOOL check_format(LPSTR path, LPSTR inf)
|
||||||
return (!inf) ? res : res && (inf == path + lstrlen(check) - 3);
|
return (!inf) ? res : res && (inf == path + lstrlen(check) - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_original_file_name(LPCSTR original, LPCSTR dest)
|
||||||
|
{
|
||||||
|
HINF hinf;
|
||||||
|
PSP_INF_INFORMATION pspii;
|
||||||
|
SP_ORIGINAL_FILE_INFO spofi;
|
||||||
|
BOOL res;
|
||||||
|
DWORD size;
|
||||||
|
|
||||||
|
hinf = SetupOpenInfFileA(dest, NULL, INF_STYLE_WIN4, NULL);
|
||||||
|
ok(hinf != NULL, "SetupOpenInfFileA failed with error %d\n", GetLastError());
|
||||||
|
|
||||||
|
res = SetupGetInfInformation(hinf, INFINFO_INF_SPEC_IS_HINF, NULL, 0, &size);
|
||||||
|
ok(res, "SetupGetInfInformation failed with error %d\n", GetLastError());
|
||||||
|
|
||||||
|
pspii = HeapAlloc(GetProcessHeap(), 0, size);
|
||||||
|
|
||||||
|
res = SetupGetInfInformation(hinf, INFINFO_INF_SPEC_IS_HINF, pspii, size, NULL);
|
||||||
|
ok(res, "SetupGetInfInformation failed with error %d\n", GetLastError());
|
||||||
|
|
||||||
|
spofi.cbSize = 0;
|
||||||
|
res = SetupQueryInfOriginalFileInformationA(pspii, 0, NULL, &spofi);
|
||||||
|
ok(!res && GetLastError() == ERROR_INVALID_USER_BUFFER,
|
||||||
|
"SetupQueryInfOriginalFileInformationA should have failed with ERROR_INVALID_USER_BUFFER instead of %d\n", GetLastError());
|
||||||
|
|
||||||
|
spofi.cbSize = sizeof(spofi);
|
||||||
|
res = SetupQueryInfOriginalFileInformationA(pspii, 0, NULL, &spofi);
|
||||||
|
ok(res, "SetupQueryInfOriginalFileInformationA failed with error %d\n", GetLastError());
|
||||||
|
ok(!spofi.OriginalCatalogName[0], "spofi.OriginalCatalogName should have been \"\" instead of \"%s\"\n", spofi.OriginalCatalogName);
|
||||||
|
todo_wine
|
||||||
|
ok(!strcmp(original, spofi.OriginalInfName), "spofi.OriginalInfName of %s didn't match real original name %s\n", spofi.OriginalInfName, original);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, pspii);
|
||||||
|
|
||||||
|
SetupCloseInfFile(hinf);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_SetupCopyOEMInf(void)
|
static void test_SetupCopyOEMInf(void)
|
||||||
{
|
{
|
||||||
CHAR toolong[MAX_PATH * 2];
|
CHAR toolong[MAX_PATH * 2];
|
||||||
|
@ -233,6 +269,8 @@ static void test_SetupCopyOEMInf(void)
|
||||||
ok(file_exists(path), "Expected source inf to exist\n");
|
ok(file_exists(path), "Expected source inf to exist\n");
|
||||||
ok(size == lstrlen(dest_save) + 1, "Expected size to be lstrlen(dest_save) + 1\n");
|
ok(size == lstrlen(dest_save) + 1, "Expected size to be lstrlen(dest_save) + 1\n");
|
||||||
|
|
||||||
|
test_original_file_name(strrchr(path, '\\') + 1, dest);
|
||||||
|
|
||||||
/* get the DestinationInfFileName, DestinationInfFileNameSize, and DestinationInfFileNameComponent */
|
/* get the DestinationInfFileName, DestinationInfFileNameSize, and DestinationInfFileNameComponent */
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
res = pSetupCopyOEMInfA(path, NULL, SPOST_NONE, 0, dest, MAX_PATH, &size, &inf);
|
res = pSetupCopyOEMInfA(path, NULL, SPOST_NONE, 0, dest, MAX_PATH, &size, &inf);
|
||||||
|
|
Loading…
Reference in New Issue