K
K
KTG2016-11-15 04:33:44
Delphi
KTG, 2016-11-15 04:33:44

How to get a list of all functions and intercept their call (Delphi)?

For example, there is a calculator program.
It has 4 actions (functions): add, multiply, subtract, divide.
We fasten the procedure for dynamically linking external libraries to it.
We compile and do not touch the source code of the program anymore.
Now we are writing an authorization library with our own forms.
As a result, I want to simply connect this library in the calculator program so that it displays all its events in its form to assign access to a particular user. And now, before each call to this action, the library checks for permissions and either produces it or issues an error message. Taking into account that we do not touch the program code and do not prescribe manual checks anywhere.
Well, the questions themselves:
How to get a list of all actions (functions / procedures) of the program where the library is connected?
How to catch them?
And is it possible, when writing a program, to somehow set aliases or descriptions to these functions, so that they appear in the list with a normal name.
Well, if the approach to the problem is not correct, then how can the idea be realized?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
kalapanga, 2016-11-15
@kalapanga

Functions from a dynamic library can receive something when called as parameters and return something as a result. But they cannot themselves access anything in the main program and directly control it. So, move the authorization procedure to the library as much as you like, but the authorization result must be processed by the main program.
Your task is not that badly formulated, but the idea itself seems too pretentious and far-fetched. Therefore, it is difficult to offer something.

R
Rou1997, 2016-11-15
@Rou1997

Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blahblah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah bla...
For a specific EXE, this is written using a debugger, a decompiler and a disassembler, the functions can then be called at addresses in memory, if you need to intercept calls, then this is also the case with writing to memory, there is a good Cydia thing - a ready-made library for such "hooks", if it does not fit, you can see how it is done and do the same.
As for an abstract program, it is much more complicated, but the same debugger works somehow, you can use its source code.
You can, of course, it is best to write it in C #, etc. for this.
And the devil knows, you didn’t formulate the problem, instead of it blah blah blah about some fictional calculator.

P
Puma Thailand, 2016-11-15
@opium

How are you going to connect your library?
by answering this question, everything else will become clear to you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question