<Compile Include="$(BclSourcesRoot)\Internal\Console.cs" />
<Compile Include="$(BclSourcesRoot)\Internal\Runtime\Augments\RuntimeThread.cs" />
<Compile Include="$(BclSourcesRoot)\Microsoft\Win32\UnsafeNativeMethods.cs" />
- <Compile Include="$(BclSourcesRoot)\Microsoft\Win32\Win32Native.cs" />
<Compile Include="$(BclSourcesRoot)\System\__Canon.cs" />
<Compile Include="$(BclSourcesRoot)\System\Activator.cs" />
<Compile Include="$(BclSourcesRoot)\System\AppContext.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\ValueType.cs" />
<Compile Include="$(BclSourcesRoot)\System\WeakReference.cs" />
<Compile Include="$(BclSourcesRoot)\System\WeakReferenceOfT.cs" />
+ <Compile Include="shared\Interop\Windows\Kernel32\Interop.GetCurrentProcessId.cs" />
+ <Compile Include="shared\Interop\Windows\Kernel32\Interop.GetCurrentThreadId.cs" />
+ <Compile Include="shared\Interop\Windows\Kernel32\Interop.GetStdHandle.cs" />
+ <Compile Include="shared\Interop\Windows\Kernel32\Interop.LocalAlloc.cs" />
+ <Compile Include="shared\Interop\Windows\Kernel32\Interop.QueryUnbiasedInterruptTime.cs" />
+ <Compile Include="shared\Interop\Windows\Kernel32\Interop.VerifyVersionExW.cs" />
+ <Compile Include="shared\Interop\Windows\Kernel32\Interop.VerSetConditionMask.cs" />
+ <Compile Include="shared\Interop\Windows\Ole32\Interop.CoTaskMemAlloc.cs" />
+ <Compile Include="shared\Interop\Windows\OleAut32\Interop.SysAllocStringByteLen.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(BclSourcesRoot)\System\Diagnostics\Eventing\XplatEventLogger.cs" Condition="'$(FeatureXplatEventSource)' == 'true'" />
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.InteropServices;
+
+internal partial class Interop
+{
+ internal partial class Kernel32
+ {
+ [DllImport(Libraries.Kernel32)]
+ internal extern static uint GetCurrentProcessId();
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class Kernel32
+ {
+ [DllImport(Libraries.Kernel32, ExactSpelling = true)]
+ public static extern int GetCurrentThreadId();
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.InteropServices;
+
+internal partial class Interop
+{
+ internal partial class Kernel32
+ {
+ internal const int STD_INPUT_HANDLE = -10;
+ internal const int STD_OUTPUT_HANDLE = -11;
+ internal const int STD_ERROR_HANDLE = -12;
+
+ [DllImport(Libraries.Kernel32, SetLastError = true)]
+ internal static extern IntPtr GetStdHandle(int nStdHandle);
+ }
+}
{
[DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool GetVersionExW(ref OSVERSIONINFOEX osvi);
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- internal unsafe struct OSVERSIONINFOEX
- {
- public int dwOSVersionInfoSize;
- public int dwMajorVersion;
- public int dwMinorVersion;
- public int dwBuildNumber;
- public int dwPlatformId;
- public fixed char szCSDVersion[128];
- public ushort wServicePackMajor;
- public ushort wServicePackMinor;
- public ushort wSuiteMask;
- public byte wProductType;
- public byte wReserved;
- }
}
}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.InteropServices;
+
+internal partial class Interop
+{
+ internal partial class Kernel32
+ {
+ internal const uint LMEM_FIXED = 0x0000;
+ internal const uint LMEM_MOVEABLE = 0x0002;
+
+ [DllImport(Libraries.Kernel32)]
+ internal static extern IntPtr LocalAlloc(uint uFlags, UIntPtr uBytes);
+
+ [DllImport(Libraries.Kernel32)]
+ internal static extern IntPtr LocalReAlloc(IntPtr hMem, IntPtr uBytes, uint uFlags);
+
+ [DllImport(Libraries.Kernel32, SetLastError = true)]
+ internal static extern IntPtr LocalFree(IntPtr hMem);
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.InteropServices;
+
+internal partial class Interop
+{
+ internal partial class Kernel32
+ {
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal unsafe struct OSVERSIONINFOEX
+ {
+ public int dwOSVersionInfoSize;
+ public int dwMajorVersion;
+ public int dwMinorVersion;
+ public int dwBuildNumber;
+ public int dwPlatformId;
+ public fixed char szCSDVersion[128];
+ public ushort wServicePackMajor;
+ public ushort wServicePackMinor;
+ public ushort wSuiteMask;
+ public byte wProductType;
+ public byte wReserved;
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.InteropServices;
+
+internal partial class Interop
+{
+ internal partial class Kernel32
+ {
+ [DllImport(Libraries.Kernel32, SetLastError = true)]
+ internal static extern bool QueryUnbiasedInterruptTime(out ulong UnbiasedTime);
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.InteropServices;
+
+internal partial class Interop
+{
+ internal partial class Kernel32
+ {
+ [DllImport(Libraries.Kernel32)]
+ internal static extern ulong VerSetConditionMask(ulong ConditionMask, uint TypeMask, byte Condition);
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.InteropServices;
+
+internal partial class Interop
+{
+ internal partial class Kernel32
+ {
+ internal const byte VER_GREATER_EQUAL = 0x3;
+ internal const uint VER_MAJORVERSION = 0x0000002;
+ internal const uint VER_MINORVERSION = 0x0000001;
+ internal const uint VER_SERVICEPACKMAJOR = 0x0000020;
+ internal const uint VER_SERVICEPACKMINOR = 0x0000010;
+
+ [DllImport(Libraries.Kernel32)]
+ internal static extern bool VerifyVersionInfoW(ref OSVERSIONINFOEX lpVersionInfo, uint dwTypeMask, ulong dwlConditionMask);
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.InteropServices;
+
+internal partial class Interop
+{
+ internal partial class Ole32
+ {
+ [DllImport(Libraries.Ole32)]
+ internal static extern IntPtr CoTaskMemAlloc(UIntPtr cb);
+
+ [DllImport(Libraries.Ole32)]
+ internal static extern IntPtr CoTaskMemRealloc(IntPtr pv, UIntPtr cb);
+
+ [DllImport(Libraries.Ole32)]
+ internal static extern void CoTaskMemFree(IntPtr ptr);
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.InteropServices;
+
+internal partial class Interop
+{
+ internal partial class OleAut32
+ {
+ [DllImport(Libraries.OleAut32)]
+ internal static extern IntPtr SysAllocStringByteLen(byte[] str, uint len);
+ }
+}
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.VirtualFree.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.VirtualQuery.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.WideCharToMultiByte.cs" />
- <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_NativeOverlapped.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Normaliz\Interop.Idna.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Normaliz\Interop.Normalization.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\NtDll\Interop.NtQuerySystemInformation.cs" Condition="'$(EnableWinRT)' != 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Ole32\Interop.CoCreateGuid.cs" />
- <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\OleAut32\Interop.SysAllocStringLen.cs" />
- <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\OleAut32\Interop.SysFreeString.cs" />
- <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\OleAut32\Interop.SysStringLen.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Secur32\Interop.GetUserNameExW.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Shell32\Interop.SHGetKnownFolderPath.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\IO\File.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\PasteArguments.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\MemoryFailPoint.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\Marshal.Windows.cs" Condition="'$(TargetsCoreRT)' != 'true'" />
- <Compile Include="$(MSBuildThisFileDirectory)System\Security\SafeBSTRHandle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Security\SecureString.Windows.cs" />
</ItemGroup>
<ItemGroup Condition="'$(FeatureAsyncCausalityTracer)' != 'true'">
</ItemGroup>
<ItemGroup Condition="$(TargetsWindows) or '$(FeaturePal)'=='true'">
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeWaitHandle.Windows.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Interop.Errors.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\OleAut32\Interop.SysAllocStringLen.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\OleAut32\Interop.SysFreeString.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\OleAut32\Interop.SysStringLen.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.CloseHandle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.Constants.cs" />
- <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Interop.Errors.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.EventWaitHandle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.GetEnvironmentVariable.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.GetEnvironmentStrings.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.FreeEnvironmentStrings.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.FormatMessage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.Mutex.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.OSVERSIONINFOEX.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.Semaphore.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.SetEnvironmentVariable.cs" />
- <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.EventWaitHandle.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Environment.Variables.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\IO\Win32Marshal.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Security\SafeBSTRHandle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Mutex.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Semaphore.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\EventWaitHandle.Windows.cs" />
var providerInfos = (UnsafeNativeMethods.ManifestEtw.TRACE_GUID_INFO*)buffer;
var providerInstance = (UnsafeNativeMethods.ManifestEtw.TRACE_PROVIDER_INSTANCE_INFO*)&providerInfos[1];
- int processId = unchecked((int)Win32Native.GetCurrentProcessId());
+ int processId = unchecked((int)Interop.Kernel32.GetCurrentProcessId());
// iterate over the instances of the EventProvider in all processes
for (int i = 0; i < providerInfos->InstanceCount; i++)
{
{
get
{
- int threadID = Win32Native.GetCurrentThreadId();
+ int threadID = Interop.Kernel32.GetCurrentThreadId();
// Managed thread IDs are more aggressively re-used than native thread IDs,
// so we'll use the latter...
// for non-BCL EventSource we must assert SecurityPermission
new SecurityPermission(PermissionState.Unrestricted).Assert();
#endif
- s_currentPid = Win32Native.GetCurrentProcessId();
+ s_currentPid = Interop.Kernel32.GetCurrentProcessId();
}
}
}
#if ES_BUILD_STANDALONE
-namespace Microsoft.Win32
+internal static partial class Interop
{
using System.Runtime.InteropServices;
using System.Security;
[SuppressUnmanagedCodeSecurityAttribute()]
- internal static class Win32Native
+ internal static partial class Kernel32
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetCurrentThreadId();
if (Interop.Errors.ERROR_INVALID_HANDLE == errorCode)
return OpenExistingResult.NameInvalid;
- // this is for passed through Win32Native Errors
throw Win32Marshal.GetExceptionForWin32Error(errorCode, name);
}
using System;
using System.Text;
-using System.Security;
-using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
namespace Internal
public static class Console
{
private static readonly SafeFileHandle _outputHandle =
- new SafeFileHandle(Win32Native.GetStdHandle(Win32Native.STD_OUTPUT_HANDLE), false);
+ new SafeFileHandle(Interop.Kernel32.GetStdHandle(Interop.Kernel32.STD_OUTPUT_HANDLE), ownsHandle: false);
public static unsafe void Write(string s)
{
byte[] bytes = Encoding.UTF8.GetBytes(s);
-
fixed (byte* pBytes = bytes)
{
- int bytesWritten;
- Win32Native.WriteFile(_outputHandle, pBytes, bytes.Length, out bytesWritten, IntPtr.Zero);
+ Interop.Kernel32.WriteFile(_outputHandle, pBytes, bytes.Length, out _, IntPtr.Zero);
}
}
- public static void WriteLine(string s)
- {
+ public static void WriteLine(string s) =>
Write(s + Environment.NewLine);
- }
- public static void WriteLine()
- {
+ public static void WriteLine() =>
Write(Environment.NewLine);
- }
}
}
internal const string User32 = "libcoreclr";
internal const string Ole32 = "libcoreclr";
internal const string OleAut32 = "libcoreclr";
+ internal const string Advapi32 = "libcoreclr";
}
}
//
// Registration APIs
//
- [DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EventRegister", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
+ [DllImport(Interop.Libraries.Advapi32, ExactSpelling = true, EntryPoint = "EventRegister", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
internal static extern unsafe uint EventRegister(
[In] ref Guid providerId,
[In]EtwEnableCallback enableCallback,
);
//
- [DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EventUnregister", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
+ [DllImport(Interop.Libraries.Advapi32, ExactSpelling = true, EntryPoint = "EventUnregister", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
internal static extern uint EventUnregister([In] long registrationHandle);
- [DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EventWriteString", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
+ [DllImport(Interop.Libraries.Advapi32, ExactSpelling = true, EntryPoint = "EventWriteString", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
internal static extern int EventWriteString(
[In] long registrationHandle,
[In] byte level,
return HResult;
}
- [DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EventWriteTransfer", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
+ [DllImport(Interop.Libraries.Advapi32, ExactSpelling = true, EntryPoint = "EventWriteTransfer", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
private static extern int EventWriteTransfer(
[In] long registrationHandle,
[In] ref EventDescriptor eventDescriptor,
EVENT_ACTIVITY_CTRL_CREATE_SET_ID = 5
};
- [DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EventActivityIdControl", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
+ [DllImport(Interop.Libraries.Advapi32, ExactSpelling = true, EntryPoint = "EventActivityIdControl", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
internal static extern int EventActivityIdControl([In] ActivityControl ControlCode, [In][Out] ref Guid ActivityId);
internal enum EVENT_INFO_CLASS
SetTraits,
}
- [DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EventSetInformation", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
+ [DllImport(Interop.Libraries.Advapi32, ExactSpelling = true, EntryPoint = "EventSetInformation", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
internal static extern int EventSetInformation(
[In] long registrationHandle,
[In] EVENT_INFO_CLASS informationClass,
public long MatchAllKeyword;
};
- [DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EnumerateTraceGuidsEx", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
+ [DllImport(Interop.Libraries.Advapi32, ExactSpelling = true, EntryPoint = "EnumerateTraceGuidsEx", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
internal static extern int EnumerateTraceGuidsEx(
TRACE_QUERY_INFO_CLASS TraceQueryInfoClass,
void* InBuffer,
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================
-**
-**
-**
-** Purpose: CoreCLR wrapper for Win32, either the native
-** operations or the Unix PAL implementation of them.
-**
-**
-===========================================================*/
-/*
- * Notes to PInvoke users: Getting the syntax exactly correct is crucial, and
- * more than a little confusing. Here's some guidelines.
- *
- * For handles, you should use a SafeHandle subclass specific to your handle
- * type. For files, we have the following set of interesting definitions:
- *
- * [DllImport(Interop.Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto, BestFitMapping=false)]
- * private static extern SafeFileHandle CreateFile(...);
- *
- * [DllImport(Interop.Libraries.Kernel32, SetLastError=true)]
- * internal static extern unsafe int ReadFile(SafeFileHandle handle, ...);
- *
- * [DllImport(Interop.Libraries.Kernel32, SetLastError=true)]
- * internal static extern bool CloseHandle(IntPtr handle);
- *
- * P/Invoke will create the SafeFileHandle instance for you and assign the
- * return value from CreateFile into the handle atomically. When we call
- * ReadFile, P/Invoke will increment a ref count, make the call, then decrement
- * it (preventing handle recycling vulnerabilities). Then SafeFileHandle's
- * ReleaseHandle method will call CloseHandle, passing in the handle field
- * as an IntPtr.
- *
- * If for some reason you cannot use a SafeHandle subclass for your handles,
- * then use IntPtr as the handle type (or possibly HandleRef - understand when
- * to use GC.KeepAlive). If your code will run in SQL Server (or any other
- * long-running process that can't be recycled easily), use a constrained
- * execution region to prevent thread aborts while allocating your
- * handle, and consider making your handle wrapper subclass
- * CriticalFinalizerObject to ensure you can free the handle. As you can
- * probably guess, SafeHandle will save you a lot of headaches if your code
- * needs to be robust to thread aborts and OOM.
- *
- *
- * If you have a method that takes a native struct, you have two options for
- * declaring that struct. You can make it a value type ('struct' in CSharp),
- * or a reference type ('class'). This choice doesn't seem very interesting,
- * but your function prototype must use different syntax depending on your
- * choice. For example, if your native method is prototyped as such:
- *
- * bool GetVersionEx(OSVERSIONINFO & lposvi);
- *
- *
- * you must use EITHER THIS OR THE NEXT syntax:
- *
- * [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
- * internal struct OSVERSIONINFO { ... }
- *
- * [DllImport(Interop.Libraries.Kernel32, CharSet=CharSet.Auto)]
- * internal static extern bool GetVersionEx(ref OSVERSIONINFO lposvi);
- *
- * OR:
- *
- * [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
- * internal class OSVERSIONINFO { ... }
- *
- * [DllImport(Interop.Libraries.Kernel32, CharSet=CharSet.Auto)]
- * internal static extern bool GetVersionEx([In, Out] OSVERSIONINFO lposvi);
- *
- * Note that classes require being marked as [In, Out] while value types must
- * be passed as ref parameters.
- *
- * Also note the CharSet.Auto on GetVersionEx - while it does not take a String
- * as a parameter, the OSVERSIONINFO contains an embedded array of TCHARs, so
- * the size of the struct varies on different platforms, and there's a
- * GetVersionExA & a GetVersionExW. Also, the OSVERSIONINFO struct has a sizeof
- * field so the OS can ensure you've passed in the correctly-sized copy of an
- * OSVERSIONINFO. You must explicitly set this using Marshal.SizeOf(Object);
- *
- * For security reasons, if you're making a P/Invoke method to a Win32 method
- * that takes an ANSI String and that String is the name of some resource you've
- * done a security check on (such as a file name), you want to disable best fit
- * mapping in WideCharToMultiByte. Do this by setting BestFitMapping=false
- * in your DllImportAttribute.
- */
-
-namespace Microsoft.Win32
-{
- using System;
- using System.Runtime.InteropServices;
- using Microsoft.Win32.SafeHandles;
-
- /**
- * Win32 encapsulation for System.Private.CoreLib.
- */
- internal static class Win32Native
- {
- internal const int LMEM_FIXED = 0x0000;
- internal const int LMEM_ZEROINIT = 0x0040;
- internal const int LPTR = (LMEM_FIXED | LMEM_ZEROINIT);
-
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
- internal unsafe struct OSVERSIONINFOEX
- {
- internal int dwOSVersionInfoSize;
- internal int dwMajorVersion;
- internal int dwMinorVersion;
- internal int dwBuildNumber;
- internal int dwPlatformId;
- internal fixed char szCSDVersion[128];
- internal ushort wServicePackMajor;
- internal ushort wServicePackMinor;
- internal short wSuiteMask;
- internal byte wProductType;
- internal byte wReserved;
- }
-
- internal const string ADVAPI32 = "advapi32.dll";
-
- [DllImport(Interop.Libraries.Kernel32, EntryPoint = "LocalAlloc")]
- internal static extern IntPtr LocalAlloc_NoSafeHandle(int uFlags, UIntPtr sizetdwBytes);
-
- [DllImport(Interop.Libraries.Kernel32, SetLastError = true)]
- internal static extern IntPtr LocalFree(IntPtr handle);
-
- [DllImport(Interop.Libraries.Kernel32)]
- internal static extern IntPtr LocalReAlloc(IntPtr handle, IntPtr sizetcbBytes, int uFlags);
-
- [DllImport(Interop.Libraries.OleAut32, CharSet = CharSet.Unicode)]
- internal static extern IntPtr SysAllocStringLen(string src, int len); // BSTR
-
- [DllImport(Interop.Libraries.OleAut32)]
- internal static extern uint SysStringLen(IntPtr bstr);
-
- [DllImport(Interop.Libraries.OleAut32)]
- internal static extern void SysFreeString(IntPtr bstr);
-
- [DllImport(Interop.Libraries.OleAut32)]
- internal static extern IntPtr SysAllocStringByteLen(byte[] str, uint len); // BSTR
-
- [DllImport(Interop.Libraries.Kernel32, SetLastError = true)]
- internal static extern unsafe int WriteFile(SafeFileHandle handle, byte* bytes, int numBytesToWrite, out int numBytesWritten, IntPtr mustBeZero);
-
- internal static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1); // WinBase.h
-
- // Note, these are #defines used to extract handles, and are NOT handles.
- internal const int STD_INPUT_HANDLE = -10;
- internal const int STD_OUTPUT_HANDLE = -11;
- internal const int STD_ERROR_HANDLE = -12;
-
- [DllImport(Interop.Libraries.Kernel32, SetLastError = true)]
- internal static extern IntPtr GetStdHandle(int nStdHandle); // param is NOT a handle, but it returns one!
-
- [DllImport(Interop.Libraries.Kernel32, CharSet = CharSet.Auto)]
- internal static extern int GetCurrentThreadId();
-
- [DllImport(Interop.Libraries.Kernel32, CharSet = CharSet.Auto)]
- internal static extern uint GetCurrentProcessId();
-
- [DllImport(Interop.Libraries.Ole32)]
- internal static extern IntPtr CoTaskMemAlloc(UIntPtr cb);
-
- [DllImport(Interop.Libraries.Ole32)]
- internal static extern void CoTaskMemFree(IntPtr ptr);
-
- [DllImport(Interop.Libraries.Ole32)]
- internal static extern IntPtr CoTaskMemRealloc(IntPtr pv, UIntPtr cb);
-
- [DllImport(Interop.Libraries.Kernel32, SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool QueryUnbiasedInterruptTime(out ulong UnbiasedTime);
-
- internal const byte VER_GREATER_EQUAL = 0x3;
- internal const uint VER_MAJORVERSION = 0x0000002;
- internal const uint VER_MINORVERSION = 0x0000001;
- internal const uint VER_SERVICEPACKMAJOR = 0x0000020;
- internal const uint VER_SERVICEPACKMINOR = 0x0000010;
- [DllImport("kernel32.dll")]
- internal static extern bool VerifyVersionInfoW(ref OSVERSIONINFOEX lpVersionInfo, uint dwTypeMask, ulong dwlConditionMask);
- [DllImport("kernel32.dll")]
- internal static extern ulong VerSetConditionMask(ulong dwlConditionMask, uint dwTypeBitMask, byte dwConditionMask);
- }
-}
{
// If set, bail out early if the specified process does not match the current process.
int processID = Convert.ToInt32(strProcessID);
- if (processID != Win32Native.GetCurrentProcessId())
+ if (processID != Interop.Kernel32.GetCurrentProcessId())
{
return null;
}
private static string BuildTraceFileName()
{
- return GetAppName() + "." + Win32Native.GetCurrentProcessId().ToString() + NetPerfFileExtension;
+ return GetAppName() + "." + Interop.Kernel32.GetCurrentProcessId().ToString() + NetPerfFileExtension;
}
private static string GetAppName()
private static bool GetIsWindows8OrAbove()
{
- ulong conditionMask = Win32Native.VerSetConditionMask(0, Win32Native.VER_MAJORVERSION, Win32Native.VER_GREATER_EQUAL);
- conditionMask = Win32Native.VerSetConditionMask(conditionMask, Win32Native.VER_MINORVERSION, Win32Native.VER_GREATER_EQUAL);
- conditionMask = Win32Native.VerSetConditionMask(conditionMask, Win32Native.VER_SERVICEPACKMAJOR, Win32Native.VER_GREATER_EQUAL);
- conditionMask = Win32Native.VerSetConditionMask(conditionMask, Win32Native.VER_SERVICEPACKMINOR, Win32Native.VER_GREATER_EQUAL);
+ ulong conditionMask = Interop.Kernel32.VerSetConditionMask(0, Interop.Kernel32.VER_MAJORVERSION, Interop.Kernel32.VER_GREATER_EQUAL);
+ conditionMask = Interop.Kernel32.VerSetConditionMask(conditionMask, Interop.Kernel32.VER_MINORVERSION, Interop.Kernel32.VER_GREATER_EQUAL);
+ conditionMask = Interop.Kernel32.VerSetConditionMask(conditionMask, Interop.Kernel32.VER_SERVICEPACKMAJOR, Interop.Kernel32.VER_GREATER_EQUAL);
+ conditionMask = Interop.Kernel32.VerSetConditionMask(conditionMask, Interop.Kernel32.VER_SERVICEPACKMINOR, Interop.Kernel32.VER_GREATER_EQUAL);
// Windows 8 version is 6.2
- var version = new Win32Native.OSVERSIONINFOEX();
+ Interop.Kernel32.OSVERSIONINFOEX version = default;
unsafe
{
- version.dwOSVersionInfoSize = sizeof(Win32Native.OSVERSIONINFOEX);
+ version.dwOSVersionInfoSize = sizeof(Interop.Kernel32.OSVERSIONINFOEX);
}
version.dwMajorVersion = 6;
version.dwMinorVersion = 2;
version.wServicePackMajor = 0;
version.wServicePackMinor = 0;
- return Win32Native.VerifyVersionInfoW(ref version,
- Win32Native.VER_MAJORVERSION | Win32Native.VER_MINORVERSION | Win32Native.VER_SERVICEPACKMAJOR | Win32Native.VER_SERVICEPACKMINOR,
+ return Interop.Kernel32.VerifyVersionInfoW(ref version,
+ Interop.Kernel32.VER_MAJORVERSION | Interop.Kernel32.VER_MINORVERSION | Interop.Kernel32.VER_SERVICEPACKMAJOR | Interop.Kernel32.VER_SERVICEPACKMINOR,
conditionMask);
}
}
internal static Guid IID_IUnknown = new Guid(0, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0x46);
#endif //FEATURE_COMINTEROP
- private const int LMEM_FIXED = 0;
- private const int LMEM_MOVEABLE = 2;
-
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern int SizeOfHelper(Type t, bool throwIfNotMarshalable);
numBytes = new UIntPtr(unchecked((uint)cb.ToInt32()));
#endif
- IntPtr pNewMem = Win32Native.LocalAlloc_NoSafeHandle(LMEM_FIXED, unchecked(numBytes));
+ IntPtr pNewMem = Interop.Kernel32.LocalAlloc(Interop.Kernel32.LMEM_FIXED, unchecked(numBytes));
if (pNewMem == IntPtr.Zero)
{
throw new OutOfMemoryException();
{
if (!IsWin32Atom(hglobal))
{
- if (IntPtr.Zero != Win32Native.LocalFree(hglobal))
+ if (IntPtr.Zero != Interop.Kernel32.LocalFree(hglobal))
{
ThrowExceptionForHR(GetHRForLastWin32Error());
}
public static IntPtr ReAllocHGlobal(IntPtr pv, IntPtr cb)
{
- IntPtr pNewMem = Win32Native.LocalReAlloc(pv, cb, LMEM_MOVEABLE);
+ IntPtr pNewMem = Interop.Kernel32.LocalReAlloc(pv, cb, Interop.Kernel32.LMEM_MOVEABLE);
if (pNewMem == IntPtr.Zero)
{
throw new OutOfMemoryException();
public static IntPtr AllocCoTaskMem(int cb)
{
- IntPtr pNewMem = Win32Native.CoTaskMemAlloc(new UIntPtr((uint)cb));
+ IntPtr pNewMem = Interop.Ole32.CoTaskMemAlloc(new UIntPtr((uint)cb));
if (pNewMem == IntPtr.Zero)
{
throw new OutOfMemoryException();
{
if (!IsWin32Atom(ptr))
{
- Win32Native.CoTaskMemFree(ptr);
+ Interop.Ole32.CoTaskMemFree(ptr);
}
}
public static IntPtr ReAllocCoTaskMem(IntPtr pv, int cb)
{
- IntPtr pNewMem = Win32Native.CoTaskMemRealloc(pv, new UIntPtr((uint)cb));
+ IntPtr pNewMem = Interop.Ole32.CoTaskMemRealloc(pv, new UIntPtr((uint)cb));
if (pNewMem == IntPtr.Zero && cb != 0)
{
throw new OutOfMemoryException();
internal static IntPtr AllocBSTR(int length)
{
- IntPtr bstr = Win32Native.SysAllocStringLen(null, length);
+ IntPtr bstr = Interop.OleAut32.SysAllocStringLen(null, length);
if (bstr == IntPtr.Zero)
{
throw new OutOfMemoryException();
{
if (!IsWin32Atom(ptr))
{
- Win32Native.SysFreeString(ptr);
+ Interop.OleAut32.SysFreeString(ptr);
}
}
throw new ArgumentOutOfRangeException(nameof(s));
}
- IntPtr bstr = Win32Native.SysAllocStringLen(s, s.Length);
+ IntPtr bstr = Interop.OleAut32.SysAllocStringLen(s, s.Length);
if (bstr == IntPtr.Zero)
{
throw new OutOfMemoryException();
public static string PtrToStringBSTR(IntPtr ptr)
{
- return PtrToStringUni(ptr, (int)Win32Native.SysStringLen(ptr));
+ return PtrToStringUni(ptr, (int)Interop.OleAut32.SysStringLen(ptr));
}
#if FEATURE_COMINTEROP
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Collections.Generic;
using System.Reflection;
-using System.Reflection.Emit;
using System.Runtime.CompilerServices;
-using System.Runtime.ConstrainedExecution;
-using Win32Native = Microsoft.Win32.Win32Native;
-using System.Diagnostics;
using System.Threading;
namespace System.Runtime.InteropServices
internal static void ClearNative(IntPtr pNative)
{
- Win32Native.CoTaskMemFree(pNative);
+ Interop.Ole32.CoTaskMemFree(pNative);
}
} // class CSTRMarshaler
{
if (pNative != IntPtr.Zero)
{
- Win32Native.CoTaskMemFree(pNative);
+ Interop.Ole32.CoTaskMemFree(pNative);
}
}
}
// If caller provided a buffer, construct the BSTR manually. The size
// of the buffer must be at least (lengthInBytes + 6) bytes.
#if DEBUG
- uint length = *((uint*)pNativeBuffer.ToPointer());
+ uint length = *((uint*)pNativeBuffer);
Debug.Assert(length >= lengthInBytes + 6, "BSTR localloc'ed buffer is too small");
#endif
// set length
- *((uint*)pNativeBuffer.ToPointer()) = lengthInBytes;
+ *((uint*)pNativeBuffer) = lengthInBytes;
- ptrToFirstChar = (byte*)pNativeBuffer.ToPointer() + 4;
+ ptrToFirstChar = (byte*)pNativeBuffer + 4;
}
else
{
// If not provided, allocate the buffer using SysAllocStringByteLen so
// that odd-sized strings will be handled as well.
- ptrToFirstChar = (byte*)Win32Native.SysAllocStringByteLen(null, lengthInBytes).ToPointer();
+ ptrToFirstChar = (byte*)Interop.OleAut32.SysAllocStringByteLen(null, lengthInBytes);
if (ptrToFirstChar == null)
{
if ((length & 1) == 1)
{
// odd-sized strings need to have the trailing byte saved in their sync block
- ret.SetTrailByte(((byte*)bstr.ToPointer())[length - 1]);
+ ret.SetTrailByte(((byte*)bstr)[length - 1]);
}
return ret;
{
if (IntPtr.Zero != pNative)
{
- Win32Native.SysFreeString(pNative);
+ Interop.OleAut32.SysFreeString(pNative);
}
}
} // class BSTRMarshaler
{
if (IntPtr.Zero != pNative)
{
- Win32Native.CoTaskMemFree((IntPtr)(((long)pNative) - sizeof(uint)));
+ Interop.Ole32.CoTaskMemFree((IntPtr)(((long)pNative) - sizeof(uint)));
}
}
} // class VBByValStrMarshaler
bytes = AnsiCharMarshaler.DoAnsiConversion(strManaged, 0 != (flags & 0xFF), 0 != (flags >> 8), out nb);
}
- return Win32Native.SysAllocStringByteLen(bytes, (uint)nb);
+ return Interop.OleAut32.SysAllocStringByteLen(bytes, (uint)nb);
}
internal static unsafe string ConvertToManaged(IntPtr bstr)
{
if (IntPtr.Zero != pNative)
{
- Win32Native.SysFreeString(pNative);
+ Interop.OleAut32.SysFreeString(pNative);
}
}
} // class AnsiBSTRMarshaler
// marshal the object as class with layout (UnmanagedType.LPStruct)
if (IsIn(dwFlags))
{
- StubHelpers.FmtClassUpdateNativeInternal(pManagedHome, (byte*)pNativeHome.ToPointer(), ref cleanupWorkList);
+ StubHelpers.FmtClassUpdateNativeInternal(pManagedHome, (byte*)pNativeHome, ref cleanupWorkList);
}
if (IsOut(dwFlags))
{
case BackPropAction.Layout:
{
- StubHelpers.FmtClassUpdateCLRInternal(pManagedHome, (byte*)pNativeHome.ToPointer());
+ StubHelpers.FmtClassUpdateCLRInternal(pManagedHome, (byte*)pNativeHome);
break;
}
// this must happen regardless of BackPropAction
Marshal.DestroyStructure(pNativeHome, layoutType);
}
- Win32Native.CoTaskMemFree(pNativeHome);
+ Interop.Ole32.CoTaskMemFree(pNativeHome);
}
StubHelpers.DestroyCleanupList(ref cleanupWorkList);
}
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
-using Microsoft.Win32;
namespace System.Threading
{
internal sealed class RegisteredWaitHandleSafe : CriticalFinalizerObject
{
- private static IntPtr InvalidHandle => Win32Native.INVALID_HANDLE_VALUE;
+ private static IntPtr InvalidHandle => new IntPtr(-1);
private IntPtr registeredWaitHandle = InvalidHandle;
private WaitHandle m_internalWaitObject;
private bool bReleaseNeeded = false;
{
ulong time100ns;
- bool result = Win32Native.QueryUnbiasedInterruptTime(out time100ns);
+ bool result = Interop.Kernel32.QueryUnbiasedInterruptTime(out time100ns);
if (!result)
throw Marshal.GetExceptionForHR(Marshal.GetLastWin32Error());
**
=============================================================================*/
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using Microsoft.Win32.SafeHandles;
+using System.Diagnostics.CodeAnalysis;
+
namespace System.Threading
{
- using System.Threading;
- using System;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- using Microsoft.Win32.SafeHandles;
- using System.Runtime.Versioning;
- using System.Runtime.ConstrainedExecution;
- using System.Diagnostics.CodeAnalysis;
- using Win32Native = Microsoft.Win32.Win32Native;
-
public abstract class WaitHandle : MarshalByRefObject, IDisposable
{
public const int WaitTimeout = 0x102;
internal bool hasThreadAffinity;
- private static IntPtr GetInvalidHandle()
- {
- return Win32Native.INVALID_HANDLE_VALUE;
- }
- protected static readonly IntPtr InvalidHandle = GetInvalidHandle();
+ protected static readonly IntPtr InvalidHandle = new IntPtr(-1);
private const int WAIT_OBJECT_0 = 0;
private const int WAIT_ABANDONED = 0x80;
private const int WAIT_FAILED = 0x7FFFFFFF;
EmitLoadNativeValue(pslILEmit);
// static void CoTaskMemFree(IntPtr ptr)
- pslILEmit->EmitCALL(METHOD__WIN32NATIVE__COTASKMEMFREE, 1, 0);
+ pslILEmit->EmitCALL(METHOD__MARSHAL__FREE_CO_TASK_MEM, 1, 0);
}
void ILWSTRMarshaler::EmitClearNativeTemp(ILCodeStream* pslILEmit)
pslILEmit->EmitLDLOC(m_dwLocalBuffer);
pslILEmit->EmitBRFALSE(pExitLabel);
pslILEmit->EmitLDLOC(m_dwLocalBuffer);
- pslILEmit->EmitCALL(METHOD__WIN32NATIVE__COTASKMEMFREE, 1, 0);
+ pslILEmit->EmitCALL(METHOD__MARSHAL__FREE_CO_TASK_MEM, 1, 0);
pslILEmit->EmitLabel(pExitLabel);
}
EmitClearNativeContents(pslILEmit);
EmitLoadNativeValue(pslILEmit);
- pslILEmit->EmitCALL(METHOD__WIN32NATIVE__COTASKMEMFREE, 1, 0);
+ pslILEmit->EmitCALL(METHOD__MARSHAL__FREE_CO_TASK_MEM, 1, 0);
pslILEmit->EmitLabel(pNullRefLabel);
}
// CoTaskMemFree
EmitLoadNativeValue(pslILEmit);
- pslILEmit->EmitCALL(METHOD__WIN32NATIVE__COTASKMEMFREE, 1, 0);
+ pslILEmit->EmitCALL(METHOD__MARSHAL__FREE_CO_TASK_MEM, 1, 0);
pslILEmit->EmitLabel(pDoneLabel);
}
};
ILUTF8BufferMarshaler() :
- ILOptimizedAllocMarshaler(METHOD__WIN32NATIVE__COTASKMEMFREE)
+ ILOptimizedAllocMarshaler(METHOD__MARSHAL__FREE_CO_TASK_MEM)
{
LIMITED_METHOD_CONTRACT;
}
};
ILWSTRBufferMarshaler() :
- ILOptimizedAllocMarshaler(METHOD__WIN32NATIVE__COTASKMEMFREE)
+ ILOptimizedAllocMarshaler(METHOD__MARSHAL__FREE_CO_TASK_MEM)
{
LIMITED_METHOD_CONTRACT;
}
};
ILCSTRBufferMarshaler() :
- ILOptimizedAllocMarshaler(METHOD__WIN32NATIVE__COTASKMEMFREE)
+ ILOptimizedAllocMarshaler(METHOD__MARSHAL__FREE_CO_TASK_MEM)
{
LIMITED_METHOD_CONTRACT;
}
EmitLoadNativeValue(pslILEmit);
// static void CoTaskMemFree(IntPtr ptr)
- pslILEmit->EmitCALL(METHOD__WIN32NATIVE__COTASKMEMFREE, 1, 0);
+ pslILEmit->EmitCALL(METHOD__MARSHAL__FREE_CO_TASK_MEM, 1, 0);
}
virtual void EmitConvertSpaceCLRToNative(ILCodeStream* pslILEmit)
pslILEmit->EmitLDC(sizeof(ELEMENT));
pslILEmit->EmitCONV_U();
// static IntPtr CoTaskMemAlloc(UIntPtr cb)
- pslILEmit->EmitCALL(METHOD__WIN32NATIVE__COTASKMEMALLOC, 1, 1);
+ pslILEmit->EmitCALL(METHOD__MARSHAL__ALLOC_CO_TASK_MEM, 1, 1);
EmitStoreNativeValue(pslILEmit);
}
}
METHOD__MNGD_HIDDEN_LENGTH_ARRAY_MARSHALER__CONVERT_CONTENTS_TO_MANAGED,
METHOD__MNGD_HIDDEN_LENGTH_ARRAY_MARSHALER__CONVERT_SPACE_TO_NATIVE,
METHOD__MNGD_HIDDEN_LENGTH_ARRAY_MARSHALER__CONVERT_CONTENTS_TO_NATIVE,
- METHOD__WIN32NATIVE__COTASKMEMFREE,
+ METHOD__MARSHAL__FREE_CO_TASK_MEM,
METHOD__MNGD_HIDDEN_LENGTH_ARRAY_MARSHALER__CLEAR_NATIVE_CONTENTS,
METHOD__NIL)
{
DEFINE_METHOD(MARSHAL, GET_FUNCTION_POINTER_FOR_DELEGATE, GetFunctionPointerForDelegate, SM_Delegate_RetIntPtr)
DEFINE_METHOD(MARSHAL, GET_DELEGATE_FOR_FUNCTION_POINTER, GetDelegateForFunctionPointer, SM_IntPtr_Type_RetDelegate)
DEFINE_METHOD(MARSHAL, ALLOC_CO_TASK_MEM, AllocCoTaskMem, SM_Int_RetIntPtr)
+DEFINE_METHOD(MARSHAL, FREE_CO_TASK_MEM, FreeCoTaskMem, SM_IntPtr_RetVoid)
DEFINE_FIELD(MARSHAL, SYSTEM_MAX_DBCS_CHAR_SIZE, SystemMaxDBCSCharSize)
DEFINE_CLASS(NATIVELIBRARY, Interop, NativeLibrary)
DEFINE_CLASS(NATIVEVARIANT, StubHelpers, NativeVariant)
-DEFINE_CLASS(WIN32NATIVE, Win32, Win32Native)
-DEFINE_METHOD(WIN32NATIVE, COTASKMEMALLOC, CoTaskMemAlloc, SM_UIntPtr_RetIntPtr)
-DEFINE_METHOD(WIN32NATIVE, COTASKMEMFREE, CoTaskMemFree, SM_IntPtr_RetVoid)
-
#ifdef FEATURE_COMINTEROP
DEFINE_CLASS(IITERABLE, WinRT, IIterable`1)
DEFINE_CLASS(IVECTOR, WinRT, IVector`1)