public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions, int threadCount, int version, TimeSpan timeout) { var dokanOperationProxy = new DokanOperationProxy(operations); var dokanOptions = new DOKAN_OPTIONS { Version = (ushort)version, MountPoint = mountPoint, ThreadCount = (ushort)threadCount, Options = (uint)mountOptions, Timeout = (uint)timeout.Milliseconds }; var dokanOperations = new DOKAN_OPERATIONS { ZwCreateFile = dokanOperationProxy.ZwCreateFileProxy, Cleanup = dokanOperationProxy.CleanupProxy, CloseFile = dokanOperationProxy.CloseFileProxy, ReadFile = dokanOperationProxy.ReadFileProxy, WriteFile = dokanOperationProxy.WriteFileProxy, FlushFileBuffers = dokanOperationProxy.FlushFileBuffersProxy, GetFileInformation = dokanOperationProxy.GetFileInformationProxy, FindFiles = dokanOperationProxy.FindFilesProxy, SetFileAttributes = dokanOperationProxy.SetFileAttributesProxy, SetFileTime = dokanOperationProxy.SetFileTimeProxy, DeleteFile = dokanOperationProxy.DeleteFileProxy, DeleteDirectory = dokanOperationProxy.DeleteDirectoryProxy, MoveFile = dokanOperationProxy.MoveFileProxy, SetEndOfFile = dokanOperationProxy.SetEndOfFileProxy, SetAllocationSize = dokanOperationProxy.SetAllocationSizeProxy, LockFile = dokanOperationProxy.LockFileProxy, UnlockFile = dokanOperationProxy.UnlockFileProxy, GetDiskFreeSpace = dokanOperationProxy.GetDiskFreeSpaceProxy, GetVolumeInformation = dokanOperationProxy.GetVolumeInformationProxy, Unmount = dokanOperationProxy.UnmountProxy, GetFileSecurity = dokanOperationProxy.GetFileSecurityProxy, SetFileSecurity = dokanOperationProxy.SetFileSecurityProxy, FindStreams = dokanOperationProxy.FindStreamsProxy }; int status = NativeMethods.DokanMain(ref dokanOptions, ref dokanOperations); switch (status) { case DOKAN_ERROR: throw new DokanException(status, "Dokan error"); case DOKAN_DRIVE_LETTER_ERROR: throw new DokanException(status, "Bad drive letter"); case DOKAN_DRIVER_INSTALL_ERROR: throw new DokanException(status, "Can't install the Dokan driver"); case DOKAN_MOUNT_ERROR: throw new DokanException(status, "Can't assign a drive letter or mount point"); case DOKAN_START_ERROR: throw new DokanException(status, "Something's wrong with the Dokan driver"); case DOKAN_MOUNT_POINT_ERROR: throw new DokanException(status, "Mount point is invalid "); } }
private void connect_Click(object sender, EventArgs e) { this.Hide(); int p = 22; sshfs = new SSHFS(); opt = new DokanOptions(); if (DokanSSHFS.DokanDebug) { opt |= DokanOptions.DebugMode; } opt |= DokanOptions.AltStream; // DokanOptions.KeepAlive always enabled. mountPoint = "n:\\"; threadCount = 0; string message = ""; if (host.Text == "") { message += "Host name is empty\n"; } if (user.Text == "") { message += "User name is empty\n"; } if (port.Text == "") { message += "Port is empty\n"; } else { try { p = Int32.Parse(port.Text); } catch (Exception) { message += "Port format error\n"; } } if (drive.Text.Length != 1) { message += "Drive letter is invalid\n"; } else { char letter = drive.Text[0]; letter = Char.ToLower(letter); if (!('e' <= letter && letter <= 'z')) { message += "Drive letter is invalid\n"; } mountPoint = string.Format("{0}:\\", letter); unmount.Text = "Unmount (" + mountPoint + ")"; } threadCount = DokanSSHFS.DokanThread; if (message.Length != 0) { this.Show(); MessageBox.Show(message, "Error"); return; } DokanSSHFS.UseOffline = !withoutOfflineAttribute.Checked; sshfs.Initialize( user.Text, host.Text, p, usePrivateKey.Checked ? null : password.Text, usePrivateKey.Checked ? privatekey.Text : null, usePrivateKey.Checked ? passphrase.Text : null, root.Text, DokanSSHFS.SSHDebug); if (sshfs.SSHConnect()) { unmount.Visible = true; mount.Visible = false; isUnmounted_ = false; MountWorker worker = null; if (disableCache.Checked) { worker = new MountWorker(sshfs, opt, mountPoint, threadCount); } else { worker = new MountWorker(new CacheOperations(sshfs), opt, mountPoint, threadCount); } dokan = new Thread(worker.Start); dokan.Start(); } else { this.Show(); MessageBox.Show("failed to connect", "Error"); return; } MessageBox.Show("sshfs start", "info"); }
public MountWorker(DokanOperations sshfs, DokanOptions opt) { sshfs_ = sshfs; opt_ = opt; }
private void Mount(string mountPoint, DokanOptions options) { log.Info(String.Format("Mount {0}", mountPoint)); dokanThrd = new Thread(delegate() { log.Info("Dokan thread started"); driver.Mount(mountPoint, options); }); dokanThrd.Start(); }
public MountedFileSystem <F> Mount(string mountPoint, DokanOptions mountOptions) { return(MountedFileSystem <F> .Mount(this, mountPoint, mountOptions)); }
public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions, int threadCount) { Mount(operations, mountPoint, mountOptions, threadCount, DOKAN_VERSION); }
private static void Main(string[] args) { try { Console.Title = "WoT XVM Proxy v" + Assembly.GetExecutingAssembly().GetName().Version; Log(Console.Title); // Check args Debug("Processing command line arguments: " + String.Join(" ", args)); for (int i = 0; i < args.Length; i++) { Debug(String.Format(" {0}: {1}", i, args[i])); if (String.Compare(args[i], "/?", true) == 0 || String.Compare(args[i], "/help", true) == 0) { Usage(); return; } if (String.Compare(args[i], "/launcher", true) == 0) { wotExeFileName = "WOTLauncher.exe"; args[i] = ""; isLauncher = true; continue; } if (String.Compare(args[i], "/debug", true) == 0) { args[i] = ""; isDebug = true; Console.Title += " (DEBUG MODE)"; Log("DEBUG MODE: ON"); continue; } if (args[i].StartsWith("/server=", StringComparison.InvariantCultureIgnoreCase)) { serverVersion = args[i].Substring(8); if (serverVersion.ToUpper() == "CN1") { serverVersion = "CN"; } args[i] = ""; continue; } if (String.Compare(args[i], "/noauto", true) == 0) { isNoAuto = true; args[i] = ""; continue; } if (String.Compare(args[i], "/noproxy", true) == 0) { isNoProxy = true; args[i] = ""; continue; } if (File.Exists(args[i])) { args[i] = String.Format(@"""{0}""", args[i]); } } // CD to game dir string game_dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); Debug("Change dir: " + game_dir); Directory.SetCurrentDirectory(game_dir); // Check for another instance started bool ok; Mutex m = new Mutex(true, "wot-xvm-proxy", out ok); if (!ok) { throw new Exception("Another proxy instance is already running."); } GC.KeepAlive(m); // Check game start file exists Debug("Check start file exists: " + wotExeFileName); if (!File.Exists(wotExeFileName)) { throw new Exception("Game start file not found: " + wotExeFileName); } // Clear log file try { File.WriteAllText("XVM.log", DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss") + " " + Console.Title + Environment.NewLine); logFileInitialized = true; } catch { // do nothing } string mp = Settings.Default.MountPoint; if (Directory.Exists("res_mods")) { mp = String.Format("res_mods{0}{1}", Path.DirectorySeparatorChar, mp); } DokanOptions opt = new DokanOptions() { DebugMode = true, MountPoint = Path.GetFullPath(mp), ThreadCount = 5, }; Debug("MountPoint: " + opt.MountPoint); // Unmount MountPoint if left from previous start. Debug("Unmount previous mount"); try { DokanNet.DokanRemoveMountPoint(opt.MountPoint); } catch { // nothing } // Create MountPoint directory. Debug("Create MountPoint directory"); DirectoryInfo di = new DirectoryInfo(opt.MountPoint); if (di.Exists) { // try to delete old Dokan link. Debug("try to delete old Dokan link"); FileAttributes fa = File.GetAttributes(opt.MountPoint); if ((fa & FileAttributes.ReparsePoint) != 0) { try { Directory.Delete(opt.MountPoint, false); } catch (Exception ex) { throw new Exception(String.Format("Cannot delete MountPoint file: {0}{1}{2}", opt.MountPoint, Environment.NewLine, ex)); } try { Directory.CreateDirectory(opt.MountPoint); } catch (Exception ex) { throw new Exception(String.Format("Cannot create MountPoint directory: {0}{1}{2}", opt.MountPoint, Environment.NewLine, ex)); } } else { if (di.GetFileSystemInfos().Length != 0) { throw new Exception("MountPoint directory exists and is not empty: " + opt.MountPoint); } } } else { try { Directory.CreateDirectory(opt.MountPoint); } catch (Exception ex) { throw new Exception(String.Format("Cannot create MountPoint directory: {0}{1}{2}", opt.MountPoint, Environment.NewLine, ex)); } } Debug("Creating server thread"); Thread thread = new Thread(StartDokan); try { Debug("Starting server thread"); thread.Start(opt); Thread.Sleep(1000); if (!thread.IsAlive) { Debug("Dokan thread is not alive. Exiting."); } else { if (!isNoAuto) { Debug("Dokan thread is alive"); string arg = String.Join(" ", args); Log(String.Format("Starting game process: {0} {1}", wotExeFileName, arg)); try { wotProcess = Process.Start(wotExeFileName, arg); Debug("Check game process"); if (wotProcess == null) { throw new Exception("Cannot start game: " + wotExeFileName); } Thread.Sleep(5000); Debug("Wait for process to exit"); wotProcess.WaitForExit(); if (isLauncher && wotProcess.ExitCode == 0) { wotProcess.Dispose(); wotProcess = null; Log("Searching game process: " + WOT_PROCESS_NAME); Thread.Sleep(5000); Process[] wotProcesses = Process.GetProcessesByName(WOT_PROCESS_NAME); Debug(String.Format("Found {0} process", wotProcesses.Length)); if (wotProcesses.Length > 0) { Debug("Wait for process to exit"); wotProcess = wotProcesses[0]; wotProcess.WaitForExit(); } } } finally { if (wotProcess != null) { wotProcess.Dispose(); wotProcess = null; } } } else { Log("Please start your game manually within 2 minutes"); for (int i = 0; i < 20; i++) { Thread.Sleep(6000); Process[] wotProcesses = Process.GetProcessesByName(WOT_PROCESS_NAME); if (wotProcesses.Length > 0) { wotProcess = wotProcesses[0]; wotProcess.WaitForExit(); wotProcess.Dispose(); wotProcess = null; break; } } } } } finally { Log("Stopping server"); // Unmount and clean. DokanNet.DokanRemoveMountPoint(opt.MountPoint); if (thread.IsAlive) { thread.Join(); } Directory.Delete(opt.MountPoint); } if (isDebug) { Log("Press any key to exit."); Console.ReadKey(true); } } catch (Exception ex) { Log(String.Format("{0}{1}{1}Press any key to exit.", ex, Environment.NewLine)); Console.ReadKey(true); } }
private void connect_Click(object sender, EventArgs e) { this.Hide(); int p = 22; sshfs = new SSHFS(); opt = new DokanOptions(); if (DokanSSHFS.DokanDebug) opt |= DokanOptions.DebugMode; opt |= DokanOptions.AltStream | DokanOptions.KeepAlive; mountPoint = "n:\\"; threadCount = 0; string message = ""; if (host.Text == "") message += "Host name is empty\n"; if (user.Text == "") message += "User name is empty\n"; if (port.Text == "") message += "Port is empty\n"; else { try { p = Int32.Parse(port.Text); } catch(Exception) { message += "Port format error\n"; } } if (drive.Text.Length != 1) { message += "Drive letter is invalid\n"; } else { char letter = drive.Text[0]; letter = Char.ToLower(letter); if (!('e' <= letter && letter <= 'z')) message += "Drive letter is invalid\n"; mountPoint = string.Format("{0}:\\", letter); unmount.Text = "Unmount (" + mountPoint + ")"; } threadCount = DokanSSHFS.DokanThread; if (message.Length != 0) { this.Show(); MessageBox.Show(message, "Error"); return; } DokanSSHFS.UseOffline = !withoutOfflineAttribute.Checked; sshfs.Initialize( user.Text, host.Text, p, usePrivateKey.Checked ? null : password.Text, usePrivateKey.Checked ? privatekey.Text : null, usePrivateKey.Checked ? passphrase.Text : null, root.Text, DokanSSHFS.SSHDebug); if (sshfs.SSHConnect()) { unmount.Visible = true; mount.Visible = false; isUnmounted_ = false; MountWorker worker = null; if (disableCache.Checked) { worker = new MountWorker(sshfs, opt, mountPoint, threadCount); } else { worker = new MountWorker(new CacheOperations(sshfs), opt, mountPoint, threadCount); } dokan = new Thread(worker.Start); dokan.Start(); } else { this.Show(); MessageBox.Show("failed to connect", "Error"); return; } MessageBox.Show("sshfs start", "info"); }
/// <summary> /// Mount a new Dokan Volume. /// This function block until the device is unmount. /// </summary> /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param> /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS)</param> /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount</param> /// <param name="threadCount">Number of threads to be used internally by Dokan library. More thread will handle more event at the same time.</param> /// <param name="version">Version of the dokan features requested (Version "123" is equal to Dokan version 1.2.3) (Version "123" is equal to Dokan version 1.2.3).</param> /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations</param> /// <exception cref="DokanException">If the mount fails.</exception> public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions, int threadCount, int version, ILogger logger = null) { Mount(operations, mountPoint, mountOptions, threadCount, version, TimeSpan.FromSeconds(20), string.Empty, 512, 512, logger); }
/// <summary> /// Mount a new Dokan Volume. /// This function block until the device is unmount. /// </summary> /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param> /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS)</param> /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount</param> /// <param name="threadCount">Number of threads to be used internally by Dokan library. More thread will handle more event at the same time.</param> /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations</param> /// <exception cref="DokanException">If the mount fails.</exception> public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions, int threadCount, ILogger logger = null) { Mount(operations, mountPoint, mountOptions, threadCount, DOKAN_VERSION, logger); }
/// <summary> /// Mount a new Dokan Volume. /// This function block until the device is unmount. /// </summary> /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param> /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS)</param> /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount</param> /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations</param> /// <exception cref="DokanException">If the mount fails.</exception> public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions, ILogger logger = null) { Mount(operations, mountPoint, mountOptions, 0, logger); }
private void StartDAV() { Dokan.DokanOptions options = new DokanOptions(); options.MountPoint = settings.Mount; options.VolumeLabel = "AV de " + settings.Username; options.DebugMode = true; notifyIcon.BalloonTipIcon = ToolTipIcon.Info; notifyIcon.BalloonTipTitle = "Montando AV"; notifyIcon.BalloonTipText = "Montando AV en " + options.MountPoint; notifyIcon.ShowBalloonTip(3000); mounted = true; mountToolStripMenuItem.Text = "Desmontar"; int status = DokanNet.DokanMain(options, operations); mountToolStripMenuItem.Text = "Montar"; mounted = false; switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: notifyIcon.BalloonTipIcon = ToolTipIcon.Error; notifyIcon.BalloonTipTitle = "Error al montar AV"; notifyIcon.BalloonTipText = "Error de letra de drive"; notifyIcon.ShowBalloonTip(3000); break; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: notifyIcon.BalloonTipIcon = ToolTipIcon.Error; notifyIcon.BalloonTipTitle = "Error al montar AV"; notifyIcon.BalloonTipText = "Error al instalar el drive"; notifyIcon.ShowBalloonTip(3000); break; case DokanNet.DOKAN_MOUNT_ERROR: notifyIcon.BalloonTipIcon = ToolTipIcon.Error; notifyIcon.BalloonTipTitle = "Error al montar AV"; notifyIcon.BalloonTipText = "Error al tratar de montar su disco"; notifyIcon.ShowBalloonTip(3000); break; case DokanNet.DOKAN_START_ERROR: notifyIcon.BalloonTipIcon = ToolTipIcon.Error; notifyIcon.BalloonTipTitle = "Error al montar AV"; notifyIcon.BalloonTipText = "Error al inicializar el disco AV"; notifyIcon.ShowBalloonTip(3000); break; case DokanNet.DOKAN_ERROR: notifyIcon.BalloonTipIcon = ToolTipIcon.Error; notifyIcon.BalloonTipTitle = "Error al montar AV"; notifyIcon.BalloonTipText = "Error desconocido"; notifyIcon.ShowBalloonTip(3000); break; case DokanNet.DOKAN_SUCCESS: notifyIcon.BalloonTipIcon = ToolTipIcon.Info; notifyIcon.BalloonTipTitle = "Disco desmontado"; notifyIcon.BalloonTipText = "El drive de AV ha sido desmontado"; notifyIcon.ShowBalloonTip(3000); break; default: notifyIcon.BalloonTipIcon = ToolTipIcon.Error; notifyIcon.BalloonTipTitle = "Error al montar AV"; notifyIcon.BalloonTipText = "Error desconocido, status: " + status; notifyIcon.ShowBalloonTip(3000); break; } }
static void Main(string[] args) { WebClient client = new WebClient(); // I hope this works. string[] Deets = File.ReadAllLines("./api_info.txt"); /* THIS FILE NEEDS TO CONTAIN THE FOLLOWING (each on a new line) * ClientId * ClientSecret * username * password */ if (Deets.Length != 4) { Console.WriteLine("Please fill out the \"api_info.txt\" with the following:"); Console.WriteLine(@" ClientId ClientSecret username password"); Environment.Exit(1); } string postData = "client_id=" + Deets[0] + "&client_secret=" + Deets[1] + "&grant_type=password&username="******"&password="******"https://api.soundcloud.com/oauth2/token"; // Now we send off the API Request: string tokenInfo = ""; try { tokenInfo = client.UploadString(soundCloudTokenRes, postData); } catch { Console.WriteLine("Failed to auth with soundcloud."); Console.Read(); Environment.Exit(1); } dynamic AuthInfo; string AToken = ""; try { AuthInfo = JObject.Parse(tokenInfo); AToken = AuthInfo.access_token; } catch { Console.WriteLine("Malformed responce from soundcloud D:"); Environment.Exit(1); } try { dynamic meobj = JObject.Parse(client.DownloadString("https://api.soundcloud.com/me.json?oauth_token=" + AToken)); Console.WriteLine("Thank you for using SoundcloudFS" + meobj.username); } catch { } Console.WriteLine("Starting Mounting process..."); DokanOptions opt = new DokanOptions(); opt.DebugMode = true; opt.MountPoint = "v:\\"; opt.ThreadCount = 5; int status = DokanNet.DokanMain(opt, new SoundCloudFS(AToken, Deets[1])); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: Console.WriteLine("Driver letter error"); break; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: Console.WriteLine("Driver install error"); break; case DokanNet.DOKAN_MOUNT_ERROR: Console.WriteLine("Mount error"); break; case DokanNet.DOKAN_START_ERROR: Console.WriteLine("Start error"); break; case DokanNet.DOKAN_ERROR: Console.WriteLine("Unknown error"); break; case DokanNet.DOKAN_SUCCESS: Console.WriteLine("Success"); break; default: Console.WriteLine("Unknown status: %d", status); break; } }
private void MountDrive() { if (mNFS == null) { throw new ApplicationException("NFS object is null!"); } string strDev = (string)cboxRemoteDevices.SelectedItem; if (cboxLocalDrive.SelectedItem == null) { throw new Exception("You must select a local drive!"); } char cDrive = ((string)cboxLocalDrive.SelectedItem).ToCharArray()[0]; MountPoint = String.Format(@"{0}:\", cDrive); string Folder = btnSelectFolder.Text; bool DiskOrFolder = rbDisk.Checked; string strDriveLabel = tbDriveLabel.Text; MainForm.In.mNFS.MountDevice(strDev); cboxLocalDrive.Enabled = false; cboxRemoteDevices.Enabled = false; btnMount.Enabled = false; btnUnmount.Enabled = true; tbDriveLabel.Enabled = false; rbDisk.Enabled = false; rbFolder.Enabled = false; btnSelectFolder.Enabled = false; chkAutoMount.Enabled = false; chkUsePrivilegedPorts.Enabled = false; chkNoCache.Enabled = false; btnClearCache.Enabled = true; if (!DiskOrFolder) { if (!Directory.Exists(Folder)) { throw new ApplicationException(String.Format("{0} not found.", Folder)); } else { MountPoint = Folder; } } bool NoCache = chkNoCache.Checked; ThreadPool.QueueUserWorkItem(new WaitCallback( delegate { try { System.IO.Directory.SetCurrentDirectory(Application.StartupPath); DokanOptions dokanOptions = new DokanOptions(); dokanOptions.DebugMode = DebugMode; dokanOptions.NetworkDrive = DiskOrFolder; dokanOptions.MountPoint = MountPoint; dokanOptions.UseKeepAlive = true; dokanOptions.UseAltStream = true; dokanOptions.VolumeLabel = strDriveLabel; dokanOptions.ThreadCount = 1; if (NoCache) { dokanOperation = new Operations(); } else { dokanOperation = new CacheOperations(new Operations()); } int status = DokanNet.DokanMain(dokanOptions, dokanOperation); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: throw new ApplicationException("Drvie letter error"); case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: throw new ApplicationException("Driver install error"); case DokanNet.DOKAN_MOUNT_ERROR: throw new ApplicationException("Mount error"); case DokanNet.DOKAN_START_ERROR: throw new ApplicationException("Start error"); case DokanNet.DOKAN_ERROR: throw new ApplicationException("Unknown error"); case DokanNet.DOKAN_SUCCESS: break; default: throw new ApplicationException("Unknown status: " + status); } } catch (Exception ex) { MessageBox.Show(ex.Message); } })); ThreadPool.QueueUserWorkItem(new WaitCallback( delegate { Thread.Sleep(2000); Process.Start("explorer.exe", " " + MountPoint); })); }
internal static MountedFileSystem <F> Mount(FileSystem <F> fileSystem, string mountPoint, DokanOptions mountOptions) { fileSystem.FileSystemOperations().Mount(mountPoint, mountOptions); return(new MountedFileSystem <F>(fileSystem, mountPoint)); }
/// <summary> /// Mount a new Dokan Volume. /// This function block until the device is unmount. /// </summary> /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param> /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS)</param> /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount</param> /// <param name="threadCount">Number of threads to be used internally by Dokan library. More thread will handle more event at the same time.</param> /// <param name="version">Version of the dokan features requested (Version "123" is equal to Dokan version 1.2.3)</param> /// <param name="timeout">Max timeout in ms of each request before dokan give up.</param> /// <param name="uncName">UNC name used for network volume</param> /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations</param> /// <exception cref="DokanException">If the mount fails.</exception> public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions, int threadCount, int version, TimeSpan timeout, string uncName, ILogger logger = null) { Mount(operations, mountPoint, mountOptions, threadCount, version, timeout, uncName, 512, 512, logger); }
public MountWorker(IDokanOperations sshfs, DokanOptions opt, string mountPoint, int threadCount) { sshfs_ = sshfs; opt_ = opt; mountPoint_ = mountPoint; threadCount_ = threadCount; }
/// <summary> /// Mount a new Dokan Volume. /// This function block until the device is unmount. /// </summary> /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param> /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS)</param> /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount</param> /// <param name="threadCount">Number of threads to be used internally by Dokan library. More thread will handle more event at the same time.</param> /// <param name="version">Version of the dokan features requested (Version "123" is equal to Dokan version 1.2.3)</param> /// <param name="timeout">Max timeout in ms of each request before dokan give up.</param> /// <param name="uncName">UNC name used for network volume</param> /// <param name="allocationUnitSize">Allocation Unit Size of the volume. This will behave on the file size.</param> /// <param name="sectorSize">Sector Size of the volume. This will behave on the file size.</param> /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations</param> /// <exception cref="DokanException">If the mount fails.</exception> public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions, int threadCount, int version, TimeSpan timeout, string uncName = null, int allocationUnitSize = 512, int sectorSize = 512, ILogger logger = null) { #if TRACE if(logger == null){ logger = new ConsoleLogger("[DokanNet] "); } #endif if (logger == null) { logger = new NullLogger(); } var dokanOperationProxy = new DokanOperationProxy(operations, logger); var dokanOptions = new DOKAN_OPTIONS { Version = (ushort) version, MountPoint = mountPoint, UNCName = string.IsNullOrEmpty(uncName) ? null : uncName, ThreadCount = (ushort) threadCount, Options = (uint) mountOptions, Timeout = (uint) timeout.Milliseconds, AllocationUnitSize = (uint) allocationUnitSize, SectorSize = (uint) sectorSize }; var dokanOperations = new DOKAN_OPERATIONS { ZwCreateFile = dokanOperationProxy.ZwCreateFileProxy, Cleanup = dokanOperationProxy.CleanupProxy, CloseFile = dokanOperationProxy.CloseFileProxy, ReadFile = dokanOperationProxy.ReadFileProxy, WriteFile = dokanOperationProxy.WriteFileProxy, FlushFileBuffers = dokanOperationProxy.FlushFileBuffersProxy, GetFileInformation = dokanOperationProxy.GetFileInformationProxy, FindFiles = dokanOperationProxy.FindFilesProxy, FindFilesWithPattern = dokanOperationProxy.FindFilesWithPatternProxy, SetFileAttributes = dokanOperationProxy.SetFileAttributesProxy, SetFileTime = dokanOperationProxy.SetFileTimeProxy, DeleteFile = dokanOperationProxy.DeleteFileProxy, DeleteDirectory = dokanOperationProxy.DeleteDirectoryProxy, MoveFile = dokanOperationProxy.MoveFileProxy, SetEndOfFile = dokanOperationProxy.SetEndOfFileProxy, SetAllocationSize = dokanOperationProxy.SetAllocationSizeProxy, LockFile = dokanOperationProxy.LockFileProxy, UnlockFile = dokanOperationProxy.UnlockFileProxy, GetDiskFreeSpace = dokanOperationProxy.GetDiskFreeSpaceProxy, GetVolumeInformation = dokanOperationProxy.GetVolumeInformationProxy, Mounted = dokanOperationProxy.MountedProxy, Unmounted = dokanOperationProxy.UnmountedProxy, GetFileSecurity = dokanOperationProxy.GetFileSecurityProxy, SetFileSecurity = dokanOperationProxy.SetFileSecurityProxy, FindStreams = dokanOperationProxy.FindStreamsProxy }; var status = NativeMethods.DokanMain(ref dokanOptions, ref dokanOperations); switch (status) { case DOKAN_ERROR: throw new DokanException(status, Resource.ErrorDokan); case DOKAN_DRIVE_LETTER_ERROR: throw new DokanException(status, Resource.ErrorBadDriveLetter); case DOKAN_DRIVER_INSTALL_ERROR: throw new DokanException(status, Resource.ErrorDriverInstall); case DOKAN_MOUNT_ERROR: throw new DokanException(status, Resource.ErrorAssignDriveLetter); case DOKAN_START_ERROR: throw new DokanException(status, Resource.ErrorStart); case DOKAN_MOUNT_POINT_ERROR: throw new DokanException(status, Resource.ErrorMountPointInvalid); case DOKAN_VERSION_ERROR: throw new DokanException(status, Resource.ErrorVersion); } }
private static void Main(string[] args) { try { AssemblyInformationalVersionAttribute attribute = (AssemblyInformationalVersionAttribute)Assembly.GetExecutingAssembly() .GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false)[0]; var a = Assembly.GetExecutingAssembly().GetName(); byte[] pt = a.GetPublicKeyToken(); PublicKeyToken = ""; for (int i = 0; i < pt.Length; i++) { PublicKeyToken += String.Format("{0:x2}", pt[i]); } Console.Title = String.Format("XVM Stat v{0} for XVM {1}+", Assembly.GetExecutingAssembly().GetName().Version, attribute.InformationalVersion); Log(Console.Title); // Check args if (!CheckArgs(args)) { return; } // CD to game dir string game_dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); Debug("Change dir: " + game_dir); Directory.SetCurrentDirectory(game_dir); // Check for another instance started bool ok; Mutex m = new Mutex(true, "xvm-stat", out ok); if (!ok) { throw new Exception("Another proxy instance is already running."); } GC.KeepAlive(m); // Check game start file exists Debug("Check start file exists: " + wotExeFileName); if (!File.Exists(wotExeFileName)) { throw new Exception("Game start file not found: " + wotExeFileName); } // Clear log file ClearLogFile(); string mp = Settings.Default.MountPoint; DokanOptions opt = new DokanOptions() { VolumeLabel = "XVMfs", DebugMode = false, MountPoint = Path.GetFullPath(mp), ThreadCount = 1, }; Debug("MountPoint: " + opt.MountPoint); PrepareMountPoint(opt.MountPoint); Debug("Creating server thread"); Thread thread = new Thread(StartDokan); try { Debug("Starting server thread"); thread.Start(opt); Thread.Sleep(2000); if (!thread.IsAlive) { Debug("Dokan thread is not alive. Exiting."); } else { ProcessMainThread(args); } } finally { Log("Stopping server"); // Unmount and clean. DokanNet.DokanRemoveMountPoint(opt.MountPoint); if (thread.IsAlive) { thread.Join(); } Directory.Delete(opt.MountPoint); } } catch (Exception ex) { Log(String.Format("{0}{1}{1}Press any key to exit.", ex, Environment.NewLine)); Console.ReadKey(true); } }
private void connect() { int p = 22; sshfs = new SSHFS(); opt = new DokanOptions(); opt.DebugMode = parser.debug; opt.UseAltStream = true; opt.ThreadCount = 0; opt.UseKeepAlive = true; string message = ""; if (parser.host == "") { message += "Host name is empty\n"; } if (parser.user == "") { message += "User name is empty\n"; } if (parser.drive.Length != 1) { message += "Drive letter is invalid\n"; } else { char letter = parser.drive[0]; letter = Char.ToLower(letter); if (!('e' <= letter && letter <= 'z')) { message += "Drive letter is invalid\n"; } opt.MountPoint = string.Format("{0}:\\", letter); unmount.Text = "Unmount (" + opt.MountPoint + ")"; } opt.MountPoint = string.Format("{0}:\\", 'r'); unmount.Text = "Unmount (" + opt.MountPoint + ")"; opt.UseStdErr = parser.debug; opt.ThreadCount = DokanSSHFS.DokanThread; if (message.Length != 0) { MessageBox.Show(message, "Error"); return; } // DokanSSHFS.UseOffline = !withoutOfflineAttribute.Checked; DokanSSHFS.UseOffline = false; //TODO: Add password auth and key passphrase support sshfs.Initialize( parser.user, parser.host, p, null, parser.identity, "", parser.root, DokanSSHFS.SSHDebug); if (sshfs.SSHConnect()) { unmount.Visible = true; mount.Visible = false; isUnmounted_ = false; MountWorker worker = null; // if (disableCache.Checked) // { worker = new MountWorker(sshfs, opt); // } // else // { // worker = new MountWorker(new CacheOperations(sshfs), opt); // } dokan = new Thread(worker.Start); dokan.Start(); } else { MessageBox.Show("failed to connect", "Error"); return; } // MessageBox.Show("sshfs start", "info"); }
public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions) { Mount(operations, mountPoint, mountOptions, 0); }
public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions, int threadCount, int version) { var dokanOperationProxy = new DokanOperationProxy(operations); var dokanOptions = new DOKAN_OPTIONS { Version = (ushort)version, MountPoint = mountPoint, ThreadCount = (ushort)threadCount, Options = (uint)mountOptions, }; /* dokanOptions.Options |= options.RemovableDrive ? DOKAN_OPTION_REMOVABLE : 0; dokanOptions.Options |= options.DebugMode ? DOKAN_OPTION_DEBUG : 0; dokanOptions.Options |= options.UseStandardError ? DOKAN_OPTION_STDERR : 0; dokanOptions.Options |= options.UseAlternativeStreams ? DOKAN_OPTION_ALT_STREAM : 0; dokanOptions.Options |= options.UseKeepAlive ? DOKAN_OPTION_KEEP_ALIVE : 0; dokanOptions.Options |= options.NetworkDrive ? DOKAN_OPTION_NETWORK : 0;*/ var dokanOperations = new DOKAN_OPERATIONS { CreateFile = dokanOperationProxy.CreateFileProxy, OpenDirectory = dokanOperationProxy.OpenDirectoryProxy, CreateDirectory = dokanOperationProxy.CreateDirectoryProxy, Cleanup = dokanOperationProxy.CleanupProxy, CloseFile = dokanOperationProxy.CloseFileProxy, ReadFile = dokanOperationProxy.ReadFileProxy, WriteFile = dokanOperationProxy.WriteFileProxy, FlushFileBuffers = dokanOperationProxy.FlushFileBuffersProxy, GetFileInformation = dokanOperationProxy.GetFileInformationProxy, FindFiles = dokanOperationProxy.FindFilesProxy, SetFileAttributes = dokanOperationProxy.SetFileAttributesProxy, SetFileTime = dokanOperationProxy.SetFileTimeProxy, DeleteFile = dokanOperationProxy.DeleteFileProxy, DeleteDirectory = dokanOperationProxy.DeleteDirectoryProxy, MoveFile = dokanOperationProxy.MoveFileProxy, SetEndOfFile = dokanOperationProxy.SetEndOfFileProxy, SetAllocationSize = dokanOperationProxy.SetAllocationSizeProxy, LockFile = dokanOperationProxy.LockFileProxy, UnlockFile = dokanOperationProxy.UnlockFileProxy, GetDiskFreeSpace = dokanOperationProxy.GetDiskFreeSpaceProxy, GetVolumeInformation = dokanOperationProxy.GetVolumeInformationProxy, Unmount = dokanOperationProxy.UnmountProxy, GetFileSecurity = dokanOperationProxy.GetFileSecurityProxy, SetFileSecurity = dokanOperationProxy.SetFileSecurityProxy, }; int status = NativeMethods.DokanMain(ref dokanOptions, ref dokanOperations); switch (status) { case DOKAN_ERROR: throw new DokanException(status, "Dokan error"); case DOKAN_DRIVE_LETTER_ERROR: throw new DokanException(status, "Bad drive letter"); case DOKAN_DRIVER_INSTALL_ERROR: throw new DokanException(status, "Can't install driver"); case DOKAN_MOUNT_ERROR: throw new DokanException(status, "Can't assign a drive letter or mount point"); case DOKAN_START_ERROR: throw new DokanException(status, "Something's wrong with Dokan driver"); case DOKAN_MOUNT_POINT_ERROR: throw new DokanException(status, "Mount point is invalid "); } }
public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions, int threadCount, int version) { Mount(operations, mountPoint, mountOptions, threadCount, version, TimeSpan.FromSeconds(20)); }
private static void Main(string[] args) { try { Console.Title = "WoT XVM Proxy v" + Assembly.GetExecutingAssembly().GetName().Version; Console.WriteLine(Console.Title); // Check args Debug("Processing command line arguments: " + String.Join(" ", args)); for (int i = 0; i < args.Length; i++) { Debug(String.Format(" {0}: {1}", i, args[i])); if (String.Compare(args[i], "/?", true) == 0 || String.Compare(args[i], "/help", true) == 0) { Usage(); return; } if (String.Compare(args[i], "/launcher", true) == 0) { wotExeFileName = "WOTLauncher.exe"; args[i] = ""; isLauncher = true; continue; } if (String.Compare(args[i], "/debug", true) == 0) { args[i] = ""; isDebug = true; Console.Title += " (DEBUG MODE)"; Console.WriteLine("DEBUG MODE: ON"); continue; } if (args[i].StartsWith("/server=", StringComparison.InvariantCultureIgnoreCase)) { serverVersion = args[i].Substring(8); args[i] = ""; continue; } if (File.Exists(args[i])) { args[i] = String.Format(@"""{0}""", args[i]); } } // CD to game dir string game_dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); Debug("Change dir: " + game_dir); Directory.SetCurrentDirectory(game_dir); // Check game start file exists Debug("Check start file exists: " + wotExeFileName); if (!File.Exists(wotExeFileName)) { throw new Exception("Game start file not found: " + wotExeFileName); } string mp = Settings.Default.MountPoint; if (Directory.Exists("res_mods")) { mp = String.Format("res_mods{0}{1}", Path.DirectorySeparatorChar, mp); } DokanOptions opt = new DokanOptions() { DebugMode = true, MountPoint = Path.GetFullPath(mp), ThreadCount = 5 }; Debug("MountPoint: " + opt.MountPoint); // Unmount MountPoint if left from previous start. Debug("Unmount previous mount"); try { DokanNet.DokanRemoveMountPoint(opt.MountPoint); } catch { // nothing } // Create MountPoint directory. Debug("Create MountPoint directory"); DirectoryInfo di = new DirectoryInfo(opt.MountPoint); if (di.Exists) { // try to delete old Dokan link. Debug("try to delete old Dokan link"); FileAttributes fa = File.GetAttributes(opt.MountPoint); if ((fa & FileAttributes.ReparsePoint) != 0) { try { Directory.Delete(opt.MountPoint, false); } catch (Exception ex) { throw new Exception(String.Format("Cannot delete MountPoint file: {0}{1}{2}", opt.MountPoint, Environment.NewLine, ex)); } try { Directory.CreateDirectory(opt.MountPoint); } catch (Exception ex) { throw new Exception(String.Format("Cannot create MountPoint directory: {0}{1}{2}", opt.MountPoint, Environment.NewLine, ex)); } } else { if (di.GetFileSystemInfos().Length != 0) { throw new Exception("MountPoint directory exists and is not empty: " + opt.MountPoint); } } } else { try { Directory.CreateDirectory(opt.MountPoint); } catch (Exception ex) { throw new Exception(String.Format("Cannot create MountPoint directory: {0}{1}{2}", opt.MountPoint, Environment.NewLine, ex)); } } Debug("Creating server thread"); Thread thread = new Thread(StartDokan); try { Debug("Starting server thread"); thread.Start(opt); Thread.Sleep(1000); if (!thread.IsAlive) { Debug("Dokan thread is not alive. Exiting."); } else { Debug("Dokan thread is alive"); string arg = String.Join(" ", args); Console.WriteLine(String.Format("Starting game process: {0} {1}", wotExeFileName, arg)); using (Process wotProc = Process.Start(wotExeFileName, arg)) { Debug("Check game process"); if (wotProc == null) { throw new Exception("Cannot start game: " + wotExeFileName); } Thread.Sleep(5000); Debug("Wait for process to exit"); wotProc.WaitForExit(); if (isLauncher && wotProc.ExitCode == 0) { Console.WriteLine("Searching game process: " + WOT_PROCESS_NAME); Thread.Sleep(5000); Process[] wotProcesses = Process.GetProcessesByName(WOT_PROCESS_NAME); Debug(String.Format("Found {0} process", wotProcesses.Length)); if (wotProcesses.Length > 0) { Debug("Wait for process to exit"); wotProcesses[0].WaitForExit(); } } } } } finally { Console.WriteLine("Stopping server"); // Unmount and clean. DokanNet.DokanRemoveMountPoint(opt.MountPoint); if (thread.IsAlive) { thread.Join(); } Directory.Delete(opt.MountPoint); } if (isDebug) { Console.WriteLine("Press any key to exit."); Console.ReadKey(true); } } catch (Exception ex) { Console.WriteLine(String.Format("{0}{1}{1}Press any key to exit.", ex, Environment.NewLine)); Console.ReadKey(true); } }