using System; using System.Runtime.InteropServices; namespace Vanara.PInvoke { public static partial class Kernel32 { /// /// Generates simple tones on the speaker. The function is synchronous; it performs an alertable wait and does not return control to /// its caller until the sound finishes. /// /// /// The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF). /// /// The duration of the sound, in milliseconds. /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// // BOOL WINAPI Beep( _In_ DWORD dwFreq, _In_ DWORD dwDuration); https://msdn.microsoft.com/en-us/library/windows/desktop/ms679277(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)] [PInvokeData("WinBase.h", MSDNShortId = "ms679277")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool Beep(uint dwFreq, uint dwDuration); /// Decodes a pointer that was previously encoded with EncodePointer. /// The pointer to be decoded. /// The function returns the decoded pointer. // PVOID DecodePointer( PVOID Ptr ); https://msdn.microsoft.com/en-us/library/bb432242(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)] [PInvokeData("UtilApiSet.h", MSDNShortId = "bb432242")] public static extern IntPtr DecodePointer([In] IntPtr Ptr); /// /// /// [Some information relates to pre-released product which may be substantially modified before it's commercially released. /// Microsoft makes no warranties, express or implied, with respect to the information provided here.] /// /// Decodes a pointer in a specified process that was previously encoded with EncodePointer or EncodeRemotePointer. /// /// Handle to the remote process that owns the pointer. /// The pointer to be decoded. /// The decoded pointer. /// Returns S_OK if successful, otherwise the function failed. // HRESULT WINAPI DecodeRemotePointer( _In_ HANDLE ProcessHandle, _In_opt_ PVOID Ptr, _Out_ PVOID * DecodedPtr ); https://msdn.microsoft.com/en-us/library/dn877133(v=vs.85).aspx [DllImport(Lib.KernelBase, SetLastError = false, ExactSpelling = true)] [PInvokeData("UtilApiSet.h", MSDNShortId = "dn877133")] public static extern HRESULT DecodeRemotePointer(HPROCESS ProcessHandle, IntPtr Ptr, out IntPtr DecodedPtr); /// Decodes a pointer that was previously encoded with EncodeSystemPointer. /// The system pointer to be decoded. /// The function returns the decoded pointer. // PVOID DecodeSystemPointer( PVOID Ptr ); https://msdn.microsoft.com/en-us/library/bb432243(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)] [PInvokeData("UtilApiSet.h", MSDNShortId = "bb432243")] public static extern IntPtr DecodeSystemPointer([In] IntPtr Ptr); /// Encodes the specified pointer. Encoded pointers can be used to provide another layer of protection for pointer values. /// The pointer to be encoded. /// The function returns the encoded pointer. // PVOID EncodePointer( _In_ PVOID Ptr ); https://msdn.microsoft.com/en-us/library/bb432254(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)] [PInvokeData("UtilApiSet.h", MSDNShortId = "bb432254")] public static extern IntPtr EncodePointer([In] IntPtr Ptr); /// /// /// [Some information relates to pre-released product which may be substantially modified before it's commercially released. /// Microsoft makes no warranties, express or implied, with respect to the information provided here.] /// /// /// Encodes the specified pointer of the specified process. Encoded pointers can be used to provide another layer of protection for /// pointer values. /// /// /// Handle to the remote process that owns the pointer. /// The pointer to be encoded. /// The encoded pointer. /// Returns S_OK if successful, otherwise the function failed. // HRESULT WINAPI EncodeRemotePointer( _In_ HANDLE ProcessHandle, _In_opt_ PVOID Ptr, _Out_ PVOID * EncodedPtr ); https://msdn.microsoft.com/en-us/library/dn877135(v=vs.85).aspx [DllImport(Lib.KernelBase, SetLastError = false, ExactSpelling = true)] [PInvokeData("UtilApiSet.h", MSDNShortId = "dn877135")] public static extern HRESULT EncodeRemotePointer(HPROCESS ProcessHandle, IntPtr Ptr, out IntPtr EncodedPtr); /// /// Encodes the specified pointer with a system-specific value. Encoded pointers can be used to provide another layer of protection /// for pointer values. /// /// The system pointer to be encoded. /// The function returns the encoded pointer. // PVOID EncodeSystemPointer( PVOID Ptr ); https://msdn.microsoft.com/en-us/library/bb432255(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)] [PInvokeData("UtilApiSet.h", MSDNShortId = "bb432255")] public static extern IntPtr EncodeSystemPointer([In] IntPtr Ptr); } }