How to get selected text of any application into a windows form application

After some reading, I have found the way: Hook the double click event using something like globalmousekeyhook.codeplex.com (Optional) Save the current state of the clipboard Get The current mouse position with GetCursorPos from user32.dll Get windows based on cursor position with WindowFromPoint from user32.dll [DllImport(“user32.dll”)] public static extern IntPtr WindowFromPoint(Point lpPoint); [DllImport(“user32.dll”)] public static extern … Read more

Print TCP Packet Data

How to print data from TCP packets Below is an example which does exactly what you need: hook received TCP packets and print their payloads. If you want to print some other information from received packet (like binary data), you just need to modify a bit the section under this comment: /* —– Print all … Read more

how could I intercept linux sys calls?

Why can’t you / don’t want to use the LD_PRELOAD trick? Example code here: /* * File: soft_atimes.c * Author: D.J. Capelis * * Compile: * gcc -fPIC -c -o soft_atimes.o soft_atimes.c * gcc -shared -o soft_atimes.so soft_atimes.o -ldl * * Use: * LD_PRELOAD=”./soft_atimes.so” command * * Copyright 2007 Regents of the University of California … Read more

Best way to allow plugins for a PHP application

You could use an Observer pattern. A simple functional way to accomplish this: <?php /** Plugin system **/ $listeners = array(); /* Create an entry point for plugins */ function hook() { global $listeners; $num_args = func_num_args(); $args = func_get_args(); if($num_args < 2) trigger_error(“Insufficient arguments”, E_USER_ERROR); // Hook name should always be first argument $hook_name … Read more

Java shutdown hook

The JVM can shutdown in either an orderly or abrupt manner. A shutdown hook runs for an orderly shutdown: when the last normal thread terminates, someone calls System.exit or by other platform specific means (such as typing Ctrl-C). Shutdown hooks will not run for an abrupt shutdown of the JVM. As you are pressing the … Read more

Is there any git hook for pull?

The githooks man page is a complete list of hooks. If it’s not on there, it doesn’t exist. That said, there is a post-merge hook, and all pulls include a merge, though not all merges are pulls. It’s run after merges, and can’t affect the outcome. It never gets executed if there were conflicts; you’d … Read more

SendInput() not equal to pressing key manually on keyboard in C++?

You can use SendInput() to send hardware scan codes as well (as opposed to virtual scan codes, which DirectInput might ignore). It’s poorly documented, but SendInput() can indeed bypass DirectInput. The reason Eric’s solution didn’t work is he set the hardware scan code, but ended up using a virtual scan code (by setting dwFlags to … Read more

How can I hook Windows functions in C/C++?

Take a look at Detours, it’s perfect for this sort of stuff. For system-wide hooking, read this article from MSDN. First, create a DLL which handles hooking the functions. This example below hooks the socket send and receive functions. #include <windows.h> #include <detours.h> #pragma comment( lib, “Ws2_32.lib” ) #pragma comment( lib, “detours.lib” ) #pragma comment( … Read more