@@ -101,7 +101,7 @@ private struct DISK_GEOMETRY_EX
101101 }
102102
103103 [ LibraryImport ( "kernel32.dll" , SetLastError = true , StringMarshalling = StringMarshalling . Utf16 ) ]
104- private static partial IntPtr CreateFile ( string lpFileName , uint dwDesiredAccess , uint dwShareMode , IntPtr lpSecurityAttributes , uint dwCreationDisposition , uint dwFlagsAndAttributes , IntPtr hTemplateFile ) ;
104+ private static partial IntPtr CreateFileW ( string lpFileName , uint dwDesiredAccess , uint dwShareMode , IntPtr lpSecurityAttributes , uint dwCreationDisposition , uint dwFlagsAndAttributes , IntPtr hTemplateFile ) ;
105105
106106 [ LibraryImport ( "kernel32.dll" , SetLastError = true ) ]
107107 [ return : MarshalAs ( UnmanagedType . Bool ) ]
@@ -161,7 +161,7 @@ public DeviceStream(string device, FileAccess access)
161161
162162 ( _length , SectorSize ) = GetDiskProperties ( devicePath ) ;
163163
164- IntPtr ptr = CreateFile ( devicePath , fileAccess , 0 , IntPtr . Zero , OPEN_EXISTING , FILE_ATTRIBUTE_DEVICE | FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH , IntPtr . Zero ) ;
164+ IntPtr ptr = CreateFileW ( devicePath , fileAccess , 0 , IntPtr . Zero , OPEN_EXISTING , FILE_ATTRIBUTE_DEVICE | FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH , IntPtr . Zero ) ;
165165 handleValue = new SafeFileHandle ( ptr , true ) ;
166166
167167 if ( handleValue . IsInvalid )
@@ -397,7 +397,7 @@ private static (long, uint) GetDiskProperties(string deviceName)
397397
398398 private static void Execute < T > ( ref T x , uint dwIoControlCode , string lpFileName , uint dwDesiredAccess = GENERIC_READ , uint dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_READ , IntPtr lpSecurityAttributes = default , uint dwCreationDisposition = OPEN_EXISTING , uint dwFlagsAndAttributes = 0 , IntPtr hTemplateFile = default )
399399 {
400- nint hDevice = CreateFile ( lpFileName , dwDesiredAccess , dwShareMode , lpSecurityAttributes , dwCreationDisposition , dwFlagsAndAttributes , hTemplateFile ) ;
400+ nint hDevice = CreateFileW ( lpFileName , dwDesiredAccess , dwShareMode , lpSecurityAttributes , dwCreationDisposition , dwFlagsAndAttributes , hTemplateFile ) ;
401401
402402 SafeFileHandle handleValue = new ( hDevice , true ) ;
403403
0 commit comments