Пример #1
0
        public override VideoFrame GetFrame(int n, ScriptEnvironment env)
        {
            if (noRotate)
            {
                return(base.GetFrame(n, env));
            }
            var res = NewVideoFrame(env);

            using (var frame = Child.GetFrame(n, env))
            {
                var vi = Child.GetVideoInfo();
                Parallel.ForEach(planes, plane =>
                {
                    var zero = plane == YUVPlanes.PLANAR_U || plane == YUVPlanes.PLANAR_V ? 128 : 0;
                    OverlayUtils.MemSet(res.GetWritePtr(plane), zero, res.GetPitch(plane) * res.GetHeight(plane));

                    // get source image size
                    var height    = frame.GetHeight(plane);
                    var width     = vi.width / (vi.height / height);
                    var pixelSize = frame.GetRowSize(plane) / width;

                    NativeUtils.BilinearRotate(
                        frame.GetReadPtr(plane), frame.GetRowSize(plane) / pixelSize, frame.GetHeight(plane),
                        frame.GetPitch(plane),
                        res.GetWritePtr(plane), res.GetRowSize(plane) / pixelSize, res.GetHeight(plane),
                        res.GetPitch(plane),
                        angle, pixelSize);
                });
            }

            return(res);
        }
Пример #2
0
        public static bool Hook(IntPtr targetWindowHandle, IntPtr thisHandle)
        {
            try
            {
                if (targetWindowHandle != IntPtr.Zero)
                {
                    int processId;
                    var threadId = NativeUtils.GetWindowThreadProcessId(targetWindowHandle, out processId);

                    var panelHandle  = thisHandle.ToInt32();
                    var targetHandle = targetWindowHandle.ToInt32();

                    var b1 = BitConverter.GetBytes(panelHandle);
                    var b2 = BitConverter.GetBytes(targetHandle);

                    var data = new byte[b1.Length + b2.Length];
                    Array.Copy(b1, data, b1.Length);
                    Array.Copy(b2, 0, data, b1.Length, b2.Length);

#warning FIX
                    // Pickup an idle message from the queue
                    //fixHookHelper.InstallIdleHandler(processId, threadId, typeof (RuntimeEditorHook).Assembly.Location, typeof (RuntimeEditorHook).FullName, data);

                    // send an idle ;;)
                    NativeUtils.SendMessage(targetWindowHandle, 0, IntPtr.Zero, IntPtr.Zero);
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "RuntimeObjectEditor");
                return(false);
            }
        }
Пример #3
0
        private void startProcess(string name)
        {
            Process app = new Process();

            app.StartInfo.FileName       = name;
            app.StartInfo.CreateNoWindow = false;
            app.StartInfo.ErrorDialog    = true;
            app.EnableRaisingEvents      = true;

            app.Exited += new System.EventHandler(on_exit);
            app.Start();
            app.WaitForExit(1 * 1000);

            if (app.HasExited)
            {
                MessageBox.Show("进程意外退出", "警告");
            }
            else
            {
                updateProcesses(this, new EventArgs());
                IntPtr appid = new IntPtr(app.Id);
                IntPtr handle;
                foreach (object ob in this.comboBox1.Items)
                {
                    handle = ((MyComboBoxItem)ob).Handle;
                    IntPtr pid = NativeUtils.GetProcessForWindow(handle);
                    if (pid == appid)
                    {
                        this._targetHandle = handle;

                        btOK.Enabled = true;
                    }
                }
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            if (AppInstance.WaitOne(TimeSpan.Zero, true))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                //Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-CA");
                Application.Run(new LayoutEditorWindow(args));
            }
            else
            {
                var myProc = Process.GetCurrentProcess();
                var procs  = Process.GetProcessesByName("SiGen");

                string message = "MUTEX#";
                if (args != null)
                {
                    message += string.Join(",", args.Select(x => x.Replace(",", ",")));
                }

                foreach (var proc in procs)
                {
                    if (proc.Id == myProc.Id)
                    {
                        continue;
                    }
                    NativeUtils.SendDataMessage(proc.MainWindowHandle, message);
                    break;
                }
            }
        }
