diff --git a/reactos/dll/win32/setupapi/query.c b/reactos/dll/win32/setupapi/query.c index ae3d636..ee36e5b 100644 --- a/reactos/dll/win32/setupapi/query.c +++ b/reactos/dll/win32/setupapi/query.c @@ -282,6 +282,138 @@ BOOL WINAPI SetupQueryInfFileInformationW(PSP_INF_INFORMATION InfInformation, } /*********************************************************************** + * SetupQueryInfVersionInformationA (SETUPAPI.@) + */ + +BOOL WINAPI SetupQueryInfVersionInformationA( PSP_INF_INFORMATION info, UINT index, + PCSTR key, PSTR buffer, DWORD buffer_size, + PDWORD required_size ) +{ + WCHAR* keyW; + WCHAR* bufferW = NULL; + DWORD required_sizeW = 0; + BOOL ret; + + if (index != 0) + { + SetLastError(ERROR_NO_MORE_ITEMS); + return FALSE; + } + + keyW = strdupAtoW(key); + if (buffer) + bufferW = HeapAlloc(GetProcessHeap(), 0, buffer_size * sizeof(WCHAR)); + ret = SetupQueryInfVersionInformationW(info, index, keyW, bufferW, buffer_size, &required_sizeW); + + if (required_size) + *required_size = required_sizeW; + + if (buffer) + { + if (required_sizeW > buffer_size) + { + ret = FALSE; + } + else + { + WideCharToMultiByte(CP_ACP, 0, bufferW, buffer_size, buffer, buffer_size, NULL, NULL); + } + } + HeapFree(GetProcessHeap(), 0, keyW); + HeapFree(GetProcessHeap(), 0, bufferW); + + + return ret; +} + +/*********************************************************************** + * SetupQueryInfVersionInformationA (SETUPAPI.@) + */ + +BOOL WINAPI SetupQueryInfVersionInformationW( PSP_INF_INFORMATION info, UINT index, + PCWSTR key, PWSTR buffer, DWORD buffer_size, + PDWORD required_size ) +{ + static const WCHAR wszVersion[] = { 'V','e','r','s','i','o','n',0 }; + + HINF hinf; + DWORD req = key ? 0 : 1; + INFCONTEXT context; + BOOL ok = TRUE, it; + + if (index != 0) + { + SetLastError(ERROR_NO_MORE_ITEMS); + return FALSE; + } + + hinf = SetupOpenInfFileW((LPWSTR)info->VersionData, NULL, INF_STYLE_WIN4, NULL); + if (hinf == INVALID_HANDLE_VALUE) return FALSE; + + it = SetupFindFirstLineW(hinf, wszVersion, key, &context); + while (it && ok) + { + PWSTR name = NULL, value = NULL; + DWORD namelen, valuelen; + if (GetStringField(&context, 0, &name) && + GetStringField(&context, 1, &value) && name && value) + { + namelen = strlenW(name)+1; + valuelen = strlenW(value)+1; + if (!key) + req += namelen; + req += valuelen; + + if (buffer) + { + if (!key) + { + if (namelen <= buffer_size) + { + lstrcpyW(buffer, name); + buffer += namelen; + buffer_size -= namelen; + } + else + { + ok = FALSE; + buffer_size = 0; + } + } + if (valuelen <= buffer_size) + { + lstrcpyW(buffer, value); + buffer += valuelen; + buffer_size -= valuelen; + } + else + { + ok = FALSE; + buffer_size = 0; + } + } + } + MyFree(name); + MyFree(value); + it = SetupFindNextMatchLineW(&context, key, &context); + } + + if (buffer) + { + if (buffer_size && ok) + *buffer = '\0'; + else + SetLastError(ERROR_INSUFFICIENT_BUFFER); + } + + if (required_size) + *required_size = req; + + SetupCloseInfFile(hinf); + return ok; +} + +/*********************************************************************** * SetupGetSourceFileLocationA (SETUPAPI.@) */ diff --git a/reactos/dll/win32/setupapi/setupapi.spec b/reactos/dll/win32/setupapi/setupapi.spec index 4f50329..86e30a6 100644 --- a/reactos/dll/win32/setupapi/setupapi.spec +++ b/reactos/dll/win32/setupapi/setupapi.spec @@ -476,8 +476,8 @@ @ stdcall SetupQueryInfFileInformationW(ptr long wstr long ptr) @ stdcall SetupQueryInfOriginalFileInformationA(ptr long ptr ptr) @ stdcall SetupQueryInfOriginalFileInformationW(ptr long ptr ptr) -@ stub SetupQueryInfVersionInformationA -@ stub SetupQueryInfVersionInformationW +@ stdcall SetupQueryInfVersionInformationA(ptr long str str long ptr) +@ stdcall SetupQueryInfVersionInformationW(ptr long wstr wstr long ptr) @ stub SetupQuerySourceListA @ stub SetupQuerySourceListW @ stdcall SetupQuerySpaceRequiredOnDriveA(long str ptr ptr long)