Ejemplo n.º 1
0
            public static byte[] GetCaptureBytes()
            {
                string res = "";
                var    a   = DllImportCaller.lib.Crnch(ref res);
                var    ptr = new IntPtr(int.Parse(res));

                byte[] buffer = new byte[480 * 800 * 4];
                MarshalBypass.Copy(ptr, buffer, 0, buffer.Length);

                return(buffer);
            }
Ejemplo n.º 2
0
        public bool MoveNext()
        {
            /*BufferHandle*/
            IntPtr handle;

            if ((this.tokenIdEnum.get_NextTokenID(out handle) != 0) || handle == IntPtr.Zero)//.IsInvalid)
            {
                return(false);
            }
            string invocationUri = MarshalBypass.PtrToStringUni(handle); //Marshal.PtrToStringUni(handle.DangerousGetHandle());

            if (this.first)
            {
                this.first   = false;
                this.current = new HackedShellTile(invocationUri, true);
            }
            else
            {
                this.current = new HackedShellTile(invocationUri);
            }
            //handle.Dispose(); => Leaks goes here :P (Cant dispose due hacked)
            return(true);
        }
Ejemplo n.º 3
0
            //public static System.Windows.Media.Imaging.WriteableBitmap CaptureScreen()
            //{
            //   // threadDisp.Dispatcher.BeginInvoke(() => {  });
            //    var buffer = GetCaptureBytes();


            //    int x = 0,
            //        y = 0,
            //        i = 0,
            //        pixW = bmp.PixelWidth;

            //    while(x < 480)
            //    {
            //        while(y < 800)
            //        {
            //            var r = buffer[i++];
            //            var g = buffer[i++];
            //            var b = buffer[i++];
            //            //var alp = buffer[i++];
            //            i++;
            //            //if (alp != 0) //alp always 0


            //            var pix = y * pixW + x;

            //            bmp.Pixels[pix] = /*alp << 24 *//* 0 | */r << 16 | g << 8 | b;
            //            y++;
            //        }
            //        y = 0;
            //        x++;
            //    }
            //    return bmp;
            //}
            public static System.Windows.Media.Imaging.WriteableBitmap CaptureScreen()
            {
                IntPtr handle;
                IntPtr bits;
                int    size;

                DllImportCaller.lib.CaptureScreen(out handle, out size, out bits);
                byte[] buffer = new byte[size];
                MarshalBypass.Copy(bits, buffer, 0, size);
                DllImportCaller.lib.DeleteObject(handle);

                int bufferPos = 0;

                for (int i = 0; i < 384000; i++)
                {
                    // colors stored as BGR
                    int pixel = buffer[bufferPos++];
                    pixel        |= buffer[bufferPos++] << 8;
                    pixel        |= buffer[bufferPos++] << 16;
                    bmp.Pixels[i] = pixel;
                }

                return(bmp);
            }