Пример #5
0
    void Update()
    {
        framesCount++;

        /* new tick? recount */
        float time       = Time.realtimeSinceStartup;
        float timePassed = time - lastTime;

        if (timePassed >= updateInterval)
        {
            /* increment/update */
            ticksTotal++;
            frameTime    = (time - lastTime) / framesCount;
            frameTimeMax = Mathf.Max(frameTimeMax, frameTime);
            timeTotal   += timePassed;
            framesTotal += framesCount;
            //#if !FPS_COUNTER_MINIMAL
            memory     = NativeUtils.GetCurrentMemoryBytes();
            memory    /= 1024;
            memoryMax  = memory > memoryMax? memory: memoryMax;
            memorySum += memory;
            //#endif

            /* reset tick counter */
            lastTime    = time;
            framesCount = 0;

            /* update fps/etc and debug info */
                        #if !FPS_COUNTER_MINIMAL
            UpdateTexts(showFullFpsInfo);
                        #endif
        }
    }
Пример #6
0
        /// <summary>
        /// Get a shader stage data to match the passed material if one exisits in the cache otherwise create a new one
        /// </summary>
        /// <param name="shaderResource"></param>
        /// <param name="customDefines"></param>
        /// <param name="specializationContants"></param>
        /// <returns></returns>

        public static ShaderStageInfo GetOrCreateShaderStageInfo(ShaderResource shaderResource, string customDefines, int[] specializationContants)
        {
            ShaderStageInfo shaderStage = new ShaderStageInfo
            {
                source             = shaderResource.sourceFile,
                stages             = shaderResource.stages,
                customDefines      = customDefines,
                specializationData = NativeUtils.WrapArray(specializationContants)
            };

            // see if we have one that matches
            foreach (int idkey in _shaderStageInfoCache.Keys)
            {
                ShaderStageInfo ssd = _shaderStageInfoCache[idkey];
                if (ssd.Equals(shaderStage))
                {
                    return(ssd);
                }
            }

            // must be new
            shaderStage.id = _shaderStageInfoCache.Count;
            _shaderStageInfoCache[shaderStage.id] = shaderStage;

            return(shaderStage);
        }
        public static void Capture(IntPtr hwnd, Direct3DVersion direct3DVersion = Direct3DVersion.AUTO_DETECT)
        {
            NativeUtils.GetWindowThreadProcessId(hwnd, out var processID);
            var process = Process.GetProcessById(processID);

            var captureConfig = new CaptureConfig
            {
                Direct3DVersion       = direct3DVersion,
                ShowOverlay           = true,
                CaptureMouseEvents    = true,
                CaptureKeyboardEvents = true
            };

            var captureInterface = new CaptureInterface();

            captureInterface.RemoteMessage += e =>
            {
                Debug.WriteLine(e.Message);
            };

            captureInterface.Connected += () =>
            {
                captureInterface.DrawOverlayInGame(new Overlay
                {
                    Elements = new List <IOverlayElement>
                    {
                        new RectangleElement
                        {
                            Colour   = Color.FromArgb(Color.Gray.ToArgb() ^ (0x33 << 24)),
                            Location = new Point(0, 0),
                            Width    = -1,
                            Height   = -1
                        },
                        new RectangleMouseHookElement
                        {
                            Colour = Color.FromArgb(Color.Green.ToArgb() ^ (0x33 << 24)),
                            Width  = 0,
                            Height = 0
                        },
                        new FramesPerSecond(new Font("Arial", 16, FontStyle.Bold))
                        {
                            Location    = new Point(0, 0),
                            Color       = Color.Red,
                            AntiAliased = true,
                            Text        = "{0:N0} FPS"
                        }
                    },
                    Hidden = false
                });
            };

            var captureProcess = new CaptureProcess(process, captureConfig, captureInterface);

            while (!captureProcess.IsDisposed)
            {
                Thread.Sleep(500);
            }

            Debug.WriteLine("Disconnected from DirectX Hook");
        }
