Example #1
0
 public static bool SetLanguage(LanguageId languageId)
 {
     return(Win32Utils.SetLanguage(languageId));
 }
Example #2
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            try
            {
                bool          createdNew;
                Assembly      assembly  = Assembly.GetExecutingAssembly();
                GuidAttribute attribute = (GuidAttribute)assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0];
                string        appGuid   = attribute.Value;
                _instance = new Mutex(true, @"Global\" + appGuid, out createdNew);
                if (!createdNew)
                {
                    // Send a message if it's a .dem provided as argument
                    if (e.Args.Length > 0 && e.Args[0].EndsWith(".dem"))
                    {
                        // send a message to display the demo's details
                        Process[] processes = Process.GetProcessesByName(AppSettings.PROCESS_NAME);
                        foreach (Process process in processes)
                        {
                            Win32Utils.SendWindowStringMessage(process.MainWindowHandle, Win32Utils.WM_LOAD_DEMO, 0, e.Args[0]);
                            Win32Utils.SetForegroundWindow(process.MainWindowHandle);
                        }
                    }
                    // shutdown as there is already an instance
                    _instance = null;
                    Current.Shutdown();
                    return;
                }

                // upgrade user settings
                if (Settings.Default.UpgradeRequired)
                {
                    Settings.Default.Upgrade();
                    Settings.Default.UpgradeRequired = false;
                }

                CultureInfo ci = CultureInfo.InstalledUICulture;
                if (string.IsNullOrEmpty(Settings.Default.Language))
                {
                    Settings.Default.Language = ci.Name;
                }
                CultureInfo culture = new CultureInfo(Settings.Default.Language);
                CultureInfo.DefaultThreadCurrentCulture   = culture;
                CultureInfo.DefaultThreadCurrentUICulture = culture;

                if (Settings.Default.StartBotOnLaunch)
                {
                    if (File.Exists(AppSettings.BOT_PROCESS_NAME + ".exe") &&
                        !AppSettings.IsBotRunning())
                    {
                        Process.Start(AppSettings.BOT_PROCESS_NAME);
                    }
                }

                for (int i = 0; i != e.Args.Length; ++i)
                {
                    // Start the app on Suspects view
                    if (e.Args[i] == "/suspects")
                    {
                        StartUpWindow = "suspects";
                    }
                    // Start demos download
                    if (e.Args[i] == "/download")
                    {
                        StartUpWindow = "download";
                    }
                    // this case is when no app instance exists and a .dem is provided as argument
                    if (e.Args[i].EndsWith(".dem") && File.Exists(e.Args[i]))
                    {
                        // change the default startup window and set the demo path to display
                        StartUpWindow = "demo";
                        DemoFilePath  = e.Args[0];
                    }
                }

                Settings.Default.DateStatsTo = DateTime.Today;
                if (Settings.Default.DownloadFolder == string.Empty && AppSettings.GetCsgoPath() != null)
                {
                    string demoFolder = AppSettings.GetCsgoPath() + Path.DirectorySeparatorChar + "replays";
                    if (Directory.Exists(demoFolder))
                    {
                        Settings.Default.DownloadFolder = Path.GetFullPath(demoFolder);
                    }
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
 /// <summary>
 /// Set a resource (e.g. a font) for the specified device context.
 /// WARNING: Calling Font.ToHfont() many times without releasing the font handle crashes the app.
 /// </summary>
 private void SetFont(RFont font)
 {
     InitHdc();
     Win32Utils.SelectObject(_hdc, ((FontAdapter)font).HFont);
 }
Example #4
0
 public static IntPtr GetCurrentKeyboardLayout()
 {
     return(Win32Utils.GetCurrentKeyboardLayout());
 }
Example #5
0
 /// <summary>
 /// Set a resource (e.g. a font) for the specified device context.
 /// WARNING: Calling Font.ToHfont() many times without releasing the font handle crashes the app.
 /// </summary>
 private void SetFont(Font font)
 {
     InitHdc();
     Win32Utils.SelectObject(_hdc, FontsUtils.GetCachedHFont(font));
 }
        /// <summary>
        /// Set a resource (e.g. a font) for the specified device context.
        /// WARNING: Calling Font.ToHfont() many times without releasing the font handle crashes the app.
        /// </summary>
        void SetFont(Font font)
        {
            InitHdc();

            Win32Utils.SelectObject(tempDc, FontStore.GetCachedHFont(font.InnerFont as System.Drawing.Font));
        }
Example #7
0
 public static bool IsDotNetFramework2PointOInstalled(string server, string username, string password)
 {
     return(Win32Utils.IsMicrosoftComponentInstalled(server, username, password, ".NET Framework", "2.0"));
 }
 private void btnEditPermissions_Click(object sender, System.EventArgs e)
 {
     Win32Utils.EditSecurity(this.Handle, _obj, _obj.Name, false);
 }
Example #9
0
    public static string ValidateCredentials(string server, NetworkCredential credentials)
    {
        string fullUserName = CUtils.GetFullUserName(credentials);

        return(Win32Utils.ValidateCredentials(server, fullUserName, credentials.Password));
    }
Example #10
0
 public static void NetCancelConnection(string server)
 {
     Win32Utils.WNetCancelConnection2(IPHelper.GetWNetServerString(server), 0, true);
 }
Example #11
0
        private void ComboBox_Devices_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            button_GenerateData.IsEnabled = false;
            button_WriteData.IsEnabled    = false;

            if (e.AddedItems.OfType <UsbDeviceArrivedEventArgs>().SingleOrDefault() is UsbDeviceArrivedEventArgs args)
            {
                var diskSpaceLayout = args.USBDeviceInfo.DiskSpaceLayout;
                var bootSectorInfo  = args.USBDeviceInfo.BootSectorInfo;


                textBox_Serial.Text = args.USBDeviceInfo.DeviceInfo?.DeviceSerialNumber;

                textBox_VolumeSerial.Text = bootSectorInfo?.VolumeSerialNumber.ToString();

                textBox_FileSystemQ.Text = bootSectorInfo?.FileSystemName_Query;
                textBox_FileSystemM.Text = bootSectorInfo?.FileSystemName_Parsed;

                textBox_BytesPerSectorQ.Text = diskSpaceLayout?.lpBytesPerSector.ToString();
                textBox_BytesPerSectorM.Text = bootSectorInfo?.BytesPerSector.ToString();

                textBox_SectorsPerClusterQ.Text = diskSpaceLayout?.lpSectorsPerCluster.ToString();
                textBox_SectorsPerClusterM.Text = bootSectorInfo?.SectorsPerCluster.ToString();

                textBox_ReservedSectorsM.Text = bootSectorInfo?.ReservedSectors.ToString();


                if (TryGetData(args, out var data))
                {
                    bool dataFound = false;

                    button_GenerateData.IsEnabled = true;
                    button_WriteData.IsEnabled    = true;

                    for (int x = 0; x < data.Length; x++)
                    {
                        if (data[x] != 0)
                        {
                            dataFound = true;
                            break;
                        }
                    }

                    if (dataFound)
                    {
                        textBox_DataSector.Text = Win32Utils.ReadNullTerminatedString(data, 0, Encoding.ASCII);
                    }
                    else
                    {
                        textBox_DataSector.Text = "";
                    }
                }
            }
            else
            {
                textBox_Serial.Text = "";

                textBox_VolumeSerial.Text = "";

                textBox_FileSystemQ.Text = "";
                textBox_FileSystemM.Text = "";

                textBox_BytesPerSectorQ.Text = "";
                textBox_BytesPerSectorM.Text = "";

                textBox_SectorsPerClusterQ.Text = "";
                textBox_SectorsPerClusterM.Text = "";

                textBox_ReservedSectorsM.Text = "";

                textBox_DataSector.Text = "";
            }
        }
Example #12
0
        // Finds the COM running objects
        public static IList GetRunningObjects(ProgressDialog progress)
        {
            ArrayList               runningObjects = new ArrayList();
            Hashtable               runningHash    = new Hashtable();
            UCOMIBindCtx            bc;
            UCOMIRunningObjectTable rot;
            UCOMIEnumMoniker        em;

            UCOMIMoniker[] monikers = new UCOMIMoniker[1];

            ActiveX.CreateBindCtx(0, out bc);
            bc.GetRunningObjectTable(out rot);
            rot.EnumRunning(out em);
            // Look at each Moniker in the ROT
            int unused;

            while (0 == em.Next(1, monikers, out unused))
            {
                try
                {
                    UCOMIMoniker moniker = monikers[0];
                    Object       obj;
                    rot.GetObject(moniker, out obj);
                    String monikerName;
                    moniker.GetDisplayName(bc, null, out monikerName);

                    ComObjectInfo comObjInfo;
                    // Check for duplicates against the other running objects
                    Object runObj = runningHash[obj];
                    if (runObj != null)
                    {
                        // Get the existing object's moniker
                        comObjInfo = (ComObjectInfo)
                                     ObjectInfo.GetObjectInfo(obj);
                        if (monikerName.Equals(comObjInfo._monikerName))
                        {
                            TraceUtil.WriteLineInfo
                                (typeof(ComObjectInfo),
                                "ROT - Skipping duplicate: " + monikerName);
                            progress.UpdateProgress(1);
                            continue;
                        }
                    }
                    else
                    {
                        runningHash.Add(obj, obj);
                    }
                    comObjInfo = (ComObjectInfo)
                                 ObjectInfoFactory.GetObjectInfo(true, obj);
                    // Need moniker name before update progress
                    comObjInfo.CalcRunningObjName(rot, bc,
                                                  moniker, monikerName);
                    progress.UpdateProgressText(comObjInfo.GetMonikerName());
                    progress.UpdateProgress(1);
                    runningObjects.Add(comObjInfo);
                    TraceUtil.WriteLineIf(typeof(ComObjectInfo),
                                          TraceLevel.Info,
                                          "ROT - added: "
                                          + comObjInfo.GetName()
                                          + " "
                                          + comObjInfo.ObjType
                                          + " "
                                          + Win32Utils.RegKeyToString
                                              (comObjInfo._classIdKey)
                                          + Win32Utils.RegKeyToString
                                              (comObjInfo._classNameKey));
                }
                catch (Exception ex)
                {
                    TraceUtil.WriteLineIf(typeof(ComObjectInfo),
                                          TraceLevel.Info,
                                          "ROT - Exception processing ROT entry: "
                                          + ex);
                    progress.UpdateProgress(1);
                    continue;
                }
            }
            Marshal.ReleaseComObject(em);
            Marshal.ReleaseComObject(bc);
            Marshal.ReleaseComObject(rot);
            return(runningObjects);
        }
Example #13
0
        private static void ProcessImports(string executable, ILogger logger, Func <string, bool> predicate)
        {
            ParsePeFile(executable, logger, (image) =>
            {
                bool shouldContinue = true;
                uint size           = 0u;

                var directoryEntry = (IMAGE_IMPORT_DESCRIPTOR *)NativeMethods.ImageDirectoryEntryToData(image.MappedAddress, 0, NativeMethods.IMAGE_DIRECTORY_ENTRY_IMPORT, &size);
                if (directoryEntry == null)
                {
                    logger.DebugWarning($"Error while parsing imports of {executable}: {Win32Utils.GetLastWin32Error()}");
                    return;
                }

                while (shouldContinue && directoryEntry->OriginalFirstThunk != 0u)
                {
                    shouldContinue = predicate(GetString(image, directoryEntry->Name));
                    directoryEntry++;
                }
            });
        }