Пример #1
0
        /// <summary>
        /// Create the screen shot request
        /// </summary>
        public void DoRequest(bool setInterval = false)
        {
            HookManager.ProcessInfo pInfo = AttachCurrentProcess();
            if (pInfo == null)
            {
                return;
            }

            ScreenshotManager_OnScreenshotDebugMessage(pInfo.Process.Id, "Do request " + setInterval);
            start = DateTime.Now;

            ScreenshotManager.AddScreenshotRequest(pInfo.Process.Id, new ScreenshotRequest(FileName(pInfo.Process), Properties.Settings.Default.format.ToString(), setInterval, Properties.Settings.Default.interval), Callback);
        }
Пример #2
0
        public void IntervalCapture(object prs)
        {
            HookManager.ProcessInfo pInfo = (HookManager.ProcessInfo)prs;
            Process process = pInfo.Process;

            while (Thread.CurrentThread == pInfo.IntervalThread && !pInfo.Process.HasExited)
            {
                ScreenshotManager.AddScreenshotRequest(process.Id, new ScreenshotRequest(FileName(process), Properties.Settings.Default.format.ToString()), Callback);
                Thread.Sleep(pInfo.Interval * 1000);
            }

            if (Thread.CurrentThread == pInfo.IntervalThread)
            {
                pInfo.IntervalThread = null;
            }
        }
Пример #3
0
        /// <summary>
        /// Create the screen shot request
        /// </summary>
        public void DoRequestOld()
        {
            HookManager.ProcessInfo pInfo = AttachCurrentProcess();
            if (pInfo == null)
            {
                return;
            }

            ScreenshotManager_OnScreenshotDebugMessage(pInfo.Process.Id, "Do request ");
            start = DateTime.Now;

            //int j;
            //ImageCodecInfo[] encoders;
            //encoders = ImageCodecInfo.GetImageEncoders();
            //for(j = 0; j < encoders.Length; ++j)
            //{
            //    ScreenshotManager_OnScreenshotDebugMessage(process.Id, encoders[j].MimeType);

            //}

            if (pInfo.IntervalThread == null)
            {
                if (Properties.Settings.Default.interval > 0)
                {
                    pInfo.Interval       = Properties.Settings.Default.interval;
                    pInfo.IntervalThread = new Thread(new ParameterizedThreadStart(IntervalCapture));
                    pInfo.IntervalThread.Start(pInfo);
                }
                else
                {
                    // Add a request to the screenshot manager - the ScreenshotInterface will pass this on to the injected assembly
                    ScreenshotManager.AddScreenshotRequest(pInfo.Process.Id, new ScreenshotRequest(FileName(pInfo.Process), Properties.Settings.Default.format.ToString()), Callback);
                }
            }
            else
            {
                pInfo.IntervalThread = null;
            }
        }
Пример #4
0
        private HookManager.ProcessInfo AttachCurrentProcess(bool force = true)
        {
            try
            {
                Process currentProcess = GetForegroundProcess();

                if (currentProcess == null)
                {
                    if (force == true)
                    {
                        ScreenshotManager_OnScreenshotDebugMessage(0, "No Foreground  found");
                    }
                    return(null);
                }

                HookManager.ProcessInfo pInfo = HookManager.GetHookedProcess(currentProcess);

                // Skip if the process is already hooked (and we want to hook multiple applications)
                if (pInfo == null)
                {
                    if (force == false & !autoAttach.Contains(currentProcess.ProcessName))
                    {
                        return(null);
                    }

                    List <String> modules = GetProcessModules(currentProcess);
                    bool          hasDx   = false;
                    foreach (String module in supportedModules)
                    {
                        hasDx = (hasDx | modules.Contains(module));
                    }

                    if (!hasDx)
                    {
                        ScreenshotManager_OnScreenshotDebugMessage(0, "No DX found");
                        return(null);
                    }

                    // Keep track of hooked processes in case more than one needs to be hooked
                    pInfo = HookManager.AddHookedProcess(currentProcess);
                    // Inject DLL into target process
                    try
                    {
                        RemoteHooking.Inject(
                            currentProcess.Id,
                            InjectionOptions.Default,
                            typeof(ScreenshotInject.ScreenshotInjection).Assembly.Location, //"ScreenshotInject.dll", // 32-bit version (the same because AnyCPU) could use different assembly that links to 32-bit C++ helper dll
                            typeof(ScreenshotInject.ScreenshotInjection).Assembly.Location, //"ScreenshotInject.dll", // 64-bit version (the same because AnyCPU) could use different assembly that links to 64-bit C++ helper dll
                            // the optional parameter list...
                            ChannelName,                                                    // The name of the IPC channel for the injected assembly to connect to
                            Direct3DVersion.AutoDetect.ToString(),                          // The direct3DVersion used in the target application
                            false                                                           //cbDrawOverlay.Checked
                            );
                    }
                    catch (Exception e)
                    {
                        ScreenshotManager_OnScreenshotDebugMessage(currentProcess.Id, e.GetType().FullName + ": " + e.Message);
                    }
                    ScreenshotManager_OnScreenshotDebugMessage(currentProcess.Id, "Injected ");
                }
                return(pInfo);
            }
            catch (Exception e)
            {
                ScreenshotManager_OnScreenshotDebugMessage(0, e.ToString());
                return(null);
            }
        }