@@ -31,11 +31,8 @@ static const WCHAR ClassInstall32[] = {'C','l','a','s','s','I','n','s','t','a',
31
31
static const WCHAR DeviceInstance [] = {'D' ,'e' ,'v' ,'i' ,'c' ,'e' ,'I' ,'n' ,'s' ,'t' ,'a' ,'n' ,'c' ,'e' ,0 };
32
32
static const WCHAR DotServices [] = {'.' ,'S' ,'e' ,'r' ,'v' ,'i' ,'c' ,'e' ,'s' ,0 };
33
33
static const WCHAR InterfaceInstall32 [] = {'I' ,'n' ,'t' ,'e' ,'r' ,'f' ,'a' ,'c' ,'e' ,'I' ,'n' ,'s' ,'t' ,'a' ,'l' ,'l' ,'3' ,'2' ,0 };
34
- static const WCHAR NtExtension [] = {'.' ,'N' ,'T' ,0 };
35
- static const WCHAR NtPlatformExtension [] = {'.' ,'N' ,'T' ,'x' ,'8' ,'6' ,0 };
36
34
static const WCHAR SymbolicLink [] = {'S' ,'y' ,'m' ,'b' ,'o' ,'l' ,'i' ,'c' ,'L' ,'i' ,'n' ,'k' ,0 };
37
35
static const WCHAR Version [] = {'V' ,'e' ,'r' ,'s' ,'i' ,'o' ,'n' ,0 };
38
- static const WCHAR WinExtension [] = {'.' ,'W' ,'i' ,'n' ,0 };
39
36
40
37
/* FIXME: header mess */
41
38
DEFINE_GUID (GUID_NULL ,
@@ -823,16 +820,53 @@ BOOL WINAPI SetupDiEnumDeviceInfo(
823
820
/***********************************************************************
824
821
* SetupDiGetActualSectionToInstallA (SETUPAPI.@)
825
822
*/
826
- BOOL WINAPI SetupDiGetActualSectionToInstallA (
827
- HINF InfHandle ,
828
- PCSTR InfSectionName ,
829
- PSTR InfSectionWithExt ,
830
- DWORD InfSectionWithExtSize ,
831
- PDWORD RequiredSize ,
832
- PSTR * Extension )
823
+ BOOL WINAPI
824
+ SetupDiGetActualSectionToInstallA (
825
+ IN HINF InfHandle ,
826
+ IN PCSTR InfSectionName ,
827
+ OUT PSTR InfSectionWithExt OPTIONAL ,
828
+ IN DWORD InfSectionWithExtSize ,
829
+ OUT PDWORD RequiredSize OPTIONAL ,
830
+ OUT PSTR * Extension OPTIONAL )
831
+ {
832
+ return SetupDiGetActualSectionToInstallExA (InfHandle , InfSectionName ,
833
+ NULL , InfSectionWithExt , InfSectionWithExtSize , RequiredSize ,
834
+ Extension , NULL );
835
+ }
836
+
837
+ /***********************************************************************
838
+ * SetupDiGetActualSectionToInstallW (SETUPAPI.@)
839
+ */
840
+ BOOL WINAPI
841
+ SetupDiGetActualSectionToInstallW (
842
+ IN HINF InfHandle ,
843
+ IN PCWSTR InfSectionName ,
844
+ OUT PWSTR InfSectionWithExt OPTIONAL ,
845
+ IN DWORD InfSectionWithExtSize ,
846
+ OUT PDWORD RequiredSize OPTIONAL ,
847
+ OUT PWSTR * Extension OPTIONAL )
848
+ {
849
+ return SetupDiGetActualSectionToInstallExW (InfHandle , InfSectionName ,
850
+ NULL , InfSectionWithExt , InfSectionWithExtSize , RequiredSize ,
851
+ Extension , NULL );
852
+ }
853
+
854
+ /***********************************************************************
855
+ * SetupDiGetActualSectionToInstallExA (SETUPAPI.@)
856
+ */
857
+ BOOL WINAPI
858
+ SetupDiGetActualSectionToInstallExA (
859
+ IN HINF InfHandle ,
860
+ IN PCSTR InfSectionName ,
861
+ IN PSP_ALTPLATFORM_INFO AlternatePlatformInfo OPTIONAL ,
862
+ OUT PSTR InfSectionWithExt OPTIONAL ,
863
+ IN DWORD InfSectionWithExtSize ,
864
+ OUT PDWORD RequiredSize OPTIONAL ,
865
+ OUT PSTR * Extension OPTIONAL ,
866
+ IN PVOID Reserved )
833
867
{
834
868
LPWSTR InfSectionNameW = NULL ;
835
- PWSTR InfSectionWithExtW = NULL ;
869
+ LPWSTR InfSectionWithExtW = NULL ;
836
870
PWSTR ExtensionW ;
837
871
BOOL bResult = FALSE;
838
872
@@ -841,18 +875,23 @@ BOOL WINAPI SetupDiGetActualSectionToInstallA(
841
875
if (InfSectionName )
842
876
{
843
877
InfSectionNameW = MultiByteToUnicode (InfSectionName , CP_ACP );
844
- if (InfSectionNameW == NULL ) goto end ;
878
+ if (InfSectionNameW == NULL )
879
+ goto cleanup ;
845
880
}
846
881
if (InfSectionWithExt )
847
882
{
848
- InfSectionWithExtW = HeapAlloc (GetProcessHeap (), 0 , InfSectionWithExtSize * sizeof (WCHAR ));
849
- if (InfSectionWithExtW == NULL ) goto end ;
883
+ InfSectionWithExtW = MyMalloc (InfSectionWithExtSize * sizeof (WCHAR ));
884
+ if (InfSectionWithExtW == NULL )
885
+ goto cleanup ;
850
886
}
851
887
852
- bResult = SetupDiGetActualSectionToInstallW (InfHandle , InfSectionNameW ,
853
- InfSectionWithExt ? InfSectionNameW : NULL ,
854
- InfSectionWithExtSize , RequiredSize ,
855
- Extension ? & ExtensionW : NULL );
888
+ bResult = SetupDiGetActualSectionToInstallExW (
889
+ InfHandle , InfSectionNameW , AlternatePlatformInfo ,
890
+ InfSectionWithExt ? InfSectionWithExtW : NULL ,
891
+ InfSectionWithExtSize ,
892
+ RequiredSize ,
893
+ Extension ? & ExtensionW : NULL ,
894
+ Reserved );
856
895
857
896
if (bResult && InfSectionWithExt )
858
897
{
@@ -867,93 +906,188 @@ BOOL WINAPI SetupDiGetActualSectionToInstallA(
867
906
* Extension = & InfSectionWithExt [ExtensionW - InfSectionWithExtW ];
868
907
}
869
908
870
- end :
871
- if ( InfSectionNameW ) MyFree (InfSectionNameW );
872
- if ( InfSectionWithExtW ) HeapFree ( GetProcessHeap (), 0 , InfSectionWithExtW );
909
+ cleanup :
910
+ MyFree (InfSectionNameW );
911
+ MyFree ( InfSectionWithExtW );
873
912
874
913
return bResult ;
875
914
}
876
915
877
916
/***********************************************************************
878
- * SetupDiGetActualSectionToInstallW (SETUPAPI.@)
917
+ * SetupDiGetActualSectionToInstallExW (SETUPAPI.@)
879
918
*/
880
- BOOL WINAPI SetupDiGetActualSectionToInstallW (
881
- HINF InfHandle ,
882
- PCWSTR InfSectionName ,
883
- PWSTR InfSectionWithExt ,
884
- DWORD InfSectionWithExtSize ,
885
- PDWORD RequiredSize ,
886
- PWSTR * Extension )
919
+ BOOL WINAPI
920
+ SetupDiGetActualSectionToInstallExW (
921
+ IN HINF InfHandle ,
922
+ IN PCWSTR InfSectionName ,
923
+ IN PSP_ALTPLATFORM_INFO AlternatePlatformInfo OPTIONAL ,
924
+ OUT PWSTR InfSectionWithExt OPTIONAL ,
925
+ IN DWORD InfSectionWithExtSize ,
926
+ OUT PDWORD RequiredSize OPTIONAL ,
927
+ OUT PWSTR * Extension OPTIONAL ,
928
+ IN PVOID Reserved )
887
929
{
888
- WCHAR szBuffer [MAX_PATH ];
889
- DWORD dwLength ;
890
- DWORD dwFullLength ;
891
- LONG lLineCount = -1 ;
892
-
893
- TRACE ("%p %s %p %lu %p %p\n" , InfHandle , debugstr_w (InfSectionName ),
894
- InfSectionWithExt , InfSectionWithExtSize , RequiredSize , Extension );
895
-
896
- lstrcpyW (szBuffer , InfSectionName );
897
- dwLength = lstrlenW (szBuffer );
930
+ BOOL ret = FALSE;
898
931
899
- if (OsVersionInfo .dwPlatformId == VER_PLATFORM_WIN32_NT )
900
- {
901
- /* Test section name with '.NTx86' extension */
902
- lstrcpyW (& szBuffer [dwLength ], NtPlatformExtension );
903
- lLineCount = SetupGetLineCountW (InfHandle , szBuffer );
932
+ TRACE ("%p %s %p %p %lu %p %p %p\n" , InfHandle , debugstr_w (InfSectionName ),
933
+ AlternatePlatformInfo , InfSectionWithExt , InfSectionWithExtSize ,
934
+ RequiredSize , Extension , Reserved );
904
935
905
- if (lLineCount == -1 )
906
- {
907
- /* Test section name with '.NT' extension */
908
- lstrcpyW (& szBuffer [dwLength ], NtExtension );
909
- lLineCount = SetupGetLineCountW (InfHandle , szBuffer );
910
- }
911
- }
936
+ if (!InfHandle || InfHandle == (HINF )INVALID_HANDLE_VALUE )
937
+ SetLastError (ERROR_INVALID_HANDLE );
938
+ else if (!InfSectionName )
939
+ SetLastError (ERROR_INVALID_PARAMETER );
940
+ else if (AlternatePlatformInfo && AlternatePlatformInfo -> cbSize != sizeof (SP_ALTPLATFORM_INFO ))
941
+ SetLastError (ERROR_INVALID_USER_BUFFER );
942
+ else if (Reserved != NULL )
943
+ SetLastError (ERROR_INVALID_PARAMETER );
912
944
else
913
945
{
914
- /* Test section name with '.Win' extension */
915
- lstrcpyW (& szBuffer [dwLength ], WinExtension );
916
- lLineCount = SetupGetLineCountW (InfHandle , szBuffer );
917
- }
946
+ static SP_ALTPLATFORM_INFO CurrentPlatform = { 0 , };
947
+ PSP_ALTPLATFORM_INFO pPlatformInfo = & CurrentPlatform ;
948
+ LPCWSTR pExtensionPlatform , pExtensionArchitecture ;
949
+ WCHAR SectionName [LINE_LEN + 1 ];
950
+ LONG lLineCount = -1 ;
951
+ DWORD dwFullLength ;
952
+
953
+ /* Fill platform info if needed */
954
+ if (AlternatePlatformInfo )
955
+ pPlatformInfo = AlternatePlatformInfo ;
956
+ else if (CurrentPlatform .cbSize != sizeof (SP_ALTPLATFORM_INFO ))
957
+ {
958
+ /* That's the first time we go here. We need to fill in the structure */
959
+ OSVERSIONINFO VersionInfo ;
960
+ SYSTEM_INFO SystemInfo ;
961
+ VersionInfo .dwOSVersionInfoSize = sizeof (OSVERSIONINFO );
962
+ ret = GetVersionEx (& VersionInfo );
963
+ if (!ret )
964
+ goto done ;
965
+ GetSystemInfo (& SystemInfo );
966
+ CurrentPlatform .cbSize = sizeof (SP_ALTPLATFORM_INFO );
967
+ CurrentPlatform .Platform = VersionInfo .dwPlatformId ;
968
+ CurrentPlatform .MajorVersion = VersionInfo .dwMajorVersion ;
969
+ CurrentPlatform .MinorVersion = VersionInfo .dwMinorVersion ;
970
+ CurrentPlatform .ProcessorArchitecture = SystemInfo .wProcessorArchitecture ;
971
+ CurrentPlatform .Reserved = 0 ;
972
+ }
918
973
919
- if (lLineCount == -1 )
920
- {
921
- /* Test section name without extension */
922
- szBuffer [dwLength ] = 0 ;
923
- lLineCount = SetupGetLineCountW (InfHandle , szBuffer );
924
- }
974
+ static const WCHAR ExtensionPlatformNone [] = {'.' ,0 };
975
+ static const WCHAR ExtensionPlatformNT [] = {'.' ,'N' ,'T' ,0 };
976
+ static const WCHAR ExtensionPlatformWindows [] = {'.' ,'W' ,'i' ,'n' ,0 };
925
977
926
- if (lLineCount == -1 )
927
- {
928
- SetLastError (ERROR_INVALID_PARAMETER );
929
- return FALSE;
930
- }
978
+ static const WCHAR ExtensionArchitectureNone [] = {0 };
979
+ static const WCHAR ExtensionArchitectureamd64 [] = {'a' ,'m' ,'d' ,'6' ,'4' ,0 };
980
+ static const WCHAR ExtensionArchitectureppc [] = {'p' ,'p' ,'c' ,0 };
981
+ static const WCHAR ExtensionArchitecturex86 [] = {'x' ,'8' ,'6' ,0 };
931
982
932
- dwFullLength = lstrlenW (szBuffer );
983
+ /* Set various extensions values */
984
+ switch (pPlatformInfo -> Platform )
985
+ {
986
+ case VER_PLATFORM_WIN32_WINDOWS :
987
+ pExtensionPlatform = ExtensionPlatformWindows ;
988
+ break ;
989
+ case VER_PLATFORM_WIN32_NT :
990
+ pExtensionPlatform = ExtensionPlatformNT ;
991
+ break ;
992
+ default :
993
+ pExtensionPlatform = ExtensionPlatformNone ;
994
+ break ;
995
+ }
996
+ switch (pPlatformInfo -> ProcessorArchitecture )
997
+ {
998
+ case PROCESSOR_ARCHITECTURE_AMD64 :
999
+ pExtensionArchitecture = ExtensionArchitectureamd64 ;
1000
+ break ;
1001
+ case PROCESSOR_ARCHITECTURE_INTEL :
1002
+ pExtensionArchitecture = ExtensionArchitecturex86 ;
1003
+ break ;
1004
+ case PROCESSOR_ARCHITECTURE_PPC :
1005
+ pExtensionArchitecture = ExtensionArchitectureppc ;
1006
+ break ;
1007
+ default :
1008
+ ERR ("Unknown processor architecture 0x%x\n" , pPlatformInfo -> ProcessorArchitecture );
1009
+ case PROCESSOR_ARCHITECTURE_UNKNOWN :
1010
+ pExtensionArchitecture = ExtensionArchitectureNone ;
1011
+ break ;
1012
+ }
933
1013
934
- if (InfSectionWithExt != NULL && InfSectionWithExtSize != 0 )
935
- {
936
- if (InfSectionWithExtSize < (dwFullLength + 1 ))
937
- {
938
- SetLastError (ERROR_INSUFFICIENT_BUFFER );
939
- return FALSE;
940
- }
1014
+ SectionName [LINE_LEN ] = UNICODE_NULL ;
1015
+
1016
+ /* Test with platform.architecture.major.minor extension */
1017
+ snprintfW (SectionName , LINE_LEN , L"%s%s%s.%lu.%lu" , InfSectionName ,
1018
+ pExtensionPlatform , pExtensionArchitecture , pPlatformInfo -> MajorVersion , pPlatformInfo -> MinorVersion );
1019
+ lLineCount = SetupGetLineCountW (InfHandle , SectionName );
1020
+ if (lLineCount != -1 ) goto sectionfound ;
1021
+
1022
+ /* Test with platform.major.minor extension */
1023
+ snprintfW (SectionName , LINE_LEN , L"%s%s.%lu.%lu" , InfSectionName ,
1024
+ pExtensionPlatform , pPlatformInfo -> MajorVersion , pPlatformInfo -> MinorVersion );
1025
+ lLineCount = SetupGetLineCountW (InfHandle , SectionName );
1026
+ if (lLineCount != -1 ) goto sectionfound ;
1027
+
1028
+ /* Test with platform.architecture.major extension */
1029
+ snprintfW (SectionName , LINE_LEN , L"%s%s%s.%lu" , InfSectionName ,
1030
+ pExtensionPlatform , pExtensionArchitecture , pPlatformInfo -> MajorVersion );
1031
+ lLineCount = SetupGetLineCountW (InfHandle , SectionName );
1032
+ if (lLineCount != -1 ) goto sectionfound ;
1033
+
1034
+ /* Test with platform.major extension */
1035
+ snprintfW (SectionName , LINE_LEN , L"%s%s.%lu" , InfSectionName ,
1036
+ pExtensionPlatform , pPlatformInfo -> MajorVersion );
1037
+ lLineCount = SetupGetLineCountW (InfHandle , SectionName );
1038
+ if (lLineCount != -1 ) goto sectionfound ;
1039
+
1040
+ /* Test with platform.architecture extension */
1041
+ snprintfW (SectionName , LINE_LEN , L"%s%s%s" , InfSectionName ,
1042
+ pExtensionPlatform , pExtensionArchitecture );
1043
+ lLineCount = SetupGetLineCountW (InfHandle , SectionName );
1044
+ if (lLineCount != -1 ) goto sectionfound ;
1045
+
1046
+ /* Test with platform extension */
1047
+ snprintfW (SectionName , LINE_LEN , L"%s%s" , InfSectionName ,
1048
+ pExtensionPlatform );
1049
+ lLineCount = SetupGetLineCountW (InfHandle , SectionName );
1050
+ if (lLineCount != -1 ) goto sectionfound ;
1051
+
1052
+ /* Test without extension */
1053
+ snprintfW (SectionName , LINE_LEN , L"%s" , InfSectionName );
1054
+ lLineCount = SetupGetLineCountW (InfHandle , SectionName );
1055
+ if (lLineCount != -1 ) goto sectionfound ;
1056
+
1057
+ /* No appropriate section found */
1058
+ SetLastError (ERROR_INVALID_PARAMETER );
1059
+ goto done ;
941
1060
942
- lstrcpyW (InfSectionWithExt , szBuffer );
943
- if (Extension != NULL )
944
- {
945
- * Extension = (dwLength == dwFullLength ) ? NULL : & InfSectionWithExt [dwLength ];
946
- }
947
- }
1061
+ sectionfound :
1062
+ dwFullLength = lstrlenW (SectionName );
1063
+ if (InfSectionWithExt != NULL && InfSectionWithExtSize != 0 )
1064
+ {
1065
+ if (InfSectionWithExtSize < (dwFullLength + 1 ))
1066
+ {
1067
+ SetLastError (ERROR_INSUFFICIENT_BUFFER );
1068
+ goto done ;
1069
+ }
948
1070
949
- if (RequiredSize != NULL )
950
- {
951
- * RequiredSize = dwFullLength + 1 ;
1071
+ lstrcpyW (InfSectionWithExt , SectionName );
1072
+ if (Extension != NULL )
1073
+ {
1074
+ DWORD dwLength = lstrlenW (SectionName );
1075
+ * Extension = (dwLength == dwFullLength ) ? NULL : & InfSectionWithExt [dwLength ];
1076
+ }
1077
+ }
1078
+
1079
+ if (RequiredSize != NULL )
1080
+ * RequiredSize = dwFullLength + 1 ;
1081
+
1082
+ ret = TRUE;
952
1083
}
953
1084
954
- return TRUE;
1085
+ done :
1086
+ TRACE ("Returning %d\n" , ret );
1087
+ return ret ;
955
1088
}
956
1089
1090
+
957
1091
/***********************************************************************
958
1092
* SetupDiGetClassDescriptionA (SETUPAPI.@)
959
1093
*/
0 commit comments