Fixing API set versioning to get PowerShell Core working on Windows 7

This commit is contained in:
Mike Richmond 2016-08-25 17:30:49 -07:00
parent eb3fd7ae6c
commit f16bc1ab16
2 changed files with 54 additions and 50 deletions

View file

@ -1227,12 +1227,12 @@ namespace System.Management.Automation
// Win32 return type is BOOLEAN (which is 1 byte and not BOOL which is 4bytes)
internal static extern byte GetUserNameEx(int format, [Out] StringBuilder domainName, ref uint domainNameLen);
[DllImport("api-ms-win-core-localization-l1-2-1.dll", CharSet = CharSet.Unicode)]
[DllImport(PinvokeDllNames.FormatMessageDllName, CharSet = CharSet.Unicode)]
internal static extern int FormatMessage(int dwFlags, IntPtr lpSource, int dwMessageId,
int dwLanguageId, [Out]StringBuilder lpBuffer,
int nSize, IntPtr va_list_arguments);
[DllImport("api-ms-win-core-sysinfo-l1-2-1.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[DllImport(PinvokeDllNames.GetVersionExDllName, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool GetVersionEx(ref OSVERSIONINFOEX osVerEx);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]

View file

@ -14,23 +14,23 @@ namespace System.Management.Automation
internal static class PinvokeDllNames
{
#if CORECLR
internal const string QueryDosDeviceDllName = "api-ms-win-core-file-l1-2-1.dll"; /*1*/
internal const string CreateSymbolicLinkDllName = "api-ms-win-core-file-l2-1-1.dll"; /*2*/
internal const string GetOEMCPDllName = "api-ms-win-core-localization-l1-2-1.dll"; /*3*/
internal const string DeviceIoControlDllName = "api-ms-win-core-io-l1-1-1.dll"; /*4*/
internal const string CreateFileDllName = "api-ms-win-core-file-l1-2-1.dll"; /*5*/
internal const string DeleteFileDllName = "api-ms-win-core-file-l1-2-1.dll"; /*6*/
internal const string FindCloseDllName = "api-ms-win-core-file-l1-2-1.dll"; /*7*/
internal const string GetFileAttributesDllName = "api-ms-win-core-file-l1-2-1.dll"; /*8*/
internal const string FindFirstFileDllName = "api-ms-win-core-file-l1-2-1.dll"; /*9*/
internal const string FindNextFileDllName = "api-ms-win-core-file-l1-2-1.dll"; /*10*/
internal const string QueryDosDeviceDllName = "api-ms-win-core-file-l1-1-0.dll"; /*1*/
internal const string CreateSymbolicLinkDllName = "api-ms-win-core-file-l2-1-0.dll"; /*2*/
internal const string GetOEMCPDllName = "api-ms-win-core-localization-l1-2-0.dll"; /*3*/
internal const string DeviceIoControlDllName = "api-ms-win-core-io-l1-1-0.dll"; /*4*/
internal const string CreateFileDllName = "api-ms-win-core-file-l1-1-0.dll"; /*5*/
internal const string DeleteFileDllName = "api-ms-win-core-file-l1-1-0.dll"; /*6*/
internal const string FindCloseDllName = "api-ms-win-core-file-l1-1-0.dll"; /*7*/
internal const string GetFileAttributesDllName = "api-ms-win-core-file-l1-1-0.dll"; /*8*/
internal const string FindFirstFileDllName = "api-ms-win-core-file-l1-1-0.dll"; /*9*/
internal const string FindNextFileDllName = "api-ms-win-core-file-l1-1-0.dll"; /*10*/
internal const string RegEnumValueDllName = "api-ms-win-core-registry-l1-1-0.dll"; /*11*/
internal const string RegOpenKeyExDllName = "api-ms-win-core-registry-l1-1-0.dll"; /*12*/
internal const string RegOpenKeyTransactedDllName = "api-ms-win-core-registry-l2-2-0.dll"; /*13*/
internal const string RegOpenKeyTransactedDllName = "api-ms-win-core-registry-l2-1-0.dll"; /*13*/
internal const string RegQueryInfoKeyDllName = "api-ms-win-core-registry-l1-1-0.dll"; /*14*/
internal const string RegQueryValueExDllName = "api-ms-win-core-registry-l1-1-0.dll"; /*15*/
internal const string RegQueryValueExDllName = "api-ms-win-core-registry-l2-1-0.dll"; /*15*/
internal const string RegSetValueExDllName = "api-ms-win-core-registry-l1-1-0.dll"; /*16*/
internal const string RegCreateKeyTransactedDllName = "api-ms-win-core-registry-l2-2-0.dll"; /*17*/
internal const string RegCreateKeyTransactedDllName = "api-ms-win-core-registry-l2-1-0.dll"; /*17*/
internal const string CryptGenKeyDllName = "api-ms-win-security-cryptoapi-l1-1-0.dll"; /*18*/
internal const string CryptDestroyKeyDllName = "api-ms-win-security-cryptoapi-l1-1-0.dll"; /*19*/
internal const string CryptAcquireContextDllName = "api-ms-win-security-cryptoapi-l1-1-0.dll"; /*20*/
@ -40,43 +40,43 @@ namespace System.Management.Automation
internal const string CryptExportKeyDllName = "api-ms-win-security-cryptoapi-l1-1-0.dll"; /*24*/
internal const string CryptImportKeyDllName = "api-ms-win-security-cryptoapi-l1-1-0.dll"; /*25*/
internal const string CryptDuplicateKeyDllName = "api-ms-win-security-cryptoapi-l1-1-0.dll"; /*26*/
internal const string GetLastErrorDllName = "api-ms-win-core-errorhandling-l1-1-1.dll"; /*27*/
internal const string GetCPInfoDllName = "api-ms-win-core-localization-l1-2-1.dll"; /*28*/
internal const string GetLastErrorDllName = "api-ms-win-core-errorhandling-l1-1-0.dll"; /*27*/
internal const string GetCPInfoDllName = "api-ms-win-core-localization-l1-2-0.dll"; /*28*/
internal const string CommandLineToArgvDllName = "api-ms-win-downlevel-shell32-l1-1-0.dll"; /*30*/
internal const string LocalFreeDllName = "api-ms-win-core-misc-l1-1-0.dll"; /*31*/
internal const string CloseHandleDllName = "api-ms-win-core-handle-l1-1-0.dll"; /*32*/
internal const string GetTokenInformationDllName = "api-ms-win-security-base-l1-2-0.dll"; /*33*/
internal const string LookupAccountSidDllName = "api-ms-win-security-lsalookup-l2-1-1.dll"; /*34*/
internal const string GetTokenInformationDllName = "api-ms-win-security-base-l1-1-0.dll"; /*33*/
internal const string LookupAccountSidDllName = "api-ms-win-security-lsalookup-l2-1-0.dll"; /*34*/
internal const string OpenProcessTokenDllName = "api-ms-win-core-processsecurity-l1-1-0.dll"; /*35*/
internal const string DosDateTimeToFileTimeDllName = "api-ms-win-core-kernel32-legacy-l1-1-1.dll"; /*36*/
internal const string LocalFileTimeToFileTimeDllName = "api-ms-win-core-file-l1-2-1.dll"; /*37*/
internal const string SetFileTimeDllName = "api-ms-win-core-file-l1-2-1.dll"; /*38*/
internal const string SetFileAttributesWDllName = "api-ms-win-core-file-l1-2-1.dll"; /*39*/
internal const string CreateHardLinkDllName = "api-ms-win-core-file-l2-1-1.dll"; /*40*/
internal const string DosDateTimeToFileTimeDllName = "api-ms-win-core-kernel32-legacy-l1-1-0.dll"; /*36*/
internal const string LocalFileTimeToFileTimeDllName = "api-ms-win-core-file-l1-1-0.dll"; /*37*/
internal const string SetFileTimeDllName = "api-ms-win-core-file-l1-1-0.dll"; /*38*/
internal const string SetFileAttributesWDllName = "api-ms-win-core-file-l1-1-0.dll"; /*39*/
internal const string CreateHardLinkDllName = "api-ms-win-core-file-l2-1-0.dll"; /*40*/
internal const string RegCloseKeyDllName = "api-ms-win-core-registry-l1-1-0.dll"; /*41*/
internal const string GetFileInformationByHandleDllName = "api-ms-win-core-file-l1-2-1.dll"; /*42*/
internal const string GetFileInformationByHandleDllName = "api-ms-win-core-file-l1-1-0.dll"; /*42*/
internal const string FindFirstStreamDllName = "api-ms-win-core-file-l1-2-2.dll"; /*43*/
internal const string FindNextStreamDllName = "api-ms-win-core-file-l1-2-2.dll"; /*44*/
internal const string GetSystemInfoDllName = "api-ms-win-core-sysinfo-l1-2-1.dll"; /*45*/
internal const string GetCurrentThreadIdDllName = "api-ms-win-core-processthreads-l1-1-2.dll"; /*46*/
internal const string SetLocalTimeDllName = "api-ms-win-core-sysinfo-l1-2-1.dll"; /*47*/
internal const string GetSystemInfoDllName = "api-ms-win-core-sysinfo-l1-1-0.dll"; /*45*/
internal const string GetCurrentThreadIdDllName = "api-ms-win-core-processthreads-l1-1-0.dll"; /*46*/
internal const string SetLocalTimeDllName = "api-ms-win-core-sysinfo-l1-1-0.dll"; /*47*/
internal const string CryptSetProvParamDllName = "api-ms-win-security-cryptoapi-l1-1-0.dll"; /*48*/
internal const string GetNamedSecurityInfoDllName = "api-ms-win-security-provider-l1-1-0.dll"; /*49*/
internal const string SetNamedSecurityInfoDllName = "api-ms-win-security-provider-l1-1-0.dll"; /*50*/
internal const string ConvertStringSidToSidDllName = "api-ms-win-security-sddl-l1-1-0.dll"; /*51*/
internal const string IsValidSidDllName = "api-ms-win-security-base-l1-2-0.dll"; /*52*/
internal const string GetLengthSidDllName = "api-ms-win-security-base-l1-2-0.dll"; /*53*/
internal const string IsValidSidDllName = "api-ms-win-security-base-l1-1-0.dll"; /*52*/
internal const string GetLengthSidDllName = "api-ms-win-security-base-l1-1-0.dll"; /*53*/
internal const string LsaFreeMemoryDllName = "api-ms-win-security-lsapolicy-l1-1-0.dll"; /*54*/
internal const string InitializeAclDllName = "api-ms-win-security-base-l1-2-0.dll"; /*55*/
internal const string GetCurrentProcessDllName = "api-ms-win-core-processthreads-l1-1-2.dll"; /*56*/
internal const string GetCurrentThreadDllName = "api-ms-win-core-processthreads-l1-1-2.dll"; /*57*/
internal const string OpenThreadTokenDllName = "api-ms-win-core-processthreads-l1-1-2.dll"; /*58*/
internal const string LookupPrivilegeValueDllName = "api-ms-win-security-lsalookup-l2-1-1.dll"; /*59*/
internal const string AdjustTokenPrivilegesDllName = "api-ms-win-security-base-l1-2-0.dll"; /*60*/
internal const string GetStdHandleDllName = "api-ms-win-core-processenvironment-l1-2-0.dll"; /*61*/
internal const string InitializeAclDllName = "api-ms-win-security-base-l1-1-0.dll"; /*55*/
internal const string GetCurrentProcessDllName = "api-ms-win-core-processthreads-l1-1-0.dll"; /*56*/
internal const string GetCurrentThreadDllName = "api-ms-win-core-processthreads-l1-1-0.dll"; /*57*/
internal const string OpenThreadTokenDllName = "api-ms-win-core-processthreads-l1-1-0.dll"; /*58*/
internal const string LookupPrivilegeValueDllName = "api-ms-win-security-lsalookup-l2-1-0.dll"; /*59*/
internal const string AdjustTokenPrivilegesDllName = "api-ms-win-security-base-l1-1-0.dll"; /*60*/
internal const string GetStdHandleDllName = "api-ms-win-core-processenvironment-l1-1-0.dll"; /*61*/
internal const string CreateProcessWithLogonWDllName = "api-ms-win-security-cpwl-l1-1-0.dll"; /*62*/
internal const string CreateProcessDllName = "api-ms-win-core-processthreads-l1-1-2.dll"; /*63*/
internal const string ResumeThreadDllName = "api-ms-win-core-processthreads-l1-1-2.dll"; /*64*/
internal const string CreateProcessDllName = "api-ms-win-core-processthreads-l1-1-0.dll"; /*63*/
internal const string ResumeThreadDllName = "api-ms-win-core-processthreads-l1-1-0.dll"; /*64*/
internal const string OpenSCManagerWDllName = "api-ms-win-service-management-l1-1-0.dll"; /*65*/
internal const string OpenServiceWDllName = "api-ms-win-service-management-l1-1-0.dll"; /*66*/
internal const string CloseServiceHandleDllName = "api-ms-win-service-management-l1-1-0.dll"; /*67*/
@ -86,19 +86,19 @@ namespace System.Management.Automation
internal const string CreateJobObjectDllName = "api-ms-win-core-job-l2-1-0.dll"; /*71*/
internal const string AssignProcessToJobObjectDllName = "api-ms-win-core-job-l2-1-0.dll"; /*72*/
internal const string QueryInformationJobObjectDllName = "api-ms-win-core-job-l2-1-0.dll"; /*73*/
internal const string CreateNamedPipeDllName = "api-ms-win-core-namedpipe-l1-2-0.dll"; /*74*/
internal const string WaitNamedPipeDllName = "api-ms-win-core-namedpipe-l1-2-0.dll"; /*75*/
internal const string PrivilegeCheckDllName = "api-ms-win-security-base-l1-2-0.dll"; /*76*/
internal const string ImpersonateNamedPipeClientDllName = "api-ms-win-core-namedpipe-l1-2-0.dll"; /*77*/
internal const string RevertToSelfDllName = "api-ms-win-security-base-l1-2-0.dll"; /*78*/
internal const string CreateNamedPipeDllName = "api-ms-win-core-namedpipe-l1-1-0.dll"; /*74*/
internal const string WaitNamedPipeDllName = "api-ms-win-core-namedpipe-l1-1-0.dll"; /*75*/
internal const string PrivilegeCheckDllName = "api-ms-win-security-base-l1-1-0.dll"; /*76*/
internal const string ImpersonateNamedPipeClientDllName = "api-ms-win-core-namedpipe-l1-1-0.dll"; /*77*/
internal const string RevertToSelfDllName = "api-ms-win-security-base-l1-1-0.dll"; /*78*/
internal const string CreateProcessInComputeSystemDllName = "vmcompute.dll"; /*79*/
internal const string CLSIDFromProgIDDllName = "api-ms-win-core-com-l1-1-1.dll"; /*80*/
internal const string LoadLibraryEx = "api-ms-win-core-libraryloader-l1-2-0.dll"; /*81*/
internal const string FreeLibrary = "api-ms-win-core-libraryloader-l1-2-0.dll"; /*82*/
internal const string CLSIDFromProgIDDllName = "api-ms-win-core-com-l1-1-0.dll"; /*80*/
internal const string LoadLibraryEx = "api-ms-win-core-libraryloader-l1-1-0.dll"; /*81*/
internal const string FreeLibrary = "api-ms-win-core-libraryloader-l1-1-0.dll"; /*82*/
internal const string EventActivityIdControlDllName = "api-ms-win-eventing-provider-l1-1-0.dll"; /*83*/
internal const string GetConsoleCPDllName = "api-ms-win-core-console-l1-1-0.dll"; /*84*/
internal const string GetConsoleOutputCPDllName = "api-ms-win-core-console-l1-1-0.dll"; /*85*/
internal const string GetConsoleWindowDllName = "api-ms-win-core-kernel32-legacy-l1-1-1.dll"; /*86*/
internal const string GetConsoleWindowDllName = "api-ms-win-core-kernel32-legacy-l1-1-0.dll"; /*86*/
internal const string GetDCDllName = "ext-ms-win-ntuser-dc-access-ext-l1-1-0.dll"; /*87*/
internal const string ReleaseDCDllName = "ext-ms-win-ntuser-dc-access-ext-l1-1-0.dll"; /*88*/
internal const string TranslateCharsetInfoDllName = "ext-ms-win-gdi-font-l1-1-1.dll"; /*89*/
@ -112,7 +112,7 @@ namespace System.Management.Automation
internal const string SetConsoleTitleDllName = "api-ms-win-core-console-l2-1-0.dll"; /*97*/
internal const string GetConsoleModeDllName = "api-ms-win-core-console-l1-1-0.dll"; /*98*/
internal const string GetConsoleScreenBufferInfoDllName = "api-ms-win-core-console-l2-1-0.dll"; /*99*/
internal const string GetFileTypeDllName = "api-ms-win-core-file-l1-2-1.dll"; /*100*/
internal const string GetFileTypeDllName = "api-ms-win-core-file-l1-1-0.dll"; /*100*/
internal const string GetLargestConsoleWindowSizeDllName = "api-ms-win-core-console-l2-1-0.dll"; /*101*/
internal const string ReadConsoleDllName = "api-ms-win-core-console-l1-1-0.dll"; /*102*/
internal const string PeekConsoleInputDllName = "api-ms-win-core-console-l2-1-0.dll"; /*103*/
@ -126,10 +126,12 @@ namespace System.Management.Automation
internal const string WriteConsoleOutputDllName = "api-ms-win-core-console-l2-1-0.dll"; /*111*/
internal const string ReadConsoleOutputDllName = "api-ms-win-core-console-l2-1-0.dll"; /*112*/
internal const string ScrollConsoleScreenBufferDllName = "api-ms-win-core-console-l2-1-0.dll"; /*113*/
internal const string SendInputDllName = "ext-ms-win-ntuser-keyboard-l1-3-0.dll"; /*114*/
internal const string SendInputDllName = "ext-ms-win-ntuser-keyboard-l1-2-1.dll"; /*114*/
internal const string GetConsoleCursorInfoDllName = "api-ms-win-core-console-l2-1-0.dll"; /*115*/
internal const string SetConsoleCursorInfoDllName = "api-ms-win-core-console-l2-1-0.dll"; /*116*/
internal const string ReadConsoleInputDllName = "api-ms-win-core-console-l1-1-0.dll"; /*117*/
internal const string GetVersionExDllName = "api-ms-win-core-sysinfo-l1-1-0.dll"; /*118*/
internal const string FormatMessageDllName = "api-ms-win-core-localization-l1-2-0.dll"; /*119*/
#else
internal const string QueryDosDeviceDllName = "kernel32.dll"; /*1*/
internal const string CreateSymbolicLinkDllName = "kernel32.dll"; /*2*/
@ -247,6 +249,8 @@ namespace System.Management.Automation
internal const string GetConsoleCursorInfoDllName = "kernel32.dll"; /*115*/
internal const string SetConsoleCursorInfoDllName = "kernel32.dll"; /*116*/
internal const string ReadConsoleInputDllName = "kernel32.dll"; /*117*/
internal const string GetVersionExDllName = "kernel32.dll"; /*118*/
internal const string FormatMessageDllName = "wevtapi.dll"; /*119*/
#endif
}
}