public NT_file_seek() { windows_syspath = new string[2]; pattern_files = new List <string>(); full_path = new List <string>(); Win32Path = new string[2]; TargetFilesPath = new List <string>(); FilesToGet = new string[sizeof(system_path_files)]; SaveFolder = string.Empty; ArchFolder = string.Empty; log = new SimpleLogger(); options = new Tool_Config(); if (Environment.Is64BitOperatingSystem) { arch_folder = "amd64"; Win32Path[0] = Environment.GetFolderPath(Environment.SpecialFolder.System); Win32Path[1] = Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\drivers\\"; log.Trace("64 bit system ?:" + Environment.Is64BitOperatingSystem); log.Warning("System is 64 bits, this may change the files path"); for (int i = 0; i < windows_syspath.Length; i++) { log.Trace("Path found " + windows_syspath[i]); } } else { arch_folder = "x86"; Win32Path[0] = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86); Win32Path[1] = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86) + "\\drivers\\"; log.Trace("64 bit system ?:" + Environment.Is64BitOperatingSystem); log.Warning("System is not 64 bits, this may change the files path"); for (int i = 0; i < Win32Path.Length; i++) { log.Trace("Path found " + Win32Path[i]); } } }
private void frm_copy_sys_Load(object sender, EventArgs e) { log = new SimpleLogger(); options = new Tool_Config(); log.Info("Application form load"); log.Info("Trying to get Admin privileges"); rd_default_files.Checked = options.Using_DefaultFilenames; rd_custom_opt.Checked = options.Using_CustomFilenames; if (WindowsIdentity.GetCurrent().Owner == WindowsIdentity.GetCurrent().User) // Check for Admin privileges { try { this.Visible = false; ProcessStartInfo info = new ProcessStartInfo(Application.ExecutablePath); // my own .exe info.UseShellExecute = true; info.Verb = "runas"; // invoke UAC prompt Process.Start(info); log.Info("Application has admin privileges"); } catch (Win32Exception ex) { if (ex.NativeErrorCode == 1223) //The operation was canceled by the user. { MessageBox.Show("Why did you not selected Yes?", "WHY?", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); log.Debug("Canceled the Admin privileges"); Application.Exit(); } else { throw new Exception("Something went wrong :-("); } } Application.Exit(); } else { log.Info("I have admin privileges :-)"); } status += "App is on" + Environment.NewLine; windows_system_path = new string[2]; pattern_files = new List <string>(); full_path = new List <string>(); log.Info("Vars are initialazed ok!"); if (Environment.Is64BitOperatingSystem) { arch_folder = "amd64"; windows_system_path[0] = Environment.GetFolderPath(Environment.SpecialFolder.System); windows_system_path[1] = Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\drivers\\"; log.Trace("64 bit system ?:" + Environment.Is64BitOperatingSystem); log.Warning("System is 64 bits, this may change the files path"); for (int i = 0; i < windows_system_path.Length; i++) { log.Trace("Path found " + windows_system_path[i]); } } else { arch_folder = "x86"; windows_system_path[0] = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86); windows_system_path[1] = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86) + "\\drivers\\"; log.Trace("64 bit system ?:" + Environment.Is64BitOperatingSystem); log.Warning("System is not 64 bits, this may change the files path"); for (int i = 0; i < windows_system_path.Length; i++) { log.Trace("Path found " + windows_system_path[i]); } } log.Info("Status seems ok"); notifyIcon1.BalloonTipTitle = " NTOSFILESEEKER"; notifyIcon1.Icon = this.Icon; notifyIcon1.Visible = true; txt_path_build.Focus(); btn_copy.Enabled = false; log.Info("Notification did its job"); if (options.Using_DefaultFilenames == true) { listfiles = options.DefaultFilenames; } if (options.Using_CustomFilenames == true) { listfiles = options.CustomFilenames; } try { for (int i = 0; i < listfiles.Length; i++) { pattern_files.Add(listfiles[i]); } if (pattern_files.Count > 0) { log.Trace("List of files copied to search pattern"); } else { log.Error("Not enough files to search, unexepected ehaviour"); } } catch (Exception ex) { log.Debug("Error while trying to set the required pattern of files"); log.Debug("Error from exception" + ex.Message); } info += "NTOSFileSeeker v" + Application.ProductVersion + Environment.NewLine; info += "How to use this tool :" + Environment.NewLine; info += "1. Copy this tool to the target OS system :" + Environment.NewLine; info += "2. Run the tool, click on the textbox, and type the OS Build number, e.g 14393" + Environment.NewLine; info += "3. Click on the 'Search Button', the files will be listed " + Environment.NewLine; info += "4. Once the files apppear, you can click the Copy button, the files will be copied to the " + Environment.NewLine; info += "<os build number\\arch_type> folder" + Environment.NewLine; info += " " + Environment.NewLine + Environment.NewLine + Environment.NewLine; info += "Tool developer : C. A. Herrera" + Environment.NewLine; txt_info.Text = info; log.Info("Application started normal."); }