Example #1
0
 /// <summary>
 /// Open a handle for writing to the device (internal handle)
 /// </summary>
 internal void OpenWriteHandle()
 {
     if (DeviceHandle != null && !DeviceHandle.IsInvalid)
     {
         Release();
     }
     if (!NativeWin32.LockDevice(Path))
     {
         throw new DeviceError(DeviceError.ErrorLevels.DeviceLockFailed);
     }
     IsLocked     = true;
     DeviceHandle = NativeWin32.GetFileHandleRaw(Path, FileAccess.Write, FileShare.None);
 }
Example #2
0
 /// <summary>
 /// Open a handle for reading from the device (internal handle)
 /// </summary>
 internal void OpenReadHandle()
 {
     if (DeviceHandle != null && !DeviceHandle.IsInvalid)
     {
         DeviceHandle.Close();
     }
     if (!NativeWin32.LockDevice(Path))
     {
         throw new DeviceError(DeviceError.ErrorLevels.DeviceLockFailed);
     }
     IsLocked     = true;
     DeviceHandle = NativeWin32.GetFileHandleRaw(Path, FileAccess.Read);
 }
Example #3
0
 /// <summary>
 ///   Open a handle for the device (internal handle)
 /// </summary>
 internal void OpenHandle()
 {
     Main.SendDebug("Opening Device Handle");
     if (_deviceHandle != null && !_deviceHandle.IsInvalid)
     {
         Release();
     }
     if (!NativeWin32.LockDevice(Path))
     {
         throw new X360NANDManagerException(X360NANDManagerException.ErrorLevels.DeviceLockFailed);
     }
     IsLocked = true;
     UnmountDevice();
     Main.SendDebug("Device locked... opening the handle now!");
     _deviceHandle = NativeWin32.GetFileHandleRaw(Path, FileAccess.ReadWrite, FileShare.ReadWrite);
     Main.SendDebug("Device opened!");
     _fileStream = new FileStream(_deviceHandle, FileAccess.ReadWrite);
 }