interception

c and LD_PRELOAD. open and open64 calls intercepted, but not stat64

故事扮演 提交于 2019-12-20 10:41:56
问题 I've done a little shared library that tries to intercept open, open64, stat and stat64 sys calls. When I export LD_PRELOAD and run oracle's sqlplus, I can see the traces of the open and open64 calls, but no traces of the stat and stat64 calls. The shared library is a single c file with all the definitions of the sys calls in it. Why does it happen that some syscalls are intercepted and others don't? thanks for your help. 回答1: Because the GNU libc implements open() and open64() as you'd

Intercept method calls

北慕城南 提交于 2019-12-17 16:33:19
问题 Is there a way of intercepting some method calls without making any code changes around the method itself? I don't need to inject any custom behaviour at runtime, only add custom performance logging to an existing project. 回答1: You want Aspect Oriented Programming. There are 4 main flavours of AOP Runtime RealProxy based AOP Runtime subclass/virtual method AOP Post Compile IL weave AOP Precompile source code AOP The above are ordered in order of speed of execution (slowest to fastest). Note

nginx proxy authentication intercept

扶醉桌前 提交于 2019-12-13 15:46:05
问题 I have a couple of service and they stand behind an nginx instance. In order to handle authentication, in nginx, I am intercepting each request and sending it to the authentication service. There, if the credentials are are correct, I am setting a cookie which includes user related info. The request should now be routed to the appropriate service, with the cookie set. Here is my nginx config: user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid;

Initialising configurable objects with dependency injection container

会有一股神秘感。 提交于 2019-12-11 23:23:25
问题 I am trying to find the best way to initialise device drivers (maintained by production staff). Configuration generally contains serial ports and other information which production staff may need to change if the underlying hardware for the device driver changes. e.g. using System.IO.Ports; public class Scanner : IDriver { public SerialPort SerialPort { get; private set; } public String Id { get; private set; } public String DisplayName { get; private set; } public Scanner(SerialPort

DI Interception vs. AOP

纵然是瞬间 提交于 2019-12-11 11:56:31
问题 From Unity documentation: Unity interception enables you to effectively capture calls to objects and add additional functionality to the target object. Interception is useful when you want to modify the behavior for individual objects but not the entire class, very much as you would do when using the Decorator pattern. It provides a flexible approach for adding new behaviors to an object at run time. Since the very same DP is used in Aspect Oriented Programming (see here) ...In the .NET

Unity Interception - Custom Interception Behaviour

倾然丶 夕夏残阳落幕 提交于 2019-12-11 09:06:13
问题 I'm using a custom interception behaviour to filter records (filter is based upon who the current user is) however I'm having some difficulty (this is the body of the interceptors Invoke method) var companies = methodReturn.ReturnValue as IEnumerable<ICompanyId>; List<string> filter = CompaniesVisibleToUser(); methodReturn.ReturnValue = companies.Where(company => filter.Contains(company.CompanyId)).ToList(); The CompaniesVisibleToUser provides a string list of company id's that the user is

AOP programming in .Net? [closed]

眉间皱痕 提交于 2019-12-09 13:55:00
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I'm wondering what's good out there for AOP / crosscutting in .Net, along the lines of AspectJ. I see Microsoft has a Policy Injection Application Block; any other good stuff out there I should take a look at? 回答1: PostSharp is probably the most popular option, although I believe

How to catch any method call on object in PHP?

半腔热情 提交于 2019-12-08 22:22:20
问题 I am trying to figure out how to catch any method called on an object in PHP. I know about the magic function __call , but it is triggered only for methods that do not exist on the called object. For example i have something like this: class Foo { public function bar() { echo 'foobar'; } public function override($method_name,$method_args) { echo 'Calling method ',$method_name,'<br />'; $this->$method_name($method_args); //dirty, but working } } And when i do this: $foo = new Foo(); $foo->bar(

Intercept or Decorate calls to ILogger

ぃ、小莉子 提交于 2019-12-07 09:08:42
问题 I'm currently using castle windsor, along with it's logging facility in my application. However, in my logging I would like to include some contextual information that is not within the logged message, but stored within the CallContext. I have tried to do this by intercepting the calls to ILogger using the following: internal class Program { private static void Main(string[] args) { var container = new WindsorContainer(); container.AddFacility<LoggingFacility>(f => f.UseNLog()); container

Is it possible to intercept calls to console from another process?

浪尽此生 提交于 2019-12-06 15:36:04
The situation is that I have program started through system() or CreateProcess() . Now, is it possible to do stuff as that program outputs data into console. I mean as the program outputs it. That is not wait for the end, gather data and then process it, but just in the moment that this external program calls console with data that it wants to print, and then get hold of that data, process it and output something else on the console. The easiest way is usually to start the program with _popen(your_program, "r"); . That will return a FILE * you can read from, and what it reads will be whatever