This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Windows.h> | |
#include <SetupAPI.h> | |
#include <cfgmgr32.h> | |
#include <usbioctl.h> | |
_Must_inspect_result_ | |
_Success_(return == TRUE) | |
BOOL | |
USB_CyclePort( | |
_In_ PCWSTR InstanceId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use e.g. https://github.com/dotnet/pinvoke/ | |
// Install-Package PInvoke.Kernel32 | |
using (var handle = Kernel32.CreateFile("\\\\.\\HidHide", | |
Kernel32.ACCESS_MASK.GenericRight.GENERIC_READ, | |
Kernel32.FileShare.FILE_SHARE_READ | Kernel32.FileShare.FILE_SHARE_WRITE, | |
IntPtr.Zero, Kernel32.CreationDisposition.OPEN_EXISTING, | |
Kernel32.CreateFileFlags.FILE_ATTRIBUTE_NORMAL, | |
Kernel32.SafeObjectHandle.Null | |
)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use e.g. https://github.com/dotnet/pinvoke/ | |
// Install-Package PInvoke.Kernel32 | |
using (var handle = Kernel32.CreateFile("\\\\.\\HidHide", | |
Kernel32.ACCESS_MASK.GenericRight.GENERIC_READ, | |
Kernel32.FileShare.FILE_SHARE_READ | Kernel32.FileShare.FILE_SHARE_WRITE, | |
IntPtr.Zero, Kernel32.CreationDisposition.OPEN_EXISTING, | |
Kernel32.CreateFileFlags.FILE_ATTRIBUTE_NORMAL, | |
Kernel32.SafeObjectHandle.Null | |
)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Path manipulation and volume helper methods. | |
/// </summary> | |
internal static class VolumeHelper | |
{ | |
[DllImport("kernel32.dll", SetLastError = true)] | |
[return: MarshalAs(UnmanagedType.Bool)] | |
private static extern bool GetVolumePathNamesForVolumeNameW( | |
[MarshalAs(UnmanagedType.LPWStr)] string lpszVolumeName, | |
[MarshalAs(UnmanagedType.LPWStr)] [Out] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// String manipulation helper methods. | |
/// </summary> | |
internal static class StringHelperUtil | |
{ | |
/// <summary> | |
/// Converts an array of <see cref="string" /> into a double-null-terminated multi-byte character memory block. | |
/// </summary> | |
/// <param name="instances">Source array of strings.</param> | |
/// <param name="length">The length of the resulting byte array.</param> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -TypeDefinition @" | |
namespace PInvoke { | |
using System; | |
using System.Runtime.InteropServices; | |
[StructLayout(LayoutKind.Sequential)] | |
public struct BLUETOOTH_FIND_RADIO_PARAMS | |
{ | |
public UInt32 dwSize; | |