Пример #8
0
        private unsafe int GetNetworkStats(out string name, int strlen)
        {
            var data = stackalloc int[5];

            if (strlen <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(strlen));
            }

            var nameBuf = strlen < 128 ? stackalloc byte[strlen] : new Span <byte>(new byte[strlen]);

            fixed(byte *nameBufPin = nameBuf)
            {
                data[0] = (int)(IntPtr)nameBufPin;
                data[1] = NativeUtils.IntPointerToInt(data + 2);

                data[2] = strlen;

                var p      = Interop.FastNativeFind("GetNetworkStats");
                var result = Interop.FastNativeInvoke(p, "S[*1]d", data);

                name = NativeUtils.GetString(nameBuf);

                return(result);
            }
        }
Пример #9
0
 private void panel_BarraSuperior_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         NativeUtils.MovimentarForm(Handle);
     }
 }
        IntPtr WndProc(IntPtr rpHandle, int rpMessage, IntPtr rpWParam, IntPtr rpLParam, ref bool rrpHandled)
        {
            if (rpMessage == (int)NativeConstants.WindowMessage.WM_HOTKEY)
            {
                var rModifierKeys = NativeUtils.LoWord(rpLParam);
                var rKey          = NativeUtils.HiWord(rpLParam);

                if (Preference.Instance.Other.PanicKey.ModifierKeys == rModifierKeys && Preference.Instance.Other.PanicKey.Key == rKey)
                {
                    var rCurrentProcessID = (uint)Process.GetCurrentProcess().Id;

                    NativeMethods.User32.EnumWindows((rpWindowHandle, _) =>
                    {
                        uint rProcessID;
                        NativeMethods.User32.GetWindowThreadProcessId(rpHandle, out rProcessID);
                        if (rProcessID != rCurrentProcessID && (BrowserService.Instance.BrowserProcessID.HasValue && rProcessID != BrowserService.Instance.BrowserProcessID.Value))
                        {
                            return(false);
                        }

                        NativeMethods.User32.ShowWindowAsync(rpHandle, !IsPanicKeyPressed ? NativeConstants.ShowCommand.SW_HIDE : NativeConstants.ShowCommand.SW_SHOW);

                        return(true);
                    }, IntPtr.Zero);

                    IsPanicKeyPressed = !IsPanicKeyPressed;
                }
            }

            return(IntPtr.Zero);
        }
Пример #11
0
        public override PSCredential PromptForCredential(string caption, string message, string userName,
                                                         string targetName, PSCredentialTypes allowedCredentialTypes,
                                                         PSCredentialUIOptions options)
        {
            try
            {
                if (_settings.PromptForCredentialsInConsole)
                {
                    return(PromptForCredentialFromConsole(caption, message, userName, targetName, allowedCredentialTypes,
                                                          options));
                }
            }
            catch
            {
            }

            IntPtr handle = _control.GetSafeWindowHandle();

            return(NativeUtils.CredUIPromptForCredential(
                       caption,
                       message,
                       userName,
                       targetName,
                       allowedCredentialTypes,
                       options,
                       handle));
        }
Пример #12
0
        /// <summary>
        /// Gets a string which describes the NT status value.
        /// </summary>
        /// <param name="status">The NT status value.</param>
        /// <returns>A message, or null if the message could not be retrieved.</returns>
        public static string GetMessage(this NtStatus status)
        {
            string message;

            message = NativeUtils.GetMessage(
                Loader.GetDllHandle("ntdll.dll"),
                0xb,
                System.Threading.Thread.CurrentThread.CurrentUICulture.LCID,
                (int)status
                );

            if (message != null)
            {
                // Fix those messages which are formatted like:
                // {Asdf}\r\nAsdf asdf asdf...
                if (message.StartsWith("{"))
                {
                    string[] split = message.Split('\n');

                    if (split.Length > 1)
                    {
                        message = split[1];
                    }
                }
            }

            return(message);
        }
Пример #13
0
        unsafe protected override void PreDetachVirtualChannel()
        {
            OpenALSoundWorld.criticalSection.Enter();

            Al.alSourceStop(alSource);
            OpenALSoundWorld.CheckError();

            if (currentSound is OpenALDataBufferSound)
            {
                if (currentSound is OpenALFileStreamSound)
                {
                    OpenALSoundWorld.Instance.fileStreamRealChannels.Remove(this);
                }

                if (streamBuffer != null)
                {
                    NativeUtils.Free((IntPtr)streamBuffer);
                    streamBuffer     = null;
                    streamBufferSize = 0;
                }
            }

            Al.alSourcei(alSource, Al.AL_BUFFER, 0);
            OpenALSoundWorld.CheckError();

            currentSound = null;

            OpenALSoundWorld.criticalSection.Leave();
        }
Пример #14
0
        private void OpenSystemContextMenu(MouseButtonEventArgs e)
        {
            System.Windows.Point position = e.GetPosition(this);
            System.Windows.Point screen   = this.PointToScreen(position);
            int num = 36;

            if (position.Y < (double)num)
            {
                IntPtr handle     = (new WindowInteropHelper(this)).Handle;
                IntPtr systemMenu = NativeUtils.GetSystemMenu(handle, false);
                if (base.WindowState != WindowState.Maximized)
                {
                    NativeUtils.EnableMenuItem(systemMenu, 61488, 0);
                }
                else
                {
                    NativeUtils.EnableMenuItem(systemMenu, 61488, 1);
                }
                int num1 = NativeUtils.TrackPopupMenuEx(systemMenu, NativeUtils.TPM_LEFTALIGN | NativeUtils.TPM_RETURNCMD, Convert.ToInt32(screen.X + 2), Convert.ToInt32(screen.Y + 2), handle, IntPtr.Zero);
                if (num1 == 0)
                {
                    return;
                }

                NativeUtils.PostMessage(handle, 274, new IntPtr(num1), IntPtr.Zero);
            }
        }
        internal bool SetWindowHandle(IntPtr handle, Point lastPoint)
        {
            Refresh();
            this.lastPoint      = lastPoint;
            this.detectedWindow = handle;
            Refresh();
            Highlight();

            bool   changed      = false;
            object activeWindow = ActiveWindow;

            if (activeWindow != selectedObject)
            {
                changed        = true;
                selectedObject = activeWindow;
            }

            // try to load plugins

            Point checkPoint = lastPoint;

            if (detectedWindow != IntPtr.Zero)
            {
                checkPoint = NativeUtils.NativeScreenToClient(detectedWindow, lastPoint);
            }

            object lastSelected = detectedWindow;

            if (checkPoint != Point.Empty && PluginManager.Instance.ResolveSelection(checkPoint, lastSelected, ref selectedObject))
            {
                changed = true;
            }

            return(changed);
        }
Пример #16
0
        public unsafe int NativeArrayOut(out int[] arr, int len)
        {
            var data = stackalloc int[3];

            if (len <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(len));
            }

            var arrBuf = NativeUtils.ArrayToIntSpan(null, len);

            fixed(int *pinned = arrBuf)
            {
                data[0] = NativeUtils.IntPointerToInt(pinned);
                data[1] = NativeUtils.IntPointerToInt(data + 2);
                data[2] = len;


                var result = Interop.FastNativeInvoke(new IntPtr(9999), "A[*1]d", data);

                arr = NativeUtils.IntSpanToArray <int>(null, arrBuf);

                return(result);
            }
        }
Пример #17
0
        public unsafe int GetPlayerNameC(int playerid, out string name, int strlen)
        {
            var data = stackalloc int[5];

            if (strlen <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(strlen));
            }

            var nameBuf = strlen < 128 ? stackalloc byte[strlen] : new Span <byte>(new byte[strlen]);

            fixed(byte *nameBufPin = &nameBuf.GetPinnableReference())
            {
                data[0] = NativeUtils.IntPointerToInt(data + 3);
                data[1] = (int)(IntPtr)nameBufPin;
                data[2] = NativeUtils.IntPointerToInt(data + 4);

                data[3] = playerid;
                data[4] = strlen;


                var result = Interop.FastNativeInvoke(new IntPtr(9999), "dSd", data);

                name = NativeUtils.GetString(nameBuf);

                return(result);
            }
        }
Пример #18
0
        private void playOperation(IntPtr h, Rectangle rect, string op)
        {
            Point p = NativeUtils.NativeClientToScreen(h, rect.Location);

            rect.Location = p;

            //从左上角调整到控件中心
            p.X += rect.Width / 2;
            p.Y += rect.Height / 2;

            string s = op + ":" + h.ToString() + rect.ToString();

            lstBox.Items.Add(s);
            lstBox.SelectedIndex = lstBox.Items.Count - 1;

            //画这次的线和框
            drawLine(_currentPoint, p);

            drawRectangle(rect);

            MouseSimulator.Position = p;
            System.Threading.Thread.Sleep(1000);
            MouseSimulator.Click(MouseButton.Left);

            System.Threading.Thread.Sleep(1000);

            //消除这次画的线和框

            drawLine(_currentPoint, p);

            drawRectangle(rect);
            System.Threading.Thread.Sleep(1000);

            _currentPoint = p;
        }
Пример #19
0
        unsafe protected override void OnDispose()
        {
            DirectSoundWorld.criticalSection.Enter();

            if (soundBuffers.Count != freeSoundBuffers.Count)
            {
                Log.Fatal("DirectSound.OnDispose: soundBuffers.Count == freeSoundBuffers.Count");
            }

            for (int n = soundBuffers.Count - 1; n >= 0; n--)
            {
                IDirectSoundBuffer *soundBuffer = (IDirectSoundBuffer *)soundBuffers[n].ToPointer();
                IDirectSoundBuffer.Release(soundBuffer);
            }
            soundBuffers.Clear();
            freeSoundBuffers.Clear();

            if (waveFormat != null)
            {
                NativeUtils.Free((IntPtr)waveFormat);
                waveFormat = null;
            }

            DirectSoundWorld.criticalSection.Leave();

            base.OnDispose();
        }
Пример #20
0
        private void btRecord_Click(object sender, EventArgs e)
        {
            if (_recording)
            {
                mouseHook.Stop();
                keyboardHook.Stop();

                btRecord.Text    = "开始";
                btPlay.Enabled   = true;
                btConfig.Enabled = true;
                btClear.Enabled  = true;
            }
            else
            {
                mouseHook.Start();
                keyboardHook.Start();

                btRecord.Text    = "停止";
                btPlay.Enabled   = false;
                btConfig.Enabled = false;
                btClear.Enabled  = false;
                NativeUtils.SetForegroundWindow(spywindow);
            }
            _recording = !_recording;
        }
        public override void ProcessChunkFile(Stream stream, string chunkFullFilename)
        {
            using var reader = new Reader(new BinaryReader(stream, Encoding.UTF8, true), chunkFullFilename);

            var header = LanguageHeaderPrimitive.Read(reader);

            LanguageInfoEntryPrimitive[] infoEntries = ReadInfoEntries(reader, header);

            // Skip buckets.
            reader.Offset(8 * 256);

            byte[] keyBlock = reader.ReadBytes((int)header.KeyBlockSize);
            byte[] stringBlock = reader.ReadBytes((int)header.StringBlockSize);

            if (stringBlock.Length == 0)
                return;

            List<string> values = ParseStringBlock(stringBlock);

            foreach (LanguageInfoEntryPrimitive infoEntry in infoEntries)
            {
                int index = (int)infoEntry.KeyOffset;

                string key = NativeUtils.GetNextString(keyBlock, ref index, Encoding.ASCII);
                string value = values[(int)infoEntry.StringIndex];

                TryAddEntry(header.LanguageId, infoEntry.StringIndex, key, value);
            }
        }
        //file,data streams

        unsafe void BeginStreamPlay()
        {
            //clear buffer
            {
                void *lockedBuffer     = null;
                uint  lockedBufferSize = 0;

                int hr = IDirectSoundBuffer.Lock(currentSoundBuffer, 0, (uint)currentSound.bufferSize,
                                                 &lockedBuffer, &lockedBufferSize, (void **)null, (uint *)null, 0);
                if (Wrapper.FAILED(hr))
                {
                    DirectSoundWorld.Warning("IDirectSoundBuffer.Lock", hr);
                    return;
                }

                NativeUtils.FillMemory((IntPtr)lockedBuffer, (int)lockedBufferSize,
                                       (byte)(currentSound.waveFormat->wBitsPerSample == 8 ? 128 : 0));

                IDirectSoundBuffer.Unlock(currentSoundBuffer, lockedBuffer, lockedBufferSize, null, 0);
            }

            UpdateStreamBuffer(true);
            UpdateStreamBuffer(false);
            streamNeedWriteFirstPart = true;
            needStopAfterBufferRead  = false;
        }
Пример #23
0
        /// <summary>
        ///     Creates a window with the information's stored in this class
        /// </summary>
        /// <returns>
        ///     true on success
        /// </returns>
        private bool CreateWindow()
        {
            Handle = NativeUtils.CreateWindowEx(
                WindowExStyleDx,
                DesktopClass,
                "",
                WindowStyleDx,
                X,
                Y,
                Width,
                Height,
                IntPtr.Zero,
                IntPtr.Zero,
                IntPtr.Zero,
                IntPtr.Zero);

            if (Handle == IntPtr.Zero)
            {
                return(false);
            }

            NativeUtils.SetLayeredWindowAttributes(Handle, 0, 255, LwaAlpha);

            ExtendFrameIntoClient();

            return(true);
        }
Пример #24
0
        /// <summary>
        ///     Makes a transparent window which adjust it's size and position to fit the parent window
        /// </summary>
        /// <param name="parent">HWND/Handle of a window</param>
        /// <param name="limitFps">VSync</param>
        /// <exception cref="Exception">
        ///     The handle of the parent window isn't valid
        ///     or
        ///     Could not create OverlayWindow
        /// </exception>
        public DirectXOverlayWindow(IntPtr parent, bool limitFps = true)
        {
            if (parent == IntPtr.Zero)
            {
                throw new Exception("The handle of the parent window isn't valid");
            }

            NativeUtils.GetWindowRect(parent, out var bounds);

            IsDisposing = false;
            IsVisible   = true;
            IsTopMost   = true;

            ParentWindowExists = true;

            X = bounds.Left;
            Y = bounds.Top;

            Width  = bounds.Right - bounds.Left;
            Height = bounds.Bottom - bounds.Top;

            ParentWindow = parent;

            if (!CreateWindow())
            {
                throw new Exception("Could not create OverlayWindow");
            }

            Graphics = new Direct2DRenderer(Handle, limitFps);

            SetBounds(X, Y, Width, Height);
        }
Пример #25
0
        private int[] GetHistogram(IEnumerable <VideoFrame> frames, VideoFrame maskFrame, int pixelSize, int channel, YUVPlanes plane, ColorSpaces pixelType, int bits, bool limitedRange)
        {
            var hist       = new int[1 << bits];
            var chroma     = plane == YUVPlanes.PLANAR_U || plane == YUVPlanes.PLANAR_V;
            var widthMult  = chroma ? pixelType.GetWidthSubsample() : 1;
            var heightMult = chroma ? pixelType.GetHeightSubsample() : 1;
            var maskPitch  = maskFrame?.GetPitch() * heightMult ?? 0;
            var maskPtr    = maskFrame?.GetReadPtr() + channel ?? IntPtr.Zero;

            foreach (var frame in frames)
            {
                NativeUtils.FillHistogram(hist,
                                          frame.GetRowSize(plane), frame.GetHeight(plane), channel,
                                          frame.GetReadPtr(plane), frame.GetPitch(plane), pixelSize,
                                          maskPtr, maskPitch, widthMult);
            }
            if (limitedRange)
            {
                var min = GetLowColor(bits);
                for (var color = 0; color < min; color++)
                {
                    hist[min]  += hist[color];
                    hist[color] = 0;
                }
                var max = GetHighColor(bits, plane);
                for (var color = max + 1; color < 1 << bits; color++)
                {
                    hist[max]  += hist[color];
                    hist[color] = 0;
                }
            }
            return(GetUniHistogram(hist));
        }
Пример #26
0
        int ReadDataFromDataStream(IntPtr buffer, int needRead)
        {
            OpenALDataStreamSound currentDataStreamSound = (OpenALDataStreamSound)currentSound;

            if (tempDataStreamReadArray.Length < needRead)
            {
                tempDataStreamReadArray = new byte[needRead];
            }

            int readed = currentDataStreamSound.dataReadCallback(tempDataStreamReadArray, 0,
                                                                 needRead);

            if (readed != 0)
            {
                Marshal.Copy(tempDataStreamReadArray, 0, buffer, readed);
            }

            if (readed < 16)
            {
                readed = Math.Min(needRead, 16);
                NativeUtils.ZeroMemory(buffer, readed);
            }

            return(readed);
        }
Пример #27
0
        private async Task UpdateCacheSizeAsync(bool resetInitialCacheSize, bool updateDetailedCacheSizes)
        {
            CacheSize = 0;
            if (resetInitialCacheSize)
            {
                InitialCacheSize = 0;
            }

            try
            {
                var cacheSize = NativeUtils.GetDirectorySize(FileUtils.GetTempFileName(string.Empty));
                CacheSize = cacheSize;
                if (resetInitialCacheSize)
                {
                    InitialCacheSize = cacheSize;
                }
                Percentage = InitialCacheSize > 0 ? Math.Round((double)(CacheSize * 100) / InitialCacheSize, 1) : 0.0D;
            }
            catch { }
            finally
            {
                if (updateDetailedCacheSizes)
                {
                    var files = await this.RetrieveCacheFilesAsync();

                    UpdateCacheTypes(files);
                }
            }
        }
Пример #28
0
        public void Run(CancellationToken cancellationToken = default)
        {
            hwnd = NativeUtils.CreateMessageOnlyWindow();

            try {
                while (IsRunning && !cancellationToken.IsCancellationRequested)
                {
                    while (PInvoke.PeekMessage(out var msg, default, default, default, Constants.PM_REMOVE))
Пример #29
0
        private unsafe int IsPlayerConnectedStackBased(int id)
        {
            var data = stackalloc int[2];

            data[0] = NativeUtils.IntPointerToInt(data + 1);
            data[1] = id;

            return(Interop.FastNativeInvoke(new IntPtr(9999), "d", data));
        }
Пример #30
0
        /// <summary>
        ///     Sets the position.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        public void SetPos(int x, int y)
        {
            X = x;
            Y = y;

            NativeUtils.SetWindowPos(Handle, HwndTopmost, X, Y, Width, Height, 0);

            ExtendFrameIntoClient();
        }