Implement SetupDiGetActualSectionToInstallExA/W

svn path=/trunk/; revision=20269
This commit is contained in:
Hervé Poussineau 2005-12-19 13:09:22 +00:00
parent d680237785
commit 8aa516fdf8
4 changed files with 232 additions and 91 deletions

View file

@ -31,11 +31,8 @@ static const WCHAR ClassInstall32[] = {'C','l','a','s','s','I','n','s','t','a',
static const WCHAR DeviceInstance[] = {'D','e','v','i','c','e','I','n','s','t','a','n','c','e',0}; static const WCHAR DeviceInstance[] = {'D','e','v','i','c','e','I','n','s','t','a','n','c','e',0};
static const WCHAR DotServices[] = {'.','S','e','r','v','i','c','e','s',0}; static const WCHAR DotServices[] = {'.','S','e','r','v','i','c','e','s',0};
static const WCHAR InterfaceInstall32[] = {'I','n','t','e','r','f','a','c','e','I','n','s','t','a','l','l','3','2',0}; static const WCHAR InterfaceInstall32[] = {'I','n','t','e','r','f','a','c','e','I','n','s','t','a','l','l','3','2',0};
static const WCHAR NtExtension[] = {'.','N','T',0};
static const WCHAR NtPlatformExtension[] = {'.','N','T','x','8','6',0};
static const WCHAR SymbolicLink[] = {'S','y','m','b','o','l','i','c','L','i','n','k',0}; static const WCHAR SymbolicLink[] = {'S','y','m','b','o','l','i','c','L','i','n','k',0};
static const WCHAR Version[] = {'V','e','r','s','i','o','n',0}; static const WCHAR Version[] = {'V','e','r','s','i','o','n',0};
static const WCHAR WinExtension[] = {'.','W','i','n',0};
/* FIXME: header mess */ /* FIXME: header mess */
DEFINE_GUID(GUID_NULL, DEFINE_GUID(GUID_NULL,
@ -823,16 +820,53 @@ BOOL WINAPI SetupDiEnumDeviceInfo(
/*********************************************************************** /***********************************************************************
* SetupDiGetActualSectionToInstallA (SETUPAPI.@) * SetupDiGetActualSectionToInstallA (SETUPAPI.@)
*/ */
BOOL WINAPI SetupDiGetActualSectionToInstallA( BOOL WINAPI
HINF InfHandle, SetupDiGetActualSectionToInstallA(
PCSTR InfSectionName, IN HINF InfHandle,
PSTR InfSectionWithExt, IN PCSTR InfSectionName,
DWORD InfSectionWithExtSize, OUT PSTR InfSectionWithExt OPTIONAL,
PDWORD RequiredSize, IN DWORD InfSectionWithExtSize,
PSTR *Extension) OUT PDWORD RequiredSize OPTIONAL,
OUT PSTR *Extension OPTIONAL)
{
return SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName,
NULL, InfSectionWithExt, InfSectionWithExtSize, RequiredSize,
Extension, NULL);
}
/***********************************************************************
* SetupDiGetActualSectionToInstallW (SETUPAPI.@)
*/
BOOL WINAPI
SetupDiGetActualSectionToInstallW(
IN HINF InfHandle,
IN PCWSTR InfSectionName,
OUT PWSTR InfSectionWithExt OPTIONAL,
IN DWORD InfSectionWithExtSize,
OUT PDWORD RequiredSize OPTIONAL,
OUT PWSTR *Extension OPTIONAL)
{
return SetupDiGetActualSectionToInstallExW(InfHandle, InfSectionName,
NULL, InfSectionWithExt, InfSectionWithExtSize, RequiredSize,
Extension, NULL);
}
/***********************************************************************
* SetupDiGetActualSectionToInstallExA (SETUPAPI.@)
*/
BOOL WINAPI
SetupDiGetActualSectionToInstallExA(
IN HINF InfHandle,
IN PCSTR InfSectionName,
IN PSP_ALTPLATFORM_INFO AlternatePlatformInfo OPTIONAL,
OUT PSTR InfSectionWithExt OPTIONAL,
IN DWORD InfSectionWithExtSize,
OUT PDWORD RequiredSize OPTIONAL,
OUT PSTR* Extension OPTIONAL,
IN PVOID Reserved)
{ {
LPWSTR InfSectionNameW = NULL; LPWSTR InfSectionNameW = NULL;
PWSTR InfSectionWithExtW = NULL; LPWSTR InfSectionWithExtW = NULL;
PWSTR ExtensionW; PWSTR ExtensionW;
BOOL bResult = FALSE; BOOL bResult = FALSE;
@ -841,18 +875,23 @@ BOOL WINAPI SetupDiGetActualSectionToInstallA(
if (InfSectionName) if (InfSectionName)
{ {
InfSectionNameW = MultiByteToUnicode(InfSectionName, CP_ACP); InfSectionNameW = MultiByteToUnicode(InfSectionName, CP_ACP);
if (InfSectionNameW == NULL) goto end; if (InfSectionNameW == NULL)
goto cleanup;
} }
if (InfSectionWithExt) if (InfSectionWithExt)
{ {
InfSectionWithExtW = HeapAlloc(GetProcessHeap(), 0, InfSectionWithExtSize * sizeof(WCHAR)); InfSectionWithExtW = MyMalloc(InfSectionWithExtSize * sizeof(WCHAR));
if (InfSectionWithExtW == NULL) goto end; if (InfSectionWithExtW == NULL)
goto cleanup;
} }
bResult = SetupDiGetActualSectionToInstallW(InfHandle, InfSectionNameW, bResult = SetupDiGetActualSectionToInstallExW(
InfSectionWithExt ? InfSectionNameW : NULL, InfHandle, InfSectionNameW, AlternatePlatformInfo,
InfSectionWithExtSize, RequiredSize, InfSectionWithExt ? InfSectionWithExtW : NULL,
Extension ? &ExtensionW : NULL); InfSectionWithExtSize,
RequiredSize,
Extension ? &ExtensionW : NULL,
Reserved);
if (bResult && InfSectionWithExt) if (bResult && InfSectionWithExt)
{ {
@ -867,93 +906,188 @@ BOOL WINAPI SetupDiGetActualSectionToInstallA(
*Extension = &InfSectionWithExt[ExtensionW - InfSectionWithExtW]; *Extension = &InfSectionWithExt[ExtensionW - InfSectionWithExtW];
} }
end: cleanup:
if (InfSectionNameW) MyFree(InfSectionNameW); MyFree(InfSectionNameW);
if (InfSectionWithExtW) HeapFree(GetProcessHeap(), 0, InfSectionWithExtW); MyFree(InfSectionWithExtW);
return bResult; return bResult;
} }
/*********************************************************************** /***********************************************************************
* SetupDiGetActualSectionToInstallW (SETUPAPI.@) * SetupDiGetActualSectionToInstallExW (SETUPAPI.@)
*/ */
BOOL WINAPI SetupDiGetActualSectionToInstallW( BOOL WINAPI
HINF InfHandle, SetupDiGetActualSectionToInstallExW(
PCWSTR InfSectionName, IN HINF InfHandle,
PWSTR InfSectionWithExt, IN PCWSTR InfSectionName,
DWORD InfSectionWithExtSize, IN PSP_ALTPLATFORM_INFO AlternatePlatformInfo OPTIONAL,
PDWORD RequiredSize, OUT PWSTR InfSectionWithExt OPTIONAL,
PWSTR *Extension) IN DWORD InfSectionWithExtSize,
OUT PDWORD RequiredSize OPTIONAL,
OUT PWSTR* Extension OPTIONAL,
IN PVOID Reserved)
{ {
WCHAR szBuffer[MAX_PATH]; BOOL ret = FALSE;
DWORD dwLength;
DWORD dwFullLength;
LONG lLineCount = -1;
TRACE("%p %s %p %lu %p %p\n", InfHandle, debugstr_w(InfSectionName), TRACE("%p %s %p %p %lu %p %p %p\n", InfHandle, debugstr_w(InfSectionName),
InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension); AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize,
RequiredSize, Extension, Reserved);
lstrcpyW(szBuffer, InfSectionName); if (!InfHandle || InfHandle == (HINF)INVALID_HANDLE_VALUE)
dwLength = lstrlenW(szBuffer); SetLastError(ERROR_INVALID_HANDLE);
else if (!InfSectionName)
if (OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) SetLastError(ERROR_INVALID_PARAMETER);
{ else if (AlternatePlatformInfo && AlternatePlatformInfo->cbSize != sizeof(SP_ALTPLATFORM_INFO))
/* Test section name with '.NTx86' extension */ SetLastError(ERROR_INVALID_USER_BUFFER);
lstrcpyW(&szBuffer[dwLength], NtPlatformExtension); else if (Reserved != NULL)
lLineCount = SetupGetLineCountW(InfHandle, szBuffer); SetLastError(ERROR_INVALID_PARAMETER);
if (lLineCount == -1)
{
/* Test section name with '.NT' extension */
lstrcpyW(&szBuffer[dwLength], NtExtension);
lLineCount = SetupGetLineCountW(InfHandle, szBuffer);
}
}
else else
{ {
/* Test section name with '.Win' extension */ static SP_ALTPLATFORM_INFO CurrentPlatform = { 0, };
lstrcpyW(&szBuffer[dwLength], WinExtension); PSP_ALTPLATFORM_INFO pPlatformInfo = &CurrentPlatform;
lLineCount = SetupGetLineCountW(InfHandle, szBuffer); LPCWSTR pExtensionPlatform, pExtensionArchitecture;
WCHAR SectionName[LINE_LEN + 1];
LONG lLineCount = -1;
DWORD dwFullLength;
/* Fill platform info if needed */
if (AlternatePlatformInfo)
pPlatformInfo = AlternatePlatformInfo;
else if (CurrentPlatform.cbSize != sizeof(SP_ALTPLATFORM_INFO))
{
/* That's the first time we go here. We need to fill in the structure */
OSVERSIONINFO VersionInfo;
SYSTEM_INFO SystemInfo;
VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
ret = GetVersionEx(&VersionInfo);
if (!ret)
goto done;
GetSystemInfo(&SystemInfo);
CurrentPlatform.cbSize = sizeof(SP_ALTPLATFORM_INFO);
CurrentPlatform.Platform = VersionInfo.dwPlatformId;
CurrentPlatform.MajorVersion = VersionInfo.dwMajorVersion;
CurrentPlatform.MinorVersion = VersionInfo.dwMinorVersion;
CurrentPlatform.ProcessorArchitecture = SystemInfo.wProcessorArchitecture;
CurrentPlatform.Reserved = 0;
} }
if (lLineCount == -1) static const WCHAR ExtensionPlatformNone[] = {'.',0};
static const WCHAR ExtensionPlatformNT[] = {'.','N','T',0};
static const WCHAR ExtensionPlatformWindows[] = {'.','W','i','n',0};
static const WCHAR ExtensionArchitectureNone[] = {0};
static const WCHAR ExtensionArchitectureamd64[] = {'a','m','d','6','4',0};
static const WCHAR ExtensionArchitectureppc[] = {'p','p','c',0};
static const WCHAR ExtensionArchitecturex86[] = {'x','8','6',0};
/* Set various extensions values */
switch (pPlatformInfo->Platform)
{ {
/* Test section name without extension */ case VER_PLATFORM_WIN32_WINDOWS:
szBuffer[dwLength] = 0; pExtensionPlatform = ExtensionPlatformWindows;
lLineCount = SetupGetLineCountW(InfHandle, szBuffer); break;
case VER_PLATFORM_WIN32_NT:
pExtensionPlatform = ExtensionPlatformNT;
break;
default:
pExtensionPlatform = ExtensionPlatformNone;
break;
}
switch (pPlatformInfo->ProcessorArchitecture)
{
case PROCESSOR_ARCHITECTURE_AMD64:
pExtensionArchitecture = ExtensionArchitectureamd64;
break;
case PROCESSOR_ARCHITECTURE_INTEL:
pExtensionArchitecture = ExtensionArchitecturex86;
break;
case PROCESSOR_ARCHITECTURE_PPC:
pExtensionArchitecture = ExtensionArchitectureppc;
break;
default:
ERR("Unknown processor architecture 0x%x\n", pPlatformInfo->ProcessorArchitecture);
case PROCESSOR_ARCHITECTURE_UNKNOWN:
pExtensionArchitecture = ExtensionArchitectureNone;
break;
} }
if (lLineCount == -1) SectionName[LINE_LEN] = UNICODE_NULL;
{
/* Test with platform.architecture.major.minor extension */
snprintfW(SectionName, LINE_LEN, L"%s%s%s.%lu.%lu", InfSectionName,
pExtensionPlatform, pExtensionArchitecture, pPlatformInfo->MajorVersion, pPlatformInfo->MinorVersion);
lLineCount = SetupGetLineCountW(InfHandle, SectionName);
if (lLineCount != -1) goto sectionfound;
/* Test with platform.major.minor extension */
snprintfW(SectionName, LINE_LEN, L"%s%s.%lu.%lu", InfSectionName,
pExtensionPlatform, pPlatformInfo->MajorVersion, pPlatformInfo->MinorVersion);
lLineCount = SetupGetLineCountW(InfHandle, SectionName);
if (lLineCount != -1) goto sectionfound;
/* Test with platform.architecture.major extension */
snprintfW(SectionName, LINE_LEN, L"%s%s%s.%lu", InfSectionName,
pExtensionPlatform, pExtensionArchitecture, pPlatformInfo->MajorVersion);
lLineCount = SetupGetLineCountW(InfHandle, SectionName);
if (lLineCount != -1) goto sectionfound;
/* Test with platform.major extension */
snprintfW(SectionName, LINE_LEN, L"%s%s.%lu", InfSectionName,
pExtensionPlatform, pPlatformInfo->MajorVersion);
lLineCount = SetupGetLineCountW(InfHandle, SectionName);
if (lLineCount != -1) goto sectionfound;
/* Test with platform.architecture extension */
snprintfW(SectionName, LINE_LEN, L"%s%s%s", InfSectionName,
pExtensionPlatform, pExtensionArchitecture);
lLineCount = SetupGetLineCountW(InfHandle, SectionName);
if (lLineCount != -1) goto sectionfound;
/* Test with platform extension */
snprintfW(SectionName, LINE_LEN, L"%s%s", InfSectionName,
pExtensionPlatform);
lLineCount = SetupGetLineCountW(InfHandle, SectionName);
if (lLineCount != -1) goto sectionfound;
/* Test without extension */
snprintfW(SectionName, LINE_LEN, L"%s", InfSectionName);
lLineCount = SetupGetLineCountW(InfHandle, SectionName);
if (lLineCount != -1) goto sectionfound;
/* No appropriate section found */
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
return FALSE; goto done;
}
dwFullLength = lstrlenW(szBuffer);
sectionfound:
dwFullLength = lstrlenW(SectionName);
if (InfSectionWithExt != NULL && InfSectionWithExtSize != 0) if (InfSectionWithExt != NULL && InfSectionWithExtSize != 0)
{ {
if (InfSectionWithExtSize < (dwFullLength + 1)) if (InfSectionWithExtSize < (dwFullLength + 1))
{ {
SetLastError(ERROR_INSUFFICIENT_BUFFER); SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE; goto done;
} }
lstrcpyW(InfSectionWithExt, szBuffer); lstrcpyW(InfSectionWithExt, SectionName);
if (Extension != NULL) if (Extension != NULL)
{ {
DWORD dwLength = lstrlenW(SectionName);
*Extension = (dwLength == dwFullLength) ? NULL : &InfSectionWithExt[dwLength]; *Extension = (dwLength == dwFullLength) ? NULL : &InfSectionWithExt[dwLength];
} }
} }
if (RequiredSize != NULL) if (RequiredSize != NULL)
{
*RequiredSize = dwFullLength + 1; *RequiredSize = dwFullLength + 1;
ret = TRUE;
} }
return TRUE; done:
TRACE("Returning %d\n", ret);
return ret;
} }
/*********************************************************************** /***********************************************************************
* SetupDiGetClassDescriptionA (SETUPAPI.@) * SetupDiGetClassDescriptionA (SETUPAPI.@)
*/ */

View file

@ -300,6 +300,8 @@
@ stdcall SetupDiEnumDriverInfoA(long ptr long long ptr) @ stdcall SetupDiEnumDriverInfoA(long ptr long long ptr)
@ stdcall SetupDiEnumDriverInfoW(long ptr long long ptr) @ stdcall SetupDiEnumDriverInfoW(long ptr long long ptr)
@ stdcall SetupDiGetActualSectionToInstallA(long str str long ptr ptr) @ stdcall SetupDiGetActualSectionToInstallA(long str str long ptr ptr)
@ stdcall SetupDiGetActualSectionToInstallExA(long str ptr str long ptr ptr ptr)
@ stdcall SetupDiGetActualSectionToInstallExW(long wstr ptr wstr long ptr ptr ptr)
@ stdcall SetupDiGetActualSectionToInstallW(long wstr wstr long ptr ptr) @ stdcall SetupDiGetActualSectionToInstallW(long wstr wstr long ptr ptr)
@ stub SetupDiGetClassBitmapIndex @ stub SetupDiGetClassBitmapIndex
@ stdcall SetupDiGetClassDescriptionA(ptr str long ptr) @ stdcall SetupDiGetClassDescriptionA(ptr str long ptr)

View file

@ -1200,6 +1200,8 @@ WINSETUPAPI BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO,PSP_DEVINFO_DATA,CO
WINSETUPAPI BOOL WINAPI SetupDiEnumDriverInfoA(HDEVINFO,PSP_DEVINFO_DATA,DWORD,DWORD,PSP_DRVINFO_DATA_A); WINSETUPAPI BOOL WINAPI SetupDiEnumDriverInfoA(HDEVINFO,PSP_DEVINFO_DATA,DWORD,DWORD,PSP_DRVINFO_DATA_A);
WINSETUPAPI BOOL WINAPI SetupDiEnumDriverInfoW(HDEVINFO,PSP_DEVINFO_DATA,DWORD,DWORD,PSP_DRVINFO_DATA_W); WINSETUPAPI BOOL WINAPI SetupDiEnumDriverInfoW(HDEVINFO,PSP_DEVINFO_DATA,DWORD,DWORD,PSP_DRVINFO_DATA_W);
WINSETUPAPI BOOL WINAPI SetupDiGetActualSectionToInstallA(HINF,PCSTR,PSTR,DWORD,PDWORD,PSTR*); WINSETUPAPI BOOL WINAPI SetupDiGetActualSectionToInstallA(HINF,PCSTR,PSTR,DWORD,PDWORD,PSTR*);
WINSETUPAPI BOOL WINAPI SetupDiGetActualSectionToInstallExA(HINF,PCSTR,PSP_ALTPLATFORM_INFO,PSTR,DWORD,PDWORD,PSTR*,PVOID);
WINSETUPAPI BOOL WINAPI SetupDiGetActualSectionToInstallExW(HINF,PCWSTR,PSP_ALTPLATFORM_INFO,PWSTR,DWORD,PDWORD,PWSTR*,PVOID);
WINSETUPAPI BOOL WINAPI SetupDiGetActualSectionToInstallW(HINF,PCWSTR,PWSTR,DWORD,PDWORD,PWSTR*); WINSETUPAPI BOOL WINAPI SetupDiGetActualSectionToInstallW(HINF,PCWSTR,PWSTR,DWORD,PDWORD,PWSTR*);
WINSETUPAPI BOOL WINAPI SetupDiGetClassBitmapIndex(CONST GUID*,PINT); WINSETUPAPI BOOL WINAPI SetupDiGetClassBitmapIndex(CONST GUID*,PINT);
WINSETUPAPI BOOL WINAPI SetupDiGetClassDescriptionA(CONST GUID*,PSTR,DWORD,PDWORD); WINSETUPAPI BOOL WINAPI SetupDiGetClassDescriptionA(CONST GUID*,PSTR,DWORD,PDWORD);
@ -1475,6 +1477,7 @@ WINSETUPAPI BOOL WINAPI UnmapAndCloseFile(HANDLE, HANDLE, PVOID);
#define SetupDiCreateDevRegKey SetupDiCreateDevRegKeyW #define SetupDiCreateDevRegKey SetupDiCreateDevRegKeyW
#define SetupDiEnumDriverInfo SetupDiEnumDriverInfoW #define SetupDiEnumDriverInfo SetupDiEnumDriverInfoW
#define SetupDiGetActualSectionToInstall SetupDiGetActualSectionToInstallW #define SetupDiGetActualSectionToInstall SetupDiGetActualSectionToInstallW
#define SetupDiGetActualSectionToInstallEx SetupDiGetActualSectionToInstallExW
#define SetupDiGetClassDescriptionEx SetupDiGetClassDescriptionExW #define SetupDiGetClassDescriptionEx SetupDiGetClassDescriptionExW
#define SetupDiGetClassDescription SetupDiGetClassDescriptionW #define SetupDiGetClassDescription SetupDiGetClassDescriptionW
#define SetupDiGetClassDevPropertySheets SetupDiGetClassDevPropertySheetsW #define SetupDiGetClassDevPropertySheets SetupDiGetClassDevPropertySheetsW
@ -1595,6 +1598,7 @@ WINSETUPAPI BOOL WINAPI UnmapAndCloseFile(HANDLE, HANDLE, PVOID);
#define SetupDiDeleteInterfaceDeviceData SetupDiDeleteDeviceInterfaceData #define SetupDiDeleteInterfaceDeviceData SetupDiDeleteDeviceInterfaceData
#define SetupDiEnumDriverInfo SetupDiEnumDriverInfoA #define SetupDiEnumDriverInfo SetupDiEnumDriverInfoA
#define SetupDiGetActualSectionToInstall SetupDiGetActualSectionToInstallA #define SetupDiGetActualSectionToInstall SetupDiGetActualSectionToInstallA
#define SetupDiGetActualSectionToInstallEx SetupDiGetActualSectionToInstallExA
#define SetupDiGetClassDescription SetupDiGetClassDescriptionA #define SetupDiGetClassDescription SetupDiGetClassDescriptionA
#define SetupDiGetClassDescriptionEx SetupDiGetClassDescriptionExA #define SetupDiGetClassDescriptionEx SetupDiGetClassDescriptionExA
#define SetupDiGetClassDevPropertySheets SetupDiGetClassDevPropertySheetsA #define SetupDiGetClassDevPropertySheets SetupDiGetClassDevPropertySheetsA

View file

@ -849,7 +849,8 @@ typedef enum
#define PROCESSOR_ARCHITECTURE_ARM 5 #define PROCESSOR_ARCHITECTURE_ARM 5
#define PROCESSOR_ARCHITECTURE_IA64 6 #define PROCESSOR_ARCHITECTURE_IA64 6
#define PROCESSOR_ARCHITECTURE_ALPHA64 7 #define PROCESSOR_ARCHITECTURE_ALPHA64 7
#define PROCESSOR_ARCHITECTURE_MSIL8 #define PROCESSOR_ARCHITECTURE_MSIL 8
#define PROCESSOR_ARCHITECTURE_AMD64 9
#define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
#define PF_FLOATING_POINT_PRECISION_ERRATA 0 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
#define PF_FLOATING_POINT_EMULATED 1 #define PF_FLOATING_POINT_EMULATED